Skip to content

Commit 835a964

Browse files
committed
Sync updates from stainless branch: yanxi0830/dev
1 parent c645726 commit 835a964

File tree

8 files changed

+786
-10
lines changed

8 files changed

+786
-10
lines changed

src/llama_stack_client/_client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,14 @@ def __init__(
126126
) -> None:
127127
"""Construct a new synchronous llama-stack-client client instance.
128128
129-
This automatically infers the `api_key` argument from the `LLAMA_STACK_CLIENT_API_KEY` environment variable if it is not provided.
129+
This automatically infers the `api_key` argument from the `LLAMA_STACK_API_KEY` environment variable if it is not provided.
130130
"""
131131
if api_key is None:
132-
api_key = os.environ.get("LLAMA_STACK_CLIENT_API_KEY")
132+
api_key = os.environ.get("LLAMA_STACK_API_KEY")
133133
self.api_key = api_key
134134

135135
if base_url is None:
136-
base_url = os.environ.get("LLAMA_STACK_CLIENT_BASE_URL")
136+
base_url = os.environ.get("LLAMA_STACK_BASE_URL")
137137
if base_url is None:
138138
base_url = f"http://any-hosted-llama-stack.com"
139139

@@ -342,14 +342,14 @@ def __init__(
342342
) -> None:
343343
"""Construct a new async llama-stack-client client instance.
344344
345-
This automatically infers the `api_key` argument from the `LLAMA_STACK_CLIENT_API_KEY` environment variable if it is not provided.
345+
This automatically infers the `api_key` argument from the `LLAMA_STACK_API_KEY` environment variable if it is not provided.
346346
"""
347347
if api_key is None:
348-
api_key = os.environ.get("LLAMA_STACK_CLIENT_API_KEY")
348+
api_key = os.environ.get("LLAMA_STACK_API_KEY")
349349
self.api_key = api_key
350350

351351
if base_url is None:
352-
base_url = os.environ.get("LLAMA_STACK_CLIENT_BASE_URL")
352+
base_url = os.environ.get("LLAMA_STACK_BASE_URL")
353353
if base_url is None:
354354
base_url = f"http://any-hosted-llama-stack.com"
355355

src/llama_stack_client/_utils/_logs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def _basic_config() -> None:
1414

1515

1616
def setup_logging() -> None:
17-
env = os.environ.get("LLAMA_STACK_CLIENT_LOG")
17+
env = os.environ.get("LLAMA_STACK_LOG")
1818
if env == "debug":
1919
_basic_config()
2020
logger.setLevel(logging.DEBUG)

src/llama_stack_client/resources/agents/turn.py

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

3031
__all__ = ["TurnResource", "AsyncTurnResource"]
@@ -225,6 +226,129 @@ def retrieve(
225226
cast_to=Turn,
226227
)
227228

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

229353
class AsyncTurnResource(AsyncAPIResource):
230354
@cached_property
@@ -421,6 +545,129 @@ async def retrieve(
421545
cast_to=Turn,
422546
)
423547

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

425672
class TurnResourceWithRawResponse:
426673
def __init__(self, turn: TurnResource) -> None:
@@ -432,6 +679,9 @@ def __init__(self, turn: TurnResource) -> None:
432679
self.retrieve = to_raw_response_wrapper(
433680
turn.retrieve,
434681
)
682+
self.resume = to_raw_response_wrapper(
683+
turn.resume,
684+
)
435685

436686

437687
class AsyncTurnResourceWithRawResponse:
@@ -444,6 +694,9 @@ def __init__(self, turn: AsyncTurnResource) -> None:
444694
self.retrieve = async_to_raw_response_wrapper(
445695
turn.retrieve,
446696
)
697+
self.resume = async_to_raw_response_wrapper(
698+
turn.resume,
699+
)
447700

448701

449702
class TurnResourceWithStreamingResponse:
@@ -456,6 +709,9 @@ def __init__(self, turn: TurnResource) -> None:
456709
self.retrieve = to_streamed_response_wrapper(
457710
turn.retrieve,
458711
)
712+
self.resume = to_streamed_response_wrapper(
713+
turn.resume,
714+
)
459715

460716

461717
class AsyncTurnResourceWithStreamingResponse:
@@ -468,3 +724,6 @@ def __init__(self, turn: AsyncTurnResource) -> None:
468724
self.retrieve = async_to_streamed_response_wrapper(
469725
turn.retrieve,
470726
)
727+
self.resume = async_to_streamed_response_wrapper(
728+
turn.resume,
729+
)

src/llama_stack_client/types/agents/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from .turn import Turn as Turn
66
from .session import Session as Session
77
from .turn_create_params import TurnCreateParams as TurnCreateParams
8+
from .turn_resume_params import TurnResumeParams as TurnResumeParams
89
from .turn_response_event import TurnResponseEvent as TurnResponseEvent
910
from .session_create_params import SessionCreateParams as SessionCreateParams
1011
from .step_retrieve_response import StepRetrieveResponse as StepRetrieveResponse

src/llama_stack_client/types/agents/turn_response_event_payload.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"AgentTurnResponseStepCompletePayloadStepDetails",
2121
"AgentTurnResponseTurnStartPayload",
2222
"AgentTurnResponseTurnCompletePayload",
23+
"AgentTurnResponseTurnAwaitingInputPayload",
2324
]
2425

2526

@@ -72,13 +73,21 @@ class AgentTurnResponseTurnCompletePayload(BaseModel):
7273
"""A single turn in an interaction with an Agentic System."""
7374

7475

76+
class AgentTurnResponseTurnAwaitingInputPayload(BaseModel):
77+
event_type: Literal["turn_awaiting_input"]
78+
79+
turn: Turn
80+
"""A single turn in an interaction with an Agentic System."""
81+
82+
7583
TurnResponseEventPayload: TypeAlias = Annotated[
7684
Union[
7785
AgentTurnResponseStepStartPayload,
7886
AgentTurnResponseStepProgressPayload,
7987
AgentTurnResponseStepCompletePayload,
8088
AgentTurnResponseTurnStartPayload,
8189
AgentTurnResponseTurnCompletePayload,
90+
AgentTurnResponseTurnAwaitingInputPayload,
8291
],
8392
PropertyInfo(discriminator="event_type"),
8493
]

0 commit comments

Comments
 (0)