mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-17 14:04:27 +01:00
Consolidate calls to openai
Starting to abstract away the calls to openai
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user