diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0cafc1c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.venv/ \ No newline at end of file diff --git a/multi_tool_agent/.env b/multi_tool_agent/.env new file mode 100644 index 0000000..975d235 --- /dev/null +++ b/multi_tool_agent/.env @@ -0,0 +1,2 @@ +GOOGLE_GENAI_USE_VERTEXAI=FALSE +GOOGLE_API_KEY=AIzaSyDndRqYTYfbsYOhGhCnkGGvpapOPTm-pBQ \ No newline at end of file diff --git a/multi_tool_agent/__init__.py b/multi_tool_agent/__init__.py new file mode 100644 index 0000000..66599b5 --- /dev/null +++ b/multi_tool_agent/__init__.py @@ -0,0 +1 @@ +from . import agent \ No newline at end of file diff --git a/multi_tool_agent/__pycache__/__init__.cpython-312.pyc b/multi_tool_agent/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..fb1f939 Binary files /dev/null and b/multi_tool_agent/__pycache__/__init__.cpython-312.pyc differ diff --git a/multi_tool_agent/__pycache__/agent.cpython-312.pyc b/multi_tool_agent/__pycache__/agent.cpython-312.pyc new file mode 100644 index 0000000..fa045e2 Binary files /dev/null and b/multi_tool_agent/__pycache__/agent.cpython-312.pyc differ diff --git a/multi_tool_agent/agent.py b/multi_tool_agent/agent.py new file mode 100644 index 0000000..da6309a --- /dev/null +++ b/multi_tool_agent/agent.py @@ -0,0 +1,67 @@ +import datetime +from zoneinfo import ZoneInfo +from google.adk.agents import Agent + +def get_weather(city: str) -> dict: + """Retrieves the current weather report for a specified city. + + Args: + city (str): The name of the city for which to retrieve the weather report. + + Returns: + dict: status and result or error msg. + """ + if city.lower() == "new york": + return { + "status": "success", + "report": ( + "The weather in New York is sunny with a temperature of 25 degrees" + " Celsius (77 degrees Fahrenheit)." + ), + } + else: + return { + "status": "error", + "error_message": f"Weather information for '{city}' is not available.", + } + + +def get_current_time(city: str) -> dict: + """Returns the current time in a specified city. + + Args: + city (str): The name of the city for which to retrieve the current time. + + Returns: + dict: status and result or error msg. + """ + + if city.lower() == "new york": + tz_identifier = "America/New_York" + else: + return { + "status": "error", + "error_message": ( + f"Sorry, I don't have timezone information for {city}." + ), + } + + tz = ZoneInfo(tz_identifier) + now = datetime.datetime.now(tz) + report = ( + f'The current time in {city} is {now.strftime("%Y-%m-%d %H:%M:%S %Z%z")}' + ) + return {"status": "success", "report": report} + + +root_agent = Agent( + name="weather_time_agent", + model="gemini-2.0-flash", + description=( + "Agent to answer questions about the time and weather in a city." + ), + instruction=( + "You are a helpful agent who can answer user questions about the time and weather in a city." + ), + tools=[get_weather, get_current_time], +) \ No newline at end of file