mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
feat: Make skill instruction optimizable and can adapt to user tasks
PiperOrigin-RevId: 869971535
This commit is contained in:
committed by
Copybara-Service
parent
3fbc27fa4d
commit
21be6adcb8
@@ -14,7 +14,6 @@
|
||||
|
||||
from unittest import mock
|
||||
|
||||
from google.adk.models import llm_request
|
||||
from google.adk.skills import models
|
||||
from google.adk.tools import skill_toolset
|
||||
from google.adk.tools import tool_context
|
||||
@@ -124,32 +123,23 @@ def test_list_skills(mock_skill1, mock_skill2):
|
||||
async def test_get_tools(mock_skill1, mock_skill2):
|
||||
toolset = skill_toolset.SkillToolset([mock_skill1, mock_skill2])
|
||||
tools = await toolset.get_tools()
|
||||
assert len(tools) == 2
|
||||
assert isinstance(tools[0], skill_toolset.LoadSkillTool)
|
||||
assert isinstance(tools[1], skill_toolset.LoadSkillResourceTool)
|
||||
assert len(tools) == 3
|
||||
assert isinstance(tools[0], skill_toolset.ListSkillsTool)
|
||||
assert isinstance(tools[1], skill_toolset.LoadSkillTool)
|
||||
assert isinstance(tools[2], skill_toolset.LoadSkillResourceTool)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_process_llm_request(
|
||||
@pytest.mark.asyncio
|
||||
async def test_list_skills_tool(
|
||||
mock_skill1, mock_skill2, tool_context_instance
|
||||
):
|
||||
toolset = skill_toolset.SkillToolset([mock_skill1, mock_skill2])
|
||||
mock_llm_request = llm_request.LlmRequest()
|
||||
mock_llm_request.config.system_instruction = "existing instruction"
|
||||
await toolset.process_llm_request(
|
||||
tool_context=tool_context_instance, llm_request=mock_llm_request
|
||||
)
|
||||
assert "<available_skills>" in mock_llm_request.config.system_instruction
|
||||
assert (
|
||||
"You can use specialized 'skills'"
|
||||
in mock_llm_request.config.system_instruction
|
||||
)
|
||||
assert (
|
||||
"skills are folders" in mock_llm_request.config.system_instruction.lower()
|
||||
)
|
||||
assert mock_llm_request.config.system_instruction.startswith(
|
||||
"existing instruction"
|
||||
)
|
||||
tool = skill_toolset.ListSkillsTool(toolset)
|
||||
result = await tool.run_async(args={}, tool_context=tool_context_instance)
|
||||
assert "<available_skills>" in result
|
||||
assert "skill1" in result
|
||||
assert "skill2" in result
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in New Issue
Block a user