Merge branch 'master' into dev

This commit is contained in:
Andres Caicedo
2023-04-03 13:51:36 +02:00
26 changed files with 716 additions and 183 deletions

View File

@@ -1,9 +1,9 @@
from googlesearch import search
import requests
from bs4 import BeautifulSoup
from readability import Document
import openai
from config import Config
from llm_utils import create_chat_completion
cfg = Config()
def scrape_text(url):
"""Scrape text from a webpage"""
@@ -94,7 +94,7 @@ def summarize_text(text, is_website=True):
messages = [
{
"role": "user",
"content": "Please summarize the following website text, do not describe the general website, but instead concisely extract the specifc information this subpage contains.: " +
"content": "Please summarize the following website text, do not describe the general website, but instead concisely extract the specific information this subpage contains.: " +
chunk},
]
else:
@@ -105,13 +105,11 @@ def summarize_text(text, is_website=True):
chunk},
]
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
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.")
@@ -122,7 +120,7 @@ def summarize_text(text, is_website=True):
messages = [
{
"role": "user",
"content": "Please summarize the following website text, do not describe the general website, but instead concisely extract the specifc information this subpage contains.: " +
"content": "Please summarize the following website text, do not describe the general website, but instead concisely extract the specific information this subpage contains.: " +
combined_summary},
]
else:
@@ -133,11 +131,10 @@ def summarize_text(text, is_website=True):
combined_summary},
]
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
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