Skip to content

Commit 367da69

Browse files
ehhuangEric Huang (AI Platform)
andauthored
feat: Sync updates from stainless branch: ehhuang/dev (#149)
# What does this PR do? ## Test Plan LLAMA_STACK_CONFIG=fireworks pytest -s -v tests/client-sdk/ --safety-shield meta-llama/Llama-Guard-3-8B [//]: # (## Documentation) [//]: # (- [ ] Added a Changelog entry if the change is significant) Co-authored-by: Eric Huang (AI Platform) <[email protected]>
1 parent ad6ffc6 commit 367da69

File tree

9 files changed

+185
-93
lines changed

9 files changed

+185
-93
lines changed

src/llama_stack_client/resources/batch_inference.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def chat_completion(
6060
logprobs: batch_inference_chat_completion_params.Logprobs | NotGiven = NOT_GIVEN,
6161
response_format: ResponseFormat | NotGiven = NOT_GIVEN,
6262
sampling_params: SamplingParams | NotGiven = NOT_GIVEN,
63-
tool_choice: Literal["auto", "required"] | NotGiven = NOT_GIVEN,
63+
tool_choice: Literal["auto", "required", "none"] | NotGiven = NOT_GIVEN,
6464
tool_prompt_format: Literal["json", "function_tag", "python_list"] | NotGiven = NOT_GIVEN,
6565
tools: Iterable[batch_inference_chat_completion_params.Tool] | NotGiven = NOT_GIVEN,
6666
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -183,7 +183,7 @@ async def chat_completion(
183183
logprobs: batch_inference_chat_completion_params.Logprobs | NotGiven = NOT_GIVEN,
184184
response_format: ResponseFormat | NotGiven = NOT_GIVEN,
185185
sampling_params: SamplingParams | NotGiven = NOT_GIVEN,
186-
tool_choice: Literal["auto", "required"] | NotGiven = NOT_GIVEN,
186+
tool_choice: Literal["auto", "required", "none"] | NotGiven = NOT_GIVEN,
187187
tool_prompt_format: Literal["json", "function_tag", "python_list"] | NotGiven = NOT_GIVEN,
188188
tools: Iterable[batch_inference_chat_completion_params.Tool] | NotGiven = NOT_GIVEN,
189189
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.

src/llama_stack_client/resources/inference.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def chat_completion(
7070
response_format: ResponseFormat | NotGiven = NOT_GIVEN,
7171
sampling_params: SamplingParams | NotGiven = NOT_GIVEN,
7272
stream: Literal[False] | NotGiven = NOT_GIVEN,
73-
tool_choice: Literal["auto", "required"] | NotGiven = NOT_GIVEN,
73+
tool_choice: Literal["auto", "required", "none"] | NotGiven = NOT_GIVEN,
7474
tool_config: inference_chat_completion_params.ToolConfig | NotGiven = NOT_GIVEN,
7575
tool_prompt_format: Literal["json", "function_tag", "python_list"] | NotGiven = NOT_GIVEN,
7676
tools: Iterable[inference_chat_completion_params.Tool] | NotGiven = NOT_GIVEN,
@@ -138,7 +138,7 @@ def chat_completion(
138138
logprobs: inference_chat_completion_params.Logprobs | NotGiven = NOT_GIVEN,
139139
response_format: ResponseFormat | NotGiven = NOT_GIVEN,
140140
sampling_params: SamplingParams | NotGiven = NOT_GIVEN,
141-
tool_choice: Literal["auto", "required"] | NotGiven = NOT_GIVEN,
141+
tool_choice: Literal["auto", "required", "none"] | NotGiven = NOT_GIVEN,
142142
tool_config: inference_chat_completion_params.ToolConfig | NotGiven = NOT_GIVEN,
143143
tool_prompt_format: Literal["json", "function_tag", "python_list"] | NotGiven = NOT_GIVEN,
144144
tools: Iterable[inference_chat_completion_params.Tool] | NotGiven = NOT_GIVEN,
@@ -206,7 +206,7 @@ def chat_completion(
206206
logprobs: inference_chat_completion_params.Logprobs | NotGiven = NOT_GIVEN,
207207
response_format: ResponseFormat | NotGiven = NOT_GIVEN,
208208
sampling_params: SamplingParams | NotGiven = NOT_GIVEN,
209-
tool_choice: Literal["auto", "required"] | NotGiven = NOT_GIVEN,
209+
tool_choice: Literal["auto", "required", "none"] | NotGiven = NOT_GIVEN,
210210
tool_config: inference_chat_completion_params.ToolConfig | NotGiven = NOT_GIVEN,
211211
tool_prompt_format: Literal["json", "function_tag", "python_list"] | NotGiven = NOT_GIVEN,
212212
tools: Iterable[inference_chat_completion_params.Tool] | NotGiven = NOT_GIVEN,
@@ -274,7 +274,7 @@ def chat_completion(
274274
response_format: ResponseFormat | NotGiven = NOT_GIVEN,
275275
sampling_params: SamplingParams | NotGiven = NOT_GIVEN,
276276
stream: Literal[False] | Literal[True] | NotGiven = NOT_GIVEN,
277-
tool_choice: Literal["auto", "required"] | NotGiven = NOT_GIVEN,
277+
tool_choice: Literal["auto", "required", "none"] | NotGiven = NOT_GIVEN,
278278
tool_config: inference_chat_completion_params.ToolConfig | NotGiven = NOT_GIVEN,
279279
tool_prompt_format: Literal["json", "function_tag", "python_list"] | NotGiven = NOT_GIVEN,
280280
tools: Iterable[inference_chat_completion_params.Tool] | NotGiven = NOT_GIVEN,
@@ -567,7 +567,7 @@ async def chat_completion(
567567
response_format: ResponseFormat | NotGiven = NOT_GIVEN,
568568
sampling_params: SamplingParams | NotGiven = NOT_GIVEN,
569569
stream: Literal[False] | NotGiven = NOT_GIVEN,
570-
tool_choice: Literal["auto", "required"] | NotGiven = NOT_GIVEN,
570+
tool_choice: Literal["auto", "required", "none"] | NotGiven = NOT_GIVEN,
571571
tool_config: inference_chat_completion_params.ToolConfig | NotGiven = NOT_GIVEN,
572572
tool_prompt_format: Literal["json", "function_tag", "python_list"] | NotGiven = NOT_GIVEN,
573573
tools: Iterable[inference_chat_completion_params.Tool] | NotGiven = NOT_GIVEN,
@@ -635,7 +635,7 @@ async def chat_completion(
635635
logprobs: inference_chat_completion_params.Logprobs | NotGiven = NOT_GIVEN,
636636
response_format: ResponseFormat | NotGiven = NOT_GIVEN,
637637
sampling_params: SamplingParams | NotGiven = NOT_GIVEN,
638-
tool_choice: Literal["auto", "required"] | NotGiven = NOT_GIVEN,
638+
tool_choice: Literal["auto", "required", "none"] | NotGiven = NOT_GIVEN,
639639
tool_config: inference_chat_completion_params.ToolConfig | NotGiven = NOT_GIVEN,
640640
tool_prompt_format: Literal["json", "function_tag", "python_list"] | NotGiven = NOT_GIVEN,
641641
tools: Iterable[inference_chat_completion_params.Tool] | NotGiven = NOT_GIVEN,
@@ -703,7 +703,7 @@ async def chat_completion(
703703
logprobs: inference_chat_completion_params.Logprobs | NotGiven = NOT_GIVEN,
704704
response_format: ResponseFormat | NotGiven = NOT_GIVEN,
705705
sampling_params: SamplingParams | NotGiven = NOT_GIVEN,
706-
tool_choice: Literal["auto", "required"] | NotGiven = NOT_GIVEN,
706+
tool_choice: Literal["auto", "required", "none"] | NotGiven = NOT_GIVEN,
707707
tool_config: inference_chat_completion_params.ToolConfig | NotGiven = NOT_GIVEN,
708708
tool_prompt_format: Literal["json", "function_tag", "python_list"] | NotGiven = NOT_GIVEN,
709709
tools: Iterable[inference_chat_completion_params.Tool] | NotGiven = NOT_GIVEN,
@@ -771,7 +771,7 @@ async def chat_completion(
771771
response_format: ResponseFormat | NotGiven = NOT_GIVEN,
772772
sampling_params: SamplingParams | NotGiven = NOT_GIVEN,
773773
stream: Literal[False] | Literal[True] | NotGiven = NOT_GIVEN,
774-
tool_choice: Literal["auto", "required"] | NotGiven = NOT_GIVEN,
774+
tool_choice: Literal["auto", "required", "none"] | NotGiven = NOT_GIVEN,
775775
tool_config: inference_chat_completion_params.ToolConfig | NotGiven = NOT_GIVEN,
776776
tool_prompt_format: Literal["json", "function_tag", "python_list"] | NotGiven = NOT_GIVEN,
777777
tools: Iterable[inference_chat_completion_params.Tool] | NotGiven = NOT_GIVEN,

src/llama_stack_client/resources/telemetry.py

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -118,20 +118,20 @@ def get_span_tree(
118118
"""
119119
if not span_id:
120120
raise ValueError(f"Expected a non-empty value for `span_id` but received {span_id!r}")
121-
return self._get(
121+
return self._post(
122122
f"/v1/telemetry/spans/{span_id}/tree",
123+
body=maybe_transform(
124+
{
125+
"attributes_to_return": attributes_to_return,
126+
"max_depth": max_depth,
127+
},
128+
telemetry_get_span_tree_params.TelemetryGetSpanTreeParams,
129+
),
123130
options=make_request_options(
124131
extra_headers=extra_headers,
125132
extra_query=extra_query,
126133
extra_body=extra_body,
127134
timeout=timeout,
128-
query=maybe_transform(
129-
{
130-
"attributes_to_return": attributes_to_return,
131-
"max_depth": max_depth,
132-
},
133-
telemetry_get_span_tree_params.TelemetryGetSpanTreeParams,
134-
),
135135
post_parser=DataWrapper[TelemetryGetSpanTreeResponse]._unwrapper,
136136
),
137137
cast_to=cast(Type[TelemetryGetSpanTreeResponse], DataWrapper[TelemetryGetSpanTreeResponse]),
@@ -229,21 +229,21 @@ def query_spans(
229229
230230
timeout: Override the client-level default timeout for this request, in seconds
231231
"""
232-
return self._get(
232+
return self._post(
233233
"/v1/telemetry/spans",
234+
body=maybe_transform(
235+
{
236+
"attribute_filters": attribute_filters,
237+
"attributes_to_return": attributes_to_return,
238+
"max_depth": max_depth,
239+
},
240+
telemetry_query_spans_params.TelemetryQuerySpansParams,
241+
),
234242
options=make_request_options(
235243
extra_headers=extra_headers,
236244
extra_query=extra_query,
237245
extra_body=extra_body,
238246
timeout=timeout,
239-
query=maybe_transform(
240-
{
241-
"attribute_filters": attribute_filters,
242-
"attributes_to_return": attributes_to_return,
243-
"max_depth": max_depth,
244-
},
245-
telemetry_query_spans_params.TelemetryQuerySpansParams,
246-
),
247247
post_parser=DataWrapper[TelemetryQuerySpansResponse]._unwrapper,
248248
),
249249
cast_to=cast(Type[TelemetryQuerySpansResponse], DataWrapper[TelemetryQuerySpansResponse]),
@@ -273,22 +273,22 @@ def query_traces(
273273
274274
timeout: Override the client-level default timeout for this request, in seconds
275275
"""
276-
return self._get(
276+
return self._post(
277277
"/v1/telemetry/traces",
278+
body=maybe_transform(
279+
{
280+
"attribute_filters": attribute_filters,
281+
"limit": limit,
282+
"offset": offset,
283+
"order_by": order_by,
284+
},
285+
telemetry_query_traces_params.TelemetryQueryTracesParams,
286+
),
278287
options=make_request_options(
279288
extra_headers=extra_headers,
280289
extra_query=extra_query,
281290
extra_body=extra_body,
282291
timeout=timeout,
283-
query=maybe_transform(
284-
{
285-
"attribute_filters": attribute_filters,
286-
"limit": limit,
287-
"offset": offset,
288-
"order_by": order_by,
289-
},
290-
telemetry_query_traces_params.TelemetryQueryTracesParams,
291-
),
292292
post_parser=DataWrapper[TelemetryQueryTracesResponse]._unwrapper,
293293
),
294294
cast_to=cast(Type[TelemetryQueryTracesResponse], DataWrapper[TelemetryQueryTracesResponse]),
@@ -416,20 +416,20 @@ async def get_span_tree(
416416
"""
417417
if not span_id:
418418
raise ValueError(f"Expected a non-empty value for `span_id` but received {span_id!r}")
419-
return await self._get(
419+
return await self._post(
420420
f"/v1/telemetry/spans/{span_id}/tree",
421+
body=await async_maybe_transform(
422+
{
423+
"attributes_to_return": attributes_to_return,
424+
"max_depth": max_depth,
425+
},
426+
telemetry_get_span_tree_params.TelemetryGetSpanTreeParams,
427+
),
421428
options=make_request_options(
422429
extra_headers=extra_headers,
423430
extra_query=extra_query,
424431
extra_body=extra_body,
425432
timeout=timeout,
426-
query=await async_maybe_transform(
427-
{
428-
"attributes_to_return": attributes_to_return,
429-
"max_depth": max_depth,
430-
},
431-
telemetry_get_span_tree_params.TelemetryGetSpanTreeParams,
432-
),
433433
post_parser=DataWrapper[TelemetryGetSpanTreeResponse]._unwrapper,
434434
),
435435
cast_to=cast(Type[TelemetryGetSpanTreeResponse], DataWrapper[TelemetryGetSpanTreeResponse]),
@@ -527,21 +527,21 @@ async def query_spans(
527527
528528
timeout: Override the client-level default timeout for this request, in seconds
529529
"""
530-
return await self._get(
530+
return await self._post(
531531
"/v1/telemetry/spans",
532+
body=await async_maybe_transform(
533+
{
534+
"attribute_filters": attribute_filters,
535+
"attributes_to_return": attributes_to_return,
536+
"max_depth": max_depth,
537+
},
538+
telemetry_query_spans_params.TelemetryQuerySpansParams,
539+
),
532540
options=make_request_options(
533541
extra_headers=extra_headers,
534542
extra_query=extra_query,
535543
extra_body=extra_body,
536544
timeout=timeout,
537-
query=await async_maybe_transform(
538-
{
539-
"attribute_filters": attribute_filters,
540-
"attributes_to_return": attributes_to_return,
541-
"max_depth": max_depth,
542-
},
543-
telemetry_query_spans_params.TelemetryQuerySpansParams,
544-
),
545545
post_parser=DataWrapper[TelemetryQuerySpansResponse]._unwrapper,
546546
),
547547
cast_to=cast(Type[TelemetryQuerySpansResponse], DataWrapper[TelemetryQuerySpansResponse]),
@@ -571,22 +571,22 @@ async def query_traces(
571571
572572
timeout: Override the client-level default timeout for this request, in seconds
573573
"""
574-
return await self._get(
574+
return await self._post(
575575
"/v1/telemetry/traces",
576+
body=await async_maybe_transform(
577+
{
578+
"attribute_filters": attribute_filters,
579+
"limit": limit,
580+
"offset": offset,
581+
"order_by": order_by,
582+
},
583+
telemetry_query_traces_params.TelemetryQueryTracesParams,
584+
),
576585
options=make_request_options(
577586
extra_headers=extra_headers,
578587
extra_query=extra_query,
579588
extra_body=extra_body,
580589
timeout=timeout,
581-
query=await async_maybe_transform(
582-
{
583-
"attribute_filters": attribute_filters,
584-
"limit": limit,
585-
"offset": offset,
586-
"order_by": order_by,
587-
},
588-
telemetry_query_traces_params.TelemetryQueryTracesParams,
589-
),
590590
post_parser=DataWrapper[TelemetryQueryTracesResponse]._unwrapper,
591591
),
592592
cast_to=cast(Type[TelemetryQueryTracesResponse], DataWrapper[TelemetryQueryTracesResponse]),

src/llama_stack_client/types/agents/turn_create_params.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"DocumentContentURL",
2222
"ToolConfig",
2323
"Toolgroup",
24-
"ToolgroupUnionMember1",
24+
"ToolgroupAgentToolGroupWithArgs",
2525
"TurnCreateParamsNonStreaming",
2626
"TurnCreateParamsStreaming",
2727
]
@@ -95,7 +95,7 @@ class Document(TypedDict, total=False):
9595

9696

9797
class ToolConfig(TypedDict, total=False):
98-
system_message_behavior: Required[Literal["append", "replace"]]
98+
system_message_behavior: Literal["append", "replace"]
9999
"""(Optional) Config for how to override the default system prompt.
100100
101101
- `SystemMessageBehavior.append`: Appends the provided system message to the
@@ -105,10 +105,11 @@ class ToolConfig(TypedDict, total=False):
105105
definitions should be inserted.
106106
"""
107107

108-
tool_choice: Literal["auto", "required"]
109-
"""(Optional) Whether tool use is required or automatic.
108+
tool_choice: Union[Literal["auto", "required", "none"], str]
109+
"""(Optional) Whether tool use is automatic, required, or none.
110110
111-
Defaults to ToolChoice.auto.
111+
Can also specify a tool name to use a specific tool. Defaults to
112+
ToolChoice.auto.
112113
"""
113114

114115
tool_prompt_format: Literal["json", "function_tag", "python_list"]
@@ -122,13 +123,13 @@ class ToolConfig(TypedDict, total=False):
122123
"""
123124

124125

125-
class ToolgroupUnionMember1(TypedDict, total=False):
126+
class ToolgroupAgentToolGroupWithArgs(TypedDict, total=False):
126127
args: Required[Dict[str, Union[bool, float, str, Iterable[object], object, None]]]
127128

128129
name: Required[str]
129130

130131

131-
Toolgroup: TypeAlias = Union[str, ToolgroupUnionMember1]
132+
Toolgroup: TypeAlias = Union[str, ToolgroupAgentToolGroupWithArgs]
132133

133134

134135
class TurnCreateParamsNonStreaming(TurnCreateParamsBase, total=False):

src/llama_stack_client/types/batch_inference_chat_completion_params.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class BatchInferenceChatCompletionParams(TypedDict, total=False):
2525

2626
sampling_params: SamplingParams
2727

28-
tool_choice: Literal["auto", "required"]
28+
tool_choice: Literal["auto", "required", "none"]
2929
"""Whether tool use is required or automatic.
3030
3131
This is a hint to the model which may not be followed. It depends on the

src/llama_stack_client/types/inference_chat_completion_params.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class InferenceChatCompletionParamsBase(TypedDict, total=False):
4949
sampling_params: SamplingParams
5050
"""Parameters to control the sampling strategy"""
5151

52-
tool_choice: Literal["auto", "required"]
52+
tool_choice: Literal["auto", "required", "none"]
5353
"""(Optional) Whether tool use is required or automatic.
5454
5555
Defaults to ToolChoice.auto. .. deprecated:: Use tool_config instead.
@@ -79,7 +79,7 @@ class Logprobs(TypedDict, total=False):
7979

8080

8181
class ToolConfig(TypedDict, total=False):
82-
system_message_behavior: Required[Literal["append", "replace"]]
82+
system_message_behavior: Literal["append", "replace"]
8383
"""(Optional) Config for how to override the default system prompt.
8484
8585
- `SystemMessageBehavior.append`: Appends the provided system message to the
@@ -89,10 +89,11 @@ class ToolConfig(TypedDict, total=False):
8989
definitions should be inserted.
9090
"""
9191

92-
tool_choice: Literal["auto", "required"]
93-
"""(Optional) Whether tool use is required or automatic.
92+
tool_choice: Union[Literal["auto", "required", "none"], str]
93+
"""(Optional) Whether tool use is automatic, required, or none.
9494
95-
Defaults to ToolChoice.auto.
95+
Can also specify a tool name to use a specific tool. Defaults to
96+
ToolChoice.auto.
9697
"""
9798

9899
tool_prompt_format: Literal["json", "function_tag", "python_list"]

0 commit comments

Comments
 (0)