Files

62 lines
1.9 KiB
Python
Raw Permalink Normal View History

2026-02-09 13:46:16 -08:00
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Example agent demonstrating the use of SkillToolset."""
2026-02-11 18:10:18 -08:00
import pathlib
2026-02-09 13:46:16 -08:00
from google.adk import Agent
2026-02-11 18:10:18 -08:00
from google.adk.skills import load_skill_from_dir
2026-02-09 13:46:16 -08:00
from google.adk.skills import models
from google.adk.tools import skill_toolset
greeting_skill = models.Skill(
frontmatter=models.Frontmatter(
name="greeting-skill",
description=(
"A friendly greeting skill that can say hello to a specific person."
),
),
instructions=(
"Step 1: Read the 'references/hello_world.txt' file to understand how"
" to greet the user. Step 2: Return a greeting based on the reference."
),
resources=models.Resources(
references={
"hello_world.txt": "Hello! 👋👋👋 So glad to have you here! ✨✨✨",
"example.md": "This is an example reference.",
},
),
)
2026-02-11 18:10:18 -08:00
weather_skill = load_skill_from_dir(
pathlib.Path(__file__).parent / "skills" / "weather_skill"
)
my_skill_toolset = skill_toolset.SkillToolset(
skills=[greeting_skill, weather_skill]
)
2026-02-09 13:46:16 -08:00
root_agent = Agent(
model="gemini-2.5-flash",
name="skill_user_agent",
description="An agent that can use specialized skills.",
instruction=(
"You are a helpful assistant that can leverage skills to perform tasks."
),
tools=[
my_skill_toolset,
],
)