MickyWin22 commited on
Commit
81388a2
·
verified ·
1 Parent(s): b585e91

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
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
- response = self.planner_model.generate(messages)
95
 
96
- if "```python" in response:
97
- response = response.split("```python")[1].split("```")[0].strip()
 
98
 
99
- print(f"--- Generated Script ---\n{response}\n------------------------")
100
- return response
 
 
 
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."""