Skip to content

Commit 55347b8

Browse files
committed
Backend almost completed
1 parent f5d5f02 commit 55347b8

File tree

1 file changed

+58
-55
lines changed

1 file changed

+58
-55
lines changed

backend/EduAssitant_Agents/agent.py

Lines changed: 58 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,69 @@
1-
import datetime
2-
from zoneinfo import ZoneInfo
31
from google.adk.agents import Agent, LoopAgent
2+
from google.adk.tools import google_search
43

5-
def get_weather(city: str) -> dict:
6-
"""Retrieves the current weather report for a specified city.
7-
8-
Args:
9-
city (str): The name of the city for which to retrieve the weather report.
10-
11-
Returns:
12-
dict: status and result or error msg.
13-
"""
14-
if city.lower() == "new york":
15-
return {
16-
"status": "success",
17-
"report": (
18-
"The weather in New York is sunny with a temperature of 25 degrees"
19-
" Celsius (77 degrees Fahrenheit)."
20-
),
21-
}
22-
else:
23-
return {
24-
"status": "error",
25-
"error_message": f"Weather information for '{city}' is not available.",
26-
}
27-
28-
29-
def get_current_time(city: str) -> dict:
30-
"""Returns the current time in a specified city.
31-
32-
Args:
33-
city (str): The name of the city for which to retrieve the current time.
34-
35-
Returns:
36-
dict: status and result or error msg.
37-
"""
4+
summarizer_agent = Agent(
5+
name="Summarizer_Agent",
6+
model="gemini-2.0-flash",
7+
description=(
8+
"You are a Summarizer Agent operating under the control of a Manager Agent in a multi-agent system. Your sole purpose is to generate concise, accurate, and coherent summaries from the content provided to you."
9+
),
10+
instruction=(
11+
"You are the Summarizer Agent responsible for generating accurate, concise summaries of the content provided to you by the Manager Agent. Also you are to return this output back to the manager agent."
12+
)
13+
)
3814

39-
if city.lower() == "new york":
40-
tz_identifier = "America/New_York"
41-
else:
42-
return {
43-
"status": "error",
44-
"error_message": (
45-
f"Sorry, I don't have timezone information for {city}."
46-
),
47-
}
15+
reference_agent = Agent(
16+
name="Reference_Agent",
17+
model="gemini-2.0-flash",
18+
description=(
19+
"This is an AI agent which is responsible for extracting relevant references or citations from the content provided to it."
20+
),
21+
instruction=(
22+
"""You are a Reference Extraction Agent working under a Manager Agent in a multi-agent system.
23+
Your primary responsibility is to carefully scan the provided content and extract all relevant references or citations strictly from this content. These may include:
4824
49-
tz = ZoneInfo(tz_identifier)
50-
now = datetime.datetime.now(tz)
51-
report = (
52-
f'The current time in {city} is {now.strftime("%Y-%m-%d %H:%M:%S %Z%z")}'
25+
- Document titles
26+
- Section or subsection headings/numbers
27+
- In-text citations
28+
- Footnotes
29+
- Bibliographic references
30+
- URLs or document links
31+
- Mentioned papers, books, articles, datasets, standards, or guidelines
32+
- Any internal or external reference points stated in the content
33+
34+
35+
Also you are to return this output back to the manager agent."""
5336
)
54-
return {"status": "success", "report": report}
37+
)
5538

56-
summarizer_agent = Agent(
57-
name="Summarizer_Agent",
39+
flash_card_agent = Agent(
40+
name="Flash_Card_Agent",
5841
model="gemini-2.0-flash",
5942
description=(
60-
"You are a Summarizer Agent operating under the control of a Manager Agent in a multi-agent system. Your sole purpose is to generate concise, accurate, and coherent summaries from the content provided to you."
43+
"This is an AI agent which is responsible for generating flash cards from the content provided to it."
6144
),
6245
instruction=(
63-
"You are the Summarizer Agent responsible for generating accurate, concise summaries of the content provided by the Manager Agent."
46+
"""You are a Flashcard Generation Agent working under the Manager Agent in a multi-agent system.
47+
Your primary responsibility is to generate a list of question-answer flashcards designed to aid in the quick revision of the concepts, facts, and ideas present in the provided content.
48+
49+
These flashcards are intended to cover all critical points, definitions, formulas, principles, processes, or factual data contained within the content.
50+
You must not use any outside knowledge, assumptions, or inference beyond what is present in the provided material.
51+
52+
You are to return the flashcards in a json format with the following structure:
53+
{
54+
"flashcards": [
55+
{
56+
"question": "Question 1",
57+
"answer": "Answer 1"
58+
},
59+
{
60+
"question": "Question 2",
61+
"answer": "Answer 2"
62+
}
63+
]
64+
}
65+
66+
Also you are to return this output back to the manager agent."""
6467
)
6568
)
6669

@@ -71,9 +74,9 @@ def get_current_time(city: str) -> dict:
7174
"This AI agent functions as an orchestrator and coordinator in a multi-agent system designed to answer queries based on domain-specific content provided to it. Its primary role is to manage the interactions between multiple specialized agents and ensure accurate, context-aware, and efficient responses to user queries."
7275
),
7376
instruction=(
74-
"You are the Manager Agent responsible for managing and directing a set of specialized AI sub-agents. Your purpose is to answer user queries solely based on the content provided to you, ensuring accuracy, relevance, and clarity."
77+
"You are the Manager Agent responsible for managing and directing a set of specialized AI sub-agents. Your purpose is to answer user queries solely based on the content provided to you, ensuring accuracy, relevance, and clarity. You are also responsible for giving the output to the user in whatever structure it desires be it json or pdf or any other format."
7578
),
76-
sub_agents=[summarizer_agent],
79+
sub_agents=[summarizer_agent, reference_agent, flash_card_agent],
7780
)
7881

7982
root_agent = LoopAgent(

0 commit comments

Comments
 (0)