Update app.py
Browse files
app.py
CHANGED
@@ -53,25 +53,28 @@ def calculate(expression: str) -> str:
|
|
53 |
# --- Agent ---
|
54 |
class GAIAAgent:
|
55 |
def __init__(self):
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
tools=[web_search, calculate],
|
61 |
-
model=model,
|
62 |
-
)
|
63 |
|
64 |
-
def __call__(self, question: str) -> str:
|
65 |
try:
|
66 |
-
|
67 |
-
|
68 |
-
system_prompt
|
69 |
-
|
70 |
-
|
71 |
-
)
|
72 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
except Exception as e:
|
74 |
-
return f"Error: {e}"
|
75 |
|
76 |
# --- Gradio UI + Submission ---
|
77 |
def submit_answers(profile: gr.OAuthProfile | None):
|
|
|
53 |
# --- Agent ---
|
54 |
class GAIAAgent:
|
55 |
def __init__(self):
|
56 |
+
self.system_prompt = """You are an AI assistant that answers questions using tools:
|
57 |
+
- Use web_search for factual queries
|
58 |
+
- Use calculate for math problems
|
59 |
+
- Be concise and accurate."""
|
|
|
|
|
|
|
60 |
|
|
|
61 |
try:
|
62 |
+
self.agent = ToolCallingAgent(
|
63 |
+
name="GAIA_Agent",
|
64 |
+
description=self.system_prompt, # this sets the prompt
|
65 |
+
tools=[web_search, calculate],
|
66 |
+
model=client.chat.completions # callable, no kwargs
|
|
|
67 |
)
|
68 |
+
print("✅ Agent initialized successfully")
|
69 |
+
except Exception as e:
|
70 |
+
raise RuntimeError(f"Agent init failed: {str(e)}")
|
71 |
+
|
72 |
+
def __call__(self, question: str) -> str:
|
73 |
+
try:
|
74 |
+
response = self.agent.run(question) # <-- no system_prompt here
|
75 |
+
return str(response) if response else "No answer generated"
|
76 |
except Exception as e:
|
77 |
+
return f"Error: {str(e)}"
|
78 |
|
79 |
# --- Gradio UI + Submission ---
|
80 |
def submit_answers(profile: gr.OAuthProfile | None):
|