Update app.py
Browse files
app.py
CHANGED
@@ -84,9 +84,9 @@ def submit_questions(answers: list[Dict[str, Any]]) -> Dict[str, Any]:
|
|
84 |
print(f"Response Body: {e.response.text if e.response else 'No response'}")
|
85 |
raise
|
86 |
|
87 |
-
# Wrap API functions in ADK Tools
|
88 |
-
responses_api = FunctionTool(func=answer_questions
|
89 |
-
submit_api = FunctionTool(func=submit_questions
|
90 |
|
91 |
# --- Agent Definitions ---
|
92 |
|
@@ -94,14 +94,14 @@ APP_NAME = "gaia_challenge_agent"
|
|
94 |
USER_ID = "test_user"
|
95 |
SESSION_ID = "main_session"
|
96 |
|
97 |
-
# A specialized agent for tasks requiring code
|
98 |
code_agent = LlmAgent(
|
99 |
name='CodeAgent',
|
100 |
-
model="gemini-
|
101 |
-
description="
|
102 |
instruction=(
|
103 |
-
"You are an expert in data analysis and code
|
104 |
-
"write Python code to find the answer. "
|
105 |
"Use pandas for data files. Fetch remote files using requests. "
|
106 |
"Your final output must be only the answer to the question, with no extra text or explanation."
|
107 |
),
|
@@ -111,7 +111,7 @@ code_agent = LlmAgent(
|
|
111 |
# A specialized agent for web searches
|
112 |
search_agent = LlmAgent(
|
113 |
name='SearchAgent',
|
114 |
-
model="gemini-
|
115 |
description="Searches the web to answer questions about current events, facts, or general knowledge. Responds with only the final, exact answer.",
|
116 |
instruction=(
|
117 |
"You are an expert web researcher. You will be given a question. "
|
@@ -125,7 +125,7 @@ search_agent = LlmAgent(
|
|
125 |
# A specialized agent for image analysis
|
126 |
image_agent = LlmAgent(
|
127 |
name='ImageAgent',
|
128 |
-
model="gemini-
|
129 |
description="Analyzes an image to answer a question about its content. Responds with only the final, exact answer.",
|
130 |
instruction=(
|
131 |
"You are an expert image analyst. You will be given a question and a URL to an image. "
|
@@ -137,7 +137,7 @@ image_agent = LlmAgent(
|
|
137 |
# A specialized agent for video analysis
|
138 |
youtube_agent = LlmAgent(
|
139 |
name='YouTubeAgent',
|
140 |
-
model="gemini-
|
141 |
description="Watches a YouTube video to answer a question about its content. Responds with only the final, exact answer.",
|
142 |
instruction=(
|
143 |
"You are an expert video analyst. You will be given a question and a URL to a YouTube video. "
|
@@ -149,7 +149,7 @@ youtube_agent = LlmAgent(
|
|
149 |
# The main orchestrator agent
|
150 |
root_agent = LlmAgent(
|
151 |
name='OrchestratorAgent',
|
152 |
-
model="gemini-
|
153 |
description="Manages a team of specialized agents to answer a list of questions and submits them for scoring.",
|
154 |
instruction=(
|
155 |
"You are the project manager. Your goal is to answer a series of questions and submit them. "
|
@@ -180,7 +180,6 @@ async def run_agent_process():
|
|
180 |
session = await session_service.create_session(
|
181 |
app_name=APP_NAME, user_id=USER_ID, session_id=SESSION_ID
|
182 |
)
|
183 |
-
# Corrected the print statement below
|
184 |
print(f"===== Agent Process Started for session: {session.session_id} =====")
|
185 |
|
186 |
initial_prompt = "Get all the questions, answer each one using your specialized agents, and submit the final list of answers for scoring."
|
|
|
84 |
print(f"Response Body: {e.response.text if e.response else 'No response'}")
|
85 |
raise
|
86 |
|
87 |
+
# Wrap API functions in ADK Tools - The description is taken from the function's docstring.
|
88 |
+
responses_api = FunctionTool(func=answer_questions)
|
89 |
+
submit_api = FunctionTool(func=submit_questions)
|
90 |
|
91 |
# --- Agent Definitions ---
|
92 |
|
|
|
94 |
USER_ID = "test_user"
|
95 |
SESSION_ID = "main_session"
|
96 |
|
97 |
+
# A specialized agent for tasks requiring code generation
|
98 |
code_agent = LlmAgent(
|
99 |
name='CodeAgent',
|
100 |
+
model="gemini-2.0-flash-lite", # Using Pro for complex code generation
|
101 |
+
description="Generates Python code to analyze data files (.csv, .xlsx, .json, .py) to answer a question. Responds with only the final, exact answer.",
|
102 |
instruction=(
|
103 |
+
"You are an expert in data analysis and code generation. Given a question and a file URL, "
|
104 |
+
"write Python code to find the answer. You cannot execute the code. "
|
105 |
"Use pandas for data files. Fetch remote files using requests. "
|
106 |
"Your final output must be only the answer to the question, with no extra text or explanation."
|
107 |
),
|
|
|
111 |
# A specialized agent for web searches
|
112 |
search_agent = LlmAgent(
|
113 |
name='SearchAgent',
|
114 |
+
model="gemini-2.0-flash-lite", # Flash is efficient for search-and-answer
|
115 |
description="Searches the web to answer questions about current events, facts, or general knowledge. Responds with only the final, exact answer.",
|
116 |
instruction=(
|
117 |
"You are an expert web researcher. You will be given a question. "
|
|
|
125 |
# A specialized agent for image analysis
|
126 |
image_agent = LlmAgent(
|
127 |
name='ImageAgent',
|
128 |
+
model="gemini-2.0-flash-lite", # Flash model has vision capabilities
|
129 |
description="Analyzes an image to answer a question about its content. Responds with only the final, exact answer.",
|
130 |
instruction=(
|
131 |
"You are an expert image analyst. You will be given a question and a URL to an image. "
|
|
|
137 |
# A specialized agent for video analysis
|
138 |
youtube_agent = LlmAgent(
|
139 |
name='YouTubeAgent',
|
140 |
+
model="gemini-2.0-flash-lite", # Flash model has vision capabilities
|
141 |
description="Watches a YouTube video to answer a question about its content. Responds with only the final, exact answer.",
|
142 |
instruction=(
|
143 |
"You are an expert video analyst. You will be given a question and a URL to a YouTube video. "
|
|
|
149 |
# The main orchestrator agent
|
150 |
root_agent = LlmAgent(
|
151 |
name='OrchestratorAgent',
|
152 |
+
model="gemini-2.0-flash-lite", # Pro for robust orchestration
|
153 |
description="Manages a team of specialized agents to answer a list of questions and submits them for scoring.",
|
154 |
instruction=(
|
155 |
"You are the project manager. Your goal is to answer a series of questions and submit them. "
|
|
|
180 |
session = await session_service.create_session(
|
181 |
app_name=APP_NAME, user_id=USER_ID, session_id=SESSION_ID
|
182 |
)
|
|
|
183 |
print(f"===== Agent Process Started for session: {session.session_id} =====")
|
184 |
|
185 |
initial_prompt = "Get all the questions, answer each one using your specialized agents, and submit the final list of answers for scoring."
|