Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -28,14 +28,17 @@ def create_assistant_json(uploaded_file, assistant_name, assistant_message):
|
|
| 28 |
return assistant.id
|
| 29 |
|
| 30 |
def generate_response(prompt):
|
|
|
|
| 31 |
instruction = "Please generate a cocktail recipe based on the user's mood description.\n\n"
|
| 32 |
prompt = instruction + prompt
|
|
|
|
|
|
|
|
|
|
| 33 |
try:
|
| 34 |
-
response =
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
max_tokens=150
|
| 38 |
-
)
|
| 39 |
return response.choices[0].text.strip()
|
| 40 |
except Exception as e:
|
| 41 |
return str(e)
|
|
|
|
| 28 |
return assistant.id
|
| 29 |
|
| 30 |
def generate_response(prompt):
|
| 31 |
+
client = openai.OpenAI(api_key=os.environ["API_TOKEN"])
|
| 32 |
instruction = "Please generate a cocktail recipe based on the user's mood description.\n\n"
|
| 33 |
prompt = instruction + prompt
|
| 34 |
+
|
| 35 |
+
response = client.chat.completions.create(
|
| 36 |
+
model="gpt-4-0125-preview")
|
| 37 |
try:
|
| 38 |
+
response = client.chat.completions.create(
|
| 39 |
+
model="gpt-4-0125-preview",
|
| 40 |
+
message=prompt,
|
| 41 |
+
max_tokens=150)
|
|
|
|
| 42 |
return response.choices[0].text.strip()
|
| 43 |
except Exception as e:
|
| 44 |
return str(e)
|