Rename llm methods
This commit is contained in:
parent
c537b1e750
commit
003eebfebf
2 changed files with 7 additions and 6 deletions
|
|
@ -84,8 +84,8 @@ def keep_only_new_originals(
|
|||
def improve_originals(originals: list[Original]) -> list[Improvement]:
|
||||
improvements: list[Improvement] = []
|
||||
for orig in originals:
|
||||
new_title = llm.rewrite_title_with_groq(orig.title)
|
||||
new_summary = llm.rewrite_summary_with_groq(orig, new_title)
|
||||
new_title = llm.rewrite_title(orig.title)
|
||||
new_summary = llm.rewrite_summary(orig, new_title)
|
||||
|
||||
improvements.append(
|
||||
Improvement(original=orig, title=new_title, summary=new_summary)
|
||||
|
|
@ -111,7 +111,7 @@ app.add_middleware(
|
|||
|
||||
@app.get("/improve-title")
|
||||
def improve_headline(content: str):
|
||||
return llm.rewrite_title_with_groq(content)
|
||||
return llm.rewrite_title(content)
|
||||
|
||||
|
||||
@app.get("/improve-summary")
|
||||
|
|
@ -119,7 +119,7 @@ def improve_summary(original_title: str, new_title: str, original_summary: str):
|
|||
o = Original(
|
||||
title=original_title, summary=original_summary, link="", date=datetime.now()
|
||||
)
|
||||
return llm.rewrite_summary_with_groq(o, new_title)
|
||||
return llm.rewrite_summary(o, new_title)
|
||||
|
||||
|
||||
@app.on_event("startup")
|
||||
|
|
@ -137,6 +137,7 @@ async def fetch_update():
|
|||
return json.dumps(improved)
|
||||
|
||||
|
||||
## HTML (& hyperdata) responses
|
||||
@app.get("/improvements", response_class=HTMLResponse)
|
||||
def list_improvements():
|
||||
improved = load_existing_improvements()
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class 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)
|
||||
|
||||
def rewrite_title_with_groq(self, original_content: str) -> str:
|
||||
def rewrite_title(self, original_content: str) -> str:
|
||||
suggestions = self.client.chat.completions.create(
|
||||
messages=[
|
||||
{
|
||||
|
|
@ -51,7 +51,7 @@ class LLMClient:
|
|||
raise ValueError
|
||||
return winner_str.strip(" \"'")
|
||||
|
||||
def rewrite_summary_with_groq(self, orig: Original, improved_title: str) -> str:
|
||||
def rewrite_summary(self, orig: Original, improved_title: str) -> str:
|
||||
summary = self.client.chat.completions.create(
|
||||
messages=[
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue