Skip to content

Commit 23e3b9f

Browse files
feat: add top_p parameter support to responses API
1 parent 6bc2bb4 commit 23e3b9f

4 files changed

Lines changed: 40 additions & 2 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 108
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-621e8b8ef37d5ebf024fe3bf6a59486a90debf01acca2c9bb4e9032e2dff92d3.yml
3-
openapi_spec_hash: 51f623cd3ea4addf8f939dd4ef8962c8
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-41c9203afe93dd495edeaad0f9494065f2ae7de5d7148207531eeddf9ed4f11e.yml
3+
openapi_spec_hash: c47e69115bbf13bdde86a076088fdad9
44
config_hash: 6aa61d4143c3e3df785972c0287d1370

src/llama_stack_client/resources/responses/responses.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ def create(
113113
text: Optional[response_create_params.Text] | Omit = omit,
114114
tool_choice: Optional[response_create_params.ToolChoice] | Omit = omit,
115115
tools: Optional[Iterable[response_create_params.Tool]] | Omit = omit,
116+
top_p: Optional[float] | Omit = omit,
116117
truncation: Optional[Literal["auto", "disabled"]] | Omit = omit,
117118
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
118119
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -176,6 +177,9 @@ def create(
176177
177178
tools: List of tools available to the model.
178179
180+
top_p: Nucleus sampling parameter that controls response diversity (lower values
181+
increase focus).
182+
179183
truncation: Controls how the service truncates input when it exceeds the model context
180184
window.
181185
@@ -235,6 +239,7 @@ def create(
235239
text: Optional[response_create_params.Text] | Omit = omit,
236240
tool_choice: Optional[response_create_params.ToolChoice] | Omit = omit,
237241
tools: Optional[Iterable[response_create_params.Tool]] | Omit = omit,
242+
top_p: Optional[float] | Omit = omit,
238243
truncation: Optional[Literal["auto", "disabled"]] | Omit = omit,
239244
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
240245
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -298,6 +303,9 @@ def create(
298303
299304
tools: List of tools available to the model.
300305
306+
top_p: Nucleus sampling parameter that controls response diversity (lower values
307+
increase focus).
308+
301309
truncation: Controls how the service truncates input when it exceeds the model context
302310
window.
303311
@@ -357,6 +365,7 @@ def create(
357365
text: Optional[response_create_params.Text] | Omit = omit,
358366
tool_choice: Optional[response_create_params.ToolChoice] | Omit = omit,
359367
tools: Optional[Iterable[response_create_params.Tool]] | Omit = omit,
368+
top_p: Optional[float] | Omit = omit,
360369
truncation: Optional[Literal["auto", "disabled"]] | Omit = omit,
361370
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
362371
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -420,6 +429,9 @@ def create(
420429
421430
tools: List of tools available to the model.
422431
432+
top_p: Nucleus sampling parameter that controls response diversity (lower values
433+
increase focus).
434+
423435
truncation: Controls how the service truncates input when it exceeds the model context
424436
window.
425437
@@ -479,6 +491,7 @@ def create(
479491
text: Optional[response_create_params.Text] | Omit = omit,
480492
tool_choice: Optional[response_create_params.ToolChoice] | Omit = omit,
481493
tools: Optional[Iterable[response_create_params.Tool]] | Omit = omit,
494+
top_p: Optional[float] | Omit = omit,
482495
truncation: Optional[Literal["auto", "disabled"]] | Omit = omit,
483496
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
484497
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -515,6 +528,7 @@ def create(
515528
"text": text,
516529
"tool_choice": tool_choice,
517530
"tools": tools,
531+
"top_p": top_p,
518532
"truncation": truncation,
519533
},
520534
response_create_params.ResponseCreateParamsStreaming
@@ -725,6 +739,7 @@ async def create(
725739
text: Optional[response_create_params.Text] | Omit = omit,
726740
tool_choice: Optional[response_create_params.ToolChoice] | Omit = omit,
727741
tools: Optional[Iterable[response_create_params.Tool]] | Omit = omit,
742+
top_p: Optional[float] | Omit = omit,
728743
truncation: Optional[Literal["auto", "disabled"]] | Omit = omit,
729744
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
730745
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -788,6 +803,9 @@ async def create(
788803
789804
tools: List of tools available to the model.
790805
806+
top_p: Nucleus sampling parameter that controls response diversity (lower values
807+
increase focus).
808+
791809
truncation: Controls how the service truncates input when it exceeds the model context
792810
window.
793811
@@ -847,6 +865,7 @@ async def create(
847865
text: Optional[response_create_params.Text] | Omit = omit,
848866
tool_choice: Optional[response_create_params.ToolChoice] | Omit = omit,
849867
tools: Optional[Iterable[response_create_params.Tool]] | Omit = omit,
868+
top_p: Optional[float] | Omit = omit,
850869
truncation: Optional[Literal["auto", "disabled"]] | Omit = omit,
851870
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
852871
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -910,6 +929,9 @@ async def create(
910929
911930
tools: List of tools available to the model.
912931
932+
top_p: Nucleus sampling parameter that controls response diversity (lower values
933+
increase focus).
934+
913935
truncation: Controls how the service truncates input when it exceeds the model context
914936
window.
915937
@@ -969,6 +991,7 @@ async def create(
969991
text: Optional[response_create_params.Text] | Omit = omit,
970992
tool_choice: Optional[response_create_params.ToolChoice] | Omit = omit,
971993
tools: Optional[Iterable[response_create_params.Tool]] | Omit = omit,
994+
top_p: Optional[float] | Omit = omit,
972995
truncation: Optional[Literal["auto", "disabled"]] | Omit = omit,
973996
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
974997
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -1032,6 +1055,9 @@ async def create(
10321055
10331056
tools: List of tools available to the model.
10341057
1058+
top_p: Nucleus sampling parameter that controls response diversity (lower values
1059+
increase focus).
1060+
10351061
truncation: Controls how the service truncates input when it exceeds the model context
10361062
window.
10371063
@@ -1091,6 +1117,7 @@ async def create(
10911117
text: Optional[response_create_params.Text] | Omit = omit,
10921118
tool_choice: Optional[response_create_params.ToolChoice] | Omit = omit,
10931119
tools: Optional[Iterable[response_create_params.Tool]] | Omit = omit,
1120+
top_p: Optional[float] | Omit = omit,
10941121
truncation: Optional[Literal["auto", "disabled"]] | Omit = omit,
10951122
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
10961123
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -1127,6 +1154,7 @@ async def create(
11271154
"text": text,
11281155
"tool_choice": tool_choice,
11291156
"tools": tools,
1157+
"top_p": top_p,
11301158
"truncation": truncation,
11311159
},
11321160
response_create_params.ResponseCreateParamsStreaming

src/llama_stack_client/types/response_create_params.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@ class ResponseCreateParamsBase(TypedDict, total=False):
170170
tools: Optional[Iterable[Tool]]
171171
"""List of tools available to the model."""
172172

173+
top_p: Optional[float]
174+
"""
175+
Nucleus sampling parameter that controls response diversity (lower values
176+
increase focus).
177+
"""
178+
173179
truncation: Optional[Literal["auto", "disabled"]]
174180
"""
175181
Controls how the service truncates input when it exceeds the model context

tests/api_resources/test_responses.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ def test_method_create_with_all_params_overload_1(self, client: LlamaStackClient
8585
"type": "web_search",
8686
}
8787
],
88+
top_p=0,
8889
truncation="auto",
8990
)
9091
assert_matches_type(ResponseObject, response, path=["response"])
@@ -173,6 +174,7 @@ def test_method_create_with_all_params_overload_2(self, client: LlamaStackClient
173174
"type": "web_search",
174175
}
175176
],
177+
top_p=0,
176178
truncation="auto",
177179
)
178180
response_stream.response.close()
@@ -378,6 +380,7 @@ async def test_method_create_with_all_params_overload_1(self, async_client: Asyn
378380
"type": "web_search",
379381
}
380382
],
383+
top_p=0,
381384
truncation="auto",
382385
)
383386
assert_matches_type(ResponseObject, response, path=["response"])
@@ -466,6 +469,7 @@ async def test_method_create_with_all_params_overload_2(self, async_client: Asyn
466469
"type": "web_search",
467470
}
468471
],
472+
top_p=0,
469473
truncation="auto",
470474
)
471475
await response_stream.response.aclose()

0 commit comments

Comments
 (0)