feat: Add single rewrite method to LLM models
This commit is contained in:
parent
333d825cb7
commit
63131b7f11
2 changed files with 13 additions and 1 deletions
|
|
@ -1,10 +1,11 @@
|
|||
from typing import Protocol
|
||||
|
||||
from prophet.domain.improvement import Improvement
|
||||
from prophet.domain.original import Original
|
||||
|
||||
|
||||
class LLMClient(Protocol):
|
||||
def get_alternative_title_suggestions(self, original_content: str) -> str:
|
||||
def rewrite(self, original: Original) -> Improvement:
|
||||
raise NotImplementedError
|
||||
|
||||
def rewrite_title(
|
||||
|
|
@ -16,3 +17,6 @@ class LLMClient(Protocol):
|
|||
self, original: Original, improved_title: str | None = None
|
||||
) -> str:
|
||||
raise NotImplementedError
|
||||
|
||||
def get_alternative_title_suggestions(self, original_content: str) -> str:
|
||||
raise NotImplementedError
|
||||
|
|
|
|||
|
|
@ -20,6 +20,14 @@ class GroqClient(LLMClient):
|
|||
self.config_ai = config_ai if config_ai else AiConfig.from_env()
|
||||
self.client = client if client else Groq(api_key=self.config_ai.API_KEY)
|
||||
|
||||
@override
|
||||
def rewrite(self, original: Original) -> Improvement:
|
||||
suggestions = self.get_alternative_title_suggestions(original.title)
|
||||
new_title = self.rewrite_title(original.title, suggestions)
|
||||
new_summary = self.rewrite_summary(original, new_title)
|
||||
|
||||
return Improvement(original=original, title=new_title, summary=new_summary)
|
||||
|
||||
@override
|
||||
def get_alternative_title_suggestions(
|
||||
self, original_content: str, custom_prompt: str | None = None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue