Spaces:
Sleeping
Sleeping
Update app.py
Browse files15 unmodified lines161718191920212218 unmodified lines41424344444546474849505152495051545253545515 unmodified lines
def gpt_call(history, user_message, model="gpt-4o", max_tokens=512, max_tokens=1500, # Increased from 512 to 1500 to prevent truncation temperature=0.7, top_p=0.95): """18 unmodified lines completion = client.chat.completions.create( model=model, messages=messages, max_tokens=max_tokens, max_tokens=max_tokens, # Increased to allow longer responses temperature=temperature, top_p=top_p )
# 5) Ensure LaTeX equations are properly wrapped in double $$ for rendering response_text = completion.choices[0].message.content formatted_response = response_text.replace("\\[", "$$").replace("\\]", "$$") formatted_response = formatted_response.replace("\\(", "$").replace("\\)", "$") # 5) Ensure full response is returned without being cut off full_response = "".join(choice.message.content for choice in completion.choices).strip()
return formatted_response return full_response
def respond(user_message, history):app.py+5-7