Make SubFox production-ready with parallel translation and UI controls
This commit is contained in:
parent
c40b8bed2b
commit
2b1d05f02c
6046 changed files with 798327 additions and 0 deletions
|
|
@ -0,0 +1,47 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from .responses import (
|
||||
Responses,
|
||||
AsyncResponses,
|
||||
ResponsesWithRawResponse,
|
||||
AsyncResponsesWithRawResponse,
|
||||
ResponsesWithStreamingResponse,
|
||||
AsyncResponsesWithStreamingResponse,
|
||||
)
|
||||
from .input_items import (
|
||||
InputItems,
|
||||
AsyncInputItems,
|
||||
InputItemsWithRawResponse,
|
||||
AsyncInputItemsWithRawResponse,
|
||||
InputItemsWithStreamingResponse,
|
||||
AsyncInputItemsWithStreamingResponse,
|
||||
)
|
||||
from .input_tokens import (
|
||||
InputTokens,
|
||||
AsyncInputTokens,
|
||||
InputTokensWithRawResponse,
|
||||
AsyncInputTokensWithRawResponse,
|
||||
InputTokensWithStreamingResponse,
|
||||
AsyncInputTokensWithStreamingResponse,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"InputItems",
|
||||
"AsyncInputItems",
|
||||
"InputItemsWithRawResponse",
|
||||
"AsyncInputItemsWithRawResponse",
|
||||
"InputItemsWithStreamingResponse",
|
||||
"AsyncInputItemsWithStreamingResponse",
|
||||
"InputTokens",
|
||||
"AsyncInputTokens",
|
||||
"InputTokensWithRawResponse",
|
||||
"AsyncInputTokensWithRawResponse",
|
||||
"InputTokensWithStreamingResponse",
|
||||
"AsyncInputTokensWithStreamingResponse",
|
||||
"Responses",
|
||||
"AsyncResponses",
|
||||
"ResponsesWithRawResponse",
|
||||
"AsyncResponsesWithRawResponse",
|
||||
"ResponsesWithStreamingResponse",
|
||||
"AsyncResponsesWithStreamingResponse",
|
||||
]
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,185 @@
|
|||
# Responses
|
||||
|
||||
Types:
|
||||
|
||||
```python
|
||||
from openai.types.responses import (
|
||||
ApplyPatchTool,
|
||||
CompactedResponse,
|
||||
ComputerAction,
|
||||
ComputerActionList,
|
||||
ComputerTool,
|
||||
ComputerUsePreviewTool,
|
||||
ContainerAuto,
|
||||
ContainerNetworkPolicyAllowlist,
|
||||
ContainerNetworkPolicyDisabled,
|
||||
ContainerNetworkPolicyDomainSecret,
|
||||
ContainerReference,
|
||||
CustomTool,
|
||||
EasyInputMessage,
|
||||
FileSearchTool,
|
||||
FunctionShellTool,
|
||||
FunctionTool,
|
||||
InlineSkill,
|
||||
InlineSkillSource,
|
||||
LocalEnvironment,
|
||||
LocalSkill,
|
||||
NamespaceTool,
|
||||
Response,
|
||||
ResponseApplyPatchToolCall,
|
||||
ResponseApplyPatchToolCallOutput,
|
||||
ResponseAudioDeltaEvent,
|
||||
ResponseAudioDoneEvent,
|
||||
ResponseAudioTranscriptDeltaEvent,
|
||||
ResponseAudioTranscriptDoneEvent,
|
||||
ResponseCodeInterpreterCallCodeDeltaEvent,
|
||||
ResponseCodeInterpreterCallCodeDoneEvent,
|
||||
ResponseCodeInterpreterCallCompletedEvent,
|
||||
ResponseCodeInterpreterCallInProgressEvent,
|
||||
ResponseCodeInterpreterCallInterpretingEvent,
|
||||
ResponseCodeInterpreterToolCall,
|
||||
ResponseCompactionItem,
|
||||
ResponseCompactionItemParam,
|
||||
ResponseCompletedEvent,
|
||||
ResponseComputerToolCall,
|
||||
ResponseComputerToolCallOutputItem,
|
||||
ResponseComputerToolCallOutputScreenshot,
|
||||
ResponseContainerReference,
|
||||
ResponseContent,
|
||||
ResponseContentPartAddedEvent,
|
||||
ResponseContentPartDoneEvent,
|
||||
ResponseConversationParam,
|
||||
ResponseCreatedEvent,
|
||||
ResponseCustomToolCall,
|
||||
ResponseCustomToolCallInputDeltaEvent,
|
||||
ResponseCustomToolCallInputDoneEvent,
|
||||
ResponseCustomToolCallOutput,
|
||||
ResponseError,
|
||||
ResponseErrorEvent,
|
||||
ResponseFailedEvent,
|
||||
ResponseFileSearchCallCompletedEvent,
|
||||
ResponseFileSearchCallInProgressEvent,
|
||||
ResponseFileSearchCallSearchingEvent,
|
||||
ResponseFileSearchToolCall,
|
||||
ResponseFormatTextConfig,
|
||||
ResponseFormatTextJSONSchemaConfig,
|
||||
ResponseFunctionCallArgumentsDeltaEvent,
|
||||
ResponseFunctionCallArgumentsDoneEvent,
|
||||
ResponseFunctionCallOutputItem,
|
||||
ResponseFunctionCallOutputItemList,
|
||||
ResponseFunctionShellCallOutputContent,
|
||||
ResponseFunctionShellToolCall,
|
||||
ResponseFunctionShellToolCallOutput,
|
||||
ResponseFunctionToolCall,
|
||||
ResponseFunctionToolCallItem,
|
||||
ResponseFunctionToolCallOutputItem,
|
||||
ResponseFunctionWebSearch,
|
||||
ResponseImageGenCallCompletedEvent,
|
||||
ResponseImageGenCallGeneratingEvent,
|
||||
ResponseImageGenCallInProgressEvent,
|
||||
ResponseImageGenCallPartialImageEvent,
|
||||
ResponseInProgressEvent,
|
||||
ResponseIncludable,
|
||||
ResponseIncompleteEvent,
|
||||
ResponseInput,
|
||||
ResponseInputAudio,
|
||||
ResponseInputContent,
|
||||
ResponseInputFile,
|
||||
ResponseInputFileContent,
|
||||
ResponseInputImage,
|
||||
ResponseInputImageContent,
|
||||
ResponseInputItem,
|
||||
ResponseInputMessageContentList,
|
||||
ResponseInputMessageItem,
|
||||
ResponseInputText,
|
||||
ResponseInputTextContent,
|
||||
ResponseItem,
|
||||
ResponseLocalEnvironment,
|
||||
ResponseMcpCallArgumentsDeltaEvent,
|
||||
ResponseMcpCallArgumentsDoneEvent,
|
||||
ResponseMcpCallCompletedEvent,
|
||||
ResponseMcpCallFailedEvent,
|
||||
ResponseMcpCallInProgressEvent,
|
||||
ResponseMcpListToolsCompletedEvent,
|
||||
ResponseMcpListToolsFailedEvent,
|
||||
ResponseMcpListToolsInProgressEvent,
|
||||
ResponseOutputAudio,
|
||||
ResponseOutputItem,
|
||||
ResponseOutputItemAddedEvent,
|
||||
ResponseOutputItemDoneEvent,
|
||||
ResponseOutputMessage,
|
||||
ResponseOutputRefusal,
|
||||
ResponseOutputText,
|
||||
ResponseOutputTextAnnotationAddedEvent,
|
||||
ResponsePrompt,
|
||||
ResponseQueuedEvent,
|
||||
ResponseReasoningItem,
|
||||
ResponseReasoningSummaryPartAddedEvent,
|
||||
ResponseReasoningSummaryPartDoneEvent,
|
||||
ResponseReasoningSummaryTextDeltaEvent,
|
||||
ResponseReasoningSummaryTextDoneEvent,
|
||||
ResponseReasoningTextDeltaEvent,
|
||||
ResponseReasoningTextDoneEvent,
|
||||
ResponseRefusalDeltaEvent,
|
||||
ResponseRefusalDoneEvent,
|
||||
ResponseStatus,
|
||||
ResponseStreamEvent,
|
||||
ResponseTextConfig,
|
||||
ResponseTextDeltaEvent,
|
||||
ResponseTextDoneEvent,
|
||||
ResponseToolSearchCall,
|
||||
ResponseToolSearchOutputItem,
|
||||
ResponseToolSearchOutputItemParam,
|
||||
ResponseUsage,
|
||||
ResponseWebSearchCallCompletedEvent,
|
||||
ResponseWebSearchCallInProgressEvent,
|
||||
ResponseWebSearchCallSearchingEvent,
|
||||
ResponsesClientEvent,
|
||||
ResponsesServerEvent,
|
||||
SkillReference,
|
||||
Tool,
|
||||
ToolChoiceAllowed,
|
||||
ToolChoiceApplyPatch,
|
||||
ToolChoiceCustom,
|
||||
ToolChoiceFunction,
|
||||
ToolChoiceMcp,
|
||||
ToolChoiceOptions,
|
||||
ToolChoiceShell,
|
||||
ToolChoiceTypes,
|
||||
ToolSearchTool,
|
||||
WebSearchPreviewTool,
|
||||
WebSearchTool,
|
||||
)
|
||||
```
|
||||
|
||||
Methods:
|
||||
|
||||
- <code title="post /responses">client.responses.<a href="./src/openai/resources/responses/responses.py">create</a>(\*\*<a href="src/openai/types/responses/response_create_params.py">params</a>) -> <a href="./src/openai/types/responses/response.py">Response</a></code>
|
||||
- <code title="get /responses/{response_id}">client.responses.<a href="./src/openai/resources/responses/responses.py">retrieve</a>(response_id, \*\*<a href="src/openai/types/responses/response_retrieve_params.py">params</a>) -> <a href="./src/openai/types/responses/response.py">Response</a></code>
|
||||
- <code title="delete /responses/{response_id}">client.responses.<a href="./src/openai/resources/responses/responses.py">delete</a>(response_id) -> None</code>
|
||||
- <code title="post /responses/{response_id}/cancel">client.responses.<a href="./src/openai/resources/responses/responses.py">cancel</a>(response_id) -> <a href="./src/openai/types/responses/response.py">Response</a></code>
|
||||
- <code title="post /responses/compact">client.responses.<a href="./src/openai/resources/responses/responses.py">compact</a>(\*\*<a href="src/openai/types/responses/response_compact_params.py">params</a>) -> <a href="./src/openai/types/responses/compacted_response.py">CompactedResponse</a></code>
|
||||
|
||||
## InputItems
|
||||
|
||||
Types:
|
||||
|
||||
```python
|
||||
from openai.types.responses import ResponseItemList
|
||||
```
|
||||
|
||||
Methods:
|
||||
|
||||
- <code title="get /responses/{response_id}/input_items">client.responses.input_items.<a href="./src/openai/resources/responses/input_items.py">list</a>(response_id, \*\*<a href="src/openai/types/responses/input_item_list_params.py">params</a>) -> <a href="./src/openai/types/responses/response_item.py">SyncCursorPage[ResponseItem]</a></code>
|
||||
|
||||
## InputTokens
|
||||
|
||||
Types:
|
||||
|
||||
```python
|
||||
from openai.types.responses import InputTokenCountResponse
|
||||
```
|
||||
|
||||
Methods:
|
||||
|
||||
- <code title="post /responses/input_tokens">client.responses.input_tokens.<a href="./src/openai/resources/responses/input_tokens.py">count</a>(\*\*<a href="src/openai/types/responses/input_token_count_params.py">params</a>) -> <a href="./src/openai/types/responses/input_token_count_response.py">InputTokenCountResponse</a></code>
|
||||
|
|
@ -0,0 +1,226 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, List, cast
|
||||
from typing_extensions import Literal
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import _legacy_response
|
||||
from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
|
||||
from ..._utils import maybe_transform
|
||||
from ..._compat import cached_property
|
||||
from ..._resource import SyncAPIResource, AsyncAPIResource
|
||||
from ..._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
|
||||
from ...pagination import SyncCursorPage, AsyncCursorPage
|
||||
from ..._base_client import AsyncPaginator, make_request_options
|
||||
from ...types.responses import input_item_list_params
|
||||
from ...types.responses.response_item import ResponseItem
|
||||
from ...types.responses.response_includable import ResponseIncludable
|
||||
|
||||
__all__ = ["InputItems", "AsyncInputItems"]
|
||||
|
||||
|
||||
class InputItems(SyncAPIResource):
|
||||
@cached_property
|
||||
def with_raw_response(self) -> InputItemsWithRawResponse:
|
||||
"""
|
||||
This property can be used as a prefix for any HTTP method call to return
|
||||
the raw response object instead of the parsed content.
|
||||
|
||||
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
|
||||
"""
|
||||
return InputItemsWithRawResponse(self)
|
||||
|
||||
@cached_property
|
||||
def with_streaming_response(self) -> InputItemsWithStreamingResponse:
|
||||
"""
|
||||
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
||||
|
||||
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
|
||||
"""
|
||||
return InputItemsWithStreamingResponse(self)
|
||||
|
||||
def list(
|
||||
self,
|
||||
response_id: str,
|
||||
*,
|
||||
after: str | Omit = omit,
|
||||
include: List[ResponseIncludable] | Omit = omit,
|
||||
limit: int | Omit = omit,
|
||||
order: Literal["asc", "desc"] | Omit = omit,
|
||||
# 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.
|
||||
extra_headers: Headers | None = None,
|
||||
extra_query: Query | None = None,
|
||||
extra_body: Body | None = None,
|
||||
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
||||
) -> SyncCursorPage[ResponseItem]:
|
||||
"""
|
||||
Returns a list of input items for a given response.
|
||||
|
||||
Args:
|
||||
after: An item ID to list items after, used in pagination.
|
||||
|
||||
include: Additional fields to include in the response. See the `include` parameter for
|
||||
Response creation above for more information.
|
||||
|
||||
limit: A limit on the number of objects to be returned. Limit can range between 1 and
|
||||
100, and the default is 20.
|
||||
|
||||
order: The order to return the input items in. Default is `desc`.
|
||||
|
||||
- `asc`: Return the input items in ascending order.
|
||||
- `desc`: Return the input items in descending order.
|
||||
|
||||
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
|
||||
"""
|
||||
if not response_id:
|
||||
raise ValueError(f"Expected a non-empty value for `response_id` but received {response_id!r}")
|
||||
return self._get_api_list(
|
||||
f"/responses/{response_id}/input_items",
|
||||
page=SyncCursorPage[ResponseItem],
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers,
|
||||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
query=maybe_transform(
|
||||
{
|
||||
"after": after,
|
||||
"include": include,
|
||||
"limit": limit,
|
||||
"order": order,
|
||||
},
|
||||
input_item_list_params.InputItemListParams,
|
||||
),
|
||||
),
|
||||
model=cast(Any, ResponseItem), # Union types cannot be passed in as arguments in the type system
|
||||
)
|
||||
|
||||
|
||||
class AsyncInputItems(AsyncAPIResource):
|
||||
@cached_property
|
||||
def with_raw_response(self) -> AsyncInputItemsWithRawResponse:
|
||||
"""
|
||||
This property can be used as a prefix for any HTTP method call to return
|
||||
the raw response object instead of the parsed content.
|
||||
|
||||
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
|
||||
"""
|
||||
return AsyncInputItemsWithRawResponse(self)
|
||||
|
||||
@cached_property
|
||||
def with_streaming_response(self) -> AsyncInputItemsWithStreamingResponse:
|
||||
"""
|
||||
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
||||
|
||||
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
|
||||
"""
|
||||
return AsyncInputItemsWithStreamingResponse(self)
|
||||
|
||||
def list(
|
||||
self,
|
||||
response_id: str,
|
||||
*,
|
||||
after: str | Omit = omit,
|
||||
include: List[ResponseIncludable] | Omit = omit,
|
||||
limit: int | Omit = omit,
|
||||
order: Literal["asc", "desc"] | Omit = omit,
|
||||
# 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.
|
||||
extra_headers: Headers | None = None,
|
||||
extra_query: Query | None = None,
|
||||
extra_body: Body | None = None,
|
||||
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
||||
) -> AsyncPaginator[ResponseItem, AsyncCursorPage[ResponseItem]]:
|
||||
"""
|
||||
Returns a list of input items for a given response.
|
||||
|
||||
Args:
|
||||
after: An item ID to list items after, used in pagination.
|
||||
|
||||
include: Additional fields to include in the response. See the `include` parameter for
|
||||
Response creation above for more information.
|
||||
|
||||
limit: A limit on the number of objects to be returned. Limit can range between 1 and
|
||||
100, and the default is 20.
|
||||
|
||||
order: The order to return the input items in. Default is `desc`.
|
||||
|
||||
- `asc`: Return the input items in ascending order.
|
||||
- `desc`: Return the input items in descending order.
|
||||
|
||||
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
|
||||
"""
|
||||
if not response_id:
|
||||
raise ValueError(f"Expected a non-empty value for `response_id` but received {response_id!r}")
|
||||
return self._get_api_list(
|
||||
f"/responses/{response_id}/input_items",
|
||||
page=AsyncCursorPage[ResponseItem],
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers,
|
||||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
query=maybe_transform(
|
||||
{
|
||||
"after": after,
|
||||
"include": include,
|
||||
"limit": limit,
|
||||
"order": order,
|
||||
},
|
||||
input_item_list_params.InputItemListParams,
|
||||
),
|
||||
),
|
||||
model=cast(Any, ResponseItem), # Union types cannot be passed in as arguments in the type system
|
||||
)
|
||||
|
||||
|
||||
class InputItemsWithRawResponse:
|
||||
def __init__(self, input_items: InputItems) -> None:
|
||||
self._input_items = input_items
|
||||
|
||||
self.list = _legacy_response.to_raw_response_wrapper(
|
||||
input_items.list,
|
||||
)
|
||||
|
||||
|
||||
class AsyncInputItemsWithRawResponse:
|
||||
def __init__(self, input_items: AsyncInputItems) -> None:
|
||||
self._input_items = input_items
|
||||
|
||||
self.list = _legacy_response.async_to_raw_response_wrapper(
|
||||
input_items.list,
|
||||
)
|
||||
|
||||
|
||||
class InputItemsWithStreamingResponse:
|
||||
def __init__(self, input_items: InputItems) -> None:
|
||||
self._input_items = input_items
|
||||
|
||||
self.list = to_streamed_response_wrapper(
|
||||
input_items.list,
|
||||
)
|
||||
|
||||
|
||||
class AsyncInputItemsWithStreamingResponse:
|
||||
def __init__(self, input_items: AsyncInputItems) -> None:
|
||||
self._input_items = input_items
|
||||
|
||||
self.list = async_to_streamed_response_wrapper(
|
||||
input_items.list,
|
||||
)
|
||||
|
|
@ -0,0 +1,311 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Union, Iterable, Optional
|
||||
from typing_extensions import Literal
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import _legacy_response
|
||||
from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
|
||||
from ..._utils import maybe_transform, async_maybe_transform
|
||||
from ..._compat import cached_property
|
||||
from ..._resource import SyncAPIResource, AsyncAPIResource
|
||||
from ..._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
|
||||
from ..._base_client import make_request_options
|
||||
from ...types.responses import input_token_count_params
|
||||
from ...types.responses.tool_param import ToolParam
|
||||
from ...types.shared_params.reasoning import Reasoning
|
||||
from ...types.responses.response_input_item_param import ResponseInputItemParam
|
||||
from ...types.responses.input_token_count_response import InputTokenCountResponse
|
||||
|
||||
__all__ = ["InputTokens", "AsyncInputTokens"]
|
||||
|
||||
|
||||
class InputTokens(SyncAPIResource):
|
||||
@cached_property
|
||||
def with_raw_response(self) -> InputTokensWithRawResponse:
|
||||
"""
|
||||
This property can be used as a prefix for any HTTP method call to return
|
||||
the raw response object instead of the parsed content.
|
||||
|
||||
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
|
||||
"""
|
||||
return InputTokensWithRawResponse(self)
|
||||
|
||||
@cached_property
|
||||
def with_streaming_response(self) -> InputTokensWithStreamingResponse:
|
||||
"""
|
||||
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
||||
|
||||
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
|
||||
"""
|
||||
return InputTokensWithStreamingResponse(self)
|
||||
|
||||
def count(
|
||||
self,
|
||||
*,
|
||||
conversation: Optional[input_token_count_params.Conversation] | Omit = omit,
|
||||
input: Union[str, Iterable[ResponseInputItemParam], None] | Omit = omit,
|
||||
instructions: Optional[str] | Omit = omit,
|
||||
model: Optional[str] | Omit = omit,
|
||||
parallel_tool_calls: Optional[bool] | Omit = omit,
|
||||
previous_response_id: Optional[str] | Omit = omit,
|
||||
reasoning: Optional[Reasoning] | Omit = omit,
|
||||
text: Optional[input_token_count_params.Text] | Omit = omit,
|
||||
tool_choice: Optional[input_token_count_params.ToolChoice] | Omit = omit,
|
||||
tools: Optional[Iterable[ToolParam]] | Omit = omit,
|
||||
truncation: Literal["auto", "disabled"] | Omit = omit,
|
||||
# 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.
|
||||
extra_headers: Headers | None = None,
|
||||
extra_query: Query | None = None,
|
||||
extra_body: Body | None = None,
|
||||
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
||||
) -> InputTokenCountResponse:
|
||||
"""
|
||||
Returns input token counts of the request.
|
||||
|
||||
Returns an object with `object` set to `response.input_tokens` and an
|
||||
`input_tokens` count.
|
||||
|
||||
Args:
|
||||
conversation: The conversation that this response belongs to. Items from this conversation are
|
||||
prepended to `input_items` for this response request. Input items and output
|
||||
items from this response are automatically added to this conversation after this
|
||||
response completes.
|
||||
|
||||
input: Text, image, or file inputs to the model, used to generate a response
|
||||
|
||||
instructions: A system (or developer) message inserted into the model's context. When used
|
||||
along with `previous_response_id`, the instructions from a previous response
|
||||
will not be carried over to the next response. This makes it simple to swap out
|
||||
system (or developer) messages in new responses.
|
||||
|
||||
model: Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI offers a
|
||||
wide range of models with different capabilities, performance characteristics,
|
||||
and price points. Refer to the
|
||||
[model guide](https://platform.openai.com/docs/models) to browse and compare
|
||||
available models.
|
||||
|
||||
parallel_tool_calls: Whether to allow the model to run tool calls in parallel.
|
||||
|
||||
previous_response_id: The unique ID of the previous response to the model. Use this to create
|
||||
multi-turn conversations. Learn more about
|
||||
[conversation state](https://platform.openai.com/docs/guides/conversation-state).
|
||||
Cannot be used in conjunction with `conversation`.
|
||||
|
||||
reasoning: **gpt-5 and o-series models only** Configuration options for
|
||||
[reasoning models](https://platform.openai.com/docs/guides/reasoning).
|
||||
|
||||
text: Configuration options for a text response from the model. Can be plain text or
|
||||
structured JSON data. Learn more:
|
||||
|
||||
- [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
|
||||
- [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
|
||||
|
||||
tool_choice: Controls which tool the model should use, if any.
|
||||
|
||||
tools: An array of tools the model may call while generating a response. You can
|
||||
specify which tool to use by setting the `tool_choice` parameter.
|
||||
|
||||
truncation: The truncation strategy to use for the model response. - `auto`: If the input to
|
||||
this Response exceeds the model's context window size, the model will truncate
|
||||
the response to fit the context window by dropping items from the beginning of
|
||||
the conversation. - `disabled` (default): If the input size will exceed the
|
||||
context window size for a model, the request will fail with a 400 error.
|
||||
|
||||
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
|
||||
"""
|
||||
return self._post(
|
||||
"/responses/input_tokens",
|
||||
body=maybe_transform(
|
||||
{
|
||||
"conversation": conversation,
|
||||
"input": input,
|
||||
"instructions": instructions,
|
||||
"model": model,
|
||||
"parallel_tool_calls": parallel_tool_calls,
|
||||
"previous_response_id": previous_response_id,
|
||||
"reasoning": reasoning,
|
||||
"text": text,
|
||||
"tool_choice": tool_choice,
|
||||
"tools": tools,
|
||||
"truncation": truncation,
|
||||
},
|
||||
input_token_count_params.InputTokenCountParams,
|
||||
),
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
||||
),
|
||||
cast_to=InputTokenCountResponse,
|
||||
)
|
||||
|
||||
|
||||
class AsyncInputTokens(AsyncAPIResource):
|
||||
@cached_property
|
||||
def with_raw_response(self) -> AsyncInputTokensWithRawResponse:
|
||||
"""
|
||||
This property can be used as a prefix for any HTTP method call to return
|
||||
the raw response object instead of the parsed content.
|
||||
|
||||
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
|
||||
"""
|
||||
return AsyncInputTokensWithRawResponse(self)
|
||||
|
||||
@cached_property
|
||||
def with_streaming_response(self) -> AsyncInputTokensWithStreamingResponse:
|
||||
"""
|
||||
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
||||
|
||||
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
|
||||
"""
|
||||
return AsyncInputTokensWithStreamingResponse(self)
|
||||
|
||||
async def count(
|
||||
self,
|
||||
*,
|
||||
conversation: Optional[input_token_count_params.Conversation] | Omit = omit,
|
||||
input: Union[str, Iterable[ResponseInputItemParam], None] | Omit = omit,
|
||||
instructions: Optional[str] | Omit = omit,
|
||||
model: Optional[str] | Omit = omit,
|
||||
parallel_tool_calls: Optional[bool] | Omit = omit,
|
||||
previous_response_id: Optional[str] | Omit = omit,
|
||||
reasoning: Optional[Reasoning] | Omit = omit,
|
||||
text: Optional[input_token_count_params.Text] | Omit = omit,
|
||||
tool_choice: Optional[input_token_count_params.ToolChoice] | Omit = omit,
|
||||
tools: Optional[Iterable[ToolParam]] | Omit = omit,
|
||||
truncation: Literal["auto", "disabled"] | Omit = omit,
|
||||
# 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.
|
||||
extra_headers: Headers | None = None,
|
||||
extra_query: Query | None = None,
|
||||
extra_body: Body | None = None,
|
||||
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
||||
) -> InputTokenCountResponse:
|
||||
"""
|
||||
Returns input token counts of the request.
|
||||
|
||||
Returns an object with `object` set to `response.input_tokens` and an
|
||||
`input_tokens` count.
|
||||
|
||||
Args:
|
||||
conversation: The conversation that this response belongs to. Items from this conversation are
|
||||
prepended to `input_items` for this response request. Input items and output
|
||||
items from this response are automatically added to this conversation after this
|
||||
response completes.
|
||||
|
||||
input: Text, image, or file inputs to the model, used to generate a response
|
||||
|
||||
instructions: A system (or developer) message inserted into the model's context. When used
|
||||
along with `previous_response_id`, the instructions from a previous response
|
||||
will not be carried over to the next response. This makes it simple to swap out
|
||||
system (or developer) messages in new responses.
|
||||
|
||||
model: Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI offers a
|
||||
wide range of models with different capabilities, performance characteristics,
|
||||
and price points. Refer to the
|
||||
[model guide](https://platform.openai.com/docs/models) to browse and compare
|
||||
available models.
|
||||
|
||||
parallel_tool_calls: Whether to allow the model to run tool calls in parallel.
|
||||
|
||||
previous_response_id: The unique ID of the previous response to the model. Use this to create
|
||||
multi-turn conversations. Learn more about
|
||||
[conversation state](https://platform.openai.com/docs/guides/conversation-state).
|
||||
Cannot be used in conjunction with `conversation`.
|
||||
|
||||
reasoning: **gpt-5 and o-series models only** Configuration options for
|
||||
[reasoning models](https://platform.openai.com/docs/guides/reasoning).
|
||||
|
||||
text: Configuration options for a text response from the model. Can be plain text or
|
||||
structured JSON data. Learn more:
|
||||
|
||||
- [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
|
||||
- [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
|
||||
|
||||
tool_choice: Controls which tool the model should use, if any.
|
||||
|
||||
tools: An array of tools the model may call while generating a response. You can
|
||||
specify which tool to use by setting the `tool_choice` parameter.
|
||||
|
||||
truncation: The truncation strategy to use for the model response. - `auto`: If the input to
|
||||
this Response exceeds the model's context window size, the model will truncate
|
||||
the response to fit the context window by dropping items from the beginning of
|
||||
the conversation. - `disabled` (default): If the input size will exceed the
|
||||
context window size for a model, the request will fail with a 400 error.
|
||||
|
||||
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
|
||||
"""
|
||||
return await self._post(
|
||||
"/responses/input_tokens",
|
||||
body=await async_maybe_transform(
|
||||
{
|
||||
"conversation": conversation,
|
||||
"input": input,
|
||||
"instructions": instructions,
|
||||
"model": model,
|
||||
"parallel_tool_calls": parallel_tool_calls,
|
||||
"previous_response_id": previous_response_id,
|
||||
"reasoning": reasoning,
|
||||
"text": text,
|
||||
"tool_choice": tool_choice,
|
||||
"tools": tools,
|
||||
"truncation": truncation,
|
||||
},
|
||||
input_token_count_params.InputTokenCountParams,
|
||||
),
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
||||
),
|
||||
cast_to=InputTokenCountResponse,
|
||||
)
|
||||
|
||||
|
||||
class InputTokensWithRawResponse:
|
||||
def __init__(self, input_tokens: InputTokens) -> None:
|
||||
self._input_tokens = input_tokens
|
||||
|
||||
self.count = _legacy_response.to_raw_response_wrapper(
|
||||
input_tokens.count,
|
||||
)
|
||||
|
||||
|
||||
class AsyncInputTokensWithRawResponse:
|
||||
def __init__(self, input_tokens: AsyncInputTokens) -> None:
|
||||
self._input_tokens = input_tokens
|
||||
|
||||
self.count = _legacy_response.async_to_raw_response_wrapper(
|
||||
input_tokens.count,
|
||||
)
|
||||
|
||||
|
||||
class InputTokensWithStreamingResponse:
|
||||
def __init__(self, input_tokens: InputTokens) -> None:
|
||||
self._input_tokens = input_tokens
|
||||
|
||||
self.count = to_streamed_response_wrapper(
|
||||
input_tokens.count,
|
||||
)
|
||||
|
||||
|
||||
class AsyncInputTokensWithStreamingResponse:
|
||||
def __init__(self, input_tokens: AsyncInputTokens) -> None:
|
||||
self._input_tokens = input_tokens
|
||||
|
||||
self.count = async_to_streamed_response_wrapper(
|
||||
input_tokens.count,
|
||||
)
|
||||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue