Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os

import chromadb
import openai
from openai import OpenAI
from chromadb.utils import embedding_functions

os.environ["TOKENIZERS_PARALLELISM"] = "false"
Expand All @@ -15,7 +15,7 @@
with open("config.json", "r") as json_file:
config_data = json.load(json_file)

openai.api_key = config_data.get("openai-secret-key")
openai_client = OpenAI(api_key=config_data.get("openai-secret-key"))

client = chromadb.PersistentClient(CHROMA_PATH)
embedding_func = embedding_functions.SentenceTransformerEmbeddingFunction(
Expand Down Expand Up @@ -46,7 +46,7 @@

reviews_str = ",".join(good_reviews["documents"][0])

good_review_summaries = openai.ChatCompletion.create(
good_review_summaries = openai_client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": context.format(reviews_str)},
Expand All @@ -62,7 +62,7 @@
print(reviews_str)
print("###########################################")

good_review_summaries = openai.ChatCompletion.create(
good_review_summaries = openai_client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": context.format(reviews_str)},
Expand All @@ -73,7 +73,7 @@
)

print("AI-Generated summary of good reviews: ")
print(good_review_summaries["choices"][0]["message"]["content"])
print(good_review_summaries.choices[0].message.content)
print("###########################################")


Expand All @@ -99,7 +99,7 @@
print(poor_reviews["documents"][0][0])
print("###########################################")

poor_review_analysis = openai.ChatCompletion.create(
poor_review_analysis = openai_client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": context.format(reviews_str)},
Expand All @@ -110,5 +110,5 @@
)

print("AI-Generated summary of the single worst review: ")
print(poor_review_analysis["choices"][0]["message"]["content"])
print("###########################################")
print(poor_review_analysis.choices[0].message.content)
print("###########################################")
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ networkx==3.2
nltk==3.8.1
numpy==1.26.1
onnxruntime==1.16.1
openai==0.28.1
openai>=1.0.0
overrides==7.4.0
packaging==23.2
Pillow==10.1.0
Expand Down