-
Notifications
You must be signed in to change notification settings - Fork 5.1k
fix(missing_documentation): Def parse in src/openai/resources/chat/completions/complet
#3636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -175,6 +175,91 @@ class MathResponse(BaseModel): | |
| print(message.parsed.steps) | ||
| print("answer: ", message.parsed.final_answer) | ||
| ``` | ||
|
|
||
| Args: | ||
| messages: A list of messages comprising the conversation so far. Depending on the | ||
| [model](https://platform.openai.com/docs/models) you use, different message | ||
| types (modalities) are supported, like text, images, and audio. | ||
|
|
||
| model: Model ID used to generate the response, like `gpt-4o` or `o3`. Refer to the | ||
| [model guide](https://platform.openai.com/docs/models) to browse available | ||
| models. | ||
|
|
||
| response_format: A Pydantic model class or other type that the response content should be | ||
| parsed into. When provided, the method automatically constructs the JSON schema | ||
| from the type and sends it to the API as a `json_schema` response format, then | ||
| deserialises the returned JSON into an instance of that type. Omit this | ||
| argument (or pass `openai.NOT_GIVEN`) to receive a plain | ||
| `ParsedChatCompletion` without automatic deserialisation. | ||
|
Comment on lines
+191
to
+193
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a typed caller follows this advice, Useful? React with 👍 / 👎. |
||
|
|
||
| tools: A list of tools the model may call. Pass tool schemas created with | ||
| `openai.pydantic_function_tool()` to enable automatic parsing of tool-call | ||
| arguments into the corresponding Pydantic model instances. | ||
|
Comment on lines
+195
to
+197
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a caller supplies a custom tool or an ordinary non-strict function tool, Useful? React with 👍 / 👎. |
||
|
|
||
| audio: Parameters for audio output. Required when audio output is requested with | ||
| `modalities: ["audio"]`. | ||
|
|
||
| frequency_penalty: Number between -2.0 and 2.0. Positive values penalize new tokens based on | ||
| their existing frequency in the text so far, decreasing the model's likelihood | ||
| to repeat the same line verbatim. | ||
|
|
||
| logit_bias: Modify the likelihood of specified tokens appearing in the completion. | ||
|
|
||
| logprobs: Whether to return log probabilities of the output tokens or not. | ||
|
|
||
| max_completion_tokens: An upper bound for the number of tokens that can be generated for a | ||
| completion, including visible output tokens and reasoning tokens. | ||
|
|
||
| max_tokens: The maximum number of tokens that can be generated in the chat completion. | ||
| Deprecated in favour of `max_completion_tokens`. | ||
|
Comment on lines
+213
to
+214
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a caller uses an o-series model such as the documented Useful? React with 👍 / 👎. |
||
|
|
||
| n: How many chat completion choices to generate for each input message. Note that | ||
| you will be charged based on the number of generated tokens across all of the | ||
| choices. Keep `n` as `1` to minimise costs. | ||
|
|
||
| parallel_tool_calls: Whether to enable parallel function calling during tool use. | ||
|
|
||
| presence_penalty: Number between -2.0 and 2.0. Positive values penalize new tokens based on | ||
| whether they appear in the text so far, increasing the model's likelihood to | ||
| talk about new topics. | ||
|
|
||
| reasoning_effort: Constrains effort on reasoning for reasoning models. Supported values are | ||
| `low`, `medium`, and `high`. | ||
|
Comment on lines
+226
to
+227
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When users need the newer reasoning modes, this incorrectly limits the supported values to Useful? React with 👍 / 👎. |
||
|
|
||
| seed: If specified, the system will make a best effort to sample deterministically. | ||
|
|
||
| service_tier: Specifies the processing type used for serving the request. | ||
|
|
||
| stop: Up to 4 sequences where the API will stop generating further tokens. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎. |
||
|
|
||
| store: Whether to store the output of this chat completion request for use in model | ||
| distillation or evals products. | ||
|
|
||
| temperature: Sampling temperature between 0 and 2. | ||
|
|
||
| tool_choice: Controls which (if any) tool is called by the model. | ||
|
|
||
| top_logprobs: An integer between 0 and 20 specifying the number of most likely tokens to | ||
| return at each token position. `logprobs` must be `true` when used. | ||
|
Comment on lines
+242
to
+243
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When consumers use this value to size or index the returned alternatives, the API may return fewer entries than requested. The canonical endpoint documentation defines Useful? React with 👍 / 👎. |
||
|
|
||
| top_p: Nucleus sampling probability mass. | ||
|
|
||
| user: A stable identifier for your end-users. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a new caller uses Useful? React with 👍 / 👎. |
||
|
|
||
| extra_headers: Send extra headers | ||
|
|
||
| extra_query: Add additional query parameters to the request | ||
|
|
||
| extra_body: Add additional JSON properties to the request | ||
|
|
||
| timeout: Override the client-level default timeout for this request, in seconds | ||
|
|
||
| Returns: | ||
| A `ParsedChatCompletion[ResponseFormatT]` object. When `response_format` is | ||
| provided the `.choices[i].message.parsed` attribute contains the deserialised | ||
| response as an instance of `ResponseFormatT`. Tool calls made with | ||
|
Comment on lines
+258
to
+260
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When the model refuses the request or returns no content, Useful? React with 👍 / 👎. |
||
| `pydantic_function_tool()` will have their `.function.parsed_arguments` | ||
| attribute populated with the corresponding Pydantic model instance. | ||
| """ | ||
| chat_completion_tools = _validate_input_tools(tools) | ||
|
|
||
|
|
@@ -1786,6 +1871,91 @@ class MathResponse(BaseModel): | |
| print(message.parsed.steps) | ||
| print("answer: ", message.parsed.final_answer) | ||
| ``` | ||
|
|
||
| Args: | ||
| messages: A list of messages comprising the conversation so far. Depending on the | ||
| [model](https://platform.openai.com/docs/models) you use, different message | ||
| types (modalities) are supported, like text, images, and audio. | ||
|
|
||
| model: Model ID used to generate the response, like `gpt-4o` or `o3`. Refer to the | ||
| [model guide](https://platform.openai.com/docs/models) to browse available | ||
| models. | ||
|
|
||
| response_format: A Pydantic model class or other type that the response content should be | ||
| parsed into. When provided, the method automatically constructs the JSON schema | ||
| from the type and sends it to the API as a `json_schema` response format, then | ||
| deserialises the returned JSON into an instance of that type. Omit this | ||
| argument (or pass `openai.NOT_GIVEN`) to receive a plain | ||
| `ParsedChatCompletion` without automatic deserialisation. | ||
|
|
||
| tools: A list of tools the model may call. Pass tool schemas created with | ||
| `openai.pydantic_function_tool()` to enable automatic parsing of tool-call | ||
| arguments into the corresponding Pydantic model instances. | ||
|
|
||
| audio: Parameters for audio output. Required when audio output is requested with | ||
| `modalities: ["audio"]`. | ||
|
|
||
| frequency_penalty: Number between -2.0 and 2.0. Positive values penalize new tokens based on | ||
| their existing frequency in the text so far, decreasing the model's likelihood | ||
| to repeat the same line verbatim. | ||
|
|
||
| logit_bias: Modify the likelihood of specified tokens appearing in the completion. | ||
|
|
||
| logprobs: Whether to return log probabilities of the output tokens or not. | ||
|
|
||
| max_completion_tokens: An upper bound for the number of tokens that can be generated for a | ||
| completion, including visible output tokens and reasoning tokens. | ||
|
|
||
| max_tokens: The maximum number of tokens that can be generated in the chat completion. | ||
| Deprecated in favour of `max_completion_tokens`. | ||
|
|
||
| n: How many chat completion choices to generate for each input message. Note that | ||
| you will be charged based on the number of generated tokens across all of the | ||
| choices. Keep `n` as `1` to minimise costs. | ||
|
|
||
| parallel_tool_calls: Whether to enable parallel function calling during tool use. | ||
|
|
||
| presence_penalty: Number between -2.0 and 2.0. Positive values penalize new tokens based on | ||
| whether they appear in the text so far, increasing the model's likelihood to | ||
| talk about new topics. | ||
|
|
||
| reasoning_effort: Constrains effort on reasoning for reasoning models. Supported values are | ||
| `low`, `medium`, and `high`. | ||
|
|
||
| seed: If specified, the system will make a best effort to sample deterministically. | ||
|
|
||
| service_tier: Specifies the processing type used for serving the request. | ||
|
|
||
| stop: Up to 4 sequences where the API will stop generating further tokens. | ||
|
|
||
| store: Whether to store the output of this chat completion request for use in model | ||
| distillation or evals products. | ||
|
|
||
| temperature: Sampling temperature between 0 and 2. | ||
|
|
||
| tool_choice: Controls which (if any) tool is called by the model. | ||
|
|
||
| top_logprobs: An integer between 0 and 20 specifying the number of most likely tokens to | ||
| return at each token position. `logprobs` must be `true` when used. | ||
|
|
||
| top_p: Nucleus sampling probability mass. | ||
|
|
||
| user: A stable identifier for your end-users. | ||
|
|
||
| extra_headers: Send extra headers | ||
|
|
||
| extra_query: Add additional query parameters to the request | ||
|
|
||
| extra_body: Add additional JSON properties to the request | ||
|
|
||
| timeout: Override the client-level default timeout for this request, in seconds | ||
|
|
||
| Returns: | ||
| A `ParsedChatCompletion[ResponseFormatT]` object. When `response_format` is | ||
| provided the `.choices[i].message.parsed` attribute contains the deserialised | ||
| response as an instance of `ResponseFormatT`. Tool calls made with | ||
| `pydantic_function_tool()` will have their `.function.parsed_arguments` | ||
| attribute populated with the corresponding Pydantic model instance. | ||
| """ | ||
| _validate_input_tools(tools) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a caller interprets “other type” as an ordinary class or
TypedDict,_type_to_response_format()raisesTypeErrorbefore sending the request; it accepts onlypydantic.BaseModelsubclasses and Pydantic dataclass-like types, with the latter requiring Pydantic v2. Name those supported alternatives instead of implying that an arbitrary type can be parsed.Useful? React with 👍 / 👎.