sirine1712 commited on
Commit
937b669
·
verified ·
1 Parent(s): a55ba01

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -15
app.py CHANGED
@@ -53,25 +53,28 @@ def calculate(expression: str) -> str:
53
  # --- Agent ---
54
  class GAIAAgent:
55
  def __init__(self):
56
- model = OpenAIServerModel(model_id="gpt-3.5-turbo", api_key=os.getenv("OPENAI_API_KEY"))
57
- self.agent = ToolCallingAgent(
58
- name="GAIA_Agent",
59
- description="AI assistant using web_search and calculate tools.",
60
- tools=[web_search, calculate],
61
- model=model,
62
- )
63
 
64
- def __call__(self, question: str) -> str:
65
  try:
66
- return self.agent.run(
67
- question,
68
- system_prompt=(
69
- "You are an AI assistant. Use web_search for factual queries "
70
- "and calculate for math problems. Be concise and accurate."
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):