Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -91,14 +91,20 @@ def respond_with_langchain(
|
|
| 91 |
|
| 92 |
response = llm.invoke(prompt_text)
|
| 93 |
|
| 94 |
-
|
| 95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
|
| 97 |
full_response = f"*{mode}*\n\n{response}"
|
| 98 |
-
|
|
|
|
|
|
|
| 99 |
|
| 100 |
except Exception as e:
|
| 101 |
-
|
| 102 |
|
| 103 |
# Create the Gradio interface
|
| 104 |
demo = gr.ChatInterface(
|
|
|
|
| 91 |
|
| 92 |
response = llm.invoke(prompt_text)
|
| 93 |
|
| 94 |
+
# Ensure response is clean and properly limited
|
| 95 |
+
if isinstance(response, str):
|
| 96 |
+
response = response.strip()
|
| 97 |
+
# Conservative limit to prevent content-length issues
|
| 98 |
+
if len(response) > 2500:
|
| 99 |
+
response = response[:2500] + "... [Response truncated - ask for continuation]"
|
| 100 |
|
| 101 |
full_response = f"*{mode}*\n\n{response}"
|
| 102 |
+
|
| 103 |
+
# Return directly instead of yielding (no streaming)
|
| 104 |
+
return full_response
|
| 105 |
|
| 106 |
except Exception as e:
|
| 107 |
+
return f"Sorry, I encountered an error: {str(e)[:150]}"
|
| 108 |
|
| 109 |
# Create the Gradio interface
|
| 110 |
demo = gr.ChatInterface(
|