Consolidate calls to openai

Starting to abstract away the calls to openai
This commit is contained in:
Taylor Brown
2023-04-02 21:51:07 -05:00
parent 744c5fa25b
commit ae9448cb89
5 changed files with 29 additions and 17 deletions

View File

@@ -4,6 +4,7 @@ from bs4 import BeautifulSoup
from readability import Document
import openai
from config import Config
from llm_utils import create_chat_completion
cfg = Config()
@@ -101,13 +102,11 @@ def summarize_text(text, is_website=True):
chunk},
]
response = openai.ChatCompletion.create(
summary = create_chat_completion(
model=cfg.fast_llm_model,
messages=messages,
max_tokens=300,
)
summary = response.choices[0].message.content
summaries.append(summary)
print("Summarized " + str(len(chunks)) + " chunks.")
@@ -129,11 +128,10 @@ def summarize_text(text, is_website=True):
combined_summary},
]
response = openai.ChatCompletion.create(
final_summary = create_chat_completion(
model=cfg.fast_llm_model,
messages=messages,
max_tokens=300,
)
final_summary = response.choices[0].message.content
return final_summary