Skip to content

Commit 2554209

Browse files
committed
Sync updates from stainless branch: yanxi0830/dev
1 parent 3cf8ac8 commit 2554209

File tree

12 files changed

+105
-765
lines changed

12 files changed

+105
-765
lines changed

src/llama_stack_client/_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def __init__(
135135
if base_url is None:
136136
base_url = os.environ.get("LLAMA_STACK_BASE_URL")
137137
if base_url is None:
138-
base_url = "http://any-hosted-llama-stack.com"
138+
base_url = f"http://any-hosted-llama-stack.com"
139139

140140
custom_headers = default_headers or {}
141141
custom_headers["X-LlamaStack-Client-Version"] = __version__
@@ -351,7 +351,7 @@ def __init__(
351351
if base_url is None:
352352
base_url = os.environ.get("LLAMA_STACK_BASE_URL")
353353
if base_url is None:
354-
base_url = "http://any-hosted-llama-stack.com"
354+
base_url = f"http://any-hosted-llama-stack.com"
355355

356356
custom_headers = default_headers or {}
357357
custom_headers["X-LlamaStack-Client-Version"] = __version__

src/llama_stack_client/_files.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def _transform_file(file: FileTypes) -> HttpxFileTypes:
7171
if is_tuple_t(file):
7272
return (file[0], _read_file_content(file[1]), *file[2:])
7373

74-
raise TypeError("Expected file types input to be a FileContent type or to be a tuple")
74+
raise TypeError(f"Expected file types input to be a FileContent type or to be a tuple")
7575

7676

7777
def _read_file_content(file: FileContent) -> HttpxFileContent:
@@ -113,7 +113,7 @@ async def _async_transform_file(file: FileTypes) -> HttpxFileTypes:
113113
if is_tuple_t(file):
114114
return (file[0], await _async_read_file_content(file[1]), *file[2:])
115115

116-
raise TypeError("Expected file types input to be a FileContent type or to be a tuple")
116+
raise TypeError(f"Expected file types input to be a FileContent type or to be a tuple")
117117

118118

119119
async def _async_read_file_content(file: FileContent) -> HttpxFileContent:

src/llama_stack_client/_response.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
229229
# the response class ourselves but that is something that should be supported directly in httpx
230230
# as it would be easy to incorrectly construct the Response object due to the multitude of arguments.
231231
if cast_to != httpx.Response:
232-
raise ValueError("Subclasses of httpx.Response cannot be passed to `cast_to`")
232+
raise ValueError(f"Subclasses of httpx.Response cannot be passed to `cast_to`")
233233
return cast(R, response)
234234

235235
if (
@@ -245,9 +245,9 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
245245

246246
if (
247247
cast_to is not object
248-
and origin is not list
249-
and origin is not dict
250-
and origin is not Union
248+
and not origin is list
249+
and not origin is dict
250+
and not origin is Union
251251
and not issubclass(origin, BaseModel)
252252
):
253253
raise RuntimeError(

src/llama_stack_client/resources/agents/turn.py

Lines changed: 1 addition & 260 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323
)
2424
from ..._streaming import Stream, AsyncStream
2525
from ..._base_client import make_request_options
26-
from ...types.agents import turn_create_params, turn_resume_params
26+
from ...types.agents import turn_create_params
2727
from ...types.agents.turn import Turn
28-
from ...types.shared_params.tool_response_message import ToolResponseMessage
2928
from ...types.agents.agent_turn_response_stream_chunk import AgentTurnResponseStreamChunk
3029

3130
__all__ = ["TurnResource", "AsyncTurnResource"]
@@ -231,129 +230,6 @@ def retrieve(
231230
cast_to=Turn,
232231
)
233232

234-
@overload
235-
def resume(
236-
self,
237-
turn_id: str,
238-
*,
239-
agent_id: str,
240-
session_id: str,
241-
tool_responses: Iterable[ToolResponseMessage],
242-
stream: Literal[False] | NotGiven = NOT_GIVEN,
243-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
244-
# The extra values given here take precedence over values defined on the client or passed to this method.
245-
extra_headers: Headers | None = None,
246-
extra_query: Query | None = None,
247-
extra_body: Body | None = None,
248-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
249-
) -> Turn:
250-
"""
251-
Args:
252-
extra_headers: Send extra headers
253-
254-
extra_query: Add additional query parameters to the request
255-
256-
extra_body: Add additional JSON properties to the request
257-
258-
timeout: Override the client-level default timeout for this request, in seconds
259-
"""
260-
...
261-
262-
@overload
263-
def resume(
264-
self,
265-
turn_id: str,
266-
*,
267-
agent_id: str,
268-
session_id: str,
269-
stream: Literal[True],
270-
tool_responses: Iterable[ToolResponseMessage],
271-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
272-
# The extra values given here take precedence over values defined on the client or passed to this method.
273-
extra_headers: Headers | None = None,
274-
extra_query: Query | None = None,
275-
extra_body: Body | None = None,
276-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
277-
) -> Stream[AgentTurnResponseStreamChunk]:
278-
"""
279-
Args:
280-
extra_headers: Send extra headers
281-
282-
extra_query: Add additional query parameters to the request
283-
284-
extra_body: Add additional JSON properties to the request
285-
286-
timeout: Override the client-level default timeout for this request, in seconds
287-
"""
288-
...
289-
290-
@overload
291-
def resume(
292-
self,
293-
turn_id: str,
294-
*,
295-
agent_id: str,
296-
session_id: str,
297-
stream: bool,
298-
tool_responses: Iterable[ToolResponseMessage],
299-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
300-
# The extra values given here take precedence over values defined on the client or passed to this method.
301-
extra_headers: Headers | None = None,
302-
extra_query: Query | None = None,
303-
extra_body: Body | None = None,
304-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
305-
) -> Turn | Stream[AgentTurnResponseStreamChunk]:
306-
"""
307-
Args:
308-
extra_headers: Send extra headers
309-
310-
extra_query: Add additional query parameters to the request
311-
312-
extra_body: Add additional JSON properties to the request
313-
314-
timeout: Override the client-level default timeout for this request, in seconds
315-
"""
316-
...
317-
318-
@required_args(["agent_id", "session_id", "tool_responses"], ["agent_id", "session_id", "stream", "tool_responses"])
319-
def resume(
320-
self,
321-
turn_id: str,
322-
*,
323-
agent_id: str,
324-
session_id: str,
325-
tool_responses: Iterable[ToolResponseMessage],
326-
stream: Literal[False] | Literal[True] | NotGiven = NOT_GIVEN,
327-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
328-
# The extra values given here take precedence over values defined on the client or passed to this method.
329-
extra_headers: Headers | None = None,
330-
extra_query: Query | None = None,
331-
extra_body: Body | None = None,
332-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
333-
) -> Turn | Stream[AgentTurnResponseStreamChunk]:
334-
if not agent_id:
335-
raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}")
336-
if not session_id:
337-
raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}")
338-
if not turn_id:
339-
raise ValueError(f"Expected a non-empty value for `turn_id` but received {turn_id!r}")
340-
return self._post(
341-
f"/v1/agents/{agent_id}/session/{session_id}/turn/{turn_id}/resume",
342-
body=maybe_transform(
343-
{
344-
"tool_responses": tool_responses,
345-
"stream": stream,
346-
},
347-
turn_resume_params.TurnResumeParams,
348-
),
349-
options=make_request_options(
350-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
351-
),
352-
cast_to=Turn,
353-
stream=stream or False,
354-
stream_cls=Stream[AgentTurnResponseStreamChunk],
355-
)
356-
357233

358234
class AsyncTurnResource(AsyncAPIResource):
359235
@cached_property
@@ -555,129 +431,6 @@ async def retrieve(
555431
cast_to=Turn,
556432
)
557433

558-
@overload
559-
async def resume(
560-
self,
561-
turn_id: str,
562-
*,
563-
agent_id: str,
564-
session_id: str,
565-
tool_responses: Iterable[ToolResponseMessage],
566-
stream: Literal[False] | NotGiven = NOT_GIVEN,
567-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
568-
# The extra values given here take precedence over values defined on the client or passed to this method.
569-
extra_headers: Headers | None = None,
570-
extra_query: Query | None = None,
571-
extra_body: Body | None = None,
572-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
573-
) -> Turn:
574-
"""
575-
Args:
576-
extra_headers: Send extra headers
577-
578-
extra_query: Add additional query parameters to the request
579-
580-
extra_body: Add additional JSON properties to the request
581-
582-
timeout: Override the client-level default timeout for this request, in seconds
583-
"""
584-
...
585-
586-
@overload
587-
async def resume(
588-
self,
589-
turn_id: str,
590-
*,
591-
agent_id: str,
592-
session_id: str,
593-
stream: Literal[True],
594-
tool_responses: Iterable[ToolResponseMessage],
595-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
596-
# The extra values given here take precedence over values defined on the client or passed to this method.
597-
extra_headers: Headers | None = None,
598-
extra_query: Query | None = None,
599-
extra_body: Body | None = None,
600-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
601-
) -> AsyncStream[AgentTurnResponseStreamChunk]:
602-
"""
603-
Args:
604-
extra_headers: Send extra headers
605-
606-
extra_query: Add additional query parameters to the request
607-
608-
extra_body: Add additional JSON properties to the request
609-
610-
timeout: Override the client-level default timeout for this request, in seconds
611-
"""
612-
...
613-
614-
@overload
615-
async def resume(
616-
self,
617-
turn_id: str,
618-
*,
619-
agent_id: str,
620-
session_id: str,
621-
stream: bool,
622-
tool_responses: Iterable[ToolResponseMessage],
623-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
624-
# The extra values given here take precedence over values defined on the client or passed to this method.
625-
extra_headers: Headers | None = None,
626-
extra_query: Query | None = None,
627-
extra_body: Body | None = None,
628-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
629-
) -> Turn | AsyncStream[AgentTurnResponseStreamChunk]:
630-
"""
631-
Args:
632-
extra_headers: Send extra headers
633-
634-
extra_query: Add additional query parameters to the request
635-
636-
extra_body: Add additional JSON properties to the request
637-
638-
timeout: Override the client-level default timeout for this request, in seconds
639-
"""
640-
...
641-
642-
@required_args(["agent_id", "session_id", "tool_responses"], ["agent_id", "session_id", "stream", "tool_responses"])
643-
async def resume(
644-
self,
645-
turn_id: str,
646-
*,
647-
agent_id: str,
648-
session_id: str,
649-
tool_responses: Iterable[ToolResponseMessage],
650-
stream: Literal[False] | Literal[True] | NotGiven = NOT_GIVEN,
651-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
652-
# The extra values given here take precedence over values defined on the client or passed to this method.
653-
extra_headers: Headers | None = None,
654-
extra_query: Query | None = None,
655-
extra_body: Body | None = None,
656-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
657-
) -> Turn | AsyncStream[AgentTurnResponseStreamChunk]:
658-
if not agent_id:
659-
raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}")
660-
if not session_id:
661-
raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}")
662-
if not turn_id:
663-
raise ValueError(f"Expected a non-empty value for `turn_id` but received {turn_id!r}")
664-
return await self._post(
665-
f"/v1/agents/{agent_id}/session/{session_id}/turn/{turn_id}/resume",
666-
body=await async_maybe_transform(
667-
{
668-
"tool_responses": tool_responses,
669-
"stream": stream,
670-
},
671-
turn_resume_params.TurnResumeParams,
672-
),
673-
options=make_request_options(
674-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
675-
),
676-
cast_to=Turn,
677-
stream=stream or False,
678-
stream_cls=AsyncStream[AgentTurnResponseStreamChunk],
679-
)
680-
681434

