From be6819fa9290e88240b4f0c3d3a3e5e4877e9faf Mon Sep 17 00:00:00 2001 From: Ashwin Bharambe Date: Thu, 2 Oct 2025 14:57:58 -0700 Subject: [PATCH] pre-commit --- llama_stack/apis/tools/tools.py | 2 +- llama_stack/models/llama/llama3_1/prompts.py | 3 ++- llama_stack/models/llama/llama3_3/prompts.py | 3 ++- .../providers/utils/inference/openai_compat.py | 1 - .../distribution/routers/test_routing_tables.py | 7 +------ .../providers/agent/test_meta_reference_agent.py | 13 ++++--------- .../agents/meta_reference/test_openai_responses.py | 9 ++------- .../meta_reference/responses/test_streaming.py | 10 ++-------- 8 files changed, 14 insertions(+), 34 deletions(-) diff --git a/llama_stack/apis/tools/tools.py b/llama_stack/apis/tools/tools.py index 37d7f92c9..b6a1a2543 100644 --- a/llama_stack/apis/tools/tools.py +++ b/llama_stack/apis/tools/tools.py @@ -7,7 +7,7 @@ from enum import Enum from typing import Any, Literal, Protocol -from pydantic import BaseModel, Field +from pydantic import BaseModel from typing_extensions import runtime_checkable from llama_stack.apis.common.content_types import URL, InterleavedContent diff --git a/llama_stack/models/llama/llama3_1/prompts.py b/llama_stack/models/llama/llama3_1/prompts.py index 579a5ee02..433c62d86 100644 --- a/llama_stack/models/llama/llama3_1/prompts.py +++ b/llama_stack/models/llama/llama3_1/prompts.py @@ -11,6 +11,7 @@ # top-level folder for each specific model found within the models/ directory at # the top-level of this source tree. +import json import textwrap from llama_stack.models.llama.datatypes import ( @@ -184,7 +185,7 @@ def usecases() -> list[UseCase | str]: ToolCall( call_id="tool_call_id", tool_name=BuiltinTool.wolfram_alpha, - arguments={"query": "100th decimal of pi"}, + arguments=json.dumps({"query": "100th decimal of pi"}), ) ], ), diff --git a/llama_stack/models/llama/llama3_3/prompts.py b/llama_stack/models/llama/llama3_3/prompts.py index 85796608a..0470e3218 100644 --- a/llama_stack/models/llama/llama3_3/prompts.py +++ b/llama_stack/models/llama/llama3_3/prompts.py @@ -11,6 +11,7 @@ # top-level folder for each specific model found within the models/ directory at # the top-level of this source tree. +import json import textwrap from llama_stack.models.llama.datatypes import ( @@ -185,7 +186,7 @@ def usecases() -> list[UseCase | str]: ToolCall( call_id="tool_call_id", tool_name=BuiltinTool.wolfram_alpha, - arguments={"query": "100th decimal of pi"}, + arguments=json.dumps({"query": "100th decimal of pi"}), ) ], ), diff --git a/llama_stack/providers/utils/inference/openai_compat.py b/llama_stack/providers/utils/inference/openai_compat.py index 499d53eeb..d863eb53a 100644 --- a/llama_stack/providers/utils/inference/openai_compat.py +++ b/llama_stack/providers/utils/inference/openai_compat.py @@ -1171,7 +1171,6 @@ async def convert_openai_chat_completion_stream( ) try: - arguments = json.loads(buffer["arguments"]) tool_call = ToolCall( call_id=buffer["call_id"], tool_name=buffer["name"], diff --git a/tests/unit/distribution/routers/test_routing_tables.py b/tests/unit/distribution/routers/test_routing_tables.py index 70bb259c8..54a9dd72e 100644 --- a/tests/unit/distribution/routers/test_routing_tables.py +++ b/tests/unit/distribution/routers/test_routing_tables.py @@ -139,12 +139,7 @@ class ToolGroupsImpl(Impl): description="Test tool", input_schema={ "type": "object", - "properties": { - "test-param": { - "type": "string", - "description": "Test param" - } - } + "properties": {"test-param": {"type": "string", "description": "Test param"}}, }, ) ] diff --git a/tests/unit/providers/agent/test_meta_reference_agent.py b/tests/unit/providers/agent/test_meta_reference_agent.py index d3a5ac89d..fdbb2b8e9 100644 --- a/tests/unit/providers/agent/test_meta_reference_agent.py +++ b/tests/unit/providers/agent/test_meta_reference_agent.py @@ -16,7 +16,6 @@ from llama_stack.apis.agents import ( ) from llama_stack.apis.common.responses import PaginatedResponse from llama_stack.apis.inference import Inference -from llama_stack.apis.resource import ResourceType from llama_stack.apis.safety import Safety from llama_stack.apis.tools import ListToolDefsResponse, ToolDef, ToolGroups, ToolRuntime from llama_stack.apis.vector_io import VectorIO @@ -241,20 +240,16 @@ async def test__initialize_tools(agents_impl, sample_agent_config): input_schema={ "type": "object", "properties": { - "story_title": { - "type": "string", - "description": "Title of the story", - "title": "Story Title" - }, + "story_title": {"type": "string", "description": "Title of the story", "title": "Story Title"}, "input_words": { "type": "array", "description": "Input words", "items": {"type": "string"}, "title": "Input Words", - "default": [] - } + "default": [], + }, }, - "required": ["story_title"] + "required": ["story_title"], }, ) ] diff --git a/tests/unit/providers/agents/meta_reference/test_openai_responses.py b/tests/unit/providers/agents/meta_reference/test_openai_responses.py index 5380824f7..0b2e6ab82 100644 --- a/tests/unit/providers/agents/meta_reference/test_openai_responses.py +++ b/tests/unit/providers/agents/meta_reference/test_openai_responses.py @@ -192,13 +192,8 @@ async def test_create_openai_response_with_string_input_with_tools(openai_respon description="Search the web for information", input_schema={ "type": "object", - "properties": { - "query": { - "type": "string", - "description": "The query to search for" - } - }, - "required": ["query"] + "properties": {"query": {"type": "string", "description": "The query to search for"}}, + "required": ["query"], }, ) diff --git a/tests/unit/providers/inline/agents/meta_reference/responses/test_streaming.py b/tests/unit/providers/inline/agents/meta_reference/responses/test_streaming.py index c67b485b9..4b706717d 100644 --- a/tests/unit/providers/inline/agents/meta_reference/responses/test_streaming.py +++ b/tests/unit/providers/inline/agents/meta_reference/responses/test_streaming.py @@ -22,14 +22,8 @@ def test_convert_tooldef_to_chat_tool_preserves_items_field(): description="A test tool with array parameter", input_schema={ "type": "object", - "properties": { - "tags": { - "type": "array", - "description": "List of tags", - "items": {"type": "string"} - } - }, - "required": ["tags"] + "properties": {"tags": {"type": "array", "description": "List of tags", "items": {"type": "string"}}}, + "required": ["tags"], }, )