From 6632d7e4104f8c98d3f54cbb6ada73f9a7c41d92 Mon Sep 17 00:00:00 2001 From: Dinesh Yeduguru Date: Tue, 7 Jan 2025 16:17:38 -0800 Subject: [PATCH] fix list tools method name --- docs/resources/llama-stack-spec.html | 64 ++++++++++++++++++- docs/resources/llama-stack-spec.yaml | 10 +++ llama_stack/apis/tools/tools.py | 4 +- llama_stack/distribution/routers/routers.py | 2 +- .../distribution/routers/routing_tables.py | 2 +- .../code_interpreter/code_interpreter.py | 2 +- .../inline/tool_runtime/memory/memory.py | 2 +- .../tool_runtime/bing_search/bing_search.py | 2 +- .../tool_runtime/brave_search/brave_search.py | 2 +- .../model_context_protocol.py | 2 +- .../tavily_search/tavily_search.py | 2 +- .../wolfram_alpha/wolfram_alpha.py | 2 +- 12 files changed, 84 insertions(+), 12 deletions(-) diff --git a/docs/resources/llama-stack-spec.html b/docs/resources/llama-stack-spec.html index 2d423b3e6..8ce86d367 100644 --- a/docs/resources/llama-stack-spec.html +++ b/docs/resources/llama-stack-spec.html @@ -1752,6 +1752,54 @@ ] } }, + "/alpha/tool-runtime/list-tools": { + "post": { + "responses": { + "200": { + "description": "OK", + "content": { + "application/jsonl": { + "schema": { + "$ref": "#/components/schemas/ToolDef" + } + } + } + } + }, + "tags": [ + "ToolRuntime" + ], + "parameters": [ + { + "name": "tool_group_id", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "X-LlamaStack-ProviderData", + "in": "header", + "description": "JSON-encoded provider data which will be made available to the adapter servicing the API", + "required": false, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListRuntimeToolsRequest" + } + } + }, + "required": true + } + } + }, "/alpha/scoring-functions/list": { "get": { "responses": { @@ -1858,7 +1906,7 @@ } }, "tags": [ - "ToolRuntime" + "ToolGroups" ], "summary": "List tools with optional tool group", "parameters": [ @@ -6207,6 +6255,15 @@ "provider_types" ] }, + "ListRuntimeToolsRequest": { + "type": "object", + "properties": { + "mcp_endpoint": { + "$ref": "#/components/schemas/URL" + } + }, + "additionalProperties": false + }, "LogSeverity": { "type": "string", "enum": [ @@ -8189,6 +8246,10 @@ "name": "LLMAsJudgeScoringFnParams", "description": "" }, + { + "name": "ListRuntimeToolsRequest", + "description": "" + }, { "name": "LogEventRequest", "description": "" @@ -8706,6 +8767,7 @@ "KeywordMemoryBank", "KeywordMemoryBankParams", "LLMAsJudgeScoringFnParams", + "ListRuntimeToolsRequest", "LogEventRequest", "LogSeverity", "LoraFinetuningConfig", diff --git a/docs/resources/llama-stack-spec.yaml b/docs/resources/llama-stack-spec.yaml index bf3b515f2..3e14bfe76 100644 --- a/docs/resources/llama-stack-spec.yaml +++ b/docs/resources/llama-stack-spec.yaml @@ -1122,6 +1122,12 @@ components: - type - judge_model type: object + ListRuntimeToolsRequest: + additionalProperties: false + properties: + mcp_endpoint: + $ref: '#/components/schemas/URL' + type: object LogEventRequest: additionalProperties: false properties: @@ -4919,6 +4925,9 @@ tags: - description: name: LLMAsJudgeScoringFnParams +- description: + name: ListRuntimeToolsRequest - description: name: LogEventRequest @@ -5290,6 +5299,7 @@ x-tagGroups: - KeywordMemoryBank - KeywordMemoryBankParams - LLMAsJudgeScoringFnParams + - ListRuntimeToolsRequest - LogEventRequest - LogSeverity - LoraFinetuningConfig diff --git a/llama_stack/apis/tools/tools.py b/llama_stack/apis/tools/tools.py index 0c2bb5863..dbfd85220 100644 --- a/llama_stack/apis/tools/tools.py +++ b/llama_stack/apis/tools/tools.py @@ -130,8 +130,8 @@ class ToolGroups(Protocol): class ToolRuntime(Protocol): tool_store: ToolStore - @webmethod(route="/tool-runtime/list-tools", method="POST") - async def list_tools( + @webmethod(route="/tool-runtime/list-tools", method="GET") + async def list_runtime_tools( self, tool_group_id: Optional[str] = None, mcp_endpoint: Optional[URL] = None ) -> List[ToolDef]: ... diff --git a/llama_stack/distribution/routers/routers.py b/llama_stack/distribution/routers/routers.py index 230feea71..05d43ad4f 100644 --- a/llama_stack/distribution/routers/routers.py +++ b/llama_stack/distribution/routers/routers.py @@ -417,7 +417,7 @@ class ToolRuntimeRouter(ToolRuntime): args=args, ) - async def list_tools( + async def list_runtime_tools( self, tool_group_id: Optional[str] = None, mcp_endpoint: Optional[URL] = None ) -> List[ToolDef]: return await self.routing_table.get_provider_impl(tool_group_id).list_tools( diff --git a/llama_stack/distribution/routers/routing_tables.py b/llama_stack/distribution/routers/routing_tables.py index 2f0288865..36ddda7a6 100644 --- a/llama_stack/distribution/routers/routing_tables.py +++ b/llama_stack/distribution/routers/routing_tables.py @@ -508,7 +508,7 @@ class ToolGroupsRoutingTable(CommonRoutingTableImpl, ToolGroups): args: Optional[Dict[str, Any]] = None, ) -> None: tools = [] - tool_defs = await self.impls_by_provider_id[provider_id].list_tools( + tool_defs = await self.impls_by_provider_id[provider_id].list_runtime_tools( toolgroup_id, mcp_endpoint ) tool_host = ( diff --git a/llama_stack/providers/inline/tool_runtime/code_interpreter/code_interpreter.py b/llama_stack/providers/inline/tool_runtime/code_interpreter/code_interpreter.py index 3b3f18032..98026fa3d 100644 --- a/llama_stack/providers/inline/tool_runtime/code_interpreter/code_interpreter.py +++ b/llama_stack/providers/inline/tool_runtime/code_interpreter/code_interpreter.py @@ -44,7 +44,7 @@ class CodeInterpreterToolRuntimeImpl(ToolsProtocolPrivate, ToolRuntime): async def unregister_tool(self, tool_id: str) -> None: return - async def list_tools( + async def list_runtime_tools( self, tool_group_id: Optional[str] = None, mcp_endpoint: Optional[URL] = None ) -> List[ToolDef]: return [ diff --git a/llama_stack/providers/inline/tool_runtime/memory/memory.py b/llama_stack/providers/inline/tool_runtime/memory/memory.py index c8c2cc772..f27cb9dd4 100644 --- a/llama_stack/providers/inline/tool_runtime/memory/memory.py +++ b/llama_stack/providers/inline/tool_runtime/memory/memory.py @@ -51,7 +51,7 @@ class MemoryToolRuntimeImpl(ToolsProtocolPrivate, ToolRuntime): async def initialize(self): pass - async def list_tools( + async def list_runtime_tools( self, tool_group_id: Optional[str] = None, mcp_endpoint: Optional[URL] = None ) -> List[ToolDef]: return [ diff --git a/llama_stack/providers/remote/tool_runtime/bing_search/bing_search.py b/llama_stack/providers/remote/tool_runtime/bing_search/bing_search.py index b0c30b0a0..a69f08ce8 100644 --- a/llama_stack/providers/remote/tool_runtime/bing_search/bing_search.py +++ b/llama_stack/providers/remote/tool_runtime/bing_search/bing_search.py @@ -51,7 +51,7 @@ class BingSearchToolRuntimeImpl( ) return provider_data.api_key - async def list_tools( + async def list_runtime_tools( self, tool_group_id: Optional[str] = None, mcp_endpoint: Optional[URL] = None ) -> List[ToolDef]: return [ diff --git a/llama_stack/providers/remote/tool_runtime/brave_search/brave_search.py b/llama_stack/providers/remote/tool_runtime/brave_search/brave_search.py index dab6ce439..05a3f2566 100644 --- a/llama_stack/providers/remote/tool_runtime/brave_search/brave_search.py +++ b/llama_stack/providers/remote/tool_runtime/brave_search/brave_search.py @@ -49,7 +49,7 @@ class BraveSearchToolRuntimeImpl( ) return provider_data.api_key - async def list_tools( + async def list_runtime_tools( self, tool_group_id: Optional[str] = None, mcp_endpoint: Optional[URL] = None ) -> List[ToolDef]: return [ diff --git a/llama_stack/providers/remote/tool_runtime/model_context_protocol/model_context_protocol.py b/llama_stack/providers/remote/tool_runtime/model_context_protocol/model_context_protocol.py index dd2bb5e5e..a304167e9 100644 --- a/llama_stack/providers/remote/tool_runtime/model_context_protocol/model_context_protocol.py +++ b/llama_stack/providers/remote/tool_runtime/model_context_protocol/model_context_protocol.py @@ -29,7 +29,7 @@ class ModelContextProtocolToolRuntimeImpl(ToolsProtocolPrivate, ToolRuntime): async def initialize(self): pass - async def list_tools( + async def list_runtime_tools( self, tool_group_id: Optional[str] = None, mcp_endpoint: Optional[URL] = None ) -> List[ToolDef]: if mcp_endpoint is None: diff --git a/llama_stack/providers/remote/tool_runtime/tavily_search/tavily_search.py b/llama_stack/providers/remote/tool_runtime/tavily_search/tavily_search.py index d22f188b3..8f666a6fb 100644 --- a/llama_stack/providers/remote/tool_runtime/tavily_search/tavily_search.py +++ b/llama_stack/providers/remote/tool_runtime/tavily_search/tavily_search.py @@ -50,7 +50,7 @@ class TavilySearchToolRuntimeImpl( ) return provider_data.api_key - async def list_tools( + async def list_runtime_tools( self, tool_group_id: Optional[str] = None, mcp_endpoint: Optional[URL] = None ) -> List[ToolDef]: return [ diff --git a/llama_stack/providers/remote/tool_runtime/wolfram_alpha/wolfram_alpha.py b/llama_stack/providers/remote/tool_runtime/wolfram_alpha/wolfram_alpha.py index 0f3fdfb39..13c298eb2 100644 --- a/llama_stack/providers/remote/tool_runtime/wolfram_alpha/wolfram_alpha.py +++ b/llama_stack/providers/remote/tool_runtime/wolfram_alpha/wolfram_alpha.py @@ -51,7 +51,7 @@ class WolframAlphaToolRuntimeImpl( ) return provider_data.api_key - async def list_tools( + async def list_runtime_tools( self, tool_group_id: Optional[str] = None, mcp_endpoint: Optional[URL] = None ) -> List[ToolDef]: return [