Skip to content

Commit

Permalink
feat(api): adding temperature parameter (#1282)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot authored Mar 29, 2024
1 parent 340d139 commit 0e68fd3
Show file tree
Hide file tree
Showing 11 changed files with 146 additions and 18 deletions.
22 changes: 16 additions & 6 deletions src/openai/resources/beta/threads/messages/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def create(
thread_id: str,
*,
content: str,
role: Literal["user"],
role: Literal["user", "assistant"],
file_ids: List[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
Expand All @@ -68,8 +68,13 @@ def create(
Args:
content: The content of the message.
role: The role of the entity that is creating the message. Currently only `user` is
supported.
role:
The role of the entity that is creating the message. Allowed values include:
- `user`: Indicates the message is sent by an actual user and should be used in
most cases to represent user-generated messages.
- `assistant`: Indicates the message is generated by the assistant. Use this
value to insert messages from the assistant into the conversation.
file_ids: A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that
the message should use. There can be a maximum of 10 files attached to a
Expand Down Expand Up @@ -276,7 +281,7 @@ async def create(
thread_id: str,
*,
content: str,
role: Literal["user"],
role: Literal["user", "assistant"],
file_ids: List[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
Expand All @@ -292,8 +297,13 @@ async def create(
Args:
content: The content of the message.
role: The role of the entity that is creating the message. Currently only `user` is
supported.
role:
The role of the entity that is creating the message. Allowed values include:
- `user`: Indicates the message is sent by an actual user and should be used in
most cases to represent user-generated messages.
- `assistant`: Indicates the message is generated by the assistant. Use this
value to insert messages from the assistant into the conversation.
file_ids: A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that
the message should use. There can be a maximum of 10 files attached to a
Expand Down
42 changes: 42 additions & 0 deletions src/openai/resources/beta/threads/runs/runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def create(
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
stream: Optional[Literal[False]] | NotGiven = NOT_GIVEN,
temperature: Optional[float] | NotGiven = NOT_GIVEN,
tools: Optional[Iterable[AssistantToolParam]] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand Down Expand Up @@ -114,6 +115,10 @@ def create(
events, terminating when the Run enters a terminal state with a `data: [DONE]`
message.
temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
make the output more random, while lower values like 0.2 will make it more
focused and deterministic.
tools: Override the tools the assistant can use for this run. This is useful for
modifying the behavior on a per-run basis.
Expand All @@ -138,6 +143,7 @@ def create(
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
temperature: Optional[float] | NotGiven = NOT_GIVEN,
tools: Optional[Iterable[AssistantToolParam]] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand Down Expand Up @@ -176,6 +182,10 @@ def create(
model associated with the assistant. If not, the model associated with the
assistant will be used.
temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
make the output more random, while lower values like 0.2 will make it more
focused and deterministic.
tools: Override the tools the assistant can use for this run. This is useful for
modifying the behavior on a per-run basis.
Expand All @@ -200,6 +210,7 @@ def create(
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
temperature: Optional[float] | NotGiven = NOT_GIVEN,
tools: Optional[Iterable[AssistantToolParam]] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand Down Expand Up @@ -238,6 +249,10 @@ def create(
model associated with the assistant. If not, the model associated with the
assistant will be used.
temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
make the output more random, while lower values like 0.2 will make it more
focused and deterministic.
tools: Override the tools the assistant can use for this run. This is useful for
modifying the behavior on a per-run basis.
Expand All @@ -262,6 +277,7 @@ def create(
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
stream: Optional[Literal[False]] | Literal[True] | NotGiven = NOT_GIVEN,
temperature: Optional[float] | NotGiven = NOT_GIVEN,
tools: Optional[Iterable[AssistantToolParam]] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand All @@ -283,6 +299,7 @@ def create(
"metadata": metadata,
"model": model,
"stream": stream,
"temperature": temperature,
"tools": tools,
},
run_create_params.RunCreateParams,
Expand Down Expand Up @@ -489,6 +506,7 @@ def create_and_stream(
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
temperature: Optional[float] | NotGiven = NOT_GIVEN,
tools: Optional[Iterable[AssistantToolParam]] | NotGiven = NOT_GIVEN,
thread_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
Expand All @@ -510,6 +528,7 @@ def create_and_stream(
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
temperature: Optional[float] | NotGiven = NOT_GIVEN,
tools: Optional[Iterable[AssistantToolParam]] | NotGiven = NOT_GIVEN,
thread_id: str,
event_handler: AssistantEventHandlerT,
Expand All @@ -531,6 +550,7 @@ def create_and_stream(
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
temperature: Optional[float] | NotGiven = NOT_GIVEN,
tools: Optional[Iterable[AssistantToolParam]] | NotGiven = NOT_GIVEN,
thread_id: str,
event_handler: AssistantEventHandlerT | None = None,
Expand Down Expand Up @@ -561,6 +581,7 @@ def create_and_stream(
"instructions": instructions,
"metadata": metadata,
"model": model,
"temperature": temperature,
"stream": True,
"tools": tools,
},
Expand Down Expand Up @@ -841,6 +862,7 @@ async def create(
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
stream: Optional[Literal[False]] | NotGiven = NOT_GIVEN,
temperature: Optional[float] | NotGiven = NOT_GIVEN,
tools: Optional[Iterable[AssistantToolParam]] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand Down Expand Up @@ -879,6 +901,10 @@ async def create(
events, terminating when the Run enters a terminal state with a `data: [DONE]`
message.
temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
make the output more random, while lower values like 0.2 will make it more
focused and deterministic.
tools: Override the tools the assistant can use for this run. This is useful for
modifying the behavior on a per-run basis.
Expand All @@ -903,6 +929,7 @@ async def create(
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
temperature: Optional[float] | NotGiven = NOT_GIVEN,
tools: Optional[Iterable[AssistantToolParam]] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand Down Expand Up @@ -941,6 +968,10 @@ async def create(
model associated with the assistant. If not, the model associated with the
assistant will be used.
temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
make the output more random, while lower values like 0.2 will make it more
focused and deterministic.
tools: Override the tools the assistant can use for this run. This is useful for
modifying the behavior on a per-run basis.
Expand All @@ -965,6 +996,7 @@ async def create(
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
temperature: Optional[float] | NotGiven = NOT_GIVEN,
tools: Optional[Iterable[AssistantToolParam]] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand Down Expand Up @@ -1003,6 +1035,10 @@ async def create(
model associated with the assistant. If not, the model associated with the
assistant will be used.
temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
make the output more random, while lower values like 0.2 will make it more
focused and deterministic.
tools: Override the tools the assistant can use for this run. This is useful for
modifying the behavior on a per-run basis.
Expand All @@ -1027,6 +1063,7 @@ async def create(
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
stream: Optional[Literal[False]] | Literal[True] | NotGiven = NOT_GIVEN,
temperature: Optional[float] | NotGiven = NOT_GIVEN,
tools: Optional[Iterable[AssistantToolParam]] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand All @@ -1048,6 +1085,7 @@ async def create(
"metadata": metadata,
"model": model,
"stream": stream,
"temperature": temperature,
"tools": tools,
},
run_create_params.RunCreateParams,
Expand Down Expand Up @@ -1254,6 +1292,7 @@ def create_and_stream(
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
temperature: Optional[float] | NotGiven = NOT_GIVEN,
tools: Optional[Iterable[AssistantToolParam]] | NotGiven = NOT_GIVEN,
thread_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
Expand All @@ -1275,6 +1314,7 @@ def create_and_stream(
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
temperature: Optional[float] | NotGiven = NOT_GIVEN,
tools: Optional[Iterable[AssistantToolParam]] | NotGiven = NOT_GIVEN,
thread_id: str,
event_handler: AsyncAssistantEventHandlerT,
Expand All @@ -1296,6 +1336,7 @@ def create_and_stream(
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
temperature: Optional[float] | NotGiven = NOT_GIVEN,
tools: Optional[Iterable[AssistantToolParam]] | NotGiven = NOT_GIVEN,
thread_id: str,
event_handler: AsyncAssistantEventHandlerT | None = None,
Expand Down Expand Up @@ -1328,6 +1369,7 @@ def create_and_stream(
"instructions": instructions,
"metadata": metadata,
"model": model,
"temperature": temperature,
"stream": True,
"tools": tools,
},
Expand Down
Loading

0 comments on commit 0e68fd3

Please sign in to comment.