-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Add BatchRequestInput and BatchRequestOutput types (Issue #1937) #2865
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
Open
Sid-V5
wants to merge
7
commits into
openai:main
Choose a base branch
from
Sid-V5:fix-batch-types-1937
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
12b9135
Add BatchRequestInput type definition
Sid-V5 e602c32
Add BatchRequestOutput type definition
Sid-V5 6049c75
Export Batch request types in src/openai/types/__init__.py
Sid-V5 62495a7
Fix SyntaxError: remove escaped newline from types/__init__.py
Sid-V5 0dbfc0f
Merge branch 'main' into fix-batch-types-1937
Sid-V5 d036b44
fix: make body Required in BatchRequestInput
Sid-V5 84e0a58
Merge branch 'main' into fix-batch-types-1937
Sid-V5 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from typing import Optional | ||
| from typing_extensions import Literal, Required, TypedDict | ||
|
|
||
| __all__ = ["BatchRequestInput"] | ||
|
|
||
|
|
||
| class BatchRequestInput(TypedDict, total=False): | ||
| custom_id: Required[str] | ||
| """A developer-provided per-request id that will be used to match outputs to inputs. | ||
|
|
||
| Must be unique for each request in a batch. | ||
| """ | ||
|
|
||
| method: Required[Literal["POST"]] | ||
| """The HTTP method to be used for the request. Currently only `POST` is supported.""" | ||
|
|
||
| url: Required[str] | ||
| """The OpenAI API relative URL to be used for the request. | ||
|
|
||
| Currently `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are | ||
| supported. | ||
| """ | ||
|
|
||
| body: Optional[object] | ||
| """The body of the request.""" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| from typing import Optional | ||
|
|
||
| from .._models import BaseModel | ||
|
|
||
| __all__ = ["BatchRequestOutput", "BatchRequestOutputError", "BatchRequestOutputResponse"] | ||
|
|
||
|
|
||
| class BatchRequestOutputError(BaseModel): | ||
| code: Optional[str] = None | ||
| """A machine-readable error code.""" | ||
|
|
||
| message: Optional[str] = None | ||
| """A human-readable error message.""" | ||
|
|
||
|
|
||
| class BatchRequestOutputResponse(BaseModel): | ||
| status_code: int | ||
| """The HTTP status code of the response.""" | ||
|
|
||
| request_id: str | ||
| """An unique identifier for the request.""" | ||
|
|
||
| body: Optional[object] = None | ||
| """The JSON body of the response.""" | ||
|
|
||
|
|
||
| class BatchRequestOutput(BaseModel): | ||
| id: str | ||
| """The ID of the batch request.""" | ||
|
|
||
| custom_id: str | ||
| """A developer-provided per-request id that will be used to match outputs to inputs.""" | ||
|
|
||
| response: Optional[BatchRequestOutputResponse] = None | ||
|
|
||
| error: Optional[BatchRequestOutputError] = None |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.