Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,12 +12,12 @@ if not OPENAI_API_KEY:
|
|
| 12 |
|
| 13 |
client = OpenAI(api_key=OPENAI_API_KEY)
|
| 14 |
|
| 15 |
-
# ✅ Ensure
|
| 16 |
def respond(user_message, history):
|
| 17 |
if not user_message:
|
| 18 |
return "", history
|
| 19 |
|
| 20 |
-
# ✅ AI
|
| 21 |
try:
|
| 22 |
assistant_reply = client.chat.completions.create(
|
| 23 |
model="gpt-4o",
|
|
@@ -29,7 +29,7 @@ def respond(user_message, history):
|
|
| 29 |
],
|
| 30 |
{"role": "user", "content": user_message}
|
| 31 |
],
|
| 32 |
-
max_tokens=
|
| 33 |
temperature=0.7,
|
| 34 |
).choices[0].message.content
|
| 35 |
except Exception as e:
|
|
|
|
| 12 |
|
| 13 |
client = OpenAI(api_key=OPENAI_API_KEY)
|
| 14 |
|
| 15 |
+
# ✅ Ensure AI asks users first & only helps if needed
|
| 16 |
def respond(user_message, history):
|
| 17 |
if not user_message:
|
| 18 |
return "", history
|
| 19 |
|
| 20 |
+
# ✅ AI waits for user answers before solving
|
| 21 |
try:
|
| 22 |
assistant_reply = client.chat.completions.create(
|
| 23 |
model="gpt-4o",
|
|
|
|
| 29 |
],
|
| 30 |
{"role": "user", "content": user_message}
|
| 31 |
],
|
| 32 |
+
max_tokens=300, # ✅ Prevents cutting off messages
|
| 33 |
temperature=0.7,
|
| 34 |
).choices[0].message.content
|
| 35 |
except Exception as e:
|