max-unfinity
chatgpt
9beb013
raw
history blame contribute delete
722 Bytes
from openai import OpenAI
def get_models(api_key):
client = OpenAI(api_key=api_key)
models = client.models.list()
models = sorted([model.id for model in models.data if model.id.startswith("gpt")])
return models
def query(api_key, reviews: list, model: str = "gpt-3.5-turbo"):
client = OpenAI(api_key=api_key)
message = str(reviews) + "\n\nAnalyze and provide a structured summary of both the positive and negative features of the hotel based on the above reviews. Quantify the frequency of each aspect mentioned in the reviews."
stream = client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": message}],
stream=True,
)
return stream