mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-23 00:12:24 +00:00
add support for built in tool type
This commit is contained in:
parent
517bc9ebea
commit
1a66ddc1b5
8 changed files with 83 additions and 75 deletions
|
|
@ -9,10 +9,12 @@ import tempfile
|
|||
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
from llama_models.llama3.api.datatypes import BuiltinTool
|
||||
|
||||
from llama_stack.apis.models import ModelInput, ModelType
|
||||
from llama_stack.apis.tools import (
|
||||
ToolDef,
|
||||
BuiltInToolDef,
|
||||
CustomToolDef,
|
||||
ToolGroupInput,
|
||||
ToolParameter,
|
||||
UserDefinedToolGroupDef,
|
||||
|
|
@ -151,42 +153,12 @@ async def agents_stack(request, inference_model, safety_shield):
|
|||
)
|
||||
)
|
||||
tool_groups = [
|
||||
ToolGroupInput(
|
||||
tool_group_id="brave_search_group",
|
||||
tool_group=UserDefinedToolGroupDef(
|
||||
tools=[
|
||||
ToolDef(
|
||||
name="brave_search",
|
||||
description="brave_search",
|
||||
parameters=[
|
||||
ToolParameter(
|
||||
name="query",
|
||||
description="query",
|
||||
parameter_type="string",
|
||||
required=True,
|
||||
),
|
||||
],
|
||||
metadata={},
|
||||
),
|
||||
],
|
||||
),
|
||||
provider_id="brave-search",
|
||||
),
|
||||
ToolGroupInput(
|
||||
tool_group_id="tavily_search_group",
|
||||
tool_group=UserDefinedToolGroupDef(
|
||||
tools=[
|
||||
ToolDef(
|
||||
name="tavily_search",
|
||||
description="tavily_search",
|
||||
parameters=[
|
||||
ToolParameter(
|
||||
name="query",
|
||||
description="query",
|
||||
parameter_type="string",
|
||||
required=True,
|
||||
),
|
||||
],
|
||||
BuiltInToolDef(
|
||||
built_in_type=BuiltinTool.brave_search,
|
||||
metadata={},
|
||||
),
|
||||
],
|
||||
|
|
@ -197,7 +169,7 @@ async def agents_stack(request, inference_model, safety_shield):
|
|||
tool_group_id="memory_group",
|
||||
tool_group=UserDefinedToolGroupDef(
|
||||
tools=[
|
||||
ToolDef(
|
||||
CustomToolDef(
|
||||
name="memory",
|
||||
description="memory",
|
||||
parameters=[
|
||||
|
|
@ -230,10 +202,8 @@ async def agents_stack(request, inference_model, safety_shield):
|
|||
tool_group_id="code_interpreter_group",
|
||||
tool_group=UserDefinedToolGroupDef(
|
||||
tools=[
|
||||
ToolDef(
|
||||
name="code_interpreter",
|
||||
description="code_interpreter",
|
||||
parameters=[],
|
||||
BuiltInToolDef(
|
||||
built_in_type=BuiltinTool.code_interpreter,
|
||||
metadata={},
|
||||
)
|
||||
],
|
||||
|
|
|
|||
|
|
@ -150,9 +150,7 @@ async def create_agent_turn_with_search_tool(
|
|||
assert isinstance(tool_execution, ToolExecutionStep)
|
||||
assert len(tool_execution.tool_calls) > 0
|
||||
actual_tool_name = tool_execution.tool_calls[0].tool_name
|
||||
if isinstance(actual_tool_name, BuiltinTool):
|
||||
actual_tool_name = actual_tool_name.value
|
||||
assert actual_tool_name == tool_name
|
||||
assert actual_tool_name.value == tool_name
|
||||
assert len(tool_execution.tool_responses) > 0
|
||||
|
||||
check_turn_complete_event(turn_response, session_id, search_query_messages)
|
||||
|
|
@ -305,20 +303,6 @@ class TestAgents:
|
|||
"brave_search",
|
||||
)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_create_agent_turn_with_tavily_search(
|
||||
self, agents_stack, search_query_messages, common_params
|
||||
):
|
||||
if "TAVILY_SEARCH_API_KEY" not in os.environ:
|
||||
pytest.skip("TAVILY_SEARCH_API_KEY not set, skipping test")
|
||||
|
||||
await create_agent_turn_with_search_tool(
|
||||
agents_stack,
|
||||
search_query_messages,
|
||||
common_params,
|
||||
"tavily_search",
|
||||
)
|
||||
|
||||
|
||||
def check_event_types(turn_response):
|
||||
event_types = [chunk.event.payload.event_type for chunk in turn_response]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue