From 835a9642c2cabc8a7a76ee04f15b06eeb85fae59 Mon Sep 17 00:00:00 2001 From: Xi Yan Date: Thu, 20 Feb 2025 19:56:04 -0800 Subject: [PATCH 01/11] Sync updates from stainless branch: yanxi0830/dev --- src/llama_stack_client/_client.py | 12 +- src/llama_stack_client/_utils/_logs.py | 2 +- .../resources/agents/turn.py | 261 +++++++++- .../types/agents/__init__.py | 1 + .../agents/turn_response_event_payload.py | 9 + .../types/agents/turn_resume_params.py | 29 ++ tests/api_resources/agents/test_turn.py | 478 ++++++++++++++++++ tests/test_client.py | 4 +- 8 files changed, 786 insertions(+), 10 deletions(-) create mode 100644 src/llama_stack_client/types/agents/turn_resume_params.py diff --git a/src/llama_stack_client/_client.py b/src/llama_stack_client/_client.py index bb5bb755..760eaeee 100644 --- a/src/llama_stack_client/_client.py +++ b/src/llama_stack_client/_client.py @@ -126,14 +126,14 @@ def __init__( ) -> None: """Construct a new synchronous llama-stack-client client instance. - This automatically infers the `api_key` argument from the `LLAMA_STACK_CLIENT_API_KEY` environment variable if it is not provided. + This automatically infers the `api_key` argument from the `LLAMA_STACK_API_KEY` environment variable if it is not provided. """ if api_key is None: - api_key = os.environ.get("LLAMA_STACK_CLIENT_API_KEY") + api_key = os.environ.get("LLAMA_STACK_API_KEY") self.api_key = api_key if base_url is None: - base_url = os.environ.get("LLAMA_STACK_CLIENT_BASE_URL") + base_url = os.environ.get("LLAMA_STACK_BASE_URL") if base_url is None: base_url = f"http://any-hosted-llama-stack.com" @@ -342,14 +342,14 @@ def __init__( ) -> None: """Construct a new async llama-stack-client client instance. - This automatically infers the `api_key` argument from the `LLAMA_STACK_CLIENT_API_KEY` environment variable if it is not provided. + This automatically infers the `api_key` argument from the `LLAMA_STACK_API_KEY` environment variable if it is not provided. """ if api_key is None: - api_key = os.environ.get("LLAMA_STACK_CLIENT_API_KEY") + api_key = os.environ.get("LLAMA_STACK_API_KEY") self.api_key = api_key if base_url is None: - base_url = os.environ.get("LLAMA_STACK_CLIENT_BASE_URL") + base_url = os.environ.get("LLAMA_STACK_BASE_URL") if base_url is None: base_url = f"http://any-hosted-llama-stack.com" diff --git a/src/llama_stack_client/_utils/_logs.py b/src/llama_stack_client/_utils/_logs.py index 39ff9635..49f3ee8c 100644 --- a/src/llama_stack_client/_utils/_logs.py +++ b/src/llama_stack_client/_utils/_logs.py @@ -14,7 +14,7 @@ def _basic_config() -> None: def setup_logging() -> None: - env = os.environ.get("LLAMA_STACK_CLIENT_LOG") + env = os.environ.get("LLAMA_STACK_LOG") if env == "debug": _basic_config() logger.setLevel(logging.DEBUG) diff --git a/src/llama_stack_client/resources/agents/turn.py b/src/llama_stack_client/resources/agents/turn.py index da659e26..aa671178 100644 --- a/src/llama_stack_client/resources/agents/turn.py +++ b/src/llama_stack_client/resources/agents/turn.py @@ -23,8 +23,9 @@ ) from ..._streaming import Stream, AsyncStream from ..._base_client import make_request_options -from ...types.agents import turn_create_params +from ...types.agents import turn_create_params, turn_resume_params from ...types.agents.turn import Turn +from ...types.shared_params.tool_response_message import ToolResponseMessage from ...types.agents.agent_turn_response_stream_chunk import AgentTurnResponseStreamChunk __all__ = ["TurnResource", "AsyncTurnResource"] @@ -225,6 +226,129 @@ def retrieve( cast_to=Turn, ) + @overload + def resume( + self, + turn_id: str, + *, + agent_id: str, + session_id: str, + tool_responses: Iterable[ToolResponseMessage], + stream: Literal[False] | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Turn: + """ + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def resume( + self, + turn_id: str, + *, + agent_id: str, + session_id: str, + stream: Literal[True], + tool_responses: Iterable[ToolResponseMessage], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Stream[AgentTurnResponseStreamChunk]: + """ + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def resume( + self, + turn_id: str, + *, + agent_id: str, + session_id: str, + stream: bool, + tool_responses: Iterable[ToolResponseMessage], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Turn | Stream[AgentTurnResponseStreamChunk]: + """ + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @required_args(["agent_id", "session_id", "tool_responses"], ["agent_id", "session_id", "stream", "tool_responses"]) + def resume( + self, + turn_id: str, + *, + agent_id: str, + session_id: str, + tool_responses: Iterable[ToolResponseMessage], + stream: Literal[False] | Literal[True] | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Turn | Stream[AgentTurnResponseStreamChunk]: + if not agent_id: + raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}") + if not session_id: + raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") + if not turn_id: + raise ValueError(f"Expected a non-empty value for `turn_id` but received {turn_id!r}") + return self._post( + f"/v1/agents/{agent_id}/session/{session_id}/turn/{turn_id}/resume", + body=maybe_transform( + { + "tool_responses": tool_responses, + "stream": stream, + }, + turn_resume_params.TurnResumeParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Turn, + stream=stream or False, + stream_cls=Stream[AgentTurnResponseStreamChunk], + ) + class AsyncTurnResource(AsyncAPIResource): @cached_property @@ -421,6 +545,129 @@ async def retrieve( cast_to=Turn, ) + @overload + async def resume( + self, + turn_id: str, + *, + agent_id: str, + session_id: str, + tool_responses: Iterable[ToolResponseMessage], + stream: Literal[False] | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Turn: + """ + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def resume( + self, + turn_id: str, + *, + agent_id: str, + session_id: str, + stream: Literal[True], + tool_responses: Iterable[ToolResponseMessage], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> AsyncStream[AgentTurnResponseStreamChunk]: + """ + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def resume( + self, + turn_id: str, + *, + agent_id: str, + session_id: str, + stream: bool, + tool_responses: Iterable[ToolResponseMessage], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Turn | AsyncStream[AgentTurnResponseStreamChunk]: + """ + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @required_args(["agent_id", "session_id", "tool_responses"], ["agent_id", "session_id", "stream", "tool_responses"]) + async def resume( + self, + turn_id: str, + *, + agent_id: str, + session_id: str, + tool_responses: Iterable[ToolResponseMessage], + stream: Literal[False] | Literal[True] | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Turn | AsyncStream[AgentTurnResponseStreamChunk]: + if not agent_id: + raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}") + if not session_id: + raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") + if not turn_id: + raise ValueError(f"Expected a non-empty value for `turn_id` but received {turn_id!r}") + return await self._post( + f"/v1/agents/{agent_id}/session/{session_id}/turn/{turn_id}/resume", + body=await async_maybe_transform( + { + "tool_responses": tool_responses, + "stream": stream, + }, + turn_resume_params.TurnResumeParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Turn, + stream=stream or False, + stream_cls=AsyncStream[AgentTurnResponseStreamChunk], + ) + class TurnResourceWithRawResponse: def __init__(self, turn: TurnResource) -> None: @@ -432,6 +679,9 @@ def __init__(self, turn: TurnResource) -> None: self.retrieve = to_raw_response_wrapper( turn.retrieve, ) + self.resume = to_raw_response_wrapper( + turn.resume, + ) class AsyncTurnResourceWithRawResponse: @@ -444,6 +694,9 @@ def __init__(self, turn: AsyncTurnResource) -> None: self.retrieve = async_to_raw_response_wrapper( turn.retrieve, ) + self.resume = async_to_raw_response_wrapper( + turn.resume, + ) class TurnResourceWithStreamingResponse: @@ -456,6 +709,9 @@ def __init__(self, turn: TurnResource) -> None: self.retrieve = to_streamed_response_wrapper( turn.retrieve, ) + self.resume = to_streamed_response_wrapper( + turn.resume, + ) class AsyncTurnResourceWithStreamingResponse: @@ -468,3 +724,6 @@ def __init__(self, turn: AsyncTurnResource) -> None: self.retrieve = async_to_streamed_response_wrapper( turn.retrieve, ) + self.resume = async_to_streamed_response_wrapper( + turn.resume, + ) diff --git a/src/llama_stack_client/types/agents/__init__.py b/src/llama_stack_client/types/agents/__init__.py index be21f291..30355cbf 100644 --- a/src/llama_stack_client/types/agents/__init__.py +++ b/src/llama_stack_client/types/agents/__init__.py @@ -5,6 +5,7 @@ from .turn import Turn as Turn from .session import Session as Session from .turn_create_params import TurnCreateParams as TurnCreateParams +from .turn_resume_params import TurnResumeParams as TurnResumeParams from .turn_response_event import TurnResponseEvent as TurnResponseEvent from .session_create_params import SessionCreateParams as SessionCreateParams from .step_retrieve_response import StepRetrieveResponse as StepRetrieveResponse diff --git a/src/llama_stack_client/types/agents/turn_response_event_payload.py b/src/llama_stack_client/types/agents/turn_response_event_payload.py index f12f8b03..e3315cb3 100644 --- a/src/llama_stack_client/types/agents/turn_response_event_payload.py +++ b/src/llama_stack_client/types/agents/turn_response_event_payload.py @@ -20,6 +20,7 @@ "AgentTurnResponseStepCompletePayloadStepDetails", "AgentTurnResponseTurnStartPayload", "AgentTurnResponseTurnCompletePayload", + "AgentTurnResponseTurnAwaitingInputPayload", ] @@ -72,6 +73,13 @@ class AgentTurnResponseTurnCompletePayload(BaseModel): """A single turn in an interaction with an Agentic System.""" +class AgentTurnResponseTurnAwaitingInputPayload(BaseModel): + event_type: Literal["turn_awaiting_input"] + + turn: Turn + """A single turn in an interaction with an Agentic System.""" + + TurnResponseEventPayload: TypeAlias = Annotated[ Union[ AgentTurnResponseStepStartPayload, @@ -79,6 +87,7 @@ class AgentTurnResponseTurnCompletePayload(BaseModel): AgentTurnResponseStepCompletePayload, AgentTurnResponseTurnStartPayload, AgentTurnResponseTurnCompletePayload, + AgentTurnResponseTurnAwaitingInputPayload, ], PropertyInfo(discriminator="event_type"), ] diff --git a/src/llama_stack_client/types/agents/turn_resume_params.py b/src/llama_stack_client/types/agents/turn_resume_params.py new file mode 100644 index 00000000..0df97072 --- /dev/null +++ b/src/llama_stack_client/types/agents/turn_resume_params.py @@ -0,0 +1,29 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union, Iterable +from typing_extensions import Literal, Required, TypedDict + +from ..shared_params.tool_response_message import ToolResponseMessage + +__all__ = ["TurnResumeParamsBase", "TurnResumeParamsNonStreaming", "TurnResumeParamsStreaming"] + + +class TurnResumeParamsBase(TypedDict, total=False): + agent_id: Required[str] + + session_id: Required[str] + + tool_responses: Required[Iterable[ToolResponseMessage]] + + +class TurnResumeParamsNonStreaming(TurnResumeParamsBase, total=False): + stream: Literal[False] + + +class TurnResumeParamsStreaming(TurnResumeParamsBase): + stream: Required[Literal[True]] + + +TurnResumeParams = Union[TurnResumeParamsNonStreaming, TurnResumeParamsStreaming] diff --git a/tests/api_resources/agents/test_turn.py b/tests/api_resources/agents/test_turn.py index b64bf957..311dfcd8 100644 --- a/tests/api_resources/agents/test_turn.py +++ b/tests/api_resources/agents/test_turn.py @@ -293,6 +293,245 @@ def test_path_params_retrieve(self, client: LlamaStackClient) -> None: session_id="session_id", ) + @parametrize + def test_method_resume_overload_1(self, client: LlamaStackClient) -> None: + turn = client.agents.turn.resume( + turn_id="turn_id", + agent_id="agent_id", + session_id="session_id", + tool_responses=[ + { + "call_id": "call_id", + "content": "string", + "role": "tool", + "tool_name": "brave_search", + } + ], + ) + assert_matches_type(Turn, turn, path=["response"]) + + @parametrize + def test_method_resume_with_all_params_overload_1(self, client: LlamaStackClient) -> None: + turn = client.agents.turn.resume( + turn_id="turn_id", + agent_id="agent_id", + session_id="session_id", + tool_responses=[ + { + "call_id": "call_id", + "content": "string", + "role": "tool", + "tool_name": "brave_search", + } + ], + stream=False, + ) + assert_matches_type(Turn, turn, path=["response"]) + + @parametrize + def test_raw_response_resume_overload_1(self, client: LlamaStackClient) -> None: + response = client.agents.turn.with_raw_response.resume( + turn_id="turn_id", + agent_id="agent_id", + session_id="session_id", + tool_responses=[ + { + "call_id": "call_id", + "content": "string", + "role": "tool", + "tool_name": "brave_search", + } + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + turn = response.parse() + assert_matches_type(Turn, turn, path=["response"]) + + @parametrize + def test_streaming_response_resume_overload_1(self, client: LlamaStackClient) -> None: + with client.agents.turn.with_streaming_response.resume( + turn_id="turn_id", + agent_id="agent_id", + session_id="session_id", + tool_responses=[ + { + "call_id": "call_id", + "content": "string", + "role": "tool", + "tool_name": "brave_search", + } + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + turn = response.parse() + assert_matches_type(Turn, turn, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_resume_overload_1(self, client: LlamaStackClient) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): + client.agents.turn.with_raw_response.resume( + turn_id="turn_id", + agent_id="", + session_id="session_id", + tool_responses=[ + { + "call_id": "call_id", + "content": "string", + "role": "tool", + "tool_name": "brave_search", + } + ], + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): + client.agents.turn.with_raw_response.resume( + turn_id="turn_id", + agent_id="agent_id", + session_id="", + tool_responses=[ + { + "call_id": "call_id", + "content": "string", + "role": "tool", + "tool_name": "brave_search", + } + ], + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `turn_id` but received ''"): + client.agents.turn.with_raw_response.resume( + turn_id="", + agent_id="agent_id", + session_id="session_id", + tool_responses=[ + { + "call_id": "call_id", + "content": "string", + "role": "tool", + "tool_name": "brave_search", + } + ], + ) + + @parametrize + def test_method_resume_overload_2(self, client: LlamaStackClient) -> None: + turn_stream = client.agents.turn.resume( + turn_id="turn_id", + agent_id="agent_id", + session_id="session_id", + stream=True, + tool_responses=[ + { + "call_id": "call_id", + "content": "string", + "role": "tool", + "tool_name": "brave_search", + } + ], + ) + turn_stream.response.close() + + @parametrize + def test_raw_response_resume_overload_2(self, client: LlamaStackClient) -> None: + response = client.agents.turn.with_raw_response.resume( + turn_id="turn_id", + agent_id="agent_id", + session_id="session_id", + stream=True, + tool_responses=[ + { + "call_id": "call_id", + "content": "string", + "role": "tool", + "tool_name": "brave_search", + } + ], + ) + + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + stream = response.parse() + stream.close() + + @parametrize + def test_streaming_response_resume_overload_2(self, client: LlamaStackClient) -> None: + with client.agents.turn.with_streaming_response.resume( + turn_id="turn_id", + agent_id="agent_id", + session_id="session_id", + stream=True, + tool_responses=[ + { + "call_id": "call_id", + "content": "string", + "role": "tool", + "tool_name": "brave_search", + } + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + stream = response.parse() + stream.close() + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_resume_overload_2(self, client: LlamaStackClient) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): + client.agents.turn.with_raw_response.resume( + turn_id="turn_id", + agent_id="", + session_id="session_id", + stream=True, + tool_responses=[ + { + "call_id": "call_id", + "content": "string", + "role": "tool", + "tool_name": "brave_search", + } + ], + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): + client.agents.turn.with_raw_response.resume( + turn_id="turn_id", + agent_id="agent_id", + session_id="", + stream=True, + tool_responses=[ + { + "call_id": "call_id", + "content": "string", + "role": "tool", + "tool_name": "brave_search", + } + ], + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `turn_id` but received ''"): + client.agents.turn.with_raw_response.resume( + turn_id="", + agent_id="agent_id", + session_id="session_id", + stream=True, + tool_responses=[ + { + "call_id": "call_id", + "content": "string", + "role": "tool", + "tool_name": "brave_search", + } + ], + ) + class TestAsyncTurn: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @@ -572,3 +811,242 @@ async def test_path_params_retrieve(self, async_client: AsyncLlamaStackClient) - agent_id="agent_id", session_id="session_id", ) + + @parametrize + async def test_method_resume_overload_1(self, async_client: AsyncLlamaStackClient) -> None: + turn = await async_client.agents.turn.resume( + turn_id="turn_id", + agent_id="agent_id", + session_id="session_id", + tool_responses=[ + { + "call_id": "call_id", + "content": "string", + "role": "tool", + "tool_name": "brave_search", + } + ], + ) + assert_matches_type(Turn, turn, path=["response"]) + + @parametrize + async def test_method_resume_with_all_params_overload_1(self, async_client: AsyncLlamaStackClient) -> None: + turn = await async_client.agents.turn.resume( + turn_id="turn_id", + agent_id="agent_id", + session_id="session_id", + tool_responses=[ + { + "call_id": "call_id", + "content": "string", + "role": "tool", + "tool_name": "brave_search", + } + ], + stream=False, + ) + assert_matches_type(Turn, turn, path=["response"]) + + @parametrize + async def test_raw_response_resume_overload_1(self, async_client: AsyncLlamaStackClient) -> None: + response = await async_client.agents.turn.with_raw_response.resume( + turn_id="turn_id", + agent_id="agent_id", + session_id="session_id", + tool_responses=[ + { + "call_id": "call_id", + "content": "string", + "role": "tool", + "tool_name": "brave_search", + } + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + turn = await response.parse() + assert_matches_type(Turn, turn, path=["response"]) + + @parametrize + async def test_streaming_response_resume_overload_1(self, async_client: AsyncLlamaStackClient) -> None: + async with async_client.agents.turn.with_streaming_response.resume( + turn_id="turn_id", + agent_id="agent_id", + session_id="session_id", + tool_responses=[ + { + "call_id": "call_id", + "content": "string", + "role": "tool", + "tool_name": "brave_search", + } + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + turn = await response.parse() + assert_matches_type(Turn, turn, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_resume_overload_1(self, async_client: AsyncLlamaStackClient) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): + await async_client.agents.turn.with_raw_response.resume( + turn_id="turn_id", + agent_id="", + session_id="session_id", + tool_responses=[ + { + "call_id": "call_id", + "content": "string", + "role": "tool", + "tool_name": "brave_search", + } + ], + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): + await async_client.agents.turn.with_raw_response.resume( + turn_id="turn_id", + agent_id="agent_id", + session_id="", + tool_responses=[ + { + "call_id": "call_id", + "content": "string", + "role": "tool", + "tool_name": "brave_search", + } + ], + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `turn_id` but received ''"): + await async_client.agents.turn.with_raw_response.resume( + turn_id="", + agent_id="agent_id", + session_id="session_id", + tool_responses=[ + { + "call_id": "call_id", + "content": "string", + "role": "tool", + "tool_name": "brave_search", + } + ], + ) + + @parametrize + async def test_method_resume_overload_2(self, async_client: AsyncLlamaStackClient) -> None: + turn_stream = await async_client.agents.turn.resume( + turn_id="turn_id", + agent_id="agent_id", + session_id="session_id", + stream=True, + tool_responses=[ + { + "call_id": "call_id", + "content": "string", + "role": "tool", + "tool_name": "brave_search", + } + ], + ) + await turn_stream.response.aclose() + + @parametrize + async def test_raw_response_resume_overload_2(self, async_client: AsyncLlamaStackClient) -> None: + response = await async_client.agents.turn.with_raw_response.resume( + turn_id="turn_id", + agent_id="agent_id", + session_id="session_id", + stream=True, + tool_responses=[ + { + "call_id": "call_id", + "content": "string", + "role": "tool", + "tool_name": "brave_search", + } + ], + ) + + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + stream = await response.parse() + await stream.close() + + @parametrize + async def test_streaming_response_resume_overload_2(self, async_client: AsyncLlamaStackClient) -> None: + async with async_client.agents.turn.with_streaming_response.resume( + turn_id="turn_id", + agent_id="agent_id", + session_id="session_id", + stream=True, + tool_responses=[ + { + "call_id": "call_id", + "content": "string", + "role": "tool", + "tool_name": "brave_search", + } + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + stream = await response.parse() + await stream.close() + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_resume_overload_2(self, async_client: AsyncLlamaStackClient) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): + await async_client.agents.turn.with_raw_response.resume( + turn_id="turn_id", + agent_id="", + session_id="session_id", + stream=True, + tool_responses=[ + { + "call_id": "call_id", + "content": "string", + "role": "tool", + "tool_name": "brave_search", + } + ], + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): + await async_client.agents.turn.with_raw_response.resume( + turn_id="turn_id", + agent_id="agent_id", + session_id="", + stream=True, + tool_responses=[ + { + "call_id": "call_id", + "content": "string", + "role": "tool", + "tool_name": "brave_search", + } + ], + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `turn_id` but received ''"): + await async_client.agents.turn.with_raw_response.resume( + turn_id="", + agent_id="agent_id", + session_id="session_id", + stream=True, + tool_responses=[ + { + "call_id": "call_id", + "content": "string", + "role": "tool", + "tool_name": "brave_search", + } + ], + ) diff --git a/tests/test_client.py b/tests/test_client.py index f282f616..8a2992af 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -526,7 +526,7 @@ def test_base_url_setter(self) -> None: assert client.base_url == "https://example.com/from_setter/" def test_base_url_env(self) -> None: - with update_env(LLAMA_STACK_CLIENT_BASE_URL="http://localhost:5000/from/env"): + with update_env(LLAMA_STACK_BASE_URL="http://localhost:5000/from/env"): client = LlamaStackClient(_strict_response_validation=True) assert client.base_url == "http://localhost:5000/from/env/" @@ -1316,7 +1316,7 @@ def test_base_url_setter(self) -> None: assert client.base_url == "https://example.com/from_setter/" def test_base_url_env(self) -> None: - with update_env(LLAMA_STACK_CLIENT_BASE_URL="http://localhost:5000/from/env"): + with update_env(LLAMA_STACK_BASE_URL="http://localhost:5000/from/env"): client = AsyncLlamaStackClient(_strict_response_validation=True) assert client.base_url == "http://localhost:5000/from/env/" From 25342b54e8a22793fc638f8885107335ab8a4562 Mon Sep 17 00:00:00 2001 From: Xi Yan Date: Thu, 20 Feb 2025 20:01:15 -0800 Subject: [PATCH 02/11] deprecate current turn --- src/llama_stack_client/lib/agents/agent.py | 24 +++++++++++++++---- .../lib/agents/event_logger.py | 4 ++-- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/llama_stack_client/lib/agents/agent.py b/src/llama_stack_client/lib/agents/agent.py index 0a8ab226..252a4e0c 100644 --- a/src/llama_stack_client/lib/agents/agent.py +++ b/src/llama_stack_client/lib/agents/agent.py @@ -65,7 +65,7 @@ def create_session(self, session_name: str) -> int: return self.session_id def _get_tool_calls(self, chunk: AgentTurnResponseStreamChunk) -> List[ToolCall]: - if chunk.event.payload.event_type != "turn_complete": + if chunk.event.payload.event_type not in {"turn_complete", "turn_awaiting_input"}: return [] message = chunk.event.payload.turn.output_message @@ -76,6 +76,12 @@ def _get_tool_calls(self, chunk: AgentTurnResponseStreamChunk) -> List[ToolCall] return self.tool_parser.get_tool_calls(message) return message.tool_calls + + def _get_turn_id(self, chunk: AgentTurnResponseStreamChunk) -> Optional[str]: + if chunk.event.payload.event_type not in ["turn_complete", "turn_awaiting_input"]: + return None + + return chunk.event.payload.turn.turn_id def _run_tool(self, tool_calls: List[ToolCall]) -> ToolResponseMessage: assert len(tool_calls) == 1, "Only one tool call is supported" @@ -127,12 +133,22 @@ def create_turn( toolgroups: Optional[List[Toolgroup]] = None, documents: Optional[List[Document]] = None, stream: bool = True, + ) -> Iterator[AgentTurnResponseStreamChunk] | Turn: + pass + + def create_turn_DEPRECATED( + self, + messages: List[Union[UserMessage, ToolResponseMessage]], + session_id: Optional[str] = None, + toolgroups: Optional[List[Toolgroup]] = None, + documents: Optional[List[Document]] = None, + stream: bool = True, ) -> Iterator[AgentTurnResponseStreamChunk] | Turn: if stream: - return self._create_turn_streaming(messages, session_id, toolgroups, documents) + return self._create_turn_streaming_DEPRECATED(messages, session_id, toolgroups, documents) else: chunks = [] - for chunk in self._create_turn_streaming(messages, session_id, toolgroups, documents): + for chunk in self._create_turn_streaming_DEPRECATED(messages, session_id, toolgroups, documents): if chunk.event.payload.event_type == "turn_complete": chunks.append(chunk) pass @@ -153,7 +169,7 @@ def create_turn( ], ) - def _create_turn_streaming( + def _create_turn_streaming_DEPRECATED( self, messages: List[Union[UserMessage, ToolResponseMessage]], session_id: Optional[str] = None, diff --git a/src/llama_stack_client/lib/agents/event_logger.py b/src/llama_stack_client/lib/agents/event_logger.py index d7fa514a..8a40353b 100644 --- a/src/llama_stack_client/lib/agents/event_logger.py +++ b/src/llama_stack_client/lib/agents/event_logger.py @@ -75,7 +75,7 @@ def _yield_printable_events( event = chunk.event event_type = event.payload.event_type - if event_type in {"turn_start", "turn_complete"}: + if event_type in {"turn_start", "turn_complete", "turn_awaiting_input"}: # Currently not logging any turn realted info yield TurnStreamPrintableEvent(role=None, content="", end="", color="grey") return @@ -149,7 +149,7 @@ def _get_event_type_step_type(self, chunk: Any) -> Tuple[Optional[str], Optional if hasattr(chunk, "event"): previous_event_type = chunk.event.payload.event_type if hasattr(chunk, "event") else None previous_step_type = ( - chunk.event.payload.step_type if previous_event_type not in {"turn_start", "turn_complete"} else None + chunk.event.payload.step_type if previous_event_type not in {"turn_start", "turn_complete", "turn_awaiting_input"} else None ) return previous_event_type, previous_step_type return None, None From 59bfe5c053048454deaff65019b1e3b5791a8b2f Mon Sep 17 00:00:00 2001 From: Xi Yan Date: Thu, 20 Feb 2025 20:05:29 -0800 Subject: [PATCH 03/11] add create turn with resume --- src/llama_stack_client/lib/agents/agent.py | 71 +++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/src/llama_stack_client/lib/agents/agent.py b/src/llama_stack_client/lib/agents/agent.py index 252a4e0c..308a501f 100644 --- a/src/llama_stack_client/lib/agents/agent.py +++ b/src/llama_stack_client/lib/agents/agent.py @@ -134,7 +134,76 @@ def create_turn( documents: Optional[List[Document]] = None, stream: bool = True, ) -> Iterator[AgentTurnResponseStreamChunk] | Turn: - pass + if stream: + return self._create_turn_streaming(messages, session_id, toolgroups, documents) + else: + chunks = [x for x in self._create_turn_streaming(messages, session_id, toolgroups, documents)] + if not chunks: + raise Exception("Turn did not complete") + return chunks[-1].event.payload.turn + + def _create_turn_streaming( + self, + messages: List[Union[UserMessage, ToolResponseMessage]], + session_id: Optional[str] = None, + toolgroups: Optional[List[Toolgroup]] = None, + documents: Optional[List[Document]] = None, + ) -> Iterator[AgentTurnResponseStreamChunk]: + n_iter = 0 + max_iter = self.agent_config.get("max_infer_iters", DEFAULT_MAX_ITER) + + # 1. create an agent turn + turn_response = self.client.agents.turn.create( + agent_id=self.agent_id, + # use specified session_id or last session created + session_id=session_id or self.session_id[-1], + messages=messages, + stream=True, + documents=documents, + toolgroups=toolgroups, + ) + is_turn_complete = True + turn_id = None + for chunk in turn_response: + tool_calls = self._get_tool_calls(chunk) + if hasattr(chunk, "error"): + yield chunk + return + elif not tool_calls: + yield chunk + else: + is_turn_complete = False + turn_id = self._get_turn_id(chunk) + yield chunk + break + + # 2. while the turn is not complete, continue the turn + while not is_turn_complete and n_iter < max_iter: + is_turn_complete = True + assert turn_id is not None, "turn_id is None" + + # run the tools + tool_response_message = self._run_tool(tool_calls) + + continue_response = self.client.agents.turn.resume( + agent_id=self.agent_id, + session_id=session_id or self.session_id[-1], + turn_id=turn_id, + tool_responses=[tool_response_message], + stream=True, + ) + for chunk in continue_response: + tool_calls = self._get_tool_calls(chunk) + if hasattr(chunk, "error"): + yield chunk + return + elif not tool_calls: + yield chunk + else: + is_turn_complete = False + turn_id = self._get_turn_id(chunk) + n_iter += 1 + def create_turn_DEPRECATED( self, From 3e4ddc97b0c6f925b1d688205cf1a237a077acc0 Mon Sep 17 00:00:00 2001 From: Xi Yan Date: Thu, 20 Feb 2025 20:09:29 -0800 Subject: [PATCH 04/11] precommit --- src/llama_stack_client/lib/agents/agent.py | 3 +-- src/llama_stack_client/lib/agents/event_logger.py | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/llama_stack_client/lib/agents/agent.py b/src/llama_stack_client/lib/agents/agent.py index 308a501f..f3064bab 100644 --- a/src/llama_stack_client/lib/agents/agent.py +++ b/src/llama_stack_client/lib/agents/agent.py @@ -76,7 +76,7 @@ def _get_tool_calls(self, chunk: AgentTurnResponseStreamChunk) -> List[ToolCall] return self.tool_parser.get_tool_calls(message) return message.tool_calls - + def _get_turn_id(self, chunk: AgentTurnResponseStreamChunk) -> Optional[str]: if chunk.event.payload.event_type not in ["turn_complete", "turn_awaiting_input"]: return None @@ -203,7 +203,6 @@ def _create_turn_streaming( is_turn_complete = False turn_id = self._get_turn_id(chunk) n_iter += 1 - def create_turn_DEPRECATED( self, diff --git a/src/llama_stack_client/lib/agents/event_logger.py b/src/llama_stack_client/lib/agents/event_logger.py index 8a40353b..40a1d359 100644 --- a/src/llama_stack_client/lib/agents/event_logger.py +++ b/src/llama_stack_client/lib/agents/event_logger.py @@ -149,7 +149,9 @@ def _get_event_type_step_type(self, chunk: Any) -> Tuple[Optional[str], Optional if hasattr(chunk, "event"): previous_event_type = chunk.event.payload.event_type if hasattr(chunk, "event") else None previous_step_type = ( - chunk.event.payload.step_type if previous_event_type not in {"turn_start", "turn_complete", "turn_awaiting_input"} else None + chunk.event.payload.step_type + if previous_event_type not in {"turn_start", "turn_complete", "turn_awaiting_input"} + else None ) return previous_event_type, previous_step_type return None, None From ca27f6fe97a44e248a1fdf7a2fccfefcaef37883 Mon Sep 17 00:00:00 2001 From: Xi Yan Date: Thu, 20 Feb 2025 22:17:17 -0800 Subject: [PATCH 05/11] add flag --- src/llama_stack_client/lib/agents/agent.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/llama_stack_client/lib/agents/agent.py b/src/llama_stack_client/lib/agents/agent.py index f3064bab..087ef10f 100644 --- a/src/llama_stack_client/lib/agents/agent.py +++ b/src/llama_stack_client/lib/agents/agent.py @@ -161,6 +161,7 @@ def _create_turn_streaming( stream=True, documents=documents, toolgroups=toolgroups, + allow_turn_resume=True, ) is_turn_complete = True turn_id = None From 5d173e2df7d32ed3e0fc435af84d8752fc24c8b8 Mon Sep 17 00:00:00 2001 From: Xi Yan Date: Fri, 21 Feb 2025 10:35:31 -0800 Subject: [PATCH 06/11] simplify loop --- src/llama_stack_client/lib/agents/agent.py | 46 +++++++++------------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/src/llama_stack_client/lib/agents/agent.py b/src/llama_stack_client/lib/agents/agent.py index 087ef10f..1ab0478e 100644 --- a/src/llama_stack_client/lib/agents/agent.py +++ b/src/llama_stack_client/lib/agents/agent.py @@ -163,37 +163,12 @@ def _create_turn_streaming( toolgroups=toolgroups, allow_turn_resume=True, ) - is_turn_complete = True - turn_id = None - for chunk in turn_response: - tool_calls = self._get_tool_calls(chunk) - if hasattr(chunk, "error"): - yield chunk - return - elif not tool_calls: - yield chunk - else: - is_turn_complete = False - turn_id = self._get_turn_id(chunk) - yield chunk - break - # 2. while the turn is not complete, continue the turn + # 2. process turn and resume if there's a tool call + is_turn_complete = False while not is_turn_complete and n_iter < max_iter: is_turn_complete = True - assert turn_id is not None, "turn_id is None" - - # run the tools - tool_response_message = self._run_tool(tool_calls) - - continue_response = self.client.agents.turn.resume( - agent_id=self.agent_id, - session_id=session_id or self.session_id[-1], - turn_id=turn_id, - tool_responses=[tool_response_message], - stream=True, - ) - for chunk in continue_response: + for chunk in turn_response: tool_calls = self._get_tool_calls(chunk) if hasattr(chunk, "error"): yield chunk @@ -203,7 +178,22 @@ def _create_turn_streaming( else: is_turn_complete = False turn_id = self._get_turn_id(chunk) + if n_iter == 0: + yield chunk + + # run the tools + tool_response_message = self._run_tool(tool_calls) + # pass it to next iteration + turn_response = self.client.agents.turn.resume( + agent_id=self.agent_id, + session_id=session_id or self.session_id[-1], + turn_id=turn_id, + tool_responses=[tool_response_message], + stream=True, + ) + n_iter += 1 + def create_turn_DEPRECATED( self, From 3996eebeb7badb4ad3092fd97378698919f08710 Mon Sep 17 00:00:00 2001 From: Xi Yan Date: Fri, 21 Feb 2025 10:37:45 -0800 Subject: [PATCH 07/11] simplify loop --- src/llama_stack_client/lib/agents/agent.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/llama_stack_client/lib/agents/agent.py b/src/llama_stack_client/lib/agents/agent.py index 1ab0478e..8acf23e5 100644 --- a/src/llama_stack_client/lib/agents/agent.py +++ b/src/llama_stack_client/lib/agents/agent.py @@ -166,7 +166,7 @@ def _create_turn_streaming( # 2. process turn and resume if there's a tool call is_turn_complete = False - while not is_turn_complete and n_iter < max_iter: + while not is_turn_complete: is_turn_complete = True for chunk in turn_response: tool_calls = self._get_tool_calls(chunk) @@ -193,7 +193,9 @@ def _create_turn_streaming( ) n_iter += 1 - + + if n_iter >= max_iter: + raise Exception(f"Turn did not complete in {max_iter} iterations") def create_turn_DEPRECATED( self, From 8845f6f21d5c5daa51e89d23492ebbb02c77d2a8 Mon Sep 17 00:00:00 2001 From: Xi Yan Date: Fri, 21 Feb 2025 10:40:03 -0800 Subject: [PATCH 08/11] pre --- src/llama_stack_client/lib/agents/agent.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/llama_stack_client/lib/agents/agent.py b/src/llama_stack_client/lib/agents/agent.py index 8acf23e5..fffba0ff 100644 --- a/src/llama_stack_client/lib/agents/agent.py +++ b/src/llama_stack_client/lib/agents/agent.py @@ -180,7 +180,7 @@ def _create_turn_streaming( turn_id = self._get_turn_id(chunk) if n_iter == 0: yield chunk - + # run the tools tool_response_message = self._run_tool(tool_calls) # pass it to next iteration @@ -193,7 +193,7 @@ def _create_turn_streaming( ) n_iter += 1 - + if n_iter >= max_iter: raise Exception(f"Turn did not complete in {max_iter} iterations") From 130b0e2cd91083129b63f7e86ead6f87ac3cfedd Mon Sep 17 00:00:00 2001 From: Xi Yan Date: Fri, 21 Feb 2025 12:23:07 -0800 Subject: [PATCH 09/11] add break --- src/llama_stack_client/lib/agents/agent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llama_stack_client/lib/agents/agent.py b/src/llama_stack_client/lib/agents/agent.py index fffba0ff..03c9d441 100644 --- a/src/llama_stack_client/lib/agents/agent.py +++ b/src/llama_stack_client/lib/agents/agent.py @@ -191,8 +191,8 @@ def _create_turn_streaming( tool_responses=[tool_response_message], stream=True, ) - n_iter += 1 + break if n_iter >= max_iter: raise Exception(f"Turn did not complete in {max_iter} iterations") From 1403c640a49ec044e36e817e0ac773f417c6e29c Mon Sep 17 00:00:00 2001 From: Xi Yan Date: Fri, 21 Feb 2025 12:24:32 -0800 Subject: [PATCH 10/11] remove DEPRECATED --- src/llama_stack_client/lib/agents/agent.py | 100 --------------------- 1 file changed, 100 deletions(-) diff --git a/src/llama_stack_client/lib/agents/agent.py b/src/llama_stack_client/lib/agents/agent.py index 03c9d441..1569c91e 100644 --- a/src/llama_stack_client/lib/agents/agent.py +++ b/src/llama_stack_client/lib/agents/agent.py @@ -196,103 +196,3 @@ def _create_turn_streaming( if n_iter >= max_iter: raise Exception(f"Turn did not complete in {max_iter} iterations") - - def create_turn_DEPRECATED( - self, - messages: List[Union[UserMessage, ToolResponseMessage]], - session_id: Optional[str] = None, - toolgroups: Optional[List[Toolgroup]] = None, - documents: Optional[List[Document]] = None, - stream: bool = True, - ) -> Iterator[AgentTurnResponseStreamChunk] | Turn: - if stream: - return self._create_turn_streaming_DEPRECATED(messages, session_id, toolgroups, documents) - else: - chunks = [] - for chunk in self._create_turn_streaming_DEPRECATED(messages, session_id, toolgroups, documents): - if chunk.event.payload.event_type == "turn_complete": - chunks.append(chunk) - pass - if not chunks: - raise Exception("Turn did not complete") - - # merge chunks - return Turn( - input_messages=chunks[0].event.payload.turn.input_messages, - output_message=chunks[-1].event.payload.turn.output_message, - session_id=chunks[0].event.payload.turn.session_id, - steps=[step for chunk in chunks for step in chunk.event.payload.turn.steps], - turn_id=chunks[0].event.payload.turn.turn_id, - started_at=chunks[0].event.payload.turn.started_at, - completed_at=chunks[-1].event.payload.turn.completed_at, - output_attachments=[ - attachment for chunk in chunks for attachment in chunk.event.payload.turn.output_attachments - ], - ) - - def _create_turn_streaming_DEPRECATED( - self, - messages: List[Union[UserMessage, ToolResponseMessage]], - session_id: Optional[str] = None, - toolgroups: Optional[List[Toolgroup]] = None, - documents: Optional[List[Document]] = None, - ) -> Iterator[AgentTurnResponseStreamChunk]: - stop = False - n_iter = 0 - max_iter = self.agent_config.get("max_infer_iters", DEFAULT_MAX_ITER) - while not stop and n_iter < max_iter: - response = self.client.agents.turn.create( - agent_id=self.agent_id, - # use specified session_id or last session created - session_id=session_id or self.session_id[-1], - messages=messages, - stream=True, - documents=documents, - toolgroups=toolgroups, - ) - # by default, we stop after the first turn - stop = True - for chunk in response: - tool_calls = self._get_tool_calls(chunk) - if hasattr(chunk, "error"): - yield chunk - return - elif not tool_calls: - yield chunk - else: - tool_execution_start_time = datetime.now() - tool_response_message = self._run_tool(tool_calls) - tool_execution_step = ToolExecutionStep( - step_type="tool_execution", - step_id=str(uuid.uuid4()), - tool_calls=tool_calls, - tool_responses=[ - ToolResponse( - tool_name=tool_response_message.tool_name, - content=tool_response_message.content, - call_id=tool_response_message.call_id, - ) - ], - turn_id=chunk.event.payload.turn.turn_id, - completed_at=datetime.now(), - started_at=tool_execution_start_time, - ) - yield AgentTurnResponseStreamChunk( - event=TurnResponseEvent( - payload=AgentTurnResponseStepCompletePayload( - event_type="step_complete", - step_id=tool_execution_step.step_id, - step_type="tool_execution", - step_details=tool_execution_step, - ) - ) - ) - - # HACK: append the tool execution step to the turn - chunk.event.payload.turn.steps.append(tool_execution_step) - yield chunk - - # continue the turn when there's a tool call - stop = False - messages = [tool_response_message] - n_iter += 1 From c583a089cfa1d18570430f7424214122777b6361 Mon Sep 17 00:00:00 2001 From: Xi Yan Date: Fri, 21 Feb 2025 12:25:24 -0800 Subject: [PATCH 11/11] pre --- src/llama_stack_client/lib/agents/agent.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/llama_stack_client/lib/agents/agent.py b/src/llama_stack_client/lib/agents/agent.py index 1569c91e..5a375275 100644 --- a/src/llama_stack_client/lib/agents/agent.py +++ b/src/llama_stack_client/lib/agents/agent.py @@ -13,18 +13,10 @@ from llama_stack_client.types.agents.turn_create_response import ( AgentTurnResponseStreamChunk, ) -from llama_stack_client.types.agents.turn_response_event import TurnResponseEvent -from llama_stack_client.types.agents.turn_response_event_payload import ( - AgentTurnResponseStepCompletePayload, -) from llama_stack_client.types.shared.tool_call import ToolCall from llama_stack_client.types.agents.turn import CompletionMessage from .client_tool import ClientTool from .tool_parser import ToolParser -from datetime import datetime -import uuid -from llama_stack_client.types.tool_execution_step import ToolExecutionStep -from llama_stack_client.types.tool_response import ToolResponse DEFAULT_MAX_ITER = 10