682435
class TurnResourceWithRawResponse:
683436
def __init__(self, turn: TurnResource) -> None:
@@ -689,9 +442,6 @@ def __init__(self, turn: TurnResource) -> None:
689442
self.retrieve = to_raw_response_wrapper(
690443
turn.retrieve,
691444
)
692-
self.resume = to_raw_response_wrapper(
693-
turn.resume,
694-
)
695445

696446

697447
class AsyncTurnResourceWithRawResponse:
@@ -704,9 +454,6 @@ def __init__(self, turn: AsyncTurnResource) -> None:
704454
self.retrieve = async_to_raw_response_wrapper(
705455
turn.retrieve,
706456
)
707-
self.resume = async_to_raw_response_wrapper(
708-
turn.resume,
709-
)
710457

711458

712459
class TurnResourceWithStreamingResponse:
@@ -719,9 +466,6 @@ def __init__(self, turn: TurnResource) -> None:
719466
self.retrieve = to_streamed_response_wrapper(
720467
turn.retrieve,
721468
)
722-
self.resume = to_streamed_response_wrapper(
723-
turn.resume,
724-
)
725469

726470

727471
class AsyncTurnResourceWithStreamingResponse:
@@ -734,6 +478,3 @@ def __init__(self, turn: AsyncTurnResource) -> None:
734478
self.retrieve = async_to_streamed_response_wrapper(
735479
turn.retrieve,
736480
)
737-
self.resume = async_to_streamed_response_wrapper(
738-
turn.resume,
739-
)

0 commit comments

Comments
 (0)