Spaces:
Sleeping
Sleeping
Update app.py
Browse files11 unmodified lines1213141516171819202122235 unmodified lines2930313233343511 unmodified linesclient = OpenAI(api_key=OPENAI_API_KEY)# ✅ Ensure Conversation Happens Step by Stepdef respond(user_message, history):if not user_message:return "", history# ✅ AI only sends ONE response at a time (step-by-step)try:assistant_reply = client.chat.completions.create(model="gpt-4o",5 unmodified lines],{"role": "user", "content": user_message}],max_tokens=256, # ✅ Limits response size (so AI doesn’t dump everything)temperature=0.7,).choices[0].message.contentexcept Exception as e:11 unmodified lines1213141516171819202122235 unmodified lines2930313233343511 unmodified linesclient = OpenAI(api_key=OPENAI_API_KEY)# ✅ Ensure AI asks users first & only helps if neededdef respond(user_message, history):if not user_message:return "", history# ✅ AI waits for user answers before solvingtry:assistant_reply = client.chat.completions.create(model="gpt-4o",5 unmodified lines],{"role": "user", "content": user_message}],max_tokens=300, # ✅ Prevents cutting off messagestemperature=0.7,).choices[0].message.contentexcept Exception as e:
app.py+3-3