Skip to content

Commit 0e68fd3

Browse files
feat(api): adding temperature parameter (#1282)
1 parent 340d139 commit 0e68fd3

File tree

11 files changed

+146
-18
lines changed

11 files changed

+146
-18
lines changed

Diff for: src/openai/resources/beta/threads/messages/messages.py

+16-6
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def create(
5252
thread_id: str,
5353
*,
5454
content: str,
55-
role: Literal["user"],
55+
role: Literal["user", "assistant"],
5656
file_ids: List[str] | NotGiven = NOT_GIVEN,
5757
metadata: Optional[object] | NotGiven = NOT_GIVEN,
5858
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -68,8 +68,13 @@ def create(
6868
Args:
6969
content: The content of the message.
7070
71-
role: The role of the entity that is creating the message. Currently only `user` is
72-
supported.
71+
role:
72+
The role of the entity that is creating the message. Allowed values include:
73+
74+
- `user`: Indicates the message is sent by an actual user and should be used in
75+
most cases to represent user-generated messages.
76+
- `assistant`: Indicates the message is generated by the assistant. Use this
77+
value to insert messages from the assistant into the conversation.
7378
7479
file_ids: A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that
7580
the message should use. There can be a maximum of 10 files attached to a
@@ -276,7 +281,7 @@ async def create(
276281
thread_id: str,
277282
*,
278283
content: str,
279-
role: Literal["user"],
284+
role: Literal["user", "assistant"],
280285
file_ids: List[str] | NotGiven = NOT_GIVEN,
281286
metadata: Optional[object] | NotGiven = NOT_GIVEN,
282287
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -292,8 +297,13 @@ async def create(
292297
Args:
293298
content: The content of the message.
294299
295-
role: The role of the entity that is creating the message. Currently only `user` is
296-
supported.
300+
role:
301+
The role of the entity that is creating the message. Allowed values include:
302+
303+
- `user`: Indicates the message is sent by an actual user and should be used in
304+
most cases to represent user-generated messages.
305+
- `assistant`: Indicates the message is generated by the assistant. Use this
306+
value to insert messages from the assistant into the conversation.
297307
298308
file_ids: A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that
299309
the message should use. There can be a maximum of 10 files attached to a

Diff for: src/openai/resources/beta/threads/runs/runs.py

+42
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def create(
7676
metadata: Optional[object] | NotGiven = NOT_GIVEN,
7777
model: Optional[str] | NotGiven = NOT_GIVEN,
7878
stream: Optional[Literal[False]] | NotGiven = NOT_GIVEN,
79+
temperature: Optional[float] | NotGiven = NOT_GIVEN,
7980
tools: Optional[Iterable[AssistantToolParam]] | NotGiven = NOT_GIVEN,
8081
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
8182
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -114,6 +115,10 @@ def create(
114115
events, terminating when the Run enters a terminal state with a `data: [DONE]`
115116
message.
116117
118+
temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
119+
make the output more random, while lower values like 0.2 will make it more
120+
focused and deterministic.
121+
117122
tools: Override the tools the assistant can use for this run. This is useful for
118123
modifying the behavior on a per-run basis.
119124
@@ -138,6 +143,7 @@ def create(
138143
instructions: Optional[str] | NotGiven = NOT_GIVEN,
139144
metadata: Optional[object] | NotGiven = NOT_GIVEN,
140145
model: Optional[str] | NotGiven = NOT_GIVEN,
146+
temperature: Optional[float] | NotGiven = NOT_GIVEN,
141147
tools: Optional[Iterable[AssistantToolParam]] | NotGiven = NOT_GIVEN,
142148
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
143149
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -176,6 +182,10 @@ def create(
176182
model associated with the assistant. If not, the model associated with the
177183
assistant will be used.
178184
185+
temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
186+
make the output more random, while lower values like 0.2 will make it more
187+
focused and deterministic.
188+
179189
tools: Override the tools the assistant can use for this run. This is useful for
180190
modifying the behavior on a per-run basis.
181191
@@ -200,6 +210,7 @@ def create(
200210
instructions: Optional[str] | NotGiven = NOT_GIVEN,
201211
metadata: Optional[object] | NotGiven = NOT_GIVEN,
202212
model: Optional[str] | NotGiven = NOT_GIVEN,
213+
temperature: Optional[float] | NotGiven = NOT_GIVEN,
203214
tools: Optional[Iterable[AssistantToolParam]] | NotGiven = NOT_GIVEN,
204215
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
205216
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -238,6 +249,10 @@ def create(
238249
model associated with the assistant. If not, the model associated with the
239250
assistant will be used.
240251
252+
temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
253+
make the output more random, while lower values like 0.2 will make it more
254+
focused and deterministic.
255+
241256
tools: Override the tools the assistant can use for this run. This is useful for
242257
modifying the behavior on a per-run basis.
243258
@@ -262,6 +277,7 @@ def create(
262277
metadata: Optional[object] | NotGiven = NOT_GIVEN,
263278
model: Optional[str] | NotGiven = NOT_GIVEN,
264279
stream: Optional[Literal[False]] | Literal[True] | NotGiven = NOT_GIVEN,
280+
temperature: Optional[float] | NotGiven = NOT_GIVEN,
265281
tools: Optional[Iterable[AssistantToolParam]] | NotGiven = NOT_GIVEN,
266282
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
267283
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -283,6 +299,7 @@ def create(
283299
"metadata": metadata,
284300
"model": model,
285301
"stream": stream,
302+
"temperature": temperature,
286303
"tools": tools,
287304
},
288305
run_create_params.RunCreateParams,
@@ -489,6 +506,7 @@ def create_and_stream(
489506
instructions: Optional[str] | NotGiven = NOT_GIVEN,
490507
metadata: Optional[object] | NotGiven = NOT_GIVEN,
491508
model: Optional[str] | NotGiven = NOT_GIVEN,
509+
temperature: Optional[float] | NotGiven = NOT_GIVEN,
492510
tools: Optional[Iterable[AssistantToolParam]] | NotGiven = NOT_GIVEN,
493511
thread_id: str,
494512
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -510,6 +528,7 @@ def create_and_stream(
510528
instructions: Optional[str] | NotGiven = NOT_GIVEN,
511529
metadata: Optional[object] | NotGiven = NOT_GIVEN,
512530
model: Optional[str] | NotGiven = NOT_GIVEN,
531+
temperature: Optional[float] | NotGiven = NOT_GIVEN,
513532
tools: Optional[Iterable[AssistantToolParam]] | NotGiven = NOT_GIVEN,
514533
thread_id: str,
515534
event_handler: AssistantEventHandlerT,
@@ -531,6 +550,7 @@ def create_and_stream(
531550
instructions: Optional[str] | NotGiven = NOT_GIVEN,
532551
metadata: Optional[object] | NotGiven = NOT_GIVEN,
533552
model: Optional[str] | NotGiven = NOT_GIVEN,
553+
temperature: Optional[float] | NotGiven = NOT_GIVEN,
534554
tools: Optional[Iterable[AssistantToolParam]] | NotGiven = NOT_GIVEN,
535555
thread_id: str,
536556
event_handler: AssistantEventHandlerT | None = None,
@@ -561,6 +581,7 @@ def create_and_stream(
561581
"instructions": instructions,
562582
"metadata": metadata,
563583
"model": model,
584+
"temperature": temperature,
564585
"stream": True,
565586
"tools": tools,
566587
},
@@ -841,6 +862,7 @@ async def create(
841862
metadata: Optional[object] | NotGiven = NOT_GIVEN,
842863
model: Optional[str] | NotGiven = NOT_GIVEN,
843864
stream: Optional[Literal[False]] | NotGiven = NOT_GIVEN,
865+
temperature: Optional[float] | NotGiven = NOT_GIVEN,
844866
tools: Optional[Iterable[AssistantToolParam]] | NotGiven = NOT_GIVEN,
845867
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
846868
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -879,6 +901,10 @@ async def create(
879901
events, terminating when the Run enters a terminal state with a `data: [DONE]`
880902
message.
881903
904+
temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
905+
make the output more random, while lower values like 0.2 will make it more
906+
focused and deterministic.
907+
882908
tools: Override the tools the assistant can use for this run. This is useful for
883909
modifying the behavior on a per-run basis.
884910
@@ -903,6 +929,7 @@ async def create(
903929
instructions: Optional[str] | NotGiven = NOT_GIVEN,
904930
metadata: Optional[object] | NotGiven = NOT_GIVEN,
905931
model: Optional[str] | NotGiven = NOT_GIVEN,
932+
temperature: Optional[float] | NotGiven = NOT_GIVEN,
906933
tools: Optional[Iterable[AssistantToolParam]] | NotGiven = NOT_GIVEN,
907934
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
908935
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -941,6 +968,10 @@ async def create(
941968
model associated with the assistant. If not, the model associated with the
942969
assistant will be used.
943970
971+
temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
972+
make the output more random, while lower values like 0.2 will make it more
973+
focused and deterministic.
974+
944975
tools: Override the tools the assistant can use for this run. This is useful for
945976
modifying the behavior on a per-run basis.
946977
@@ -965,6 +996,7 @@ async def create(
965996
instructions: Optional[str] | NotGiven = NOT_GIVEN,
966997
metadata: Optional[object] | NotGiven = NOT_GIVEN,
967998
model: Optional[str] | NotGiven = NOT_GIVEN,
999+
temperature: Optional[float] | NotGiven = NOT_GIVEN,
9681000
tools: Optional[Iterable[AssistantToolParam]] | NotGiven = NOT_GIVEN,
9691001
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
9701002
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -1003,6 +1035,10 @@ async def create(
10031035
model associated with the assistant. If not, the model associated with the
10041036
assistant will be used.
10051037
1038+
temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
1039+
make the output more random, while lower values like 0.2 will make it more
1040+
focused and deterministic.
1041+
10061042
tools: Override the tools the assistant can use for this run. This is useful for
10071043
modifying the behavior on a per-run basis.
10081044
@@ -1027,6 +1063,7 @@ async def create(
10271063
metadata: Optional[object] | NotGiven = NOT_GIVEN,
10281064
model: Optional[str] | NotGiven = NOT_GIVEN,
10291065
stream: Optional[Literal[False]] | Literal[True] | NotGiven = NOT_GIVEN,
1066+
temperature: Optional[float] | NotGiven = NOT_GIVEN,
10301067
tools: Optional[Iterable[AssistantToolParam]] | NotGiven = NOT_GIVEN,
10311068
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
10321069
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -1048,6 +1085,7 @@ async def create(
10481085
"metadata": metadata,
10491086
"model": model,
10501087
"stream": stream,
1088+
"temperature": temperature,
10511089
"tools": tools,
10521090
},
10531091
run_create_params.RunCreateParams,
@@ -1254,6 +1292,7 @@ def create_and_stream(
12541292
instructions: Optional[str] | NotGiven = NOT_GIVEN,
12551293
metadata: Optional[object] | NotGiven = NOT_GIVEN,
12561294
model: Optional[str] | NotGiven = NOT_GIVEN,
1295+
temperature: Optional[float] | NotGiven = NOT_GIVEN,
12571296
tools: Optional[Iterable[AssistantToolParam]] | NotGiven = NOT_GIVEN,
12581297
thread_id: str,
12591298
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -1275,6 +1314,7 @@ def create_and_stream(
12751314
instructions: Optional[str] | NotGiven = NOT_GIVEN,
12761315
metadata: Optional[object] | NotGiven = NOT_GIVEN,
12771316
model: Optional[str] | NotGiven = NOT_GIVEN,
1317+
temperature: Optional[float] | NotGiven = NOT_GIVEN,
12781318
tools: Optional[Iterable[AssistantToolParam]] | NotGiven = NOT_GIVEN,
12791319
thread_id: str,
12801320
event_handler: AsyncAssistantEventHandlerT,
@@ -1296,6 +1336,7 @@ def create_and_stream(
12961336
instructions: Optional[str] | NotGiven = NOT_GIVEN,
12971337
metadata: Optional[object] | NotGiven = NOT_GIVEN,
12981338
model: Optional[str] | NotGiven = NOT_GIVEN,
1339+
temperature: Optional[float] | NotGiven = NOT_GIVEN,
12991340
tools: Optional[Iterable[AssistantToolParam]] | NotGiven = NOT_GIVEN,
13001341
thread_id: str,
13011342
event_handler: AsyncAssistantEventHandlerT | None = None,
@@ -1328,6 +1369,7 @@ def create_and_stream(
13281369
"instructions": instructions,
13291370
"metadata": metadata,
13301371
"model": model,
1372+
"temperature": temperature,
13311373
"stream": True,
13321374
"tools": tools,
13331375
},

0 commit comments

Comments
 (0)