Spaces:
Sleeping
Sleeping
Update app.py
Browse files15 unmodified lines1617181920212218 unmodified lines414243444546474849505152535455565715 unmodified linesdef gpt_call(history, user_message,model="gpt-4o",max_tokens=512,temperature=0.7,top_p=0.95):"""18 unmodified linescompletion = client.chat.completions.create(model=model,messages=messages,max_tokens=max_tokens,temperature=temperature,top_p=top_p)# 5) Ensure LaTeX equations are properly wrapped in double $$ for renderingresponse_text = completion.choices[0].message.contentformatted_response = response_text.replace("\\[", "$$").replace("\\]", "$$")formatted_response = formatted_response.replace("\\(", "$").replace("\\)", "$")return formatted_responsedef respond(user_message, history):15 unmodified lines1617181920212218 unmodified lines41424344454647484950515253545515 unmodified linesdef gpt_call(history, user_message,model="gpt-4o",max_tokens=1500, # Increased from 512 to 1500 to prevent truncationtemperature=0.7,top_p=0.95):"""18 unmodified linescompletion = client.chat.completions.create(model=model,messages=messages,max_tokens=max_tokens, # Increased to allow longer responsestemperature=temperature,top_p=top_p)# 5) Ensure full response is returned without being cut offfull_response = "".join(choice.message.content for choice in completion.choices).strip()return full_responsedef respond(user_message, history):
app.py+5-7