8000 testing · charsoft/adk-python@36ebfb2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 36ebfb2

Browse files
committed
testing
1 parent a5bf6e3 commit 36ebfb2

File tree

5 files changed

+90
-3
lines changed

5 files changed

+90
-3
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import agent
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from google.adk.agents import Agent
2+
from google.adk.tools import google_search # Import the tool
3+
4+
root_agent = Agent(
5+
# A unique name for the agent.
6+
name="basic_search_agent",
7+
# The Large Language Model (LLM) that agent will use.
8+
model="gemini-2.0-flash-exp", # Google AI Studio
9+
#model="gemini-2.0-flash-live-preview-04-09" # Vertex AI Studio
10+
# A short description of the agent's purpose.
11+
description="Agent to answer questions using Google Search.",
12+
# Instructions to set the agent's behavior.
13+
instruction="You are an expert researcher. You always stick to the facts.",
14+
# Add google_search tool to perform grounding with Google search.
15+
tools=[google_search]
16+
)

src/google/adk/cli/utils/logs.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import os
1717
import tempfile
1818
import time
19+
import shutil
1920

2021
LOGGING_FORMAT = (
2122
'%(asctime)s - %(levelname)s - %(filename)s:%(lineno)d - %(message)s'
@@ -64,9 +65,10 @@ def log_to_tmp_folder(
6465
print(f'Log setup complete: {log_filepath}')
6566

6667
latest_log_link = os.path.join(log_dir, f'{log_file_prefix}.latest.log')
67-
if os.path.islink(latest_log_link):
68-
os.unlink(latest_log_link)
69-
os.symlink(log_filepath, latest_log_link)
68+
try:
69+
shutil.copy2(log_filepath, latest_log_link)
70+
except Exception as e:
71+
logging.getLogger(__name__).error(f"Failed to update latest log link: {e}")
7072

7173
print(f'To access latest log: tail -F {latest_log_link}')
7274
return log_filepath
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import agent
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import datetime
2+
from zoneinfo import ZoneInfo
3+
from google.adk.agents import Agent
4+
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+
"""
38+
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+
}
48+
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")}'
53+
)
54+
return {"status": "success", "report": report}
55+
56+
57+
root_agent = Agent(
58+
name="weather_time_agent",
59+
model="gemini-2.0-flash",
60+
description=(
61+
"Agent to answer questions about the time and weather in a city."
62+
),
63+
instruction=(
64+
"You are a helpful agent who can answer user questions about the time and weather in a city."
65+
),
66+
tools=[get_weather, get_current_time],
67+
)

0 commit comments

Comments
 (0)
0