Update app.py
Browse files
app.py
CHANGED
|
@@ -91,13 +91,17 @@ class GaiaSmolAgent:
|
|
| 91 |
Now, write the Python script to answer the user's question.
|
| 92 |
"""
|
| 93 |
messages = [{"role": "user", "content": [{"type": "text", "text": prompt}]}]
|
| 94 |
-
|
| 95 |
|
| 96 |
-
|
| 97 |
-
|
|
|
|
| 98 |
|
| 99 |
-
|
| 100 |
-
|
|
|
|
|
|
|
|
|
|
| 101 |
|
| 102 |
def __call__(self, question: str) -> str:
|
| 103 |
"""Generates and executes a single script to answer the question."""
|
|
|
|
| 91 |
Now, write the Python script to answer the user's question.
|
| 92 |
"""
|
| 93 |
messages = [{"role": "user", "content": [{"type": "text", "text": prompt}]}]
|
| 94 |
+
response_object = self.planner_model.generate(messages)
|
| 95 |
|
| 96 |
+
# --- THIS IS THE FIX ---
|
| 97 |
+
# The response is an object, not a string. We need to access its .content attribute.
|
| 98 |
+
response_content = response_object.content
|
| 99 |
|
| 100 |
+
if "```python" in response_content:
|
| 101 |
+
response_content = response_content.split("```python")[1].split("```")[0].strip()
|
| 102 |
+
|
| 103 |
+
print(f"--- Generated Script ---\n{response_content}\n------------------------")
|
| 104 |
+
return response_content
|
| 105 |
|
| 106 |
def __call__(self, question: str) -> str:
|
| 107 |
"""Generates and executes a single script to answer the question."""
|