From fb0854a1f92d41e189a7d2360e024f0d5e8bb871 Mon Sep 17 00:00:00 2001 From: josedario87 Date: Wed, 14 May 2025 14:26:59 -0600 Subject: [PATCH] corriendo ejemplo google ADK --- .gitignore | 1 + multi_tool_agent/.env | 2 + multi_tool_agent/__init__.py | 1 + .../__pycache__/__init__.cpython-312.pyc | Bin 0 -> 208 bytes .../__pycache__/agent.cpython-312.pyc | Bin 0 -> 2194 bytes multi_tool_agent/agent.py | 67 ++++++++++++++++++ 6 files changed, 71 insertions(+) create mode 100644 .gitignore create mode 100644 multi_tool_agent/.env create mode 100644 multi_tool_agent/__init__.py create mode 100644 multi_tool_agent/__pycache__/__init__.cpython-312.pyc create mode 100644 multi_tool_agent/__pycache__/agent.cpython-312.pyc create mode 100644 multi_tool_agent/agent.py 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 0000000000000000000000000000000000000000..fb1f939e1f023a5d3498351350425c7d5c465a7b GIT binary patch literal 208 zcmX@j%ge<81Rt*|WQYOj#~=<2FhLog1%Qm{3@HpLj5!Rsj8Tk?43$ip%r6;%!kUb? zSQFDz^Gf_QnQk!@F$0BGGJFPU{N?9t6_b~*kY1Wtl#*B!lUJIYlbWv(W(;NNg0-P? za!YecGUH3~^K;@Mvhnemd6^~g@p=W7w>WHa^HWN5QtgU3fX0I?F9tC_Ff%eT-eV9h HVgqsj4UIOI literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..fa045e2d2bdd257d18b98aea38850090209923ef GIT binary patch literal 2194 zcmcIlL2MI86rEk~+Us?khJ*$XgiM93#8u;>KmkP+GzGOqRcV2$EiRI^*%{j#*1PHK zY@)1;1Zt(KQY&#I5=G(&qEfFMIk!ES=0LhFQly@Ga}-XT`v2HL38z+7NAk>{nLq#k z{r~;vpNmDC!1#8RHowae@+WS#hSe7~=Rmkg7-5=Es<`UD*3zrGhH}Qww2Z0&vcXMe z@@(B;*{_UhZreTwdrK$WU>3_Wn-zGDTMhk(f%|69M>W5!m5YDj=3H4zt!fzXvq3!s z*_>_gK&FQ4$>lUFxQs>MYQ1M_Hek-cZ}SXHH%Xh!Z@*P4gxv41OuI5kh%lMXGR*j1 zzet$LvTbsUu-xqov+$&xPky_=rSSM7kEm>N>c&Dq5Oj$!^6ELt5#lECqmJ0!MD{53!IM1wrFVW>tTuF0L?7BRPk~xfN z%aIq*bD(hvG^iKRC=P;Uy5z|we5&NF1unpeP~lI%K^bod4p}K;>g18JWNcf>2Ut(eZp|&gWoA z6rh%AQN6CUAbzL85hs4Q#6?*X2&o7mK%c#TdggKv(njnE=7`Hd?D{;UpB(8+Q}8m7 zJ2x#zn^%)z=+}C;YOX9Sr-cTWwSJbwFxXd)-U8to=?)WX;Opdi@@4x*@@wvu_0jRJ zq3t@lk;@L*U6Re)pt0xR+W3hFyB}mbC(n1rE^L??yvyY6O|U_BU^)v23e&%U@DDMa zVfs}q$Rn;5o=w1W7V#|6k{WI8e!n-a>Js}#jrr%&)(Ii=Kn5?4w*LHehUJtGtDTw8 zzo|&%_kXw3Rwtvs|K3ajDKZ(FZE@kb z&g;-OHS8Nv#N(-pp%BZj(X*6=!GxquXOUC%n*h1Nx9&uHs#U}wKHH7WxIIivOJZOr zB%`HEQ>E5aiP6$~Go=q^N*8IVT1o_#Kp>HqO)-QrRy?(sBRM)uGeNkNTEIVb+=3E9 zH!aGf<}v61WG|8GG7)?5@c>K_Y9Mt{u?uyF5d8h9YG_34hvPBSybcp|!0w$Lu(tQr zZ;IV4fPQ`W)I;OJ;=}Wup?5cOCSu;q+fN6HJ$z$oHBYa-{f9mL*xvuh-v8Jhe`Jr} z(O2z5*G{k72Up}u{mz-YBR?Lvcc63Z+-mv5&g4fO>wGsu%mNyxcaJ?POm~cFF@jMJ z_uErN*z4Z}B5!$tH#J>3JXQCdsF|Fa#kNPLb%F>ugMJb72x$kXb1sbG1}cExsF-vc zFFHMjPd>jC#?%20bZC?N3-#EiiY0);L+Uz!;-1|&`uE1mW@_NyLu$4{#{IOwc;pIi z0pm*xUI0amU9~Zhq@uDdM)A`vM3n-Ss{O7;7&d?|9d@OnVv7WJd76RuseykNio#SC zQ(J_g?4|1-QJL%&-Fg#Zh<$!iz<(w|=7>InshiO>?RWCh6EgOM9O@b`YxWJdOJG@H zo49lj@6(Q~9O)8R?i}63W#a@H99hect=R|Gt+P 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