diff --git a/src/llama_stack_client/resources/agents/sessions.py b/src/llama_stack_client/resources/agents/sessions.py deleted file mode 100644 index b8c6ae4..0000000 --- a/src/llama_stack_client/resources/agents/sessions.py +++ /dev/null @@ -1,394 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import List - -import httpx - -from ..._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven -from ..._utils import ( - maybe_transform, - strip_not_given, - async_maybe_transform, -) -from ..._compat import cached_property -from ..._resource import SyncAPIResource, AsyncAPIResource -from ..._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from ..._base_client import make_request_options -from ...types.agents import session_create_params, session_delete_params, session_retrieve_params -from ...types.agents.session import Session -from ...types.agents.session_create_response import SessionCreateResponse - -__all__ = ["SessionsResource", "AsyncSessionsResource"] - - -class SessionsResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> SessionsResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return the - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/stainless-sdks/llama-stack-python#accessing-raw-response-data-eg-headers - """ - return SessionsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> SessionsResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/stainless-sdks/llama-stack-python#with_streaming_response - """ - return SessionsResourceWithStreamingResponse(self) - - def create( - self, - *, - agent_id: str, - session_name: str, - x_llama_stack_provider_data: str | 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, - ) -> SessionCreateResponse: - """ - 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 - """ - extra_headers = { - **strip_not_given({"X-LlamaStack-ProviderData": x_llama_stack_provider_data}), - **(extra_headers or {}), - } - return self._post( - "/agents/session/create", - body=maybe_transform( - { - "agent_id": agent_id, - "session_name": session_name, - }, - session_create_params.SessionCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=SessionCreateResponse, - ) - - def retrieve( - self, - *, - agent_id: str, - session_id: str, - turn_ids: List[str] | NotGiven = NOT_GIVEN, - x_llama_stack_provider_data: str | 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, - ) -> Session: - """ - 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 - """ - extra_headers = { - **strip_not_given({"X-LlamaStack-ProviderData": x_llama_stack_provider_data}), - **(extra_headers or {}), - } - return self._post( - "/agents/session/get", - body=maybe_transform({"turn_ids": turn_ids}, session_retrieve_params.SessionRetrieveParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "agent_id": agent_id, - "session_id": session_id, - }, - session_retrieve_params.SessionRetrieveParams, - ), - ), - cast_to=Session, - ) - - def delete( - self, - *, - agent_id: str, - session_id: str, - x_llama_stack_provider_data: str | 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, - ) -> None: - """ - 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 - """ - extra_headers = {"Accept": "*/*", **(extra_headers or {})} - extra_headers = { - **strip_not_given({"X-LlamaStack-ProviderData": x_llama_stack_provider_data}), - **(extra_headers or {}), - } - return self._post( - "/agents/session/delete", - body=maybe_transform( - { - "agent_id": agent_id, - "session_id": session_id, - }, - session_delete_params.SessionDeleteParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=NoneType, - ) - - -class AsyncSessionsResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncSessionsResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return the - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/stainless-sdks/llama-stack-python#accessing-raw-response-data-eg-headers - """ - return AsyncSessionsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncSessionsResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/stainless-sdks/llama-stack-python#with_streaming_response - """ - return AsyncSessionsResourceWithStreamingResponse(self) - - async def create( - self, - *, - agent_id: str, - session_name: str, - x_llama_stack_provider_data: str | 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, - ) -> SessionCreateResponse: - """ - 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 - """ - extra_headers = { - **strip_not_given({"X-LlamaStack-ProviderData": x_llama_stack_provider_data}), - **(extra_headers or {}), - } - return await self._post( - "/agents/session/create", - body=await async_maybe_transform( - { - "agent_id": agent_id, - "session_name": session_name, - }, - session_create_params.SessionCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=SessionCreateResponse, - ) - - async def retrieve( - self, - *, - agent_id: str, - session_id: str, - turn_ids: List[str] | NotGiven = NOT_GIVEN, - x_llama_stack_provider_data: str | 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, - ) -> Session: - """ - 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 - """ - extra_headers = { - **strip_not_given({"X-LlamaStack-ProviderData": x_llama_stack_provider_data}), - **(extra_headers or {}), - } - return await self._post( - "/agents/session/get", - body=await async_maybe_transform({"turn_ids": turn_ids}, session_retrieve_params.SessionRetrieveParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=await async_maybe_transform( - { - "agent_id": agent_id, - "session_id": session_id, - }, - session_retrieve_params.SessionRetrieveParams, - ), - ), - cast_to=Session, - ) - - async def delete( - self, - *, - agent_id: str, - session_id: str, - x_llama_stack_provider_data: str | 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, - ) -> None: - """ - 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 - """ - extra_headers = {"Accept": "*/*", **(extra_headers or {})} - extra_headers = { - **strip_not_given({"X-LlamaStack-ProviderData": x_llama_stack_provider_data}), - **(extra_headers or {}), - } - return await self._post( - "/agents/session/delete", - body=await async_maybe_transform( - { - "agent_id": agent_id, - "session_id": session_id, - }, - session_delete_params.SessionDeleteParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=NoneType, - ) - - -class SessionsResourceWithRawResponse: - def __init__(self, sessions: SessionsResource) -> None: - self._sessions = sessions - - self.create = to_raw_response_wrapper( - sessions.create, - ) - self.retrieve = to_raw_response_wrapper( - sessions.retrieve, - ) - self.delete = to_raw_response_wrapper( - sessions.delete, - ) - - -class AsyncSessionsResourceWithRawResponse: - def __init__(self, sessions: AsyncSessionsResource) -> None: - self._sessions = sessions - - self.create = async_to_raw_response_wrapper( - sessions.create, - ) - self.retrieve = async_to_raw_response_wrapper( - sessions.retrieve, - ) - self.delete = async_to_raw_response_wrapper( - sessions.delete, - ) - - -class SessionsResourceWithStreamingResponse: - def __init__(self, sessions: SessionsResource) -> None: - self._sessions = sessions - - self.create = to_streamed_response_wrapper( - sessions.create, - ) - self.retrieve = to_streamed_response_wrapper( - sessions.retrieve, - ) - self.delete = to_streamed_response_wrapper( - sessions.delete, - ) - - -class AsyncSessionsResourceWithStreamingResponse: - def __init__(self, sessions: AsyncSessionsResource) -> None: - self._sessions = sessions - - self.create = async_to_streamed_response_wrapper( - sessions.create, - ) - self.retrieve = async_to_streamed_response_wrapper( - sessions.retrieve, - ) - self.delete = async_to_streamed_response_wrapper( - sessions.delete, - ) diff --git a/src/llama_stack_client/resources/agents/turns.py b/src/llama_stack_client/resources/agents/turns.py deleted file mode 100644 index 2023dd7..0000000 --- a/src/llama_stack_client/resources/agents/turns.py +++ /dev/null @@ -1,468 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Iterable -from typing_extensions import Literal, overload - -import httpx - -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ..._utils import ( - required_args, - maybe_transform, - strip_not_given, - async_maybe_transform, -) -from ..._compat import cached_property -from ..._resource import SyncAPIResource, AsyncAPIResource -from ..._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from ..._streaming import Stream, AsyncStream -from ..._base_client import make_request_options -from ...types.agents import turn_create_params, turn_retrieve_params -from ...types.agents.turn import Turn -from ...types.shared_params.attachment import Attachment -from ...types.agents.agents_turn_stream_chunk import AgentsTurnStreamChunk - -__all__ = ["TurnsResource", "AsyncTurnsResource"] - - -class TurnsResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> TurnsResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return the - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/stainless-sdks/llama-stack-python#accessing-raw-response-data-eg-headers - """ - return TurnsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> TurnsResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/stainless-sdks/llama-stack-python#with_streaming_response - """ - return TurnsResourceWithStreamingResponse(self) - - @overload - def create( - self, - *, - agent_id: str, - messages: Iterable[turn_create_params.Message], - session_id: str, - attachments: Iterable[Attachment] | NotGiven = NOT_GIVEN, - stream: Literal[False] | NotGiven = NOT_GIVEN, - x_llama_stack_provider_data: str | 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, - ) -> AgentsTurnStreamChunk: - """ - 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 create( - self, - *, - agent_id: str, - messages: Iterable[turn_create_params.Message], - session_id: str, - stream: Literal[True], - attachments: Iterable[Attachment] | NotGiven = NOT_GIVEN, - x_llama_stack_provider_data: str | 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, - ) -> Stream[AgentsTurnStreamChunk]: - """ - 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 create( - self, - *, - agent_id: str, - messages: Iterable[turn_create_params.Message], - session_id: str, - stream: bool, - attachments: Iterable[Attachment] | NotGiven = NOT_GIVEN, - x_llama_stack_provider_data: str | 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, - ) -> AgentsTurnStreamChunk | Stream[AgentsTurnStreamChunk]: - """ - 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", "messages", "session_id"], ["agent_id", "messages", "session_id", "stream"]) - def create( - self, - *, - agent_id: str, - messages: Iterable[turn_create_params.Message], - session_id: str, - attachments: Iterable[Attachment] | NotGiven = NOT_GIVEN, - stream: Literal[False] | Literal[True] | NotGiven = NOT_GIVEN, - x_llama_stack_provider_data: str | 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, - ) -> AgentsTurnStreamChunk | Stream[AgentsTurnStreamChunk]: - extra_headers = { - **strip_not_given({"X-LlamaStack-ProviderData": x_llama_stack_provider_data}), - **(extra_headers or {}), - } - return self._post( - "/agents/turn/create", - body=maybe_transform( - { - "agent_id": agent_id, - "messages": messages, - "session_id": session_id, - "attachments": attachments, - "stream": stream, - }, - turn_create_params.TurnCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=AgentsTurnStreamChunk, - stream=stream or False, - stream_cls=Stream[AgentsTurnStreamChunk], - ) - - def retrieve( - self, - *, - agent_id: str, - turn_id: str, - x_llama_stack_provider_data: str | 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 - """ - extra_headers = { - **strip_not_given({"X-LlamaStack-ProviderData": x_llama_stack_provider_data}), - **(extra_headers or {}), - } - return self._get( - "/agents/turn/get", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "agent_id": agent_id, - "turn_id": turn_id, - }, - turn_retrieve_params.TurnRetrieveParams, - ), - ), - cast_to=Turn, - ) - - -class AsyncTurnsResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncTurnsResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return the - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/stainless-sdks/llama-stack-python#accessing-raw-response-data-eg-headers - """ - return AsyncTurnsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncTurnsResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/stainless-sdks/llama-stack-python#with_streaming_response - """ - return AsyncTurnsResourceWithStreamingResponse(self) - - @overload - async def create( - self, - *, - agent_id: str, - messages: Iterable[turn_create_params.Message], - session_id: str, - attachments: Iterable[Attachment] | NotGiven = NOT_GIVEN, - stream: Literal[False] | NotGiven = NOT_GIVEN, - x_llama_stack_provider_data: str | 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, - ) -> AgentsTurnStreamChunk: - """ - 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 create( - self, - *, - agent_id: str, - messages: Iterable[turn_create_params.Message], - session_id: str, - stream: Literal[True], - attachments: Iterable[Attachment] | NotGiven = NOT_GIVEN, - x_llama_stack_provider_data: str | 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, - ) -> AsyncStream[AgentsTurnStreamChunk]: - """ - 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 create( - self, - *, - agent_id: str, - messages: Iterable[turn_create_params.Message], - session_id: str, - stream: bool, - attachments: Iterable[Attachment] | NotGiven = NOT_GIVEN, - x_llama_stack_provider_data: str | 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, - ) -> AgentsTurnStreamChunk | AsyncStream[AgentsTurnStreamChunk]: - """ - 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", "messages", "session_id"], ["agent_id", "messages", "session_id", "stream"]) - async def create( - self, - *, - agent_id: str, - messages: Iterable[turn_create_params.Message], - session_id: str, - attachments: Iterable[Attachment] | NotGiven = NOT_GIVEN, - stream: Literal[False] | Literal[True] | NotGiven = NOT_GIVEN, - x_llama_stack_provider_data: str | 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, - ) -> AgentsTurnStreamChunk | AsyncStream[AgentsTurnStreamChunk]: - extra_headers = { - **strip_not_given({"X-LlamaStack-ProviderData": x_llama_stack_provider_data}), - **(extra_headers or {}), - } - return await self._post( - "/agents/turn/create", - body=await async_maybe_transform( - { - "agent_id": agent_id, - "messages": messages, - "session_id": session_id, - "attachments": attachments, - "stream": stream, - }, - turn_create_params.TurnCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=AgentsTurnStreamChunk, - stream=stream or False, - stream_cls=AsyncStream[AgentsTurnStreamChunk], - ) - - async def retrieve( - self, - *, - agent_id: str, - turn_id: str, - x_llama_stack_provider_data: str | 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 - """ - extra_headers = { - **strip_not_given({"X-LlamaStack-ProviderData": x_llama_stack_provider_data}), - **(extra_headers or {}), - } - return await self._get( - "/agents/turn/get", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=await async_maybe_transform( - { - "agent_id": agent_id, - "turn_id": turn_id, - }, - turn_retrieve_params.TurnRetrieveParams, - ), - ), - cast_to=Turn, - ) - - -class TurnsResourceWithRawResponse: - def __init__(self, turns: TurnsResource) -> None: - self._turns = turns - - self.create = to_raw_response_wrapper( - turns.create, - ) - self.retrieve = to_raw_response_wrapper( - turns.retrieve, - ) - - -class AsyncTurnsResourceWithRawResponse: - def __init__(self, turns: AsyncTurnsResource) -> None: - self._turns = turns - - self.create = async_to_raw_response_wrapper( - turns.create, - ) - self.retrieve = async_to_raw_response_wrapper( - turns.retrieve, - ) - - -class TurnsResourceWithStreamingResponse: - def __init__(self, turns: TurnsResource) -> None: - self._turns = turns - - self.create = to_streamed_response_wrapper( - turns.create, - ) - self.retrieve = to_streamed_response_wrapper( - turns.retrieve, - ) - - -class AsyncTurnsResourceWithStreamingResponse: - def __init__(self, turns: AsyncTurnsResource) -> None: - self._turns = turns - - self.create = async_to_streamed_response_wrapper( - turns.create, - ) - self.retrieve = async_to_streamed_response_wrapper( - turns.retrieve, - ) diff --git a/tests/api_resources/agents/test_sessions.py b/tests/api_resources/agents/test_sessions.py deleted file mode 100644 index b7118b0..0000000 --- a/tests/api_resources/agents/test_sessions.py +++ /dev/null @@ -1,285 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, cast - -import pytest - -from tests.utils import assert_matches_type -from llama_stack_client import LlamaStackClient, AsyncLlamaStackClient -from llama_stack_client.types.agents import ( - Session, - SessionCreateResponse, -) - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestSessions: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - def test_method_create(self, client: LlamaStackClient) -> None: - session = client.agents.sessions.create( - agent_id="agent_id", - session_name="session_name", - ) - assert_matches_type(SessionCreateResponse, session, path=["response"]) - - @parametrize - def test_method_create_with_all_params(self, client: LlamaStackClient) -> None: - session = client.agents.sessions.create( - agent_id="agent_id", - session_name="session_name", - x_llama_stack_provider_data="X-LlamaStack-ProviderData", - ) - assert_matches_type(SessionCreateResponse, session, path=["response"]) - - @parametrize - def test_raw_response_create(self, client: LlamaStackClient) -> None: - response = client.agents.sessions.with_raw_response.create( - agent_id="agent_id", - session_name="session_name", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - session = response.parse() - assert_matches_type(SessionCreateResponse, session, path=["response"]) - - @parametrize - def test_streaming_response_create(self, client: LlamaStackClient) -> None: - with client.agents.sessions.with_streaming_response.create( - agent_id="agent_id", - session_name="session_name", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - session = response.parse() - assert_matches_type(SessionCreateResponse, session, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_method_retrieve(self, client: LlamaStackClient) -> None: - session = client.agents.sessions.retrieve( - agent_id="agent_id", - session_id="session_id", - ) - assert_matches_type(Session, session, path=["response"]) - - @parametrize - def test_method_retrieve_with_all_params(self, client: LlamaStackClient) -> None: - session = client.agents.sessions.retrieve( - agent_id="agent_id", - session_id="session_id", - turn_ids=["string", "string", "string"], - x_llama_stack_provider_data="X-LlamaStack-ProviderData", - ) - assert_matches_type(Session, session, path=["response"]) - - @parametrize - def test_raw_response_retrieve(self, client: LlamaStackClient) -> None: - response = client.agents.sessions.with_raw_response.retrieve( - agent_id="agent_id", - session_id="session_id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - session = response.parse() - assert_matches_type(Session, session, path=["response"]) - - @parametrize - def test_streaming_response_retrieve(self, client: LlamaStackClient) -> None: - with client.agents.sessions.with_streaming_response.retrieve( - agent_id="agent_id", - session_id="session_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - session = response.parse() - assert_matches_type(Session, session, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_method_delete(self, client: LlamaStackClient) -> None: - session = client.agents.sessions.delete( - agent_id="agent_id", - session_id="session_id", - ) - assert session is None - - @parametrize - def test_method_delete_with_all_params(self, client: LlamaStackClient) -> None: - session = client.agents.sessions.delete( - agent_id="agent_id", - session_id="session_id", - x_llama_stack_provider_data="X-LlamaStack-ProviderData", - ) - assert session is None - - @parametrize - def test_raw_response_delete(self, client: LlamaStackClient) -> None: - response = client.agents.sessions.with_raw_response.delete( - agent_id="agent_id", - session_id="session_id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - session = response.parse() - assert session is None - - @parametrize - def test_streaming_response_delete(self, client: LlamaStackClient) -> None: - with client.agents.sessions.with_streaming_response.delete( - agent_id="agent_id", - session_id="session_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - session = response.parse() - assert session is None - - assert cast(Any, response.is_closed) is True - - -class TestAsyncSessions: - parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - async def test_method_create(self, async_client: AsyncLlamaStackClient) -> None: - session = await async_client.agents.sessions.create( - agent_id="agent_id", - session_name="session_name", - ) - assert_matches_type(SessionCreateResponse, session, path=["response"]) - - @parametrize - async def test_method_create_with_all_params(self, async_client: AsyncLlamaStackClient) -> None: - session = await async_client.agents.sessions.create( - agent_id="agent_id", - session_name="session_name", - x_llama_stack_provider_data="X-LlamaStack-ProviderData", - ) - assert_matches_type(SessionCreateResponse, session, path=["response"]) - - @parametrize - async def test_raw_response_create(self, async_client: AsyncLlamaStackClient) -> None: - response = await async_client.agents.sessions.with_raw_response.create( - agent_id="agent_id", - session_name="session_name", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - session = await response.parse() - assert_matches_type(SessionCreateResponse, session, path=["response"]) - - @parametrize - async def test_streaming_response_create(self, async_client: AsyncLlamaStackClient) -> None: - async with async_client.agents.sessions.with_streaming_response.create( - agent_id="agent_id", - session_name="session_name", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - session = await response.parse() - assert_matches_type(SessionCreateResponse, session, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_method_retrieve(self, async_client: AsyncLlamaStackClient) -> None: - session = await async_client.agents.sessions.retrieve( - agent_id="agent_id", - session_id="session_id", - ) - assert_matches_type(Session, session, path=["response"]) - - @parametrize - async def test_method_retrieve_with_all_params(self, async_client: AsyncLlamaStackClient) -> None: - session = await async_client.agents.sessions.retrieve( - agent_id="agent_id", - session_id="session_id", - turn_ids=["string", "string", "string"], - x_llama_stack_provider_data="X-LlamaStack-ProviderData", - ) - assert_matches_type(Session, session, path=["response"]) - - @parametrize - async def test_raw_response_retrieve(self, async_client: AsyncLlamaStackClient) -> None: - response = await async_client.agents.sessions.with_raw_response.retrieve( - agent_id="agent_id", - session_id="session_id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - session = await response.parse() - assert_matches_type(Session, session, path=["response"]) - - @parametrize - async def test_streaming_response_retrieve(self, async_client: AsyncLlamaStackClient) -> None: - async with async_client.agents.sessions.with_streaming_response.retrieve( - agent_id="agent_id", - session_id="session_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - session = await response.parse() - assert_matches_type(Session, session, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_method_delete(self, async_client: AsyncLlamaStackClient) -> None: - session = await async_client.agents.sessions.delete( - agent_id="agent_id", - session_id="session_id", - ) - assert session is None - - @parametrize - async def test_method_delete_with_all_params(self, async_client: AsyncLlamaStackClient) -> None: - session = await async_client.agents.sessions.delete( - agent_id="agent_id", - session_id="session_id", - x_llama_stack_provider_data="X-LlamaStack-ProviderData", - ) - assert session is None - - @parametrize - async def test_raw_response_delete(self, async_client: AsyncLlamaStackClient) -> None: - response = await async_client.agents.sessions.with_raw_response.delete( - agent_id="agent_id", - session_id="session_id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - session = await response.parse() - assert session is None - - @parametrize - async def test_streaming_response_delete(self, async_client: AsyncLlamaStackClient) -> None: - async with async_client.agents.sessions.with_streaming_response.delete( - agent_id="agent_id", - session_id="session_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - session = await response.parse() - assert session is None - - assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/agents/test_turns.py b/tests/api_resources/agents/test_turns.py deleted file mode 100644 index 30510a2..0000000 --- a/tests/api_resources/agents/test_turns.py +++ /dev/null @@ -1,580 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, cast - -import pytest - -from tests.utils import assert_matches_type -from llama_stack_client import LlamaStackClient, AsyncLlamaStackClient -from llama_stack_client.types.agents import Turn, AgentsTurnStreamChunk - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestTurns: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - def test_method_create_overload_1(self, client: LlamaStackClient) -> None: - turn = client.agents.turns.create( - agent_id="agent_id", - messages=[ - { - "content": "string", - "role": "user", - }, - { - "content": "string", - "role": "user", - }, - { - "content": "string", - "role": "user", - }, - ], - session_id="session_id", - ) - assert_matches_type(AgentsTurnStreamChunk, turn, path=["response"]) - - @parametrize - def test_method_create_with_all_params_overload_1(self, client: LlamaStackClient) -> None: - turn = client.agents.turns.create( - agent_id="agent_id", - messages=[ - { - "content": "string", - "role": "user", - "context": "string", - }, - { - "content": "string", - "role": "user", - "context": "string", - }, - { - "content": "string", - "role": "user", - "context": "string", - }, - ], - session_id="session_id", - attachments=[ - { - "content": "string", - "mime_type": "mime_type", - }, - { - "content": "string", - "mime_type": "mime_type", - }, - { - "content": "string", - "mime_type": "mime_type", - }, - ], - stream=False, - x_llama_stack_provider_data="X-LlamaStack-ProviderData", - ) - assert_matches_type(AgentsTurnStreamChunk, turn, path=["response"]) - - @parametrize - def test_raw_response_create_overload_1(self, client: LlamaStackClient) -> None: - response = client.agents.turns.with_raw_response.create( - agent_id="agent_id", - messages=[ - { - "content": "string", - "role": "user", - }, - { - "content": "string", - "role": "user", - }, - { - "content": "string", - "role": "user", - }, - ], - session_id="session_id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - turn = response.parse() - assert_matches_type(AgentsTurnStreamChunk, turn, path=["response"]) - - @parametrize - def test_streaming_response_create_overload_1(self, client: LlamaStackClient) -> None: - with client.agents.turns.with_streaming_response.create( - agent_id="agent_id", - messages=[ - { - "content": "string", - "role": "user", - }, - { - "content": "string", - "role": "user", - }, - { - "content": "string", - "role": "user", - }, - ], - session_id="session_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - turn = response.parse() - assert_matches_type(AgentsTurnStreamChunk, turn, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_method_create_overload_2(self, client: LlamaStackClient) -> None: - turn_stream = client.agents.turns.create( - agent_id="agent_id", - messages=[ - { - "content": "string", - "role": "user", - }, - { - "content": "string", - "role": "user", - }, - { - "content": "string", - "role": "user", - }, - ], - session_id="session_id", - stream=True, - ) - turn_stream.response.close() - - @parametrize - def test_method_create_with_all_params_overload_2(self, client: LlamaStackClient) -> None: - turn_stream = client.agents.turns.create( - agent_id="agent_id", - messages=[ - { - "content": "string", - "role": "user", - "context": "string", - }, - { - "content": "string", - "role": "user", - "context": "string", - }, - { - "content": "string", - "role": "user", - "context": "string", - }, - ], - session_id="session_id", - stream=True, - attachments=[ - { - "content": "string", - "mime_type": "mime_type", - }, - { - "content": "string", - "mime_type": "mime_type", - }, - { - "content": "string", - "mime_type": "mime_type", - }, - ], - x_llama_stack_provider_data="X-LlamaStack-ProviderData", - ) - turn_stream.response.close() - - @parametrize - def test_raw_response_create_overload_2(self, client: LlamaStackClient) -> None: - response = client.agents.turns.with_raw_response.create( - agent_id="agent_id", - messages=[ - { - "content": "string", - "role": "user", - }, - { - "content": "string", - "role": "user", - }, - { - "content": "string", - "role": "user", - }, - ], - session_id="session_id", - stream=True, - ) - - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - stream = response.parse() - stream.close() - - @parametrize - def test_streaming_response_create_overload_2(self, client: LlamaStackClient) -> None: - with client.agents.turns.with_streaming_response.create( - agent_id="agent_id", - messages=[ - { - "content": "string", - "role": "user", - }, - { - "content": "string", - "role": "user", - }, - { - "content": "string", - "role": "user", - }, - ], - session_id="session_id", - stream=True, - ) 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_method_retrieve(self, client: LlamaStackClient) -> None: - turn = client.agents.turns.retrieve( - agent_id="agent_id", - turn_id="turn_id", - ) - assert_matches_type(Turn, turn, path=["response"]) - - @parametrize - def test_method_retrieve_with_all_params(self, client: LlamaStackClient) -> None: - turn = client.agents.turns.retrieve( - agent_id="agent_id", - turn_id="turn_id", - x_llama_stack_provider_data="X-LlamaStack-ProviderData", - ) - assert_matches_type(Turn, turn, path=["response"]) - - @parametrize - def test_raw_response_retrieve(self, client: LlamaStackClient) -> None: - response = client.agents.turns.with_raw_response.retrieve( - agent_id="agent_id", - turn_id="turn_id", - ) - - 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_retrieve(self, client: LlamaStackClient) -> None: - with client.agents.turns.with_streaming_response.retrieve( - agent_id="agent_id", - turn_id="turn_id", - ) 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 - - -class TestAsyncTurns: - parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - async def test_method_create_overload_1(self, async_client: AsyncLlamaStackClient) -> None: - turn = await async_client.agents.turns.create( - agent_id="agent_id", - messages=[ - { - "content": "string", - "role": "user", - }, - { - "content": "string", - "role": "user", - }, - { - "content": "string", - "role": "user", - }, - ], - session_id="session_id", - ) - assert_matches_type(AgentsTurnStreamChunk, turn, path=["response"]) - - @parametrize - async def test_method_create_with_all_params_overload_1(self, async_client: AsyncLlamaStackClient) -> None: - turn = await async_client.agents.turns.create( - agent_id="agent_id", - messages=[ - { - "content": "string", - "role": "user", - "context": "string", - }, - { - "content": "string", - "role": "user", - "context": "string", - }, - { - "content": "string", - "role": "user", - "context": "string", - }, - ], - session_id="session_id", - attachments=[ - { - "content": "string", - "mime_type": "mime_type", - }, - { - "content": "string", - "mime_type": "mime_type", - }, - { - "content": "string", - "mime_type": "mime_type", - }, - ], - stream=False, - x_llama_stack_provider_data="X-LlamaStack-ProviderData", - ) - assert_matches_type(AgentsTurnStreamChunk, turn, path=["response"]) - - @parametrize - async def test_raw_response_create_overload_1(self, async_client: AsyncLlamaStackClient) -> None: - response = await async_client.agents.turns.with_raw_response.create( - agent_id="agent_id", - messages=[ - { - "content": "string", - "role": "user", - }, - { - "content": "string", - "role": "user", - }, - { - "content": "string", - "role": "user", - }, - ], - session_id="session_id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - turn = await response.parse() - assert_matches_type(AgentsTurnStreamChunk, turn, path=["response"]) - - @parametrize - async def test_streaming_response_create_overload_1(self, async_client: AsyncLlamaStackClient) -> None: - async with async_client.agents.turns.with_streaming_response.create( - agent_id="agent_id", - messages=[ - { - "content": "string", - "role": "user", - }, - { - "content": "string", - "role": "user", - }, - { - "content": "string", - "role": "user", - }, - ], - session_id="session_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - turn = await response.parse() - assert_matches_type(AgentsTurnStreamChunk, turn, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_method_create_overload_2(self, async_client: AsyncLlamaStackClient) -> None: - turn_stream = await async_client.agents.turns.create( - agent_id="agent_id", - messages=[ - { - "content": "string", - "role": "user", - }, - { - "content": "string", - "role": "user", - }, - { - "content": "string", - "role": "user", - }, - ], - session_id="session_id", - stream=True, - ) - await turn_stream.response.aclose() - - @parametrize - async def test_method_create_with_all_params_overload_2(self, async_client: AsyncLlamaStackClient) -> None: - turn_stream = await async_client.agents.turns.create( - agent_id="agent_id", - messages=[ - { - "content": "string", - "role": "user", - "context": "string", - }, - { - "content": "string", - "role": "user", - "context": "string", - }, - { - "content": "string", - "role": "user", - "context": "string", - }, - ], - session_id="session_id", - stream=True, - attachments=[ - { - "content": "string", - "mime_type": "mime_type", - }, - { - "content": "string", - "mime_type": "mime_type", - }, - { - "content": "string", - "mime_type": "mime_type", - }, - ], - x_llama_stack_provider_data="X-LlamaStack-ProviderData", - ) - await turn_stream.response.aclose() - - @parametrize - async def test_raw_response_create_overload_2(self, async_client: AsyncLlamaStackClient) -> None: - response = await async_client.agents.turns.with_raw_response.create( - agent_id="agent_id", - messages=[ - { - "content": "string", - "role": "user", - }, - { - "content": "string", - "role": "user", - }, - { - "content": "string", - "role": "user", - }, - ], - session_id="session_id", - stream=True, - ) - - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - stream = await response.parse() - await stream.close() - - @parametrize - async def test_streaming_response_create_overload_2(self, async_client: AsyncLlamaStackClient) -> None: - async with async_client.agents.turns.with_streaming_response.create( - agent_id="agent_id", - messages=[ - { - "content": "string", - "role": "user", - }, - { - "content": "string", - "role": "user", - }, - { - "content": "string", - "role": "user", - }, - ], - session_id="session_id", - stream=True, - ) 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_method_retrieve(self, async_client: AsyncLlamaStackClient) -> None: - turn = await async_client.agents.turns.retrieve( - agent_id="agent_id", - turn_id="turn_id", - ) - assert_matches_type(Turn, turn, path=["response"]) - - @parametrize - async def test_method_retrieve_with_all_params(self, async_client: AsyncLlamaStackClient) -> None: - turn = await async_client.agents.turns.retrieve( - agent_id="agent_id", - turn_id="turn_id", - x_llama_stack_provider_data="X-LlamaStack-ProviderData", - ) - assert_matches_type(Turn, turn, path=["response"]) - - @parametrize - async def test_raw_response_retrieve(self, async_client: AsyncLlamaStackClient) -> None: - response = await async_client.agents.turns.with_raw_response.retrieve( - agent_id="agent_id", - turn_id="turn_id", - ) - - 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_retrieve(self, async_client: AsyncLlamaStackClient) -> None: - async with async_client.agents.turns.with_streaming_response.retrieve( - agent_id="agent_id", - turn_id="turn_id", - ) 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