Update app.py
Browse files
app.py
CHANGED
|
@@ -143,15 +143,20 @@ class BasicAgent:
|
|
| 143 |
llm = ChatOpenAI(model="gpt-4o", temperature=0)
|
| 144 |
self.agent= CodeAgent(
|
| 145 |
tools = [add, subtract, multiply, divide, web_search, image_generation_tool],
|
| 146 |
-
|
| 147 |
)
|
| 148 |
-
def __call__(self, question: str,context: str="") -> str:
|
| 149 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 150 |
# Inject system prompt + question
|
| 151 |
question_with_prompt = f"{self.system_prompt}\n\nContext: {context}\n\nQuestion: {question.strip()}"
|
| 152 |
answer = self.agent.run(question_with_prompt)
|
| 153 |
-
|
| 154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
|
| 156 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 157 |
"""
|
|
|
|
| 143 |
llm = ChatOpenAI(model="gpt-4o", temperature=0)
|
| 144 |
self.agent= CodeAgent(
|
| 145 |
tools = [add, subtract, multiply, divide, web_search, image_generation_tool],
|
| 146 |
+
llm=llm,
|
| 147 |
)
|
| 148 |
+
def __call__(self, question: str, context: str = "") -> str:
|
| 149 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 150 |
# Inject system prompt + question
|
| 151 |
question_with_prompt = f"{self.system_prompt}\n\nContext: {context}\n\nQuestion: {question.strip()}"
|
| 152 |
answer = self.agent.run(question_with_prompt)
|
| 153 |
+
# Fix: handle dict or string
|
| 154 |
+
if isinstance(answer, dict) and "content" in answer:
|
| 155 |
+
result = answer["content"]
|
| 156 |
+
else:
|
| 157 |
+
result = str(answer)
|
| 158 |
+
print(f"Agent returning answer: {result.strip()}")
|
| 159 |
+
return result.strip()
|
| 160 |
|
| 161 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 162 |
"""
|