Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -61,4 +61,21 @@ def run_agent(user_input):
|
|
61 |
|
62 |
print("Raw Model Response:", raw_response) # Debug output (optional)
|
63 |
|
64 |
-
if not
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
print("Raw Model Response:", raw_response) # Debug output (optional)
|
63 |
|
64 |
+
if not raw_response.strip():
|
65 |
+
return "I'm sorry, but I couldn't generate a response. Please try again."
|
66 |
+
|
67 |
+
clean_response = remove_code_snippets(raw_response)
|
68 |
+
words = clean_response.split()
|
69 |
+
if len(set(words)) < 5: # Check for repetition or overly brief output.
|
70 |
+
return "I'm unable to generate a meaningful response. Please refine your query."
|
71 |
+
return clean_response
|
72 |
+
|
73 |
+
# Create a simple agent wrapper with a run method.
|
74 |
+
class SimpleAgent:
|
75 |
+
def __init__(self, run_function):
|
76 |
+
self.run = run_function
|
77 |
+
|
78 |
+
agent = SimpleAgent(run_agent)
|
79 |
+
|
80 |
+
# Launch the Gradio UI using the simple agent.
|
81 |
+
GradioUI(agent).launch()
|