Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/__pycache__/__init__.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/__pycache__/batches.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/__pycache__/completions.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/__pycache__/embeddings.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/__pycache__/files.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/__pycache__/images.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/__pycache__/models.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/__pycache__/moderations.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/__pycache__/webhooks.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/audio/__pycache__/__init__.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/audio/__pycache__/audio.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/audio/__pycache__/speech.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/audio/__pycache__/transcriptions.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/audio/__pycache__/translations.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/__pycache__/__init__.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/__pycache__/assistants.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/__pycache__/beta.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/realtime/__init__.py +47 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/realtime/__pycache__/__init__.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/realtime/__pycache__/realtime.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/realtime/__pycache__/sessions.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/realtime/__pycache__/transcription_sessions.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/realtime/realtime.py +1092 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/realtime/sessions.py +420 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/realtime/transcription_sessions.py +282 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/threads/__init__.py +47 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/threads/__pycache__/__init__.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/threads/__pycache__/messages.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/threads/__pycache__/threads.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/threads/messages.py +718 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/threads/runs/__init__.py +33 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/threads/runs/__pycache__/__init__.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/threads/runs/__pycache__/runs.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/threads/runs/__pycache__/steps.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/threads/runs/runs.py +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/threads/runs/steps.py +399 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/threads/threads.py +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/chat/__pycache__/__init__.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/chat/__pycache__/chat.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/chat/completions/__init__.py +33 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/chat/completions/__pycache__/__init__.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/chat/completions/__pycache__/completions.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/chat/completions/__pycache__/messages.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/chat/completions/completions.py +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/chat/completions/messages.py +212 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/containers/__pycache__/__init__.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/containers/__pycache__/containers.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/containers/files/__init__.py +33 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/containers/files/__pycache__/__init__.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/openai/resources/containers/files/__pycache__/content.cpython-312.pyc +0 -0
tool_server/.venv/lib/python3.12/site-packages/openai/resources/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (4.08 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/__pycache__/batches.cpython-312.pyc
ADDED
|
Binary file (14.7 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/__pycache__/completions.cpython-312.pyc
ADDED
|
Binary file (27.7 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/__pycache__/embeddings.cpython-312.pyc
ADDED
|
Binary file (10.2 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/__pycache__/files.cpython-312.pyc
ADDED
|
Binary file (21.1 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/__pycache__/images.cpython-312.pyc
ADDED
|
Binary file (44 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/__pycache__/models.cpython-312.pyc
ADDED
|
Binary file (9.22 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/__pycache__/moderations.cpython-312.pyc
ADDED
|
Binary file (7.13 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/__pycache__/webhooks.cpython-312.pyc
ADDED
|
Binary file (7.58 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/audio/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (1.3 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/audio/__pycache__/audio.cpython-312.pyc
ADDED
|
Binary file (8.47 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/audio/__pycache__/speech.cpython-312.pyc
ADDED
|
Binary file (8.4 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/audio/__pycache__/transcriptions.cpython-312.pyc
ADDED
|
Binary file (23.6 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/audio/__pycache__/translations.cpython-312.pyc
ADDED
|
Binary file (12.4 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (981 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/__pycache__/assistants.cpython-312.pyc
ADDED
|
Binary file (27.1 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/__pycache__/beta.cpython-312.pyc
ADDED
|
Binary file (7.66 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/realtime/__init__.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
| 2 |
+
|
| 3 |
+
from .realtime import (
|
| 4 |
+
Realtime,
|
| 5 |
+
AsyncRealtime,
|
| 6 |
+
RealtimeWithRawResponse,
|
| 7 |
+
AsyncRealtimeWithRawResponse,
|
| 8 |
+
RealtimeWithStreamingResponse,
|
| 9 |
+
AsyncRealtimeWithStreamingResponse,
|
| 10 |
+
)
|
| 11 |
+
from .sessions import (
|
| 12 |
+
Sessions,
|
| 13 |
+
AsyncSessions,
|
| 14 |
+
SessionsWithRawResponse,
|
| 15 |
+
AsyncSessionsWithRawResponse,
|
| 16 |
+
SessionsWithStreamingResponse,
|
| 17 |
+
AsyncSessionsWithStreamingResponse,
|
| 18 |
+
)
|
| 19 |
+
from .transcription_sessions import (
|
| 20 |
+
TranscriptionSessions,
|
| 21 |
+
AsyncTranscriptionSessions,
|
| 22 |
+
TranscriptionSessionsWithRawResponse,
|
| 23 |
+
AsyncTranscriptionSessionsWithRawResponse,
|
| 24 |
+
TranscriptionSessionsWithStreamingResponse,
|
| 25 |
+
AsyncTranscriptionSessionsWithStreamingResponse,
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
__all__ = [
|
| 29 |
+
"Sessions",
|
| 30 |
+
"AsyncSessions",
|
| 31 |
+
"SessionsWithRawResponse",
|
| 32 |
+
"AsyncSessionsWithRawResponse",
|
| 33 |
+
"SessionsWithStreamingResponse",
|
| 34 |
+
"AsyncSessionsWithStreamingResponse",
|
| 35 |
+
"TranscriptionSessions",
|
| 36 |
+
"AsyncTranscriptionSessions",
|
| 37 |
+
"TranscriptionSessionsWithRawResponse",
|
| 38 |
+
"AsyncTranscriptionSessionsWithRawResponse",
|
| 39 |
+
"TranscriptionSessionsWithStreamingResponse",
|
| 40 |
+
"AsyncTranscriptionSessionsWithStreamingResponse",
|
| 41 |
+
"Realtime",
|
| 42 |
+
"AsyncRealtime",
|
| 43 |
+
"RealtimeWithRawResponse",
|
| 44 |
+
"AsyncRealtimeWithRawResponse",
|
| 45 |
+
"RealtimeWithStreamingResponse",
|
| 46 |
+
"AsyncRealtimeWithStreamingResponse",
|
| 47 |
+
]
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/realtime/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (1.1 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/realtime/__pycache__/realtime.cpython-312.pyc
ADDED
|
Binary file (44.8 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/realtime/__pycache__/sessions.cpython-312.pyc
ADDED
|
Binary file (14.4 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/realtime/__pycache__/transcription_sessions.cpython-312.pyc
ADDED
|
Binary file (10.2 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/realtime/realtime.py
ADDED
|
@@ -0,0 +1,1092 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
import json
|
| 6 |
+
import logging
|
| 7 |
+
from types import TracebackType
|
| 8 |
+
from typing import TYPE_CHECKING, Any, Iterator, cast
|
| 9 |
+
from typing_extensions import AsyncIterator
|
| 10 |
+
|
| 11 |
+
import httpx
|
| 12 |
+
from pydantic import BaseModel
|
| 13 |
+
|
| 14 |
+
from .sessions import (
|
| 15 |
+
Sessions,
|
| 16 |
+
AsyncSessions,
|
| 17 |
+
SessionsWithRawResponse,
|
| 18 |
+
AsyncSessionsWithRawResponse,
|
| 19 |
+
SessionsWithStreamingResponse,
|
| 20 |
+
AsyncSessionsWithStreamingResponse,
|
| 21 |
+
)
|
| 22 |
+
from ...._types import NOT_GIVEN, Query, Headers, NotGiven
|
| 23 |
+
from ...._utils import (
|
| 24 |
+
is_azure_client,
|
| 25 |
+
maybe_transform,
|
| 26 |
+
strip_not_given,
|
| 27 |
+
async_maybe_transform,
|
| 28 |
+
is_async_azure_client,
|
| 29 |
+
)
|
| 30 |
+
from ...._compat import cached_property
|
| 31 |
+
from ...._models import construct_type_unchecked
|
| 32 |
+
from ...._resource import SyncAPIResource, AsyncAPIResource
|
| 33 |
+
from ...._exceptions import OpenAIError
|
| 34 |
+
from ...._base_client import _merge_mappings
|
| 35 |
+
from ....types.beta.realtime import (
|
| 36 |
+
session_update_event_param,
|
| 37 |
+
response_create_event_param,
|
| 38 |
+
transcription_session_update_param,
|
| 39 |
+
)
|
| 40 |
+
from .transcription_sessions import (
|
| 41 |
+
TranscriptionSessions,
|
| 42 |
+
AsyncTranscriptionSessions,
|
| 43 |
+
TranscriptionSessionsWithRawResponse,
|
| 44 |
+
AsyncTranscriptionSessionsWithRawResponse,
|
| 45 |
+
TranscriptionSessionsWithStreamingResponse,
|
| 46 |
+
AsyncTranscriptionSessionsWithStreamingResponse,
|
| 47 |
+
)
|
| 48 |
+
from ....types.websocket_connection_options import WebsocketConnectionOptions
|
| 49 |
+
from ....types.beta.realtime.realtime_client_event import RealtimeClientEvent
|
| 50 |
+
from ....types.beta.realtime.realtime_server_event import RealtimeServerEvent
|
| 51 |
+
from ....types.beta.realtime.conversation_item_param import ConversationItemParam
|
| 52 |
+
from ....types.beta.realtime.realtime_client_event_param import RealtimeClientEventParam
|
| 53 |
+
|
| 54 |
+
if TYPE_CHECKING:
|
| 55 |
+
from websockets.sync.client import ClientConnection as WebsocketConnection
|
| 56 |
+
from websockets.asyncio.client import ClientConnection as AsyncWebsocketConnection
|
| 57 |
+
|
| 58 |
+
from ...._client import OpenAI, AsyncOpenAI
|
| 59 |
+
|
| 60 |
+
__all__ = ["Realtime", "AsyncRealtime"]
|
| 61 |
+
|
| 62 |
+
log: logging.Logger = logging.getLogger(__name__)
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
class Realtime(SyncAPIResource):
|
| 66 |
+
@cached_property
|
| 67 |
+
def sessions(self) -> Sessions:
|
| 68 |
+
return Sessions(self._client)
|
| 69 |
+
|
| 70 |
+
@cached_property
|
| 71 |
+
def transcription_sessions(self) -> TranscriptionSessions:
|
| 72 |
+
return TranscriptionSessions(self._client)
|
| 73 |
+
|
| 74 |
+
@cached_property
|
| 75 |
+
def with_raw_response(self) -> RealtimeWithRawResponse:
|
| 76 |
+
"""
|
| 77 |
+
This property can be used as a prefix for any HTTP method call to return
|
| 78 |
+
the raw response object instead of the parsed content.
|
| 79 |
+
|
| 80 |
+
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
|
| 81 |
+
"""
|
| 82 |
+
return RealtimeWithRawResponse(self)
|
| 83 |
+
|
| 84 |
+
@cached_property
|
| 85 |
+
def with_streaming_response(self) -> RealtimeWithStreamingResponse:
|
| 86 |
+
"""
|
| 87 |
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
| 88 |
+
|
| 89 |
+
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
|
| 90 |
+
"""
|
| 91 |
+
return RealtimeWithStreamingResponse(self)
|
| 92 |
+
|
| 93 |
+
def connect(
|
| 94 |
+
self,
|
| 95 |
+
*,
|
| 96 |
+
model: str,
|
| 97 |
+
extra_query: Query = {},
|
| 98 |
+
extra_headers: Headers = {},
|
| 99 |
+
websocket_connection_options: WebsocketConnectionOptions = {},
|
| 100 |
+
) -> RealtimeConnectionManager:
|
| 101 |
+
"""
|
| 102 |
+
The Realtime API enables you to build low-latency, multi-modal conversational experiences. It currently supports text and audio as both input and output, as well as function calling.
|
| 103 |
+
|
| 104 |
+
Some notable benefits of the API include:
|
| 105 |
+
|
| 106 |
+
- Native speech-to-speech: Skipping an intermediate text format means low latency and nuanced output.
|
| 107 |
+
- Natural, steerable voices: The models have natural inflection and can laugh, whisper, and adhere to tone direction.
|
| 108 |
+
- Simultaneous multimodal output: Text is useful for moderation; faster-than-realtime audio ensures stable playback.
|
| 109 |
+
|
| 110 |
+
The Realtime API is a stateful, event-based API that communicates over a WebSocket.
|
| 111 |
+
"""
|
| 112 |
+
return RealtimeConnectionManager(
|
| 113 |
+
client=self._client,
|
| 114 |
+
extra_query=extra_query,
|
| 115 |
+
extra_headers=extra_headers,
|
| 116 |
+
websocket_connection_options=websocket_connection_options,
|
| 117 |
+
model=model,
|
| 118 |
+
)
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
class AsyncRealtime(AsyncAPIResource):
|
| 122 |
+
@cached_property
|
| 123 |
+
def sessions(self) -> AsyncSessions:
|
| 124 |
+
return AsyncSessions(self._client)
|
| 125 |
+
|
| 126 |
+
@cached_property
|
| 127 |
+
def transcription_sessions(self) -> AsyncTranscriptionSessions:
|
| 128 |
+
return AsyncTranscriptionSessions(self._client)
|
| 129 |
+
|
| 130 |
+
@cached_property
|
| 131 |
+
def with_raw_response(self) -> AsyncRealtimeWithRawResponse:
|
| 132 |
+
"""
|
| 133 |
+
This property can be used as a prefix for any HTTP method call to return
|
| 134 |
+
the raw response object instead of the parsed content.
|
| 135 |
+
|
| 136 |
+
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
|
| 137 |
+
"""
|
| 138 |
+
return AsyncRealtimeWithRawResponse(self)
|
| 139 |
+
|
| 140 |
+
@cached_property
|
| 141 |
+
def with_streaming_response(self) -> AsyncRealtimeWithStreamingResponse:
|
| 142 |
+
"""
|
| 143 |
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
| 144 |
+
|
| 145 |
+
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
|
| 146 |
+
"""
|
| 147 |
+
return AsyncRealtimeWithStreamingResponse(self)
|
| 148 |
+
|
| 149 |
+
def connect(
|
| 150 |
+
self,
|
| 151 |
+
*,
|
| 152 |
+
model: str,
|
| 153 |
+
extra_query: Query = {},
|
| 154 |
+
extra_headers: Headers = {},
|
| 155 |
+
websocket_connection_options: WebsocketConnectionOptions = {},
|
| 156 |
+
) -> AsyncRealtimeConnectionManager:
|
| 157 |
+
"""
|
| 158 |
+
The Realtime API enables you to build low-latency, multi-modal conversational experiences. It currently supports text and audio as both input and output, as well as function calling.
|
| 159 |
+
|
| 160 |
+
Some notable benefits of the API include:
|
| 161 |
+
|
| 162 |
+
- Native speech-to-speech: Skipping an intermediate text format means low latency and nuanced output.
|
| 163 |
+
- Natural, steerable voices: The models have natural inflection and can laugh, whisper, and adhere to tone direction.
|
| 164 |
+
- Simultaneous multimodal output: Text is useful for moderation; faster-than-realtime audio ensures stable playback.
|
| 165 |
+
|
| 166 |
+
The Realtime API is a stateful, event-based API that communicates over a WebSocket.
|
| 167 |
+
"""
|
| 168 |
+
return AsyncRealtimeConnectionManager(
|
| 169 |
+
client=self._client,
|
| 170 |
+
extra_query=extra_query,
|
| 171 |
+
extra_headers=extra_headers,
|
| 172 |
+
websocket_connection_options=websocket_connection_options,
|
| 173 |
+
model=model,
|
| 174 |
+
)
|
| 175 |
+
|
| 176 |
+
|
| 177 |
+
class RealtimeWithRawResponse:
|
| 178 |
+
def __init__(self, realtime: Realtime) -> None:
|
| 179 |
+
self._realtime = realtime
|
| 180 |
+
|
| 181 |
+
@cached_property
|
| 182 |
+
def sessions(self) -> SessionsWithRawResponse:
|
| 183 |
+
return SessionsWithRawResponse(self._realtime.sessions)
|
| 184 |
+
|
| 185 |
+
@cached_property
|
| 186 |
+
def transcription_sessions(self) -> TranscriptionSessionsWithRawResponse:
|
| 187 |
+
return TranscriptionSessionsWithRawResponse(self._realtime.transcription_sessions)
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
class AsyncRealtimeWithRawResponse:
|
| 191 |
+
def __init__(self, realtime: AsyncRealtime) -> None:
|
| 192 |
+
self._realtime = realtime
|
| 193 |
+
|
| 194 |
+
@cached_property
|
| 195 |
+
def sessions(self) -> AsyncSessionsWithRawResponse:
|
| 196 |
+
return AsyncSessionsWithRawResponse(self._realtime.sessions)
|
| 197 |
+
|
| 198 |
+
@cached_property
|
| 199 |
+
def transcription_sessions(self) -> AsyncTranscriptionSessionsWithRawResponse:
|
| 200 |
+
return AsyncTranscriptionSessionsWithRawResponse(self._realtime.transcription_sessions)
|
| 201 |
+
|
| 202 |
+
|
| 203 |
+
class RealtimeWithStreamingResponse:
|
| 204 |
+
def __init__(self, realtime: Realtime) -> None:
|
| 205 |
+
self._realtime = realtime
|
| 206 |
+
|
| 207 |
+
@cached_property
|
| 208 |
+
def sessions(self) -> SessionsWithStreamingResponse:
|
| 209 |
+
return SessionsWithStreamingResponse(self._realtime.sessions)
|
| 210 |
+
|
| 211 |
+
@cached_property
|
| 212 |
+
def transcription_sessions(self) -> TranscriptionSessionsWithStreamingResponse:
|
| 213 |
+
return TranscriptionSessionsWithStreamingResponse(self._realtime.transcription_sessions)
|
| 214 |
+
|
| 215 |
+
|
| 216 |
+
class AsyncRealtimeWithStreamingResponse:
|
| 217 |
+
def __init__(self, realtime: AsyncRealtime) -> None:
|
| 218 |
+
self._realtime = realtime
|
| 219 |
+
|
| 220 |
+
@cached_property
|
| 221 |
+
def sessions(self) -> AsyncSessionsWithStreamingResponse:
|
| 222 |
+
return AsyncSessionsWithStreamingResponse(self._realtime.sessions)
|
| 223 |
+
|
| 224 |
+
@cached_property
|
| 225 |
+
def transcription_sessions(self) -> AsyncTranscriptionSessionsWithStreamingResponse:
|
| 226 |
+
return AsyncTranscriptionSessionsWithStreamingResponse(self._realtime.transcription_sessions)
|
| 227 |
+
|
| 228 |
+
|
| 229 |
+
class AsyncRealtimeConnection:
|
| 230 |
+
"""Represents a live websocket connection to the Realtime API"""
|
| 231 |
+
|
| 232 |
+
session: AsyncRealtimeSessionResource
|
| 233 |
+
response: AsyncRealtimeResponseResource
|
| 234 |
+
input_audio_buffer: AsyncRealtimeInputAudioBufferResource
|
| 235 |
+
conversation: AsyncRealtimeConversationResource
|
| 236 |
+
output_audio_buffer: AsyncRealtimeOutputAudioBufferResource
|
| 237 |
+
transcription_session: AsyncRealtimeTranscriptionSessionResource
|
| 238 |
+
|
| 239 |
+
_connection: AsyncWebsocketConnection
|
| 240 |
+
|
| 241 |
+
def __init__(self, connection: AsyncWebsocketConnection) -> None:
|
| 242 |
+
self._connection = connection
|
| 243 |
+
|
| 244 |
+
self.session = AsyncRealtimeSessionResource(self)
|
| 245 |
+
self.response = AsyncRealtimeResponseResource(self)
|
| 246 |
+
self.input_audio_buffer = AsyncRealtimeInputAudioBufferResource(self)
|
| 247 |
+
self.conversation = AsyncRealtimeConversationResource(self)
|
| 248 |
+
self.output_audio_buffer = AsyncRealtimeOutputAudioBufferResource(self)
|
| 249 |
+
self.transcription_session = AsyncRealtimeTranscriptionSessionResource(self)
|
| 250 |
+
|
| 251 |
+
async def __aiter__(self) -> AsyncIterator[RealtimeServerEvent]:
|
| 252 |
+
"""
|
| 253 |
+
An infinite-iterator that will continue to yield events until
|
| 254 |
+
the connection is closed.
|
| 255 |
+
"""
|
| 256 |
+
from websockets.exceptions import ConnectionClosedOK
|
| 257 |
+
|
| 258 |
+
try:
|
| 259 |
+
while True:
|
| 260 |
+
yield await self.recv()
|
| 261 |
+
except ConnectionClosedOK:
|
| 262 |
+
return
|
| 263 |
+
|
| 264 |
+
async def recv(self) -> RealtimeServerEvent:
|
| 265 |
+
"""
|
| 266 |
+
Receive the next message from the connection and parses it into a `RealtimeServerEvent` object.
|
| 267 |
+
|
| 268 |
+
Canceling this method is safe. There's no risk of losing data.
|
| 269 |
+
"""
|
| 270 |
+
return self.parse_event(await self.recv_bytes())
|
| 271 |
+
|
| 272 |
+
async def recv_bytes(self) -> bytes:
|
| 273 |
+
"""Receive the next message from the connection as raw bytes.
|
| 274 |
+
|
| 275 |
+
Canceling this method is safe. There's no risk of losing data.
|
| 276 |
+
|
| 277 |
+
If you want to parse the message into a `RealtimeServerEvent` object like `.recv()` does,
|
| 278 |
+
then you can call `.parse_event(data)`.
|
| 279 |
+
"""
|
| 280 |
+
message = await self._connection.recv(decode=False)
|
| 281 |
+
log.debug(f"Received websocket message: %s", message)
|
| 282 |
+
return message
|
| 283 |
+
|
| 284 |
+
async def send(self, event: RealtimeClientEvent | RealtimeClientEventParam) -> None:
|
| 285 |
+
data = (
|
| 286 |
+
event.to_json(use_api_names=True, exclude_defaults=True, exclude_unset=True)
|
| 287 |
+
if isinstance(event, BaseModel)
|
| 288 |
+
else json.dumps(await async_maybe_transform(event, RealtimeClientEventParam))
|
| 289 |
+
)
|
| 290 |
+
await self._connection.send(data)
|
| 291 |
+
|
| 292 |
+
async def close(self, *, code: int = 1000, reason: str = "") -> None:
|
| 293 |
+
await self._connection.close(code=code, reason=reason)
|
| 294 |
+
|
| 295 |
+
def parse_event(self, data: str | bytes) -> RealtimeServerEvent:
|
| 296 |
+
"""
|
| 297 |
+
Converts a raw `str` or `bytes` message into a `RealtimeServerEvent` object.
|
| 298 |
+
|
| 299 |
+
This is helpful if you're using `.recv_bytes()`.
|
| 300 |
+
"""
|
| 301 |
+
return cast(
|
| 302 |
+
RealtimeServerEvent, construct_type_unchecked(value=json.loads(data), type_=cast(Any, RealtimeServerEvent))
|
| 303 |
+
)
|
| 304 |
+
|
| 305 |
+
|
| 306 |
+
class AsyncRealtimeConnectionManager:
|
| 307 |
+
"""
|
| 308 |
+
Context manager over a `AsyncRealtimeConnection` that is returned by `beta.realtime.connect()`
|
| 309 |
+
|
| 310 |
+
This context manager ensures that the connection will be closed when it exits.
|
| 311 |
+
|
| 312 |
+
---
|
| 313 |
+
|
| 314 |
+
Note that if your application doesn't work well with the context manager approach then you
|
| 315 |
+
can call the `.enter()` method directly to initiate a connection.
|
| 316 |
+
|
| 317 |
+
**Warning**: You must remember to close the connection with `.close()`.
|
| 318 |
+
|
| 319 |
+
```py
|
| 320 |
+
connection = await client.beta.realtime.connect(...).enter()
|
| 321 |
+
# ...
|
| 322 |
+
await connection.close()
|
| 323 |
+
```
|
| 324 |
+
"""
|
| 325 |
+
|
| 326 |
+
def __init__(
|
| 327 |
+
self,
|
| 328 |
+
*,
|
| 329 |
+
client: AsyncOpenAI,
|
| 330 |
+
model: str,
|
| 331 |
+
extra_query: Query,
|
| 332 |
+
extra_headers: Headers,
|
| 333 |
+
websocket_connection_options: WebsocketConnectionOptions,
|
| 334 |
+
) -> None:
|
| 335 |
+
self.__client = client
|
| 336 |
+
self.__model = model
|
| 337 |
+
self.__connection: AsyncRealtimeConnection | None = None
|
| 338 |
+
self.__extra_query = extra_query
|
| 339 |
+
self.__extra_headers = extra_headers
|
| 340 |
+
self.__websocket_connection_options = websocket_connection_options
|
| 341 |
+
|
| 342 |
+
async def __aenter__(self) -> AsyncRealtimeConnection:
|
| 343 |
+
"""
|
| 344 |
+
👋 If your application doesn't work well with the context manager approach then you
|
| 345 |
+
can call this method directly to initiate a connection.
|
| 346 |
+
|
| 347 |
+
**Warning**: You must remember to close the connection with `.close()`.
|
| 348 |
+
|
| 349 |
+
```py
|
| 350 |
+
connection = await client.beta.realtime.connect(...).enter()
|
| 351 |
+
# ...
|
| 352 |
+
await connection.close()
|
| 353 |
+
```
|
| 354 |
+
"""
|
| 355 |
+
try:
|
| 356 |
+
from websockets.asyncio.client import connect
|
| 357 |
+
except ImportError as exc:
|
| 358 |
+
raise OpenAIError("You need to install `openai[realtime]` to use this method") from exc
|
| 359 |
+
|
| 360 |
+
extra_query = self.__extra_query
|
| 361 |
+
auth_headers = self.__client.auth_headers
|
| 362 |
+
if is_async_azure_client(self.__client):
|
| 363 |
+
url, auth_headers = await self.__client._configure_realtime(self.__model, extra_query)
|
| 364 |
+
else:
|
| 365 |
+
url = self._prepare_url().copy_with(
|
| 366 |
+
params={
|
| 367 |
+
**self.__client.base_url.params,
|
| 368 |
+
"model": self.__model,
|
| 369 |
+
**extra_query,
|
| 370 |
+
},
|
| 371 |
+
)
|
| 372 |
+
log.debug("Connecting to %s", url)
|
| 373 |
+
if self.__websocket_connection_options:
|
| 374 |
+
log.debug("Connection options: %s", self.__websocket_connection_options)
|
| 375 |
+
|
| 376 |
+
self.__connection = AsyncRealtimeConnection(
|
| 377 |
+
await connect(
|
| 378 |
+
str(url),
|
| 379 |
+
user_agent_header=self.__client.user_agent,
|
| 380 |
+
additional_headers=_merge_mappings(
|
| 381 |
+
{
|
| 382 |
+
**auth_headers,
|
| 383 |
+
"OpenAI-Beta": "realtime=v1",
|
| 384 |
+
},
|
| 385 |
+
self.__extra_headers,
|
| 386 |
+
),
|
| 387 |
+
**self.__websocket_connection_options,
|
| 388 |
+
)
|
| 389 |
+
)
|
| 390 |
+
|
| 391 |
+
return self.__connection
|
| 392 |
+
|
| 393 |
+
enter = __aenter__
|
| 394 |
+
|
| 395 |
+
def _prepare_url(self) -> httpx.URL:
|
| 396 |
+
if self.__client.websocket_base_url is not None:
|
| 397 |
+
base_url = httpx.URL(self.__client.websocket_base_url)
|
| 398 |
+
else:
|
| 399 |
+
base_url = self.__client._base_url.copy_with(scheme="wss")
|
| 400 |
+
|
| 401 |
+
merge_raw_path = base_url.raw_path.rstrip(b"/") + b"/realtime"
|
| 402 |
+
return base_url.copy_with(raw_path=merge_raw_path)
|
| 403 |
+
|
| 404 |
+
async def __aexit__(
|
| 405 |
+
self, exc_type: type[BaseException] | None, exc: BaseException | None, exc_tb: TracebackType | None
|
| 406 |
+
) -> None:
|
| 407 |
+
if self.__connection is not None:
|
| 408 |
+
await self.__connection.close()
|
| 409 |
+
|
| 410 |
+
|
| 411 |
+
class RealtimeConnection:
|
| 412 |
+
"""Represents a live websocket connection to the Realtime API"""
|
| 413 |
+
|
| 414 |
+
session: RealtimeSessionResource
|
| 415 |
+
response: RealtimeResponseResource
|
| 416 |
+
input_audio_buffer: RealtimeInputAudioBufferResource
|
| 417 |
+
conversation: RealtimeConversationResource
|
| 418 |
+
output_audio_buffer: RealtimeOutputAudioBufferResource
|
| 419 |
+
transcription_session: RealtimeTranscriptionSessionResource
|
| 420 |
+
|
| 421 |
+
_connection: WebsocketConnection
|
| 422 |
+
|
| 423 |
+
def __init__(self, connection: WebsocketConnection) -> None:
|
| 424 |
+
self._connection = connection
|
| 425 |
+
|
| 426 |
+
self.session = RealtimeSessionResource(self)
|
| 427 |
+
self.response = RealtimeResponseResource(self)
|
| 428 |
+
self.input_audio_buffer = RealtimeInputAudioBufferResource(self)
|
| 429 |
+
self.conversation = RealtimeConversationResource(self)
|
| 430 |
+
self.output_audio_buffer = RealtimeOutputAudioBufferResource(self)
|
| 431 |
+
self.transcription_session = RealtimeTranscriptionSessionResource(self)
|
| 432 |
+
|
| 433 |
+
def __iter__(self) -> Iterator[RealtimeServerEvent]:
|
| 434 |
+
"""
|
| 435 |
+
An infinite-iterator that will continue to yield events until
|
| 436 |
+
the connection is closed.
|
| 437 |
+
"""
|
| 438 |
+
from websockets.exceptions import ConnectionClosedOK
|
| 439 |
+
|
| 440 |
+
try:
|
| 441 |
+
while True:
|
| 442 |
+
yield self.recv()
|
| 443 |
+
except ConnectionClosedOK:
|
| 444 |
+
return
|
| 445 |
+
|
| 446 |
+
def recv(self) -> RealtimeServerEvent:
|
| 447 |
+
"""
|
| 448 |
+
Receive the next message from the connection and parses it into a `RealtimeServerEvent` object.
|
| 449 |
+
|
| 450 |
+
Canceling this method is safe. There's no risk of losing data.
|
| 451 |
+
"""
|
| 452 |
+
return self.parse_event(self.recv_bytes())
|
| 453 |
+
|
| 454 |
+
def recv_bytes(self) -> bytes:
|
| 455 |
+
"""Receive the next message from the connection as raw bytes.
|
| 456 |
+
|
| 457 |
+
Canceling this method is safe. There's no risk of losing data.
|
| 458 |
+
|
| 459 |
+
If you want to parse the message into a `RealtimeServerEvent` object like `.recv()` does,
|
| 460 |
+
then you can call `.parse_event(data)`.
|
| 461 |
+
"""
|
| 462 |
+
message = self._connection.recv(decode=False)
|
| 463 |
+
log.debug(f"Received websocket message: %s", message)
|
| 464 |
+
return message
|
| 465 |
+
|
| 466 |
+
def send(self, event: RealtimeClientEvent | RealtimeClientEventParam) -> None:
|
| 467 |
+
data = (
|
| 468 |
+
event.to_json(use_api_names=True, exclude_defaults=True, exclude_unset=True)
|
| 469 |
+
if isinstance(event, BaseModel)
|
| 470 |
+
else json.dumps(maybe_transform(event, RealtimeClientEventParam))
|
| 471 |
+
)
|
| 472 |
+
self._connection.send(data)
|
| 473 |
+
|
| 474 |
+
def close(self, *, code: int = 1000, reason: str = "") -> None:
|
| 475 |
+
self._connection.close(code=code, reason=reason)
|
| 476 |
+
|
| 477 |
+
def parse_event(self, data: str | bytes) -> RealtimeServerEvent:
|
| 478 |
+
"""
|
| 479 |
+
Converts a raw `str` or `bytes` message into a `RealtimeServerEvent` object.
|
| 480 |
+
|
| 481 |
+
This is helpful if you're using `.recv_bytes()`.
|
| 482 |
+
"""
|
| 483 |
+
return cast(
|
| 484 |
+
RealtimeServerEvent, construct_type_unchecked(value=json.loads(data), type_=cast(Any, RealtimeServerEvent))
|
| 485 |
+
)
|
| 486 |
+
|
| 487 |
+
|
| 488 |
+
class RealtimeConnectionManager:
|
| 489 |
+
"""
|
| 490 |
+
Context manager over a `RealtimeConnection` that is returned by `beta.realtime.connect()`
|
| 491 |
+
|
| 492 |
+
This context manager ensures that the connection will be closed when it exits.
|
| 493 |
+
|
| 494 |
+
---
|
| 495 |
+
|
| 496 |
+
Note that if your application doesn't work well with the context manager approach then you
|
| 497 |
+
can call the `.enter()` method directly to initiate a connection.
|
| 498 |
+
|
| 499 |
+
**Warning**: You must remember to close the connection with `.close()`.
|
| 500 |
+
|
| 501 |
+
```py
|
| 502 |
+
connection = client.beta.realtime.connect(...).enter()
|
| 503 |
+
# ...
|
| 504 |
+
connection.close()
|
| 505 |
+
```
|
| 506 |
+
"""
|
| 507 |
+
|
| 508 |
+
def __init__(
|
| 509 |
+
self,
|
| 510 |
+
*,
|
| 511 |
+
client: OpenAI,
|
| 512 |
+
model: str,
|
| 513 |
+
extra_query: Query,
|
| 514 |
+
extra_headers: Headers,
|
| 515 |
+
websocket_connection_options: WebsocketConnectionOptions,
|
| 516 |
+
) -> None:
|
| 517 |
+
self.__client = client
|
| 518 |
+
self.__model = model
|
| 519 |
+
self.__connection: RealtimeConnection | None = None
|
| 520 |
+
self.__extra_query = extra_query
|
| 521 |
+
self.__extra_headers = extra_headers
|
| 522 |
+
self.__websocket_connection_options = websocket_connection_options
|
| 523 |
+
|
| 524 |
+
def __enter__(self) -> RealtimeConnection:
|
| 525 |
+
"""
|
| 526 |
+
👋 If your application doesn't work well with the context manager approach then you
|
| 527 |
+
can call this method directly to initiate a connection.
|
| 528 |
+
|
| 529 |
+
**Warning**: You must remember to close the connection with `.close()`.
|
| 530 |
+
|
| 531 |
+
```py
|
| 532 |
+
connection = client.beta.realtime.connect(...).enter()
|
| 533 |
+
# ...
|
| 534 |
+
connection.close()
|
| 535 |
+
```
|
| 536 |
+
"""
|
| 537 |
+
try:
|
| 538 |
+
from websockets.sync.client import connect
|
| 539 |
+
except ImportError as exc:
|
| 540 |
+
raise OpenAIError("You need to install `openai[realtime]` to use this method") from exc
|
| 541 |
+
|
| 542 |
+
extra_query = self.__extra_query
|
| 543 |
+
auth_headers = self.__client.auth_headers
|
| 544 |
+
if is_azure_client(self.__client):
|
| 545 |
+
url, auth_headers = self.__client._configure_realtime(self.__model, extra_query)
|
| 546 |
+
else:
|
| 547 |
+
url = self._prepare_url().copy_with(
|
| 548 |
+
params={
|
| 549 |
+
**self.__client.base_url.params,
|
| 550 |
+
"model": self.__model,
|
| 551 |
+
**extra_query,
|
| 552 |
+
},
|
| 553 |
+
)
|
| 554 |
+
log.debug("Connecting to %s", url)
|
| 555 |
+
if self.__websocket_connection_options:
|
| 556 |
+
log.debug("Connection options: %s", self.__websocket_connection_options)
|
| 557 |
+
|
| 558 |
+
self.__connection = RealtimeConnection(
|
| 559 |
+
connect(
|
| 560 |
+
str(url),
|
| 561 |
+
user_agent_header=self.__client.user_agent,
|
| 562 |
+
additional_headers=_merge_mappings(
|
| 563 |
+
{
|
| 564 |
+
**auth_headers,
|
| 565 |
+
"OpenAI-Beta": "realtime=v1",
|
| 566 |
+
},
|
| 567 |
+
self.__extra_headers,
|
| 568 |
+
),
|
| 569 |
+
**self.__websocket_connection_options,
|
| 570 |
+
)
|
| 571 |
+
)
|
| 572 |
+
|
| 573 |
+
return self.__connection
|
| 574 |
+
|
| 575 |
+
enter = __enter__
|
| 576 |
+
|
| 577 |
+
def _prepare_url(self) -> httpx.URL:
|
| 578 |
+
if self.__client.websocket_base_url is not None:
|
| 579 |
+
base_url = httpx.URL(self.__client.websocket_base_url)
|
| 580 |
+
else:
|
| 581 |
+
base_url = self.__client._base_url.copy_with(scheme="wss")
|
| 582 |
+
|
| 583 |
+
merge_raw_path = base_url.raw_path.rstrip(b"/") + b"/realtime"
|
| 584 |
+
return base_url.copy_with(raw_path=merge_raw_path)
|
| 585 |
+
|
| 586 |
+
def __exit__(
|
| 587 |
+
self, exc_type: type[BaseException] | None, exc: BaseException | None, exc_tb: TracebackType | None
|
| 588 |
+
) -> None:
|
| 589 |
+
if self.__connection is not None:
|
| 590 |
+
self.__connection.close()
|
| 591 |
+
|
| 592 |
+
|
| 593 |
+
class BaseRealtimeConnectionResource:
|
| 594 |
+
def __init__(self, connection: RealtimeConnection) -> None:
|
| 595 |
+
self._connection = connection
|
| 596 |
+
|
| 597 |
+
|
| 598 |
+
class RealtimeSessionResource(BaseRealtimeConnectionResource):
|
| 599 |
+
def update(self, *, session: session_update_event_param.Session, event_id: str | NotGiven = NOT_GIVEN) -> None:
|
| 600 |
+
"""
|
| 601 |
+
Send this event to update the session’s default configuration.
|
| 602 |
+
The client may send this event at any time to update any field,
|
| 603 |
+
except for `voice`. However, note that once a session has been
|
| 604 |
+
initialized with a particular `model`, it can’t be changed to
|
| 605 |
+
another model using `session.update`.
|
| 606 |
+
|
| 607 |
+
When the server receives a `session.update`, it will respond
|
| 608 |
+
with a `session.updated` event showing the full, effective configuration.
|
| 609 |
+
Only the fields that are present are updated. To clear a field like
|
| 610 |
+
`instructions`, pass an empty string.
|
| 611 |
+
"""
|
| 612 |
+
self._connection.send(
|
| 613 |
+
cast(
|
| 614 |
+
RealtimeClientEventParam,
|
| 615 |
+
strip_not_given({"type": "session.update", "session": session, "event_id": event_id}),
|
| 616 |
+
)
|
| 617 |
+
)
|
| 618 |
+
|
| 619 |
+
|
| 620 |
+
class RealtimeResponseResource(BaseRealtimeConnectionResource):
|
| 621 |
+
def create(
|
| 622 |
+
self,
|
| 623 |
+
*,
|
| 624 |
+
event_id: str | NotGiven = NOT_GIVEN,
|
| 625 |
+
response: response_create_event_param.Response | NotGiven = NOT_GIVEN,
|
| 626 |
+
) -> None:
|
| 627 |
+
"""
|
| 628 |
+
This event instructs the server to create a Response, which means triggering
|
| 629 |
+
model inference. When in Server VAD mode, the server will create Responses
|
| 630 |
+
automatically.
|
| 631 |
+
|
| 632 |
+
A Response will include at least one Item, and may have two, in which case
|
| 633 |
+
the second will be a function call. These Items will be appended to the
|
| 634 |
+
conversation history.
|
| 635 |
+
|
| 636 |
+
The server will respond with a `response.created` event, events for Items
|
| 637 |
+
and content created, and finally a `response.done` event to indicate the
|
| 638 |
+
Response is complete.
|
| 639 |
+
|
| 640 |
+
The `response.create` event includes inference configuration like
|
| 641 |
+
`instructions`, and `temperature`. These fields will override the Session's
|
| 642 |
+
configuration for this Response only.
|
| 643 |
+
"""
|
| 644 |
+
self._connection.send(
|
| 645 |
+
cast(
|
| 646 |
+
RealtimeClientEventParam,
|
| 647 |
+
strip_not_given({"type": "response.create", "event_id": event_id, "response": response}),
|
| 648 |
+
)
|
| 649 |
+
)
|
| 650 |
+
|
| 651 |
+
def cancel(self, *, event_id: str | NotGiven = NOT_GIVEN, response_id: str | NotGiven = NOT_GIVEN) -> None:
|
| 652 |
+
"""Send this event to cancel an in-progress response.
|
| 653 |
+
|
| 654 |
+
The server will respond
|
| 655 |
+
with a `response.done` event with a status of `response.status=cancelled`. If
|
| 656 |
+
there is no response to cancel, the server will respond with an error.
|
| 657 |
+
"""
|
| 658 |
+
self._connection.send(
|
| 659 |
+
cast(
|
| 660 |
+
RealtimeClientEventParam,
|
| 661 |
+
strip_not_given({"type": "response.cancel", "event_id": event_id, "response_id": response_id}),
|
| 662 |
+
)
|
| 663 |
+
)
|
| 664 |
+
|
| 665 |
+
|
| 666 |
+
class RealtimeInputAudioBufferResource(BaseRealtimeConnectionResource):
|
| 667 |
+
def clear(self, *, event_id: str | NotGiven = NOT_GIVEN) -> None:
|
| 668 |
+
"""Send this event to clear the audio bytes in the buffer.
|
| 669 |
+
|
| 670 |
+
The server will
|
| 671 |
+
respond with an `input_audio_buffer.cleared` event.
|
| 672 |
+
"""
|
| 673 |
+
self._connection.send(
|
| 674 |
+
cast(RealtimeClientEventParam, strip_not_given({"type": "input_audio_buffer.clear", "event_id": event_id}))
|
| 675 |
+
)
|
| 676 |
+
|
| 677 |
+
def commit(self, *, event_id: str | NotGiven = NOT_GIVEN) -> None:
|
| 678 |
+
"""
|
| 679 |
+
Send this event to commit the user input audio buffer, which will create a
|
| 680 |
+
new user message item in the conversation. This event will produce an error
|
| 681 |
+
if the input audio buffer is empty. When in Server VAD mode, the client does
|
| 682 |
+
not need to send this event, the server will commit the audio buffer
|
| 683 |
+
automatically.
|
| 684 |
+
|
| 685 |
+
Committing the input audio buffer will trigger input audio transcription
|
| 686 |
+
(if enabled in session configuration), but it will not create a response
|
| 687 |
+
from the model. The server will respond with an `input_audio_buffer.committed`
|
| 688 |
+
event.
|
| 689 |
+
"""
|
| 690 |
+
self._connection.send(
|
| 691 |
+
cast(RealtimeClientEventParam, strip_not_given({"type": "input_audio_buffer.commit", "event_id": event_id}))
|
| 692 |
+
)
|
| 693 |
+
|
| 694 |
+
def append(self, *, audio: str, event_id: str | NotGiven = NOT_GIVEN) -> None:
|
| 695 |
+
"""Send this event to append audio bytes to the input audio buffer.
|
| 696 |
+
|
| 697 |
+
The audio
|
| 698 |
+
buffer is temporary storage you can write to and later commit. In Server VAD
|
| 699 |
+
mode, the audio buffer is used to detect speech and the server will decide
|
| 700 |
+
when to commit. When Server VAD is disabled, you must commit the audio buffer
|
| 701 |
+
manually.
|
| 702 |
+
|
| 703 |
+
The client may choose how much audio to place in each event up to a maximum
|
| 704 |
+
of 15 MiB, for example streaming smaller chunks from the client may allow the
|
| 705 |
+
VAD to be more responsive. Unlike made other client events, the server will
|
| 706 |
+
not send a confirmation response to this event.
|
| 707 |
+
"""
|
| 708 |
+
self._connection.send(
|
| 709 |
+
cast(
|
| 710 |
+
RealtimeClientEventParam,
|
| 711 |
+
strip_not_given({"type": "input_audio_buffer.append", "audio": audio, "event_id": event_id}),
|
| 712 |
+
)
|
| 713 |
+
)
|
| 714 |
+
|
| 715 |
+
|
| 716 |
+
class RealtimeConversationResource(BaseRealtimeConnectionResource):
|
| 717 |
+
@cached_property
|
| 718 |
+
def item(self) -> RealtimeConversationItemResource:
|
| 719 |
+
return RealtimeConversationItemResource(self._connection)
|
| 720 |
+
|
| 721 |
+
|
| 722 |
+
class RealtimeConversationItemResource(BaseRealtimeConnectionResource):
|
| 723 |
+
def delete(self, *, item_id: str, event_id: str | NotGiven = NOT_GIVEN) -> None:
|
| 724 |
+
"""Send this event when you want to remove any item from the conversation
|
| 725 |
+
history.
|
| 726 |
+
|
| 727 |
+
The server will respond with a `conversation.item.deleted` event,
|
| 728 |
+
unless the item does not exist in the conversation history, in which case the
|
| 729 |
+
server will respond with an error.
|
| 730 |
+
"""
|
| 731 |
+
self._connection.send(
|
| 732 |
+
cast(
|
| 733 |
+
RealtimeClientEventParam,
|
| 734 |
+
strip_not_given({"type": "conversation.item.delete", "item_id": item_id, "event_id": event_id}),
|
| 735 |
+
)
|
| 736 |
+
)
|
| 737 |
+
|
| 738 |
+
def create(
|
| 739 |
+
self,
|
| 740 |
+
*,
|
| 741 |
+
item: ConversationItemParam,
|
| 742 |
+
event_id: str | NotGiven = NOT_GIVEN,
|
| 743 |
+
previous_item_id: str | NotGiven = NOT_GIVEN,
|
| 744 |
+
) -> None:
|
| 745 |
+
"""
|
| 746 |
+
Add a new Item to the Conversation's context, including messages, function
|
| 747 |
+
calls, and function call responses. This event can be used both to populate a
|
| 748 |
+
"history" of the conversation and to add new items mid-stream, but has the
|
| 749 |
+
current limitation that it cannot populate assistant audio messages.
|
| 750 |
+
|
| 751 |
+
If successful, the server will respond with a `conversation.item.created`
|
| 752 |
+
event, otherwise an `error` event will be sent.
|
| 753 |
+
"""
|
| 754 |
+
self._connection.send(
|
| 755 |
+
cast(
|
| 756 |
+
RealtimeClientEventParam,
|
| 757 |
+
strip_not_given(
|
| 758 |
+
{
|
| 759 |
+
"type": "conversation.item.create",
|
| 760 |
+
"item": item,
|
| 761 |
+
"event_id": event_id,
|
| 762 |
+
"previous_item_id": previous_item_id,
|
| 763 |
+
}
|
| 764 |
+
),
|
| 765 |
+
)
|
| 766 |
+
)
|
| 767 |
+
|
| 768 |
+
def truncate(
|
| 769 |
+
self, *, audio_end_ms: int, content_index: int, item_id: str, event_id: str | NotGiven = NOT_GIVEN
|
| 770 |
+
) -> None:
|
| 771 |
+
"""Send this event to truncate a previous assistant message’s audio.
|
| 772 |
+
|
| 773 |
+
The server
|
| 774 |
+
will produce audio faster than realtime, so this event is useful when the user
|
| 775 |
+
interrupts to truncate audio that has already been sent to the client but not
|
| 776 |
+
yet played. This will synchronize the server's understanding of the audio with
|
| 777 |
+
the client's playback.
|
| 778 |
+
|
| 779 |
+
Truncating audio will delete the server-side text transcript to ensure there
|
| 780 |
+
is not text in the context that hasn't been heard by the user.
|
| 781 |
+
|
| 782 |
+
If successful, the server will respond with a `conversation.item.truncated`
|
| 783 |
+
event.
|
| 784 |
+
"""
|
| 785 |
+
self._connection.send(
|
| 786 |
+
cast(
|
| 787 |
+
RealtimeClientEventParam,
|
| 788 |
+
strip_not_given(
|
| 789 |
+
{
|
| 790 |
+
"type": "conversation.item.truncate",
|
| 791 |
+
"audio_end_ms": audio_end_ms,
|
| 792 |
+
"content_index": content_index,
|
| 793 |
+
"item_id": item_id,
|
| 794 |
+
"event_id": event_id,
|
| 795 |
+
}
|
| 796 |
+
),
|
| 797 |
+
)
|
| 798 |
+
)
|
| 799 |
+
|
| 800 |
+
def retrieve(self, *, item_id: str, event_id: str | NotGiven = NOT_GIVEN) -> None:
|
| 801 |
+
"""
|
| 802 |
+
Send this event when you want to retrieve the server's representation of a specific item in the conversation history. This is useful, for example, to inspect user audio after noise cancellation and VAD.
|
| 803 |
+
The server will respond with a `conversation.item.retrieved` event,
|
| 804 |
+
unless the item does not exist in the conversation history, in which case the
|
| 805 |
+
server will respond with an error.
|
| 806 |
+
"""
|
| 807 |
+
self._connection.send(
|
| 808 |
+
cast(
|
| 809 |
+
RealtimeClientEventParam,
|
| 810 |
+
strip_not_given({"type": "conversation.item.retrieve", "item_id": item_id, "event_id": event_id}),
|
| 811 |
+
)
|
| 812 |
+
)
|
| 813 |
+
|
| 814 |
+
|
| 815 |
+
class RealtimeOutputAudioBufferResource(BaseRealtimeConnectionResource):
|
| 816 |
+
def clear(self, *, event_id: str | NotGiven = NOT_GIVEN) -> None:
|
| 817 |
+
"""**WebRTC Only:** Emit to cut off the current audio response.
|
| 818 |
+
|
| 819 |
+
This will trigger the server to
|
| 820 |
+
stop generating audio and emit a `output_audio_buffer.cleared` event. This
|
| 821 |
+
event should be preceded by a `response.cancel` client event to stop the
|
| 822 |
+
generation of the current response.
|
| 823 |
+
[Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc).
|
| 824 |
+
"""
|
| 825 |
+
self._connection.send(
|
| 826 |
+
cast(RealtimeClientEventParam, strip_not_given({"type": "output_audio_buffer.clear", "event_id": event_id}))
|
| 827 |
+
)
|
| 828 |
+
|
| 829 |
+
|
| 830 |
+
class RealtimeTranscriptionSessionResource(BaseRealtimeConnectionResource):
|
| 831 |
+
def update(
|
| 832 |
+
self, *, session: transcription_session_update_param.Session, event_id: str | NotGiven = NOT_GIVEN
|
| 833 |
+
) -> None:
|
| 834 |
+
"""Send this event to update a transcription session."""
|
| 835 |
+
self._connection.send(
|
| 836 |
+
cast(
|
| 837 |
+
RealtimeClientEventParam,
|
| 838 |
+
strip_not_given({"type": "transcription_session.update", "session": session, "event_id": event_id}),
|
| 839 |
+
)
|
| 840 |
+
)
|
| 841 |
+
|
| 842 |
+
|
| 843 |
+
class BaseAsyncRealtimeConnectionResource:
|
| 844 |
+
def __init__(self, connection: AsyncRealtimeConnection) -> None:
|
| 845 |
+
self._connection = connection
|
| 846 |
+
|
| 847 |
+
|
| 848 |
+
class AsyncRealtimeSessionResource(BaseAsyncRealtimeConnectionResource):
|
| 849 |
+
async def update(
|
| 850 |
+
self, *, session: session_update_event_param.Session, event_id: str | NotGiven = NOT_GIVEN
|
| 851 |
+
) -> None:
|
| 852 |
+
"""
|
| 853 |
+
Send this event to update the session’s default configuration.
|
| 854 |
+
The client may send this event at any time to update any field,
|
| 855 |
+
except for `voice`. However, note that once a session has been
|
| 856 |
+
initialized with a particular `model`, it can’t be changed to
|
| 857 |
+
another model using `session.update`.
|
| 858 |
+
|
| 859 |
+
When the server receives a `session.update`, it will respond
|
| 860 |
+
with a `session.updated` event showing the full, effective configuration.
|
| 861 |
+
Only the fields that are present are updated. To clear a field like
|
| 862 |
+
`instructions`, pass an empty string.
|
| 863 |
+
"""
|
| 864 |
+
await self._connection.send(
|
| 865 |
+
cast(
|
| 866 |
+
RealtimeClientEventParam,
|
| 867 |
+
strip_not_given({"type": "session.update", "session": session, "event_id": event_id}),
|
| 868 |
+
)
|
| 869 |
+
)
|
| 870 |
+
|
| 871 |
+
|
| 872 |
+
class AsyncRealtimeResponseResource(BaseAsyncRealtimeConnectionResource):
|
| 873 |
+
async def create(
|
| 874 |
+
self,
|
| 875 |
+
*,
|
| 876 |
+
event_id: str | NotGiven = NOT_GIVEN,
|
| 877 |
+
response: response_create_event_param.Response | NotGiven = NOT_GIVEN,
|
| 878 |
+
) -> None:
|
| 879 |
+
"""
|
| 880 |
+
This event instructs the server to create a Response, which means triggering
|
| 881 |
+
model inference. When in Server VAD mode, the server will create Responses
|
| 882 |
+
automatically.
|
| 883 |
+
|
| 884 |
+
A Response will include at least one Item, and may have two, in which case
|
| 885 |
+
the second will be a function call. These Items will be appended to the
|
| 886 |
+
conversation history.
|
| 887 |
+
|
| 888 |
+
The server will respond with a `response.created` event, events for Items
|
| 889 |
+
and content created, and finally a `response.done` event to indicate the
|
| 890 |
+
Response is complete.
|
| 891 |
+
|
| 892 |
+
The `response.create` event includes inference configuration like
|
| 893 |
+
`instructions`, and `temperature`. These fields will override the Session's
|
| 894 |
+
configuration for this Response only.
|
| 895 |
+
"""
|
| 896 |
+
await self._connection.send(
|
| 897 |
+
cast(
|
| 898 |
+
RealtimeClientEventParam,
|
| 899 |
+
strip_not_given({"type": "response.create", "event_id": event_id, "response": response}),
|
| 900 |
+
)
|
| 901 |
+
)
|
| 902 |
+
|
| 903 |
+
async def cancel(self, *, event_id: str | NotGiven = NOT_GIVEN, response_id: str | NotGiven = NOT_GIVEN) -> None:
|
| 904 |
+
"""Send this event to cancel an in-progress response.
|
| 905 |
+
|
| 906 |
+
The server will respond
|
| 907 |
+
with a `response.done` event with a status of `response.status=cancelled`. If
|
| 908 |
+
there is no response to cancel, the server will respond with an error.
|
| 909 |
+
"""
|
| 910 |
+
await self._connection.send(
|
| 911 |
+
cast(
|
| 912 |
+
RealtimeClientEventParam,
|
| 913 |
+
strip_not_given({"type": "response.cancel", "event_id": event_id, "response_id": response_id}),
|
| 914 |
+
)
|
| 915 |
+
)
|
| 916 |
+
|
| 917 |
+
|
| 918 |
+
class AsyncRealtimeInputAudioBufferResource(BaseAsyncRealtimeConnectionResource):
|
| 919 |
+
async def clear(self, *, event_id: str | NotGiven = NOT_GIVEN) -> None:
|
| 920 |
+
"""Send this event to clear the audio bytes in the buffer.
|
| 921 |
+
|
| 922 |
+
The server will
|
| 923 |
+
respond with an `input_audio_buffer.cleared` event.
|
| 924 |
+
"""
|
| 925 |
+
await self._connection.send(
|
| 926 |
+
cast(RealtimeClientEventParam, strip_not_given({"type": "input_audio_buffer.clear", "event_id": event_id}))
|
| 927 |
+
)
|
| 928 |
+
|
| 929 |
+
async def commit(self, *, event_id: str | NotGiven = NOT_GIVEN) -> None:
|
| 930 |
+
"""
|
| 931 |
+
Send this event to commit the user input audio buffer, which will create a
|
| 932 |
+
new user message item in the conversation. This event will produce an error
|
| 933 |
+
if the input audio buffer is empty. When in Server VAD mode, the client does
|
| 934 |
+
not need to send this event, the server will commit the audio buffer
|
| 935 |
+
automatically.
|
| 936 |
+
|
| 937 |
+
Committing the input audio buffer will trigger input audio transcription
|
| 938 |
+
(if enabled in session configuration), but it will not create a response
|
| 939 |
+
from the model. The server will respond with an `input_audio_buffer.committed`
|
| 940 |
+
event.
|
| 941 |
+
"""
|
| 942 |
+
await self._connection.send(
|
| 943 |
+
cast(RealtimeClientEventParam, strip_not_given({"type": "input_audio_buffer.commit", "event_id": event_id}))
|
| 944 |
+
)
|
| 945 |
+
|
| 946 |
+
async def append(self, *, audio: str, event_id: str | NotGiven = NOT_GIVEN) -> None:
|
| 947 |
+
"""Send this event to append audio bytes to the input audio buffer.
|
| 948 |
+
|
| 949 |
+
The audio
|
| 950 |
+
buffer is temporary storage you can write to and later commit. In Server VAD
|
| 951 |
+
mode, the audio buffer is used to detect speech and the server will decide
|
| 952 |
+
when to commit. When Server VAD is disabled, you must commit the audio buffer
|
| 953 |
+
manually.
|
| 954 |
+
|
| 955 |
+
The client may choose how much audio to place in each event up to a maximum
|
| 956 |
+
of 15 MiB, for example streaming smaller chunks from the client may allow the
|
| 957 |
+
VAD to be more responsive. Unlike made other client events, the server will
|
| 958 |
+
not send a confirmation response to this event.
|
| 959 |
+
"""
|
| 960 |
+
await self._connection.send(
|
| 961 |
+
cast(
|
| 962 |
+
RealtimeClientEventParam,
|
| 963 |
+
strip_not_given({"type": "input_audio_buffer.append", "audio": audio, "event_id": event_id}),
|
| 964 |
+
)
|
| 965 |
+
)
|
| 966 |
+
|
| 967 |
+
|
| 968 |
+
class AsyncRealtimeConversationResource(BaseAsyncRealtimeConnectionResource):
|
| 969 |
+
@cached_property
|
| 970 |
+
def item(self) -> AsyncRealtimeConversationItemResource:
|
| 971 |
+
return AsyncRealtimeConversationItemResource(self._connection)
|
| 972 |
+
|
| 973 |
+
|
| 974 |
+
class AsyncRealtimeConversationItemResource(BaseAsyncRealtimeConnectionResource):
|
| 975 |
+
async def delete(self, *, item_id: str, event_id: str | NotGiven = NOT_GIVEN) -> None:
|
| 976 |
+
"""Send this event when you want to remove any item from the conversation
|
| 977 |
+
history.
|
| 978 |
+
|
| 979 |
+
The server will respond with a `conversation.item.deleted` event,
|
| 980 |
+
unless the item does not exist in the conversation history, in which case the
|
| 981 |
+
server will respond with an error.
|
| 982 |
+
"""
|
| 983 |
+
await self._connection.send(
|
| 984 |
+
cast(
|
| 985 |
+
RealtimeClientEventParam,
|
| 986 |
+
strip_not_given({"type": "conversation.item.delete", "item_id": item_id, "event_id": event_id}),
|
| 987 |
+
)
|
| 988 |
+
)
|
| 989 |
+
|
| 990 |
+
async def create(
|
| 991 |
+
self,
|
| 992 |
+
*,
|
| 993 |
+
item: ConversationItemParam,
|
| 994 |
+
event_id: str | NotGiven = NOT_GIVEN,
|
| 995 |
+
previous_item_id: str | NotGiven = NOT_GIVEN,
|
| 996 |
+
) -> None:
|
| 997 |
+
"""
|
| 998 |
+
Add a new Item to the Conversation's context, including messages, function
|
| 999 |
+
calls, and function call responses. This event can be used both to populate a
|
| 1000 |
+
"history" of the conversation and to add new items mid-stream, but has the
|
| 1001 |
+
current limitation that it cannot populate assistant audio messages.
|
| 1002 |
+
|
| 1003 |
+
If successful, the server will respond with a `conversation.item.created`
|
| 1004 |
+
event, otherwise an `error` event will be sent.
|
| 1005 |
+
"""
|
| 1006 |
+
await self._connection.send(
|
| 1007 |
+
cast(
|
| 1008 |
+
RealtimeClientEventParam,
|
| 1009 |
+
strip_not_given(
|
| 1010 |
+
{
|
| 1011 |
+
"type": "conversation.item.create",
|
| 1012 |
+
"item": item,
|
| 1013 |
+
"event_id": event_id,
|
| 1014 |
+
"previous_item_id": previous_item_id,
|
| 1015 |
+
}
|
| 1016 |
+
),
|
| 1017 |
+
)
|
| 1018 |
+
)
|
| 1019 |
+
|
| 1020 |
+
async def truncate(
|
| 1021 |
+
self, *, audio_end_ms: int, content_index: int, item_id: str, event_id: str | NotGiven = NOT_GIVEN
|
| 1022 |
+
) -> None:
|
| 1023 |
+
"""Send this event to truncate a previous assistant message’s audio.
|
| 1024 |
+
|
| 1025 |
+
The server
|
| 1026 |
+
will produce audio faster than realtime, so this event is useful when the user
|
| 1027 |
+
interrupts to truncate audio that has already been sent to the client but not
|
| 1028 |
+
yet played. This will synchronize the server's understanding of the audio with
|
| 1029 |
+
the client's playback.
|
| 1030 |
+
|
| 1031 |
+
Truncating audio will delete the server-side text transcript to ensure there
|
| 1032 |
+
is not text in the context that hasn't been heard by the user.
|
| 1033 |
+
|
| 1034 |
+
If successful, the server will respond with a `conversation.item.truncated`
|
| 1035 |
+
event.
|
| 1036 |
+
"""
|
| 1037 |
+
await self._connection.send(
|
| 1038 |
+
cast(
|
| 1039 |
+
RealtimeClientEventParam,
|
| 1040 |
+
strip_not_given(
|
| 1041 |
+
{
|
| 1042 |
+
"type": "conversation.item.truncate",
|
| 1043 |
+
"audio_end_ms": audio_end_ms,
|
| 1044 |
+
"content_index": content_index,
|
| 1045 |
+
"item_id": item_id,
|
| 1046 |
+
"event_id": event_id,
|
| 1047 |
+
}
|
| 1048 |
+
),
|
| 1049 |
+
)
|
| 1050 |
+
)
|
| 1051 |
+
|
| 1052 |
+
async def retrieve(self, *, item_id: str, event_id: str | NotGiven = NOT_GIVEN) -> None:
|
| 1053 |
+
"""
|
| 1054 |
+
Send this event when you want to retrieve the server's representation of a specific item in the conversation history. This is useful, for example, to inspect user audio after noise cancellation and VAD.
|
| 1055 |
+
The server will respond with a `conversation.item.retrieved` event,
|
| 1056 |
+
unless the item does not exist in the conversation history, in which case the
|
| 1057 |
+
server will respond with an error.
|
| 1058 |
+
"""
|
| 1059 |
+
await self._connection.send(
|
| 1060 |
+
cast(
|
| 1061 |
+
RealtimeClientEventParam,
|
| 1062 |
+
strip_not_given({"type": "conversation.item.retrieve", "item_id": item_id, "event_id": event_id}),
|
| 1063 |
+
)
|
| 1064 |
+
)
|
| 1065 |
+
|
| 1066 |
+
|
| 1067 |
+
class AsyncRealtimeOutputAudioBufferResource(BaseAsyncRealtimeConnectionResource):
|
| 1068 |
+
async def clear(self, *, event_id: str | NotGiven = NOT_GIVEN) -> None:
|
| 1069 |
+
"""**WebRTC Only:** Emit to cut off the current audio response.
|
| 1070 |
+
|
| 1071 |
+
This will trigger the server to
|
| 1072 |
+
stop generating audio and emit a `output_audio_buffer.cleared` event. This
|
| 1073 |
+
event should be preceded by a `response.cancel` client event to stop the
|
| 1074 |
+
generation of the current response.
|
| 1075 |
+
[Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc).
|
| 1076 |
+
"""
|
| 1077 |
+
await self._connection.send(
|
| 1078 |
+
cast(RealtimeClientEventParam, strip_not_given({"type": "output_audio_buffer.clear", "event_id": event_id}))
|
| 1079 |
+
)
|
| 1080 |
+
|
| 1081 |
+
|
| 1082 |
+
class AsyncRealtimeTranscriptionSessionResource(BaseAsyncRealtimeConnectionResource):
|
| 1083 |
+
async def update(
|
| 1084 |
+
self, *, session: transcription_session_update_param.Session, event_id: str | NotGiven = NOT_GIVEN
|
| 1085 |
+
) -> None:
|
| 1086 |
+
"""Send this event to update a transcription session."""
|
| 1087 |
+
await self._connection.send(
|
| 1088 |
+
cast(
|
| 1089 |
+
RealtimeClientEventParam,
|
| 1090 |
+
strip_not_given({"type": "transcription_session.update", "session": session, "event_id": event_id}),
|
| 1091 |
+
)
|
| 1092 |
+
)
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/realtime/sessions.py
ADDED
|
@@ -0,0 +1,420 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
| 1 |
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
from typing import List, Union, Iterable
|
| 6 |
+
from typing_extensions import Literal
|
| 7 |
+
|
| 8 |
+
import httpx
|
| 9 |
+
|
| 10 |
+
from .... import _legacy_response
|
| 11 |
+
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
|
| 12 |
+
from ...._utils import maybe_transform, async_maybe_transform
|
| 13 |
+
from ...._compat import cached_property
|
| 14 |
+
from ...._resource import SyncAPIResource, AsyncAPIResource
|
| 15 |
+
from ...._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
|
| 16 |
+
from ...._base_client import make_request_options
|
| 17 |
+
from ....types.beta.realtime import session_create_params
|
| 18 |
+
from ....types.beta.realtime.session_create_response import SessionCreateResponse
|
| 19 |
+
|
| 20 |
+
__all__ = ["Sessions", "AsyncSessions"]
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
class Sessions(SyncAPIResource):
|
| 24 |
+
@cached_property
|
| 25 |
+
def with_raw_response(self) -> SessionsWithRawResponse:
|
| 26 |
+
"""
|
| 27 |
+
This property can be used as a prefix for any HTTP method call to return
|
| 28 |
+
the raw response object instead of the parsed content.
|
| 29 |
+
|
| 30 |
+
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
|
| 31 |
+
"""
|
| 32 |
+
return SessionsWithRawResponse(self)
|
| 33 |
+
|
| 34 |
+
@cached_property
|
| 35 |
+
def with_streaming_response(self) -> SessionsWithStreamingResponse:
|
| 36 |
+
"""
|
| 37 |
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
| 38 |
+
|
| 39 |
+
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
|
| 40 |
+
"""
|
| 41 |
+
return SessionsWithStreamingResponse(self)
|
| 42 |
+
|
| 43 |
+
def create(
|
| 44 |
+
self,
|
| 45 |
+
*,
|
| 46 |
+
client_secret: session_create_params.ClientSecret | NotGiven = NOT_GIVEN,
|
| 47 |
+
input_audio_format: Literal["pcm16", "g711_ulaw", "g711_alaw"] | NotGiven = NOT_GIVEN,
|
| 48 |
+
input_audio_noise_reduction: session_create_params.InputAudioNoiseReduction | NotGiven = NOT_GIVEN,
|
| 49 |
+
input_audio_transcription: session_create_params.InputAudioTranscription | NotGiven = NOT_GIVEN,
|
| 50 |
+
instructions: str | NotGiven = NOT_GIVEN,
|
| 51 |
+
max_response_output_tokens: Union[int, Literal["inf"]] | NotGiven = NOT_GIVEN,
|
| 52 |
+
modalities: List[Literal["text", "audio"]] | NotGiven = NOT_GIVEN,
|
| 53 |
+
model: Literal[
|
| 54 |
+
"gpt-4o-realtime-preview",
|
| 55 |
+
"gpt-4o-realtime-preview-2024-10-01",
|
| 56 |
+
"gpt-4o-realtime-preview-2024-12-17",
|
| 57 |
+
"gpt-4o-realtime-preview-2025-06-03",
|
| 58 |
+
"gpt-4o-mini-realtime-preview",
|
| 59 |
+
"gpt-4o-mini-realtime-preview-2024-12-17",
|
| 60 |
+
]
|
| 61 |
+
| NotGiven = NOT_GIVEN,
|
| 62 |
+
output_audio_format: Literal["pcm16", "g711_ulaw", "g711_alaw"] | NotGiven = NOT_GIVEN,
|
| 63 |
+
speed: float | NotGiven = NOT_GIVEN,
|
| 64 |
+
temperature: float | NotGiven = NOT_GIVEN,
|
| 65 |
+
tool_choice: str | NotGiven = NOT_GIVEN,
|
| 66 |
+
tools: Iterable[session_create_params.Tool] | NotGiven = NOT_GIVEN,
|
| 67 |
+
tracing: session_create_params.Tracing | NotGiven = NOT_GIVEN,
|
| 68 |
+
turn_detection: session_create_params.TurnDetection | NotGiven = NOT_GIVEN,
|
| 69 |
+
voice: Union[str, Literal["alloy", "ash", "ballad", "coral", "echo", "sage", "shimmer", "verse"]]
|
| 70 |
+
| NotGiven = NOT_GIVEN,
|
| 71 |
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
| 72 |
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
| 73 |
+
extra_headers: Headers | None = None,
|
| 74 |
+
extra_query: Query | None = None,
|
| 75 |
+
extra_body: Body | None = None,
|
| 76 |
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
| 77 |
+
) -> SessionCreateResponse:
|
| 78 |
+
"""
|
| 79 |
+
Create an ephemeral API token for use in client-side applications with the
|
| 80 |
+
Realtime API. Can be configured with the same session parameters as the
|
| 81 |
+
`session.update` client event.
|
| 82 |
+
|
| 83 |
+
It responds with a session object, plus a `client_secret` key which contains a
|
| 84 |
+
usable ephemeral API token that can be used to authenticate browser clients for
|
| 85 |
+
the Realtime API.
|
| 86 |
+
|
| 87 |
+
Args:
|
| 88 |
+
client_secret: Configuration options for the generated client secret.
|
| 89 |
+
|
| 90 |
+
input_audio_format: The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. For
|
| 91 |
+
`pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
|
| 92 |
+
(mono), and little-endian byte order.
|
| 93 |
+
|
| 94 |
+
input_audio_noise_reduction: Configuration for input audio noise reduction. This can be set to `null` to turn
|
| 95 |
+
off. Noise reduction filters audio added to the input audio buffer before it is
|
| 96 |
+
sent to VAD and the model. Filtering the audio can improve VAD and turn
|
| 97 |
+
detection accuracy (reducing false positives) and model performance by improving
|
| 98 |
+
perception of the input audio.
|
| 99 |
+
|
| 100 |
+
input_audio_transcription: Configuration for input audio transcription, defaults to off and can be set to
|
| 101 |
+
`null` to turn off once on. Input audio transcription is not native to the
|
| 102 |
+
model, since the model consumes audio directly. Transcription runs
|
| 103 |
+
asynchronously through
|
| 104 |
+
[the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription)
|
| 105 |
+
and should be treated as guidance of input audio content rather than precisely
|
| 106 |
+
what the model heard. The client can optionally set the language and prompt for
|
| 107 |
+
transcription, these offer additional guidance to the transcription service.
|
| 108 |
+
|
| 109 |
+
instructions: The default system instructions (i.e. system message) prepended to model calls.
|
| 110 |
+
This field allows the client to guide the model on desired responses. The model
|
| 111 |
+
can be instructed on response content and format, (e.g. "be extremely succinct",
|
| 112 |
+
"act friendly", "here are examples of good responses") and on audio behavior
|
| 113 |
+
(e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The
|
| 114 |
+
instructions are not guaranteed to be followed by the model, but they provide
|
| 115 |
+
guidance to the model on the desired behavior.
|
| 116 |
+
|
| 117 |
+
Note that the server sets default instructions which will be used if this field
|
| 118 |
+
is not set and are visible in the `session.created` event at the start of the
|
| 119 |
+
session.
|
| 120 |
+
|
| 121 |
+
max_response_output_tokens: Maximum number of output tokens for a single assistant response, inclusive of
|
| 122 |
+
tool calls. Provide an integer between 1 and 4096 to limit output tokens, or
|
| 123 |
+
`inf` for the maximum available tokens for a given model. Defaults to `inf`.
|
| 124 |
+
|
| 125 |
+
modalities: The set of modalities the model can respond with. To disable audio, set this to
|
| 126 |
+
["text"].
|
| 127 |
+
|
| 128 |
+
model: The Realtime model used for this session.
|
| 129 |
+
|
| 130 |
+
output_audio_format: The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
|
| 131 |
+
For `pcm16`, output audio is sampled at a rate of 24kHz.
|
| 132 |
+
|
| 133 |
+
speed: The speed of the model's spoken response. 1.0 is the default speed. 0.25 is the
|
| 134 |
+
minimum speed. 1.5 is the maximum speed. This value can only be changed in
|
| 135 |
+
between model turns, not while a response is in progress.
|
| 136 |
+
|
| 137 |
+
temperature: Sampling temperature for the model, limited to [0.6, 1.2]. For audio models a
|
| 138 |
+
temperature of 0.8 is highly recommended for best performance.
|
| 139 |
+
|
| 140 |
+
tool_choice: How the model chooses tools. Options are `auto`, `none`, `required`, or specify
|
| 141 |
+
a function.
|
| 142 |
+
|
| 143 |
+
tools: Tools (functions) available to the model.
|
| 144 |
+
|
| 145 |
+
tracing: Configuration options for tracing. Set to null to disable tracing. Once tracing
|
| 146 |
+
is enabled for a session, the configuration cannot be modified.
|
| 147 |
+
|
| 148 |
+
`auto` will create a trace for the session with default values for the workflow
|
| 149 |
+
name, group id, and metadata.
|
| 150 |
+
|
| 151 |
+
turn_detection: Configuration for turn detection, ether Server VAD or Semantic VAD. This can be
|
| 152 |
+
set to `null` to turn off, in which case the client must manually trigger model
|
| 153 |
+
response. Server VAD means that the model will detect the start and end of
|
| 154 |
+
speech based on audio volume and respond at the end of user speech. Semantic VAD
|
| 155 |
+
is more advanced and uses a turn detection model (in conjunction with VAD) to
|
| 156 |
+
semantically estimate whether the user has finished speaking, then dynamically
|
| 157 |
+
sets a timeout based on this probability. For example, if user audio trails off
|
| 158 |
+
with "uhhm", the model will score a low probability of turn end and wait longer
|
| 159 |
+
for the user to continue speaking. This can be useful for more natural
|
| 160 |
+
conversations, but may have a higher latency.
|
| 161 |
+
|
| 162 |
+
voice: The voice the model uses to respond. Voice cannot be changed during the session
|
| 163 |
+
once the model has responded with audio at least once. Current voice options are
|
| 164 |
+
`alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`.
|
| 165 |
+
|
| 166 |
+
extra_headers: Send extra headers
|
| 167 |
+
|
| 168 |
+
extra_query: Add additional query parameters to the request
|
| 169 |
+
|
| 170 |
+
extra_body: Add additional JSON properties to the request
|
| 171 |
+
|
| 172 |
+
timeout: Override the client-level default timeout for this request, in seconds
|
| 173 |
+
"""
|
| 174 |
+
extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
|
| 175 |
+
return self._post(
|
| 176 |
+
"/realtime/sessions",
|
| 177 |
+
body=maybe_transform(
|
| 178 |
+
{
|
| 179 |
+
"client_secret": client_secret,
|
| 180 |
+
"input_audio_format": input_audio_format,
|
| 181 |
+
"input_audio_noise_reduction": input_audio_noise_reduction,
|
| 182 |
+
"input_audio_transcription": input_audio_transcription,
|
| 183 |
+
"instructions": instructions,
|
| 184 |
+
"max_response_output_tokens": max_response_output_tokens,
|
| 185 |
+
"modalities": modalities,
|
| 186 |
+
"model": model,
|
| 187 |
+
"output_audio_format": output_audio_format,
|
| 188 |
+
"speed": speed,
|
| 189 |
+
"temperature": temperature,
|
| 190 |
+
"tool_choice": tool_choice,
|
| 191 |
+
"tools": tools,
|
| 192 |
+
"tracing": tracing,
|
| 193 |
+
"turn_detection": turn_detection,
|
| 194 |
+
"voice": voice,
|
| 195 |
+
},
|
| 196 |
+
session_create_params.SessionCreateParams,
|
| 197 |
+
),
|
| 198 |
+
options=make_request_options(
|
| 199 |
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
| 200 |
+
),
|
| 201 |
+
cast_to=SessionCreateResponse,
|
| 202 |
+
)
|
| 203 |
+
|
| 204 |
+
|
| 205 |
+
class AsyncSessions(AsyncAPIResource):
|
| 206 |
+
@cached_property
|
| 207 |
+
def with_raw_response(self) -> AsyncSessionsWithRawResponse:
|
| 208 |
+
"""
|
| 209 |
+
This property can be used as a prefix for any HTTP method call to return
|
| 210 |
+
the raw response object instead of the parsed content.
|
| 211 |
+
|
| 212 |
+
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
|
| 213 |
+
"""
|
| 214 |
+
return AsyncSessionsWithRawResponse(self)
|
| 215 |
+
|
| 216 |
+
@cached_property
|
| 217 |
+
def with_streaming_response(self) -> AsyncSessionsWithStreamingResponse:
|
| 218 |
+
"""
|
| 219 |
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
| 220 |
+
|
| 221 |
+
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
|
| 222 |
+
"""
|
| 223 |
+
return AsyncSessionsWithStreamingResponse(self)
|
| 224 |
+
|
| 225 |
+
async def create(
|
| 226 |
+
self,
|
| 227 |
+
*,
|
| 228 |
+
client_secret: session_create_params.ClientSecret | NotGiven = NOT_GIVEN,
|
| 229 |
+
input_audio_format: Literal["pcm16", "g711_ulaw", "g711_alaw"] | NotGiven = NOT_GIVEN,
|
| 230 |
+
input_audio_noise_reduction: session_create_params.InputAudioNoiseReduction | NotGiven = NOT_GIVEN,
|
| 231 |
+
input_audio_transcription: session_create_params.InputAudioTranscription | NotGiven = NOT_GIVEN,
|
| 232 |
+
instructions: str | NotGiven = NOT_GIVEN,
|
| 233 |
+
max_response_output_tokens: Union[int, Literal["inf"]] | NotGiven = NOT_GIVEN,
|
| 234 |
+
modalities: List[Literal["text", "audio"]] | NotGiven = NOT_GIVEN,
|
| 235 |
+
model: Literal[
|
| 236 |
+
"gpt-4o-realtime-preview",
|
| 237 |
+
"gpt-4o-realtime-preview-2024-10-01",
|
| 238 |
+
"gpt-4o-realtime-preview-2024-12-17",
|
| 239 |
+
"gpt-4o-realtime-preview-2025-06-03",
|
| 240 |
+
"gpt-4o-mini-realtime-preview",
|
| 241 |
+
"gpt-4o-mini-realtime-preview-2024-12-17",
|
| 242 |
+
]
|
| 243 |
+
| NotGiven = NOT_GIVEN,
|
| 244 |
+
output_audio_format: Literal["pcm16", "g711_ulaw", "g711_alaw"] | NotGiven = NOT_GIVEN,
|
| 245 |
+
speed: float | NotGiven = NOT_GIVEN,
|
| 246 |
+
temperature: float | NotGiven = NOT_GIVEN,
|
| 247 |
+
tool_choice: str | NotGiven = NOT_GIVEN,
|
| 248 |
+
tools: Iterable[session_create_params.Tool] | NotGiven = NOT_GIVEN,
|
| 249 |
+
tracing: session_create_params.Tracing | NotGiven = NOT_GIVEN,
|
| 250 |
+
turn_detection: session_create_params.TurnDetection | NotGiven = NOT_GIVEN,
|
| 251 |
+
voice: Union[str, Literal["alloy", "ash", "ballad", "coral", "echo", "sage", "shimmer", "verse"]]
|
| 252 |
+
| NotGiven = NOT_GIVEN,
|
| 253 |
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
| 254 |
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
| 255 |
+
extra_headers: Headers | None = None,
|
| 256 |
+
extra_query: Query | None = None,
|
| 257 |
+
extra_body: Body | None = None,
|
| 258 |
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
| 259 |
+
) -> SessionCreateResponse:
|
| 260 |
+
"""
|
| 261 |
+
Create an ephemeral API token for use in client-side applications with the
|
| 262 |
+
Realtime API. Can be configured with the same session parameters as the
|
| 263 |
+
`session.update` client event.
|
| 264 |
+
|
| 265 |
+
It responds with a session object, plus a `client_secret` key which contains a
|
| 266 |
+
usable ephemeral API token that can be used to authenticate browser clients for
|
| 267 |
+
the Realtime API.
|
| 268 |
+
|
| 269 |
+
Args:
|
| 270 |
+
client_secret: Configuration options for the generated client secret.
|
| 271 |
+
|
| 272 |
+
input_audio_format: The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. For
|
| 273 |
+
`pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
|
| 274 |
+
(mono), and little-endian byte order.
|
| 275 |
+
|
| 276 |
+
input_audio_noise_reduction: Configuration for input audio noise reduction. This can be set to `null` to turn
|
| 277 |
+
off. Noise reduction filters audio added to the input audio buffer before it is
|
| 278 |
+
sent to VAD and the model. Filtering the audio can improve VAD and turn
|
| 279 |
+
detection accuracy (reducing false positives) and model performance by improving
|
| 280 |
+
perception of the input audio.
|
| 281 |
+
|
| 282 |
+
input_audio_transcription: Configuration for input audio transcription, defaults to off and can be set to
|
| 283 |
+
`null` to turn off once on. Input audio transcription is not native to the
|
| 284 |
+
model, since the model consumes audio directly. Transcription runs
|
| 285 |
+
asynchronously through
|
| 286 |
+
[the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription)
|
| 287 |
+
and should be treated as guidance of input audio content rather than precisely
|
| 288 |
+
what the model heard. The client can optionally set the language and prompt for
|
| 289 |
+
transcription, these offer additional guidance to the transcription service.
|
| 290 |
+
|
| 291 |
+
instructions: The default system instructions (i.e. system message) prepended to model calls.
|
| 292 |
+
This field allows the client to guide the model on desired responses. The model
|
| 293 |
+
can be instructed on response content and format, (e.g. "be extremely succinct",
|
| 294 |
+
"act friendly", "here are examples of good responses") and on audio behavior
|
| 295 |
+
(e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The
|
| 296 |
+
instructions are not guaranteed to be followed by the model, but they provide
|
| 297 |
+
guidance to the model on the desired behavior.
|
| 298 |
+
|
| 299 |
+
Note that the server sets default instructions which will be used if this field
|
| 300 |
+
is not set and are visible in the `session.created` event at the start of the
|
| 301 |
+
session.
|
| 302 |
+
|
| 303 |
+
max_response_output_tokens: Maximum number of output tokens for a single assistant response, inclusive of
|
| 304 |
+
tool calls. Provide an integer between 1 and 4096 to limit output tokens, or
|
| 305 |
+
`inf` for the maximum available tokens for a given model. Defaults to `inf`.
|
| 306 |
+
|
| 307 |
+
modalities: The set of modalities the model can respond with. To disable audio, set this to
|
| 308 |
+
["text"].
|
| 309 |
+
|
| 310 |
+
model: The Realtime model used for this session.
|
| 311 |
+
|
| 312 |
+
output_audio_format: The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
|
| 313 |
+
For `pcm16`, output audio is sampled at a rate of 24kHz.
|
| 314 |
+
|
| 315 |
+
speed: The speed of the model's spoken response. 1.0 is the default speed. 0.25 is the
|
| 316 |
+
minimum speed. 1.5 is the maximum speed. This value can only be changed in
|
| 317 |
+
between model turns, not while a response is in progress.
|
| 318 |
+
|
| 319 |
+
temperature: Sampling temperature for the model, limited to [0.6, 1.2]. For audio models a
|
| 320 |
+
temperature of 0.8 is highly recommended for best performance.
|
| 321 |
+
|
| 322 |
+
tool_choice: How the model chooses tools. Options are `auto`, `none`, `required`, or specify
|
| 323 |
+
a function.
|
| 324 |
+
|
| 325 |
+
tools: Tools (functions) available to the model.
|
| 326 |
+
|
| 327 |
+
tracing: Configuration options for tracing. Set to null to disable tracing. Once tracing
|
| 328 |
+
is enabled for a session, the configuration cannot be modified.
|
| 329 |
+
|
| 330 |
+
`auto` will create a trace for the session with default values for the workflow
|
| 331 |
+
name, group id, and metadata.
|
| 332 |
+
|
| 333 |
+
turn_detection: Configuration for turn detection, ether Server VAD or Semantic VAD. This can be
|
| 334 |
+
set to `null` to turn off, in which case the client must manually trigger model
|
| 335 |
+
response. Server VAD means that the model will detect the start and end of
|
| 336 |
+
speech based on audio volume and respond at the end of user speech. Semantic VAD
|
| 337 |
+
is more advanced and uses a turn detection model (in conjunction with VAD) to
|
| 338 |
+
semantically estimate whether the user has finished speaking, then dynamically
|
| 339 |
+
sets a timeout based on this probability. For example, if user audio trails off
|
| 340 |
+
with "uhhm", the model will score a low probability of turn end and wait longer
|
| 341 |
+
for the user to continue speaking. This can be useful for more natural
|
| 342 |
+
conversations, but may have a higher latency.
|
| 343 |
+
|
| 344 |
+
voice: The voice the model uses to respond. Voice cannot be changed during the session
|
| 345 |
+
once the model has responded with audio at least once. Current voice options are
|
| 346 |
+
`alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`.
|
| 347 |
+
|
| 348 |
+
extra_headers: Send extra headers
|
| 349 |
+
|
| 350 |
+
extra_query: Add additional query parameters to the request
|
| 351 |
+
|
| 352 |
+
extra_body: Add additional JSON properties to the request
|
| 353 |
+
|
| 354 |
+
timeout: Override the client-level default timeout for this request, in seconds
|
| 355 |
+
"""
|
| 356 |
+
extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
|
| 357 |
+
return await self._post(
|
| 358 |
+
"/realtime/sessions",
|
| 359 |
+
body=await async_maybe_transform(
|
| 360 |
+
{
|
| 361 |
+
"client_secret": client_secret,
|
| 362 |
+
"input_audio_format": input_audio_format,
|
| 363 |
+
"input_audio_noise_reduction": input_audio_noise_reduction,
|
| 364 |
+
"input_audio_transcription": input_audio_transcription,
|
| 365 |
+
"instructions": instructions,
|
| 366 |
+
"max_response_output_tokens": max_response_output_tokens,
|
| 367 |
+
"modalities": modalities,
|
| 368 |
+
"model": model,
|
| 369 |
+
"output_audio_format": output_audio_format,
|
| 370 |
+
"speed": speed,
|
| 371 |
+
"temperature": temperature,
|
| 372 |
+
"tool_choice": tool_choice,
|
| 373 |
+
"tools": tools,
|
| 374 |
+
"tracing": tracing,
|
| 375 |
+
"turn_detection": turn_detection,
|
| 376 |
+
"voice": voice,
|
| 377 |
+
},
|
| 378 |
+
session_create_params.SessionCreateParams,
|
| 379 |
+
),
|
| 380 |
+
options=make_request_options(
|
| 381 |
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
| 382 |
+
),
|
| 383 |
+
cast_to=SessionCreateResponse,
|
| 384 |
+
)
|
| 385 |
+
|
| 386 |
+
|
| 387 |
+
class SessionsWithRawResponse:
|
| 388 |
+
def __init__(self, sessions: Sessions) -> None:
|
| 389 |
+
self._sessions = sessions
|
| 390 |
+
|
| 391 |
+
self.create = _legacy_response.to_raw_response_wrapper(
|
| 392 |
+
sessions.create,
|
| 393 |
+
)
|
| 394 |
+
|
| 395 |
+
|
| 396 |
+
class AsyncSessionsWithRawResponse:
|
| 397 |
+
def __init__(self, sessions: AsyncSessions) -> None:
|
| 398 |
+
self._sessions = sessions
|
| 399 |
+
|
| 400 |
+
self.create = _legacy_response.async_to_raw_response_wrapper(
|
| 401 |
+
sessions.create,
|
| 402 |
+
)
|
| 403 |
+
|
| 404 |
+
|
| 405 |
+
class SessionsWithStreamingResponse:
|
| 406 |
+
def __init__(self, sessions: Sessions) -> None:
|
| 407 |
+
self._sessions = sessions
|
| 408 |
+
|
| 409 |
+
self.create = to_streamed_response_wrapper(
|
| 410 |
+
sessions.create,
|
| 411 |
+
)
|
| 412 |
+
|
| 413 |
+
|
| 414 |
+
class AsyncSessionsWithStreamingResponse:
|
| 415 |
+
def __init__(self, sessions: AsyncSessions) -> None:
|
| 416 |
+
self._sessions = sessions
|
| 417 |
+
|
| 418 |
+
self.create = async_to_streamed_response_wrapper(
|
| 419 |
+
sessions.create,
|
| 420 |
+
)
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/realtime/transcription_sessions.py
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
from typing import List
|
| 6 |
+
from typing_extensions import Literal
|
| 7 |
+
|
| 8 |
+
import httpx
|
| 9 |
+
|
| 10 |
+
from .... import _legacy_response
|
| 11 |
+
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
|
| 12 |
+
from ...._utils import maybe_transform, async_maybe_transform
|
| 13 |
+
from ...._compat import cached_property
|
| 14 |
+
from ...._resource import SyncAPIResource, AsyncAPIResource
|
| 15 |
+
from ...._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
|
| 16 |
+
from ...._base_client import make_request_options
|
| 17 |
+
from ....types.beta.realtime import transcription_session_create_params
|
| 18 |
+
from ....types.beta.realtime.transcription_session import TranscriptionSession
|
| 19 |
+
|
| 20 |
+
__all__ = ["TranscriptionSessions", "AsyncTranscriptionSessions"]
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
class TranscriptionSessions(SyncAPIResource):
|
| 24 |
+
@cached_property
|
| 25 |
+
def with_raw_response(self) -> TranscriptionSessionsWithRawResponse:
|
| 26 |
+
"""
|
| 27 |
+
This property can be used as a prefix for any HTTP method call to return
|
| 28 |
+
the raw response object instead of the parsed content.
|
| 29 |
+
|
| 30 |
+
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
|
| 31 |
+
"""
|
| 32 |
+
return TranscriptionSessionsWithRawResponse(self)
|
| 33 |
+
|
| 34 |
+
@cached_property
|
| 35 |
+
def with_streaming_response(self) -> TranscriptionSessionsWithStreamingResponse:
|
| 36 |
+
"""
|
| 37 |
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
| 38 |
+
|
| 39 |
+
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
|
| 40 |
+
"""
|
| 41 |
+
return TranscriptionSessionsWithStreamingResponse(self)
|
| 42 |
+
|
| 43 |
+
def create(
|
| 44 |
+
self,
|
| 45 |
+
*,
|
| 46 |
+
client_secret: transcription_session_create_params.ClientSecret | NotGiven = NOT_GIVEN,
|
| 47 |
+
include: List[str] | NotGiven = NOT_GIVEN,
|
| 48 |
+
input_audio_format: Literal["pcm16", "g711_ulaw", "g711_alaw"] | NotGiven = NOT_GIVEN,
|
| 49 |
+
input_audio_noise_reduction: transcription_session_create_params.InputAudioNoiseReduction
|
| 50 |
+
| NotGiven = NOT_GIVEN,
|
| 51 |
+
input_audio_transcription: transcription_session_create_params.InputAudioTranscription | NotGiven = NOT_GIVEN,
|
| 52 |
+
modalities: List[Literal["text", "audio"]] | NotGiven = NOT_GIVEN,
|
| 53 |
+
turn_detection: transcription_session_create_params.TurnDetection | NotGiven = NOT_GIVEN,
|
| 54 |
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
| 55 |
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
| 56 |
+
extra_headers: Headers | None = None,
|
| 57 |
+
extra_query: Query | None = None,
|
| 58 |
+
extra_body: Body | None = None,
|
| 59 |
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
| 60 |
+
) -> TranscriptionSession:
|
| 61 |
+
"""
|
| 62 |
+
Create an ephemeral API token for use in client-side applications with the
|
| 63 |
+
Realtime API specifically for realtime transcriptions. Can be configured with
|
| 64 |
+
the same session parameters as the `transcription_session.update` client event.
|
| 65 |
+
|
| 66 |
+
It responds with a session object, plus a `client_secret` key which contains a
|
| 67 |
+
usable ephemeral API token that can be used to authenticate browser clients for
|
| 68 |
+
the Realtime API.
|
| 69 |
+
|
| 70 |
+
Args:
|
| 71 |
+
client_secret: Configuration options for the generated client secret.
|
| 72 |
+
|
| 73 |
+
include:
|
| 74 |
+
The set of items to include in the transcription. Current available items are:
|
| 75 |
+
|
| 76 |
+
- `item.input_audio_transcription.logprobs`
|
| 77 |
+
|
| 78 |
+
input_audio_format: The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. For
|
| 79 |
+
`pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
|
| 80 |
+
(mono), and little-endian byte order.
|
| 81 |
+
|
| 82 |
+
input_audio_noise_reduction: Configuration for input audio noise reduction. This can be set to `null` to turn
|
| 83 |
+
off. Noise reduction filters audio added to the input audio buffer before it is
|
| 84 |
+
sent to VAD and the model. Filtering the audio can improve VAD and turn
|
| 85 |
+
detection accuracy (reducing false positives) and model performance by improving
|
| 86 |
+
perception of the input audio.
|
| 87 |
+
|
| 88 |
+
input_audio_transcription: Configuration for input audio transcription. The client can optionally set the
|
| 89 |
+
language and prompt for transcription, these offer additional guidance to the
|
| 90 |
+
transcription service.
|
| 91 |
+
|
| 92 |
+
modalities: The set of modalities the model can respond with. To disable audio, set this to
|
| 93 |
+
["text"].
|
| 94 |
+
|
| 95 |
+
turn_detection: Configuration for turn detection, ether Server VAD or Semantic VAD. This can be
|
| 96 |
+
set to `null` to turn off, in which case the client must manually trigger model
|
| 97 |
+
response. Server VAD means that the model will detect the start and end of
|
| 98 |
+
speech based on audio volume and respond at the end of user speech. Semantic VAD
|
| 99 |
+
is more advanced and uses a turn detection model (in conjunction with VAD) to
|
| 100 |
+
semantically estimate whether the user has finished speaking, then dynamically
|
| 101 |
+
sets a timeout based on this probability. For example, if user audio trails off
|
| 102 |
+
with "uhhm", the model will score a low probability of turn end and wait longer
|
| 103 |
+
for the user to continue speaking. This can be useful for more natural
|
| 104 |
+
conversations, but may have a higher latency.
|
| 105 |
+
|
| 106 |
+
extra_headers: Send extra headers
|
| 107 |
+
|
| 108 |
+
extra_query: Add additional query parameters to the request
|
| 109 |
+
|
| 110 |
+
extra_body: Add additional JSON properties to the request
|
| 111 |
+
|
| 112 |
+
timeout: Override the client-level default timeout for this request, in seconds
|
| 113 |
+
"""
|
| 114 |
+
extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
|
| 115 |
+
return self._post(
|
| 116 |
+
"/realtime/transcription_sessions",
|
| 117 |
+
body=maybe_transform(
|
| 118 |
+
{
|
| 119 |
+
"client_secret": client_secret,
|
| 120 |
+
"include": include,
|
| 121 |
+
"input_audio_format": input_audio_format,
|
| 122 |
+
"input_audio_noise_reduction": input_audio_noise_reduction,
|
| 123 |
+
"input_audio_transcription": input_audio_transcription,
|
| 124 |
+
"modalities": modalities,
|
| 125 |
+
"turn_detection": turn_detection,
|
| 126 |
+
},
|
| 127 |
+
transcription_session_create_params.TranscriptionSessionCreateParams,
|
| 128 |
+
),
|
| 129 |
+
options=make_request_options(
|
| 130 |
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
| 131 |
+
),
|
| 132 |
+
cast_to=TranscriptionSession,
|
| 133 |
+
)
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
class AsyncTranscriptionSessions(AsyncAPIResource):
|
| 137 |
+
@cached_property
|
| 138 |
+
def with_raw_response(self) -> AsyncTranscriptionSessionsWithRawResponse:
|
| 139 |
+
"""
|
| 140 |
+
This property can be used as a prefix for any HTTP method call to return
|
| 141 |
+
the raw response object instead of the parsed content.
|
| 142 |
+
|
| 143 |
+
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
|
| 144 |
+
"""
|
| 145 |
+
return AsyncTranscriptionSessionsWithRawResponse(self)
|
| 146 |
+
|
| 147 |
+
@cached_property
|
| 148 |
+
def with_streaming_response(self) -> AsyncTranscriptionSessionsWithStreamingResponse:
|
| 149 |
+
"""
|
| 150 |
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
| 151 |
+
|
| 152 |
+
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
|
| 153 |
+
"""
|
| 154 |
+
return AsyncTranscriptionSessionsWithStreamingResponse(self)
|
| 155 |
+
|
| 156 |
+
async def create(
|
| 157 |
+
self,
|
| 158 |
+
*,
|
| 159 |
+
client_secret: transcription_session_create_params.ClientSecret | NotGiven = NOT_GIVEN,
|
| 160 |
+
include: List[str] | NotGiven = NOT_GIVEN,
|
| 161 |
+
input_audio_format: Literal["pcm16", "g711_ulaw", "g711_alaw"] | NotGiven = NOT_GIVEN,
|
| 162 |
+
input_audio_noise_reduction: transcription_session_create_params.InputAudioNoiseReduction
|
| 163 |
+
| NotGiven = NOT_GIVEN,
|
| 164 |
+
input_audio_transcription: transcription_session_create_params.InputAudioTranscription | NotGiven = NOT_GIVEN,
|
| 165 |
+
modalities: List[Literal["text", "audio"]] | NotGiven = NOT_GIVEN,
|
| 166 |
+
turn_detection: transcription_session_create_params.TurnDetection | NotGiven = NOT_GIVEN,
|
| 167 |
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
| 168 |
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
| 169 |
+
extra_headers: Headers | None = None,
|
| 170 |
+
extra_query: Query | None = None,
|
| 171 |
+
extra_body: Body | None = None,
|
| 172 |
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
| 173 |
+
) -> TranscriptionSession:
|
| 174 |
+
"""
|
| 175 |
+
Create an ephemeral API token for use in client-side applications with the
|
| 176 |
+
Realtime API specifically for realtime transcriptions. Can be configured with
|
| 177 |
+
the same session parameters as the `transcription_session.update` client event.
|
| 178 |
+
|
| 179 |
+
It responds with a session object, plus a `client_secret` key which contains a
|
| 180 |
+
usable ephemeral API token that can be used to authenticate browser clients for
|
| 181 |
+
the Realtime API.
|
| 182 |
+
|
| 183 |
+
Args:
|
| 184 |
+
client_secret: Configuration options for the generated client secret.
|
| 185 |
+
|
| 186 |
+
include:
|
| 187 |
+
The set of items to include in the transcription. Current available items are:
|
| 188 |
+
|
| 189 |
+
- `item.input_audio_transcription.logprobs`
|
| 190 |
+
|
| 191 |
+
input_audio_format: The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. For
|
| 192 |
+
`pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
|
| 193 |
+
(mono), and little-endian byte order.
|
| 194 |
+
|
| 195 |
+
input_audio_noise_reduction: Configuration for input audio noise reduction. This can be set to `null` to turn
|
| 196 |
+
off. Noise reduction filters audio added to the input audio buffer before it is
|
| 197 |
+
sent to VAD and the model. Filtering the audio can improve VAD and turn
|
| 198 |
+
detection accuracy (reducing false positives) and model performance by improving
|
| 199 |
+
perception of the input audio.
|
| 200 |
+
|
| 201 |
+
input_audio_transcription: Configuration for input audio transcription. The client can optionally set the
|
| 202 |
+
language and prompt for transcription, these offer additional guidance to the
|
| 203 |
+
transcription service.
|
| 204 |
+
|
| 205 |
+
modalities: The set of modalities the model can respond with. To disable audio, set this to
|
| 206 |
+
["text"].
|
| 207 |
+
|
| 208 |
+
turn_detection: Configuration for turn detection, ether Server VAD or Semantic VAD. This can be
|
| 209 |
+
set to `null` to turn off, in which case the client must manually trigger model
|
| 210 |
+
response. Server VAD means that the model will detect the start and end of
|
| 211 |
+
speech based on audio volume and respond at the end of user speech. Semantic VAD
|
| 212 |
+
is more advanced and uses a turn detection model (in conjunction with VAD) to
|
| 213 |
+
semantically estimate whether the user has finished speaking, then dynamically
|
| 214 |
+
sets a timeout based on this probability. For example, if user audio trails off
|
| 215 |
+
with "uhhm", the model will score a low probability of turn end and wait longer
|
| 216 |
+
for the user to continue speaking. This can be useful for more natural
|
| 217 |
+
conversations, but may have a higher latency.
|
| 218 |
+
|
| 219 |
+
extra_headers: Send extra headers
|
| 220 |
+
|
| 221 |
+
extra_query: Add additional query parameters to the request
|
| 222 |
+
|
| 223 |
+
extra_body: Add additional JSON properties to the request
|
| 224 |
+
|
| 225 |
+
timeout: Override the client-level default timeout for this request, in seconds
|
| 226 |
+
"""
|
| 227 |
+
extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
|
| 228 |
+
return await self._post(
|
| 229 |
+
"/realtime/transcription_sessions",
|
| 230 |
+
body=await async_maybe_transform(
|
| 231 |
+
{
|
| 232 |
+
"client_secret": client_secret,
|
| 233 |
+
"include": include,
|
| 234 |
+
"input_audio_format": input_audio_format,
|
| 235 |
+
"input_audio_noise_reduction": input_audio_noise_reduction,
|
| 236 |
+
"input_audio_transcription": input_audio_transcription,
|
| 237 |
+
"modalities": modalities,
|
| 238 |
+
"turn_detection": turn_detection,
|
| 239 |
+
},
|
| 240 |
+
transcription_session_create_params.TranscriptionSessionCreateParams,
|
| 241 |
+
),
|
| 242 |
+
options=make_request_options(
|
| 243 |
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
| 244 |
+
),
|
| 245 |
+
cast_to=TranscriptionSession,
|
| 246 |
+
)
|
| 247 |
+
|
| 248 |
+
|
| 249 |
+
class TranscriptionSessionsWithRawResponse:
|
| 250 |
+
def __init__(self, transcription_sessions: TranscriptionSessions) -> None:
|
| 251 |
+
self._transcription_sessions = transcription_sessions
|
| 252 |
+
|
| 253 |
+
self.create = _legacy_response.to_raw_response_wrapper(
|
| 254 |
+
transcription_sessions.create,
|
| 255 |
+
)
|
| 256 |
+
|
| 257 |
+
|
| 258 |
+
class AsyncTranscriptionSessionsWithRawResponse:
|
| 259 |
+
def __init__(self, transcription_sessions: AsyncTranscriptionSessions) -> None:
|
| 260 |
+
self._transcription_sessions = transcription_sessions
|
| 261 |
+
|
| 262 |
+
self.create = _legacy_response.async_to_raw_response_wrapper(
|
| 263 |
+
transcription_sessions.create,
|
| 264 |
+
)
|
| 265 |
+
|
| 266 |
+
|
| 267 |
+
class TranscriptionSessionsWithStreamingResponse:
|
| 268 |
+
def __init__(self, transcription_sessions: TranscriptionSessions) -> None:
|
| 269 |
+
self._transcription_sessions = transcription_sessions
|
| 270 |
+
|
| 271 |
+
self.create = to_streamed_response_wrapper(
|
| 272 |
+
transcription_sessions.create,
|
| 273 |
+
)
|
| 274 |
+
|
| 275 |
+
|
| 276 |
+
class AsyncTranscriptionSessionsWithStreamingResponse:
|
| 277 |
+
def __init__(self, transcription_sessions: AsyncTranscriptionSessions) -> None:
|
| 278 |
+
self._transcription_sessions = transcription_sessions
|
| 279 |
+
|
| 280 |
+
self.create = async_to_streamed_response_wrapper(
|
| 281 |
+
transcription_sessions.create,
|
| 282 |
+
)
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/threads/__init__.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
| 2 |
+
|
| 3 |
+
from .runs import (
|
| 4 |
+
Runs,
|
| 5 |
+
AsyncRuns,
|
| 6 |
+
RunsWithRawResponse,
|
| 7 |
+
AsyncRunsWithRawResponse,
|
| 8 |
+
RunsWithStreamingResponse,
|
| 9 |
+
AsyncRunsWithStreamingResponse,
|
| 10 |
+
)
|
| 11 |
+
from .threads import (
|
| 12 |
+
Threads,
|
| 13 |
+
AsyncThreads,
|
| 14 |
+
ThreadsWithRawResponse,
|
| 15 |
+
AsyncThreadsWithRawResponse,
|
| 16 |
+
ThreadsWithStreamingResponse,
|
| 17 |
+
AsyncThreadsWithStreamingResponse,
|
| 18 |
+
)
|
| 19 |
+
from .messages import (
|
| 20 |
+
Messages,
|
| 21 |
+
AsyncMessages,
|
| 22 |
+
MessagesWithRawResponse,
|
| 23 |
+
AsyncMessagesWithRawResponse,
|
| 24 |
+
MessagesWithStreamingResponse,
|
| 25 |
+
AsyncMessagesWithStreamingResponse,
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
__all__ = [
|
| 29 |
+
"Runs",
|
| 30 |
+
"AsyncRuns",
|
| 31 |
+
"RunsWithRawResponse",
|
| 32 |
+
"AsyncRunsWithRawResponse",
|
| 33 |
+
"RunsWithStreamingResponse",
|
| 34 |
+
"AsyncRunsWithStreamingResponse",
|
| 35 |
+
"Messages",
|
| 36 |
+
"AsyncMessages",
|
| 37 |
+
"MessagesWithRawResponse",
|
| 38 |
+
"AsyncMessagesWithRawResponse",
|
| 39 |
+
"MessagesWithStreamingResponse",
|
| 40 |
+
"AsyncMessagesWithStreamingResponse",
|
| 41 |
+
"Threads",
|
| 42 |
+
"AsyncThreads",
|
| 43 |
+
"ThreadsWithRawResponse",
|
| 44 |
+
"AsyncThreadsWithRawResponse",
|
| 45 |
+
"ThreadsWithStreamingResponse",
|
| 46 |
+
"AsyncThreadsWithStreamingResponse",
|
| 47 |
+
]
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/threads/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (975 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/threads/__pycache__/messages.cpython-312.pyc
ADDED
|
Binary file (20 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/threads/__pycache__/threads.cpython-312.pyc
ADDED
|
Binary file (51.8 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/threads/messages.py
ADDED
|
@@ -0,0 +1,718 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
import typing_extensions
|
| 6 |
+
from typing import Union, Iterable, Optional
|
| 7 |
+
from typing_extensions import Literal
|
| 8 |
+
|
| 9 |
+
import httpx
|
| 10 |
+
|
| 11 |
+
from .... import _legacy_response
|
| 12 |
+
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
|
| 13 |
+
from ...._utils import maybe_transform, async_maybe_transform
|
| 14 |
+
from ...._compat import cached_property
|
| 15 |
+
from ...._resource import SyncAPIResource, AsyncAPIResource
|
| 16 |
+
from ...._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
|
| 17 |
+
from ....pagination import SyncCursorPage, AsyncCursorPage
|
| 18 |
+
from ...._base_client import (
|
| 19 |
+
AsyncPaginator,
|
| 20 |
+
make_request_options,
|
| 21 |
+
)
|
| 22 |
+
from ....types.beta.threads import message_list_params, message_create_params, message_update_params
|
| 23 |
+
from ....types.beta.threads.message import Message
|
| 24 |
+
from ....types.shared_params.metadata import Metadata
|
| 25 |
+
from ....types.beta.threads.message_deleted import MessageDeleted
|
| 26 |
+
from ....types.beta.threads.message_content_part_param import MessageContentPartParam
|
| 27 |
+
|
| 28 |
+
__all__ = ["Messages", "AsyncMessages"]
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
class Messages(SyncAPIResource):
|
| 32 |
+
@cached_property
|
| 33 |
+
def with_raw_response(self) -> MessagesWithRawResponse:
|
| 34 |
+
"""
|
| 35 |
+
This property can be used as a prefix for any HTTP method call to return
|
| 36 |
+
the raw response object instead of the parsed content.
|
| 37 |
+
|
| 38 |
+
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
|
| 39 |
+
"""
|
| 40 |
+
return MessagesWithRawResponse(self)
|
| 41 |
+
|
| 42 |
+
@cached_property
|
| 43 |
+
def with_streaming_response(self) -> MessagesWithStreamingResponse:
|
| 44 |
+
"""
|
| 45 |
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
| 46 |
+
|
| 47 |
+
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
|
| 48 |
+
"""
|
| 49 |
+
return MessagesWithStreamingResponse(self)
|
| 50 |
+
|
| 51 |
+
@typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
|
| 52 |
+
def create(
|
| 53 |
+
self,
|
| 54 |
+
thread_id: str,
|
| 55 |
+
*,
|
| 56 |
+
content: Union[str, Iterable[MessageContentPartParam]],
|
| 57 |
+
role: Literal["user", "assistant"],
|
| 58 |
+
attachments: Optional[Iterable[message_create_params.Attachment]] | NotGiven = NOT_GIVEN,
|
| 59 |
+
metadata: Optional[Metadata] | NotGiven = NOT_GIVEN,
|
| 60 |
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
| 61 |
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
| 62 |
+
extra_headers: Headers | None = None,
|
| 63 |
+
extra_query: Query | None = None,
|
| 64 |
+
extra_body: Body | None = None,
|
| 65 |
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
| 66 |
+
) -> Message:
|
| 67 |
+
"""
|
| 68 |
+
Create a message.
|
| 69 |
+
|
| 70 |
+
Args:
|
| 71 |
+
content: The text contents of the message.
|
| 72 |
+
|
| 73 |
+
role:
|
| 74 |
+
The role of the entity that is creating the message. Allowed values include:
|
| 75 |
+
|
| 76 |
+
- `user`: Indicates the message is sent by an actual user and should be used in
|
| 77 |
+
most cases to represent user-generated messages.
|
| 78 |
+
- `assistant`: Indicates the message is generated by the assistant. Use this
|
| 79 |
+
value to insert messages from the assistant into the conversation.
|
| 80 |
+
|
| 81 |
+
attachments: A list of files attached to the message, and the tools they should be added to.
|
| 82 |
+
|
| 83 |
+
metadata: Set of 16 key-value pairs that can be attached to an object. This can be useful
|
| 84 |
+
for storing additional information about the object in a structured format, and
|
| 85 |
+
querying for objects via API or the dashboard.
|
| 86 |
+
|
| 87 |
+
Keys are strings with a maximum length of 64 characters. Values are strings with
|
| 88 |
+
a maximum length of 512 characters.
|
| 89 |
+
|
| 90 |
+
extra_headers: Send extra headers
|
| 91 |
+
|
| 92 |
+
extra_query: Add additional query parameters to the request
|
| 93 |
+
|
| 94 |
+
extra_body: Add additional JSON properties to the request
|
| 95 |
+
|
| 96 |
+
timeout: Override the client-level default timeout for this request, in seconds
|
| 97 |
+
"""
|
| 98 |
+
if not thread_id:
|
| 99 |
+
raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}")
|
| 100 |
+
extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
|
| 101 |
+
return self._post(
|
| 102 |
+
f"/threads/{thread_id}/messages",
|
| 103 |
+
body=maybe_transform(
|
| 104 |
+
{
|
| 105 |
+
"content": content,
|
| 106 |
+
"role": role,
|
| 107 |
+
"attachments": attachments,
|
| 108 |
+
"metadata": metadata,
|
| 109 |
+
},
|
| 110 |
+
message_create_params.MessageCreateParams,
|
| 111 |
+
),
|
| 112 |
+
options=make_request_options(
|
| 113 |
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
| 114 |
+
),
|
| 115 |
+
cast_to=Message,
|
| 116 |
+
)
|
| 117 |
+
|
| 118 |
+
@typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
|
| 119 |
+
def retrieve(
|
| 120 |
+
self,
|
| 121 |
+
message_id: str,
|
| 122 |
+
*,
|
| 123 |
+
thread_id: str,
|
| 124 |
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
| 125 |
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
| 126 |
+
extra_headers: Headers | None = None,
|
| 127 |
+
extra_query: Query | None = None,
|
| 128 |
+
extra_body: Body | None = None,
|
| 129 |
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
| 130 |
+
) -> Message:
|
| 131 |
+
"""
|
| 132 |
+
Retrieve a message.
|
| 133 |
+
|
| 134 |
+
Args:
|
| 135 |
+
extra_headers: Send extra headers
|
| 136 |
+
|
| 137 |
+
extra_query: Add additional query parameters to the request
|
| 138 |
+
|
| 139 |
+
extra_body: Add additional JSON properties to the request
|
| 140 |
+
|
| 141 |
+
timeout: Override the client-level default timeout for this request, in seconds
|
| 142 |
+
"""
|
| 143 |
+
if not thread_id:
|
| 144 |
+
raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}")
|
| 145 |
+
if not message_id:
|
| 146 |
+
raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}")
|
| 147 |
+
extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
|
| 148 |
+
return self._get(
|
| 149 |
+
f"/threads/{thread_id}/messages/{message_id}",
|
| 150 |
+
options=make_request_options(
|
| 151 |
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
| 152 |
+
),
|
| 153 |
+
cast_to=Message,
|
| 154 |
+
)
|
| 155 |
+
|
| 156 |
+
@typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
|
| 157 |
+
def update(
|
| 158 |
+
self,
|
| 159 |
+
message_id: str,
|
| 160 |
+
*,
|
| 161 |
+
thread_id: str,
|
| 162 |
+
metadata: Optional[Metadata] | NotGiven = NOT_GIVEN,
|
| 163 |
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
| 164 |
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
| 165 |
+
extra_headers: Headers | None = None,
|
| 166 |
+
extra_query: Query | None = None,
|
| 167 |
+
extra_body: Body | None = None,
|
| 168 |
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
| 169 |
+
) -> Message:
|
| 170 |
+
"""
|
| 171 |
+
Modifies a message.
|
| 172 |
+
|
| 173 |
+
Args:
|
| 174 |
+
metadata: Set of 16 key-value pairs that can be attached to an object. This can be useful
|
| 175 |
+
for storing additional information about the object in a structured format, and
|
| 176 |
+
querying for objects via API or the dashboard.
|
| 177 |
+
|
| 178 |
+
Keys are strings with a maximum length of 64 characters. Values are strings with
|
| 179 |
+
a maximum length of 512 characters.
|
| 180 |
+
|
| 181 |
+
extra_headers: Send extra headers
|
| 182 |
+
|
| 183 |
+
extra_query: Add additional query parameters to the request
|
| 184 |
+
|
| 185 |
+
extra_body: Add additional JSON properties to the request
|
| 186 |
+
|
| 187 |
+
timeout: Override the client-level default timeout for this request, in seconds
|
| 188 |
+
"""
|
| 189 |
+
if not thread_id:
|
| 190 |
+
raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}")
|
| 191 |
+
if not message_id:
|
| 192 |
+
raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}")
|
| 193 |
+
extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
|
| 194 |
+
return self._post(
|
| 195 |
+
f"/threads/{thread_id}/messages/{message_id}",
|
| 196 |
+
body=maybe_transform({"metadata": metadata}, message_update_params.MessageUpdateParams),
|
| 197 |
+
options=make_request_options(
|
| 198 |
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
| 199 |
+
),
|
| 200 |
+
cast_to=Message,
|
| 201 |
+
)
|
| 202 |
+
|
| 203 |
+
@typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
|
| 204 |
+
def list(
|
| 205 |
+
self,
|
| 206 |
+
thread_id: str,
|
| 207 |
+
*,
|
| 208 |
+
after: str | NotGiven = NOT_GIVEN,
|
| 209 |
+
before: str | NotGiven = NOT_GIVEN,
|
| 210 |
+
limit: int | NotGiven = NOT_GIVEN,
|
| 211 |
+
order: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
|
| 212 |
+
run_id: str | NotGiven = NOT_GIVEN,
|
| 213 |
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
| 214 |
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
| 215 |
+
extra_headers: Headers | None = None,
|
| 216 |
+
extra_query: Query | None = None,
|
| 217 |
+
extra_body: Body | None = None,
|
| 218 |
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
| 219 |
+
) -> SyncCursorPage[Message]:
|
| 220 |
+
"""
|
| 221 |
+
Returns a list of messages for a given thread.
|
| 222 |
+
|
| 223 |
+
Args:
|
| 224 |
+
after: A cursor for use in pagination. `after` is an object ID that defines your place
|
| 225 |
+
in the list. For instance, if you make a list request and receive 100 objects,
|
| 226 |
+
ending with obj_foo, your subsequent call can include after=obj_foo in order to
|
| 227 |
+
fetch the next page of the list.
|
| 228 |
+
|
| 229 |
+
before: A cursor for use in pagination. `before` is an object ID that defines your place
|
| 230 |
+
in the list. For instance, if you make a list request and receive 100 objects,
|
| 231 |
+
starting with obj_foo, your subsequent call can include before=obj_foo in order
|
| 232 |
+
to fetch the previous page of the list.
|
| 233 |
+
|
| 234 |
+
limit: A limit on the number of objects to be returned. Limit can range between 1 and
|
| 235 |
+
100, and the default is 20.
|
| 236 |
+
|
| 237 |
+
order: Sort order by the `created_at` timestamp of the objects. `asc` for ascending
|
| 238 |
+
order and `desc` for descending order.
|
| 239 |
+
|
| 240 |
+
run_id: Filter messages by the run ID that generated them.
|
| 241 |
+
|
| 242 |
+
extra_headers: Send extra headers
|
| 243 |
+
|
| 244 |
+
extra_query: Add additional query parameters to the request
|
| 245 |
+
|
| 246 |
+
extra_body: Add additional JSON properties to the request
|
| 247 |
+
|
| 248 |
+
timeout: Override the client-level default timeout for this request, in seconds
|
| 249 |
+
"""
|
| 250 |
+
if not thread_id:
|
| 251 |
+
raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}")
|
| 252 |
+
extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
|
| 253 |
+
return self._get_api_list(
|
| 254 |
+
f"/threads/{thread_id}/messages",
|
| 255 |
+
page=SyncCursorPage[Message],
|
| 256 |
+
options=make_request_options(
|
| 257 |
+
extra_headers=extra_headers,
|
| 258 |
+
extra_query=extra_query,
|
| 259 |
+
extra_body=extra_body,
|
| 260 |
+
timeout=timeout,
|
| 261 |
+
query=maybe_transform(
|
| 262 |
+
{
|
| 263 |
+
"after": after,
|
| 264 |
+
"before": before,
|
| 265 |
+
"limit": limit,
|
| 266 |
+
"order": order,
|
| 267 |
+
"run_id": run_id,
|
| 268 |
+
},
|
| 269 |
+
message_list_params.MessageListParams,
|
| 270 |
+
),
|
| 271 |
+
),
|
| 272 |
+
model=Message,
|
| 273 |
+
)
|
| 274 |
+
|
| 275 |
+
@typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
|
| 276 |
+
def delete(
|
| 277 |
+
self,
|
| 278 |
+
message_id: str,
|
| 279 |
+
*,
|
| 280 |
+
thread_id: str,
|
| 281 |
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
| 282 |
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
| 283 |
+
extra_headers: Headers | None = None,
|
| 284 |
+
extra_query: Query | None = None,
|
| 285 |
+
extra_body: Body | None = None,
|
| 286 |
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
| 287 |
+
) -> MessageDeleted:
|
| 288 |
+
"""
|
| 289 |
+
Deletes a message.
|
| 290 |
+
|
| 291 |
+
Args:
|
| 292 |
+
extra_headers: Send extra headers
|
| 293 |
+
|
| 294 |
+
extra_query: Add additional query parameters to the request
|
| 295 |
+
|
| 296 |
+
extra_body: Add additional JSON properties to the request
|
| 297 |
+
|
| 298 |
+
timeout: Override the client-level default timeout for this request, in seconds
|
| 299 |
+
"""
|
| 300 |
+
if not thread_id:
|
| 301 |
+
raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}")
|
| 302 |
+
if not message_id:
|
| 303 |
+
raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}")
|
| 304 |
+
extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
|
| 305 |
+
return self._delete(
|
| 306 |
+
f"/threads/{thread_id}/messages/{message_id}",
|
| 307 |
+
options=make_request_options(
|
| 308 |
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
| 309 |
+
),
|
| 310 |
+
cast_to=MessageDeleted,
|
| 311 |
+
)
|
| 312 |
+
|
| 313 |
+
|
| 314 |
+
class AsyncMessages(AsyncAPIResource):
|
| 315 |
+
@cached_property
|
| 316 |
+
def with_raw_response(self) -> AsyncMessagesWithRawResponse:
|
| 317 |
+
"""
|
| 318 |
+
This property can be used as a prefix for any HTTP method call to return
|
| 319 |
+
the raw response object instead of the parsed content.
|
| 320 |
+
|
| 321 |
+
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
|
| 322 |
+
"""
|
| 323 |
+
return AsyncMessagesWithRawResponse(self)
|
| 324 |
+
|
| 325 |
+
@cached_property
|
| 326 |
+
def with_streaming_response(self) -> AsyncMessagesWithStreamingResponse:
|
| 327 |
+
"""
|
| 328 |
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
| 329 |
+
|
| 330 |
+
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
|
| 331 |
+
"""
|
| 332 |
+
return AsyncMessagesWithStreamingResponse(self)
|
| 333 |
+
|
| 334 |
+
@typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
|
| 335 |
+
async def create(
|
| 336 |
+
self,
|
| 337 |
+
thread_id: str,
|
| 338 |
+
*,
|
| 339 |
+
content: Union[str, Iterable[MessageContentPartParam]],
|
| 340 |
+
role: Literal["user", "assistant"],
|
| 341 |
+
attachments: Optional[Iterable[message_create_params.Attachment]] | NotGiven = NOT_GIVEN,
|
| 342 |
+
metadata: Optional[Metadata] | NotGiven = NOT_GIVEN,
|
| 343 |
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
| 344 |
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
| 345 |
+
extra_headers: Headers | None = None,
|
| 346 |
+
extra_query: Query | None = None,
|
| 347 |
+
extra_body: Body | None = None,
|
| 348 |
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
| 349 |
+
) -> Message:
|
| 350 |
+
"""
|
| 351 |
+
Create a message.
|
| 352 |
+
|
| 353 |
+
Args:
|
| 354 |
+
content: The text contents of the message.
|
| 355 |
+
|
| 356 |
+
role:
|
| 357 |
+
The role of the entity that is creating the message. Allowed values include:
|
| 358 |
+
|
| 359 |
+
- `user`: Indicates the message is sent by an actual user and should be used in
|
| 360 |
+
most cases to represent user-generated messages.
|
| 361 |
+
- `assistant`: Indicates the message is generated by the assistant. Use this
|
| 362 |
+
value to insert messages from the assistant into the conversation.
|
| 363 |
+
|
| 364 |
+
attachments: A list of files attached to the message, and the tools they should be added to.
|
| 365 |
+
|
| 366 |
+
metadata: Set of 16 key-value pairs that can be attached to an object. This can be useful
|
| 367 |
+
for storing additional information about the object in a structured format, and
|
| 368 |
+
querying for objects via API or the dashboard.
|
| 369 |
+
|
| 370 |
+
Keys are strings with a maximum length of 64 characters. Values are strings with
|
| 371 |
+
a maximum length of 512 characters.
|
| 372 |
+
|
| 373 |
+
extra_headers: Send extra headers
|
| 374 |
+
|
| 375 |
+
extra_query: Add additional query parameters to the request
|
| 376 |
+
|
| 377 |
+
extra_body: Add additional JSON properties to the request
|
| 378 |
+
|
| 379 |
+
timeout: Override the client-level default timeout for this request, in seconds
|
| 380 |
+
"""
|
| 381 |
+
if not thread_id:
|
| 382 |
+
raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}")
|
| 383 |
+
extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
|
| 384 |
+
return await self._post(
|
| 385 |
+
f"/threads/{thread_id}/messages",
|
| 386 |
+
body=await async_maybe_transform(
|
| 387 |
+
{
|
| 388 |
+
"content": content,
|
| 389 |
+
"role": role,
|
| 390 |
+
"attachments": attachments,
|
| 391 |
+
"metadata": metadata,
|
| 392 |
+
},
|
| 393 |
+
message_create_params.MessageCreateParams,
|
| 394 |
+
),
|
| 395 |
+
options=make_request_options(
|
| 396 |
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
| 397 |
+
),
|
| 398 |
+
cast_to=Message,
|
| 399 |
+
)
|
| 400 |
+
|
| 401 |
+
@typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
|
| 402 |
+
async def retrieve(
|
| 403 |
+
self,
|
| 404 |
+
message_id: str,
|
| 405 |
+
*,
|
| 406 |
+
thread_id: str,
|
| 407 |
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
| 408 |
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
| 409 |
+
extra_headers: Headers | None = None,
|
| 410 |
+
extra_query: Query | None = None,
|
| 411 |
+
extra_body: Body | None = None,
|
| 412 |
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
| 413 |
+
) -> Message:
|
| 414 |
+
"""
|
| 415 |
+
Retrieve a message.
|
| 416 |
+
|
| 417 |
+
Args:
|
| 418 |
+
extra_headers: Send extra headers
|
| 419 |
+
|
| 420 |
+
extra_query: Add additional query parameters to the request
|
| 421 |
+
|
| 422 |
+
extra_body: Add additional JSON properties to the request
|
| 423 |
+
|
| 424 |
+
timeout: Override the client-level default timeout for this request, in seconds
|
| 425 |
+
"""
|
| 426 |
+
if not thread_id:
|
| 427 |
+
raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}")
|
| 428 |
+
if not message_id:
|
| 429 |
+
raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}")
|
| 430 |
+
extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
|
| 431 |
+
return await self._get(
|
| 432 |
+
f"/threads/{thread_id}/messages/{message_id}",
|
| 433 |
+
options=make_request_options(
|
| 434 |
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
| 435 |
+
),
|
| 436 |
+
cast_to=Message,
|
| 437 |
+
)
|
| 438 |
+
|
| 439 |
+
@typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
|
| 440 |
+
async def update(
|
| 441 |
+
self,
|
| 442 |
+
message_id: str,
|
| 443 |
+
*,
|
| 444 |
+
thread_id: str,
|
| 445 |
+
metadata: Optional[Metadata] | NotGiven = NOT_GIVEN,
|
| 446 |
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
| 447 |
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
| 448 |
+
extra_headers: Headers | None = None,
|
| 449 |
+
extra_query: Query | None = None,
|
| 450 |
+
extra_body: Body | None = None,
|
| 451 |
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
| 452 |
+
) -> Message:
|
| 453 |
+
"""
|
| 454 |
+
Modifies a message.
|
| 455 |
+
|
| 456 |
+
Args:
|
| 457 |
+
metadata: Set of 16 key-value pairs that can be attached to an object. This can be useful
|
| 458 |
+
for storing additional information about the object in a structured format, and
|
| 459 |
+
querying for objects via API or the dashboard.
|
| 460 |
+
|
| 461 |
+
Keys are strings with a maximum length of 64 characters. Values are strings with
|
| 462 |
+
a maximum length of 512 characters.
|
| 463 |
+
|
| 464 |
+
extra_headers: Send extra headers
|
| 465 |
+
|
| 466 |
+
extra_query: Add additional query parameters to the request
|
| 467 |
+
|
| 468 |
+
extra_body: Add additional JSON properties to the request
|
| 469 |
+
|
| 470 |
+
timeout: Override the client-level default timeout for this request, in seconds
|
| 471 |
+
"""
|
| 472 |
+
if not thread_id:
|
| 473 |
+
raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}")
|
| 474 |
+
if not message_id:
|
| 475 |
+
raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}")
|
| 476 |
+
extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
|
| 477 |
+
return await self._post(
|
| 478 |
+
f"/threads/{thread_id}/messages/{message_id}",
|
| 479 |
+
body=await async_maybe_transform({"metadata": metadata}, message_update_params.MessageUpdateParams),
|
| 480 |
+
options=make_request_options(
|
| 481 |
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
| 482 |
+
),
|
| 483 |
+
cast_to=Message,
|
| 484 |
+
)
|
| 485 |
+
|
| 486 |
+
@typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
|
| 487 |
+
def list(
|
| 488 |
+
self,
|
| 489 |
+
thread_id: str,
|
| 490 |
+
*,
|
| 491 |
+
after: str | NotGiven = NOT_GIVEN,
|
| 492 |
+
before: str | NotGiven = NOT_GIVEN,
|
| 493 |
+
limit: int | NotGiven = NOT_GIVEN,
|
| 494 |
+
order: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
|
| 495 |
+
run_id: str | NotGiven = NOT_GIVEN,
|
| 496 |
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
| 497 |
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
| 498 |
+
extra_headers: Headers | None = None,
|
| 499 |
+
extra_query: Query | None = None,
|
| 500 |
+
extra_body: Body | None = None,
|
| 501 |
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
| 502 |
+
) -> AsyncPaginator[Message, AsyncCursorPage[Message]]:
|
| 503 |
+
"""
|
| 504 |
+
Returns a list of messages for a given thread.
|
| 505 |
+
|
| 506 |
+
Args:
|
| 507 |
+
after: A cursor for use in pagination. `after` is an object ID that defines your place
|
| 508 |
+
in the list. For instance, if you make a list request and receive 100 objects,
|
| 509 |
+
ending with obj_foo, your subsequent call can include after=obj_foo in order to
|
| 510 |
+
fetch the next page of the list.
|
| 511 |
+
|
| 512 |
+
before: A cursor for use in pagination. `before` is an object ID that defines your place
|
| 513 |
+
in the list. For instance, if you make a list request and receive 100 objects,
|
| 514 |
+
starting with obj_foo, your subsequent call can include before=obj_foo in order
|
| 515 |
+
to fetch the previous page of the list.
|
| 516 |
+
|
| 517 |
+
limit: A limit on the number of objects to be returned. Limit can range between 1 and
|
| 518 |
+
100, and the default is 20.
|
| 519 |
+
|
| 520 |
+
order: Sort order by the `created_at` timestamp of the objects. `asc` for ascending
|
| 521 |
+
order and `desc` for descending order.
|
| 522 |
+
|
| 523 |
+
run_id: Filter messages by the run ID that generated them.
|
| 524 |
+
|
| 525 |
+
extra_headers: Send extra headers
|
| 526 |
+
|
| 527 |
+
extra_query: Add additional query parameters to the request
|
| 528 |
+
|
| 529 |
+
extra_body: Add additional JSON properties to the request
|
| 530 |
+
|
| 531 |
+
timeout: Override the client-level default timeout for this request, in seconds
|
| 532 |
+
"""
|
| 533 |
+
if not thread_id:
|
| 534 |
+
raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}")
|
| 535 |
+
extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
|
| 536 |
+
return self._get_api_list(
|
| 537 |
+
f"/threads/{thread_id}/messages",
|
| 538 |
+
page=AsyncCursorPage[Message],
|
| 539 |
+
options=make_request_options(
|
| 540 |
+
extra_headers=extra_headers,
|
| 541 |
+
extra_query=extra_query,
|
| 542 |
+
extra_body=extra_body,
|
| 543 |
+
timeout=timeout,
|
| 544 |
+
query=maybe_transform(
|
| 545 |
+
{
|
| 546 |
+
"after": after,
|
| 547 |
+
"before": before,
|
| 548 |
+
"limit": limit,
|
| 549 |
+
"order": order,
|
| 550 |
+
"run_id": run_id,
|
| 551 |
+
},
|
| 552 |
+
message_list_params.MessageListParams,
|
| 553 |
+
),
|
| 554 |
+
),
|
| 555 |
+
model=Message,
|
| 556 |
+
)
|
| 557 |
+
|
| 558 |
+
@typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
|
| 559 |
+
async def delete(
|
| 560 |
+
self,
|
| 561 |
+
message_id: str,
|
| 562 |
+
*,
|
| 563 |
+
thread_id: str,
|
| 564 |
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
| 565 |
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
| 566 |
+
extra_headers: Headers | None = None,
|
| 567 |
+
extra_query: Query | None = None,
|
| 568 |
+
extra_body: Body | None = None,
|
| 569 |
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
| 570 |
+
) -> MessageDeleted:
|
| 571 |
+
"""
|
| 572 |
+
Deletes a message.
|
| 573 |
+
|
| 574 |
+
Args:
|
| 575 |
+
extra_headers: Send extra headers
|
| 576 |
+
|
| 577 |
+
extra_query: Add additional query parameters to the request
|
| 578 |
+
|
| 579 |
+
extra_body: Add additional JSON properties to the request
|
| 580 |
+
|
| 581 |
+
timeout: Override the client-level default timeout for this request, in seconds
|
| 582 |
+
"""
|
| 583 |
+
if not thread_id:
|
| 584 |
+
raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}")
|
| 585 |
+
if not message_id:
|
| 586 |
+
raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}")
|
| 587 |
+
extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
|
| 588 |
+
return await self._delete(
|
| 589 |
+
f"/threads/{thread_id}/messages/{message_id}",
|
| 590 |
+
options=make_request_options(
|
| 591 |
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
| 592 |
+
),
|
| 593 |
+
cast_to=MessageDeleted,
|
| 594 |
+
)
|
| 595 |
+
|
| 596 |
+
|
| 597 |
+
class MessagesWithRawResponse:
|
| 598 |
+
def __init__(self, messages: Messages) -> None:
|
| 599 |
+
self._messages = messages
|
| 600 |
+
|
| 601 |
+
self.create = ( # pyright: ignore[reportDeprecated]
|
| 602 |
+
_legacy_response.to_raw_response_wrapper(
|
| 603 |
+
messages.create, # pyright: ignore[reportDeprecated],
|
| 604 |
+
)
|
| 605 |
+
)
|
| 606 |
+
self.retrieve = ( # pyright: ignore[reportDeprecated]
|
| 607 |
+
_legacy_response.to_raw_response_wrapper(
|
| 608 |
+
messages.retrieve, # pyright: ignore[reportDeprecated],
|
| 609 |
+
)
|
| 610 |
+
)
|
| 611 |
+
self.update = ( # pyright: ignore[reportDeprecated]
|
| 612 |
+
_legacy_response.to_raw_response_wrapper(
|
| 613 |
+
messages.update, # pyright: ignore[reportDeprecated],
|
| 614 |
+
)
|
| 615 |
+
)
|
| 616 |
+
self.list = ( # pyright: ignore[reportDeprecated]
|
| 617 |
+
_legacy_response.to_raw_response_wrapper(
|
| 618 |
+
messages.list, # pyright: ignore[reportDeprecated],
|
| 619 |
+
)
|
| 620 |
+
)
|
| 621 |
+
self.delete = ( # pyright: ignore[reportDeprecated]
|
| 622 |
+
_legacy_response.to_raw_response_wrapper(
|
| 623 |
+
messages.delete, # pyright: ignore[reportDeprecated],
|
| 624 |
+
)
|
| 625 |
+
)
|
| 626 |
+
|
| 627 |
+
|
| 628 |
+
class AsyncMessagesWithRawResponse:
|
| 629 |
+
def __init__(self, messages: AsyncMessages) -> None:
|
| 630 |
+
self._messages = messages
|
| 631 |
+
|
| 632 |
+
self.create = ( # pyright: ignore[reportDeprecated]
|
| 633 |
+
_legacy_response.async_to_raw_response_wrapper(
|
| 634 |
+
messages.create, # pyright: ignore[reportDeprecated],
|
| 635 |
+
)
|
| 636 |
+
)
|
| 637 |
+
self.retrieve = ( # pyright: ignore[reportDeprecated]
|
| 638 |
+
_legacy_response.async_to_raw_response_wrapper(
|
| 639 |
+
messages.retrieve, # pyright: ignore[reportDeprecated],
|
| 640 |
+
)
|
| 641 |
+
)
|
| 642 |
+
self.update = ( # pyright: ignore[reportDeprecated]
|
| 643 |
+
_legacy_response.async_to_raw_response_wrapper(
|
| 644 |
+
messages.update, # pyright: ignore[reportDeprecated],
|
| 645 |
+
)
|
| 646 |
+
)
|
| 647 |
+
self.list = ( # pyright: ignore[reportDeprecated]
|
| 648 |
+
_legacy_response.async_to_raw_response_wrapper(
|
| 649 |
+
messages.list, # pyright: ignore[reportDeprecated],
|
| 650 |
+
)
|
| 651 |
+
)
|
| 652 |
+
self.delete = ( # pyright: ignore[reportDeprecated]
|
| 653 |
+
_legacy_response.async_to_raw_response_wrapper(
|
| 654 |
+
messages.delete, # pyright: ignore[reportDeprecated],
|
| 655 |
+
)
|
| 656 |
+
)
|
| 657 |
+
|
| 658 |
+
|
| 659 |
+
class MessagesWithStreamingResponse:
|
| 660 |
+
def __init__(self, messages: Messages) -> None:
|
| 661 |
+
self._messages = messages
|
| 662 |
+
|
| 663 |
+
self.create = ( # pyright: ignore[reportDeprecated]
|
| 664 |
+
to_streamed_response_wrapper(
|
| 665 |
+
messages.create, # pyright: ignore[reportDeprecated],
|
| 666 |
+
)
|
| 667 |
+
)
|
| 668 |
+
self.retrieve = ( # pyright: ignore[reportDeprecated]
|
| 669 |
+
to_streamed_response_wrapper(
|
| 670 |
+
messages.retrieve, # pyright: ignore[reportDeprecated],
|
| 671 |
+
)
|
| 672 |
+
)
|
| 673 |
+
self.update = ( # pyright: ignore[reportDeprecated]
|
| 674 |
+
to_streamed_response_wrapper(
|
| 675 |
+
messages.update, # pyright: ignore[reportDeprecated],
|
| 676 |
+
)
|
| 677 |
+
)
|
| 678 |
+
self.list = ( # pyright: ignore[reportDeprecated]
|
| 679 |
+
to_streamed_response_wrapper(
|
| 680 |
+
messages.list, # pyright: ignore[reportDeprecated],
|
| 681 |
+
)
|
| 682 |
+
)
|
| 683 |
+
self.delete = ( # pyright: ignore[reportDeprecated]
|
| 684 |
+
to_streamed_response_wrapper(
|
| 685 |
+
messages.delete, # pyright: ignore[reportDeprecated],
|
| 686 |
+
)
|
| 687 |
+
)
|
| 688 |
+
|
| 689 |
+
|
| 690 |
+
class AsyncMessagesWithStreamingResponse:
|
| 691 |
+
def __init__(self, messages: AsyncMessages) -> None:
|
| 692 |
+
self._messages = messages
|
| 693 |
+
|
| 694 |
+
self.create = ( # pyright: ignore[reportDeprecated]
|
| 695 |
+
async_to_streamed_response_wrapper(
|
| 696 |
+
messages.create, # pyright: ignore[reportDeprecated],
|
| 697 |
+
)
|
| 698 |
+
)
|
| 699 |
+
self.retrieve = ( # pyright: ignore[reportDeprecated]
|
| 700 |
+
async_to_streamed_response_wrapper(
|
| 701 |
+
messages.retrieve, # pyright: ignore[reportDeprecated],
|
| 702 |
+
)
|
| 703 |
+
)
|
| 704 |
+
self.update = ( # pyright: ignore[reportDeprecated]
|
| 705 |
+
async_to_streamed_response_wrapper(
|
| 706 |
+
messages.update, # pyright: ignore[reportDeprecated],
|
| 707 |
+
)
|
| 708 |
+
)
|
| 709 |
+
self.list = ( # pyright: ignore[reportDeprecated]
|
| 710 |
+
async_to_streamed_response_wrapper(
|
| 711 |
+
messages.list, # pyright: ignore[reportDeprecated],
|
| 712 |
+
)
|
| 713 |
+
)
|
| 714 |
+
self.delete = ( # pyright: ignore[reportDeprecated]
|
| 715 |
+
async_to_streamed_response_wrapper(
|
| 716 |
+
messages.delete, # pyright: ignore[reportDeprecated],
|
| 717 |
+
)
|
| 718 |
+
)
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/threads/runs/__init__.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
| 2 |
+
|
| 3 |
+
from .runs import (
|
| 4 |
+
Runs,
|
| 5 |
+
AsyncRuns,
|
| 6 |
+
RunsWithRawResponse,
|
| 7 |
+
AsyncRunsWithRawResponse,
|
| 8 |
+
RunsWithStreamingResponse,
|
| 9 |
+
AsyncRunsWithStreamingResponse,
|
| 10 |
+
)
|
| 11 |
+
from .steps import (
|
| 12 |
+
Steps,
|
| 13 |
+
AsyncSteps,
|
| 14 |
+
StepsWithRawResponse,
|
| 15 |
+
AsyncStepsWithRawResponse,
|
| 16 |
+
StepsWithStreamingResponse,
|
| 17 |
+
AsyncStepsWithStreamingResponse,
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
__all__ = [
|
| 21 |
+
"Steps",
|
| 22 |
+
"AsyncSteps",
|
| 23 |
+
"StepsWithRawResponse",
|
| 24 |
+
"AsyncStepsWithRawResponse",
|
| 25 |
+
"StepsWithStreamingResponse",
|
| 26 |
+
"AsyncStepsWithStreamingResponse",
|
| 27 |
+
"Runs",
|
| 28 |
+
"AsyncRuns",
|
| 29 |
+
"RunsWithRawResponse",
|
| 30 |
+
"AsyncRunsWithRawResponse",
|
| 31 |
+
"RunsWithStreamingResponse",
|
| 32 |
+
"AsyncRunsWithStreamingResponse",
|
| 33 |
+
]
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/threads/runs/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (705 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/threads/runs/__pycache__/runs.cpython-312.pyc
ADDED
|
Binary file (79.5 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/threads/runs/__pycache__/steps.cpython-312.pyc
ADDED
|
Binary file (12.5 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/threads/runs/runs.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/threads/runs/steps.py
ADDED
|
@@ -0,0 +1,399 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
import typing_extensions
|
| 6 |
+
from typing import List
|
| 7 |
+
from typing_extensions import Literal
|
| 8 |
+
|
| 9 |
+
import httpx
|
| 10 |
+
|
| 11 |
+
from ..... import _legacy_response
|
| 12 |
+
from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven
|
| 13 |
+
from ....._utils import maybe_transform, async_maybe_transform
|
| 14 |
+
from ....._compat import cached_property
|
| 15 |
+
from ....._resource import SyncAPIResource, AsyncAPIResource
|
| 16 |
+
from ....._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
|
| 17 |
+
from .....pagination import SyncCursorPage, AsyncCursorPage
|
| 18 |
+
from ....._base_client import AsyncPaginator, make_request_options
|
| 19 |
+
from .....types.beta.threads.runs import step_list_params, step_retrieve_params
|
| 20 |
+
from .....types.beta.threads.runs.run_step import RunStep
|
| 21 |
+
from .....types.beta.threads.runs.run_step_include import RunStepInclude
|
| 22 |
+
|
| 23 |
+
__all__ = ["Steps", "AsyncSteps"]
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
class Steps(SyncAPIResource):
|
| 27 |
+
@cached_property
|
| 28 |
+
def with_raw_response(self) -> StepsWithRawResponse:
|
| 29 |
+
"""
|
| 30 |
+
This property can be used as a prefix for any HTTP method call to return
|
| 31 |
+
the raw response object instead of the parsed content.
|
| 32 |
+
|
| 33 |
+
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
|
| 34 |
+
"""
|
| 35 |
+
return StepsWithRawResponse(self)
|
| 36 |
+
|
| 37 |
+
@cached_property
|
| 38 |
+
def with_streaming_response(self) -> StepsWithStreamingResponse:
|
| 39 |
+
"""
|
| 40 |
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
| 41 |
+
|
| 42 |
+
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
|
| 43 |
+
"""
|
| 44 |
+
return StepsWithStreamingResponse(self)
|
| 45 |
+
|
| 46 |
+
@typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
|
| 47 |
+
def retrieve(
|
| 48 |
+
self,
|
| 49 |
+
step_id: str,
|
| 50 |
+
*,
|
| 51 |
+
thread_id: str,
|
| 52 |
+
run_id: str,
|
| 53 |
+
include: List[RunStepInclude] | NotGiven = NOT_GIVEN,
|
| 54 |
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
| 55 |
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
| 56 |
+
extra_headers: Headers | None = None,
|
| 57 |
+
extra_query: Query | None = None,
|
| 58 |
+
extra_body: Body | None = None,
|
| 59 |
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
| 60 |
+
) -> RunStep:
|
| 61 |
+
"""
|
| 62 |
+
Retrieves a run step.
|
| 63 |
+
|
| 64 |
+
Args:
|
| 65 |
+
include: A list of additional fields to include in the response. Currently the only
|
| 66 |
+
supported value is `step_details.tool_calls[*].file_search.results[*].content`
|
| 67 |
+
to fetch the file search result content.
|
| 68 |
+
|
| 69 |
+
See the
|
| 70 |
+
[file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
|
| 71 |
+
for more information.
|
| 72 |
+
|
| 73 |
+
extra_headers: Send extra headers
|
| 74 |
+
|
| 75 |
+
extra_query: Add additional query parameters to the request
|
| 76 |
+
|
| 77 |
+
extra_body: Add additional JSON properties to the request
|
| 78 |
+
|
| 79 |
+
timeout: Override the client-level default timeout for this request, in seconds
|
| 80 |
+
"""
|
| 81 |
+
if not thread_id:
|
| 82 |
+
raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}")
|
| 83 |
+
if not run_id:
|
| 84 |
+
raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}")
|
| 85 |
+
if not step_id:
|
| 86 |
+
raise ValueError(f"Expected a non-empty value for `step_id` but received {step_id!r}")
|
| 87 |
+
extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
|
| 88 |
+
return self._get(
|
| 89 |
+
f"/threads/{thread_id}/runs/{run_id}/steps/{step_id}",
|
| 90 |
+
options=make_request_options(
|
| 91 |
+
extra_headers=extra_headers,
|
| 92 |
+
extra_query=extra_query,
|
| 93 |
+
extra_body=extra_body,
|
| 94 |
+
timeout=timeout,
|
| 95 |
+
query=maybe_transform({"include": include}, step_retrieve_params.StepRetrieveParams),
|
| 96 |
+
),
|
| 97 |
+
cast_to=RunStep,
|
| 98 |
+
)
|
| 99 |
+
|
| 100 |
+
@typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
|
| 101 |
+
def list(
|
| 102 |
+
self,
|
| 103 |
+
run_id: str,
|
| 104 |
+
*,
|
| 105 |
+
thread_id: str,
|
| 106 |
+
after: str | NotGiven = NOT_GIVEN,
|
| 107 |
+
before: str | NotGiven = NOT_GIVEN,
|
| 108 |
+
include: List[RunStepInclude] | NotGiven = NOT_GIVEN,
|
| 109 |
+
limit: int | NotGiven = NOT_GIVEN,
|
| 110 |
+
order: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
|
| 111 |
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
| 112 |
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
| 113 |
+
extra_headers: Headers | None = None,
|
| 114 |
+
extra_query: Query | None = None,
|
| 115 |
+
extra_body: Body | None = None,
|
| 116 |
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
| 117 |
+
) -> SyncCursorPage[RunStep]:
|
| 118 |
+
"""
|
| 119 |
+
Returns a list of run steps belonging to a run.
|
| 120 |
+
|
| 121 |
+
Args:
|
| 122 |
+
after: A cursor for use in pagination. `after` is an object ID that defines your place
|
| 123 |
+
in the list. For instance, if you make a list request and receive 100 objects,
|
| 124 |
+
ending with obj_foo, your subsequent call can include after=obj_foo in order to
|
| 125 |
+
fetch the next page of the list.
|
| 126 |
+
|
| 127 |
+
before: A cursor for use in pagination. `before` is an object ID that defines your place
|
| 128 |
+
in the list. For instance, if you make a list request and receive 100 objects,
|
| 129 |
+
starting with obj_foo, your subsequent call can include before=obj_foo in order
|
| 130 |
+
to fetch the previous page of the list.
|
| 131 |
+
|
| 132 |
+
include: A list of additional fields to include in the response. Currently the only
|
| 133 |
+
supported value is `step_details.tool_calls[*].file_search.results[*].content`
|
| 134 |
+
to fetch the file search result content.
|
| 135 |
+
|
| 136 |
+
See the
|
| 137 |
+
[file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
|
| 138 |
+
for more information.
|
| 139 |
+
|
| 140 |
+
limit: A limit on the number of objects to be returned. Limit can range between 1 and
|
| 141 |
+
100, and the default is 20.
|
| 142 |
+
|
| 143 |
+
order: Sort order by the `created_at` timestamp of the objects. `asc` for ascending
|
| 144 |
+
order and `desc` for descending order.
|
| 145 |
+
|
| 146 |
+
extra_headers: Send extra headers
|
| 147 |
+
|
| 148 |
+
extra_query: Add additional query parameters to the request
|
| 149 |
+
|
| 150 |
+
extra_body: Add additional JSON properties to the request
|
| 151 |
+
|
| 152 |
+
timeout: Override the client-level default timeout for this request, in seconds
|
| 153 |
+
"""
|
| 154 |
+
if not thread_id:
|
| 155 |
+
raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}")
|
| 156 |
+
if not run_id:
|
| 157 |
+
raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}")
|
| 158 |
+
extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
|
| 159 |
+
return self._get_api_list(
|
| 160 |
+
f"/threads/{thread_id}/runs/{run_id}/steps",
|
| 161 |
+
page=SyncCursorPage[RunStep],
|
| 162 |
+
options=make_request_options(
|
| 163 |
+
extra_headers=extra_headers,
|
| 164 |
+
extra_query=extra_query,
|
| 165 |
+
extra_body=extra_body,
|
| 166 |
+
timeout=timeout,
|
| 167 |
+
query=maybe_transform(
|
| 168 |
+
{
|
| 169 |
+
"after": after,
|
| 170 |
+
"before": before,
|
| 171 |
+
"include": include,
|
| 172 |
+
"limit": limit,
|
| 173 |
+
"order": order,
|
| 174 |
+
},
|
| 175 |
+
step_list_params.StepListParams,
|
| 176 |
+
),
|
| 177 |
+
),
|
| 178 |
+
model=RunStep,
|
| 179 |
+
)
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
class AsyncSteps(AsyncAPIResource):
|
| 183 |
+
@cached_property
|
| 184 |
+
def with_raw_response(self) -> AsyncStepsWithRawResponse:
|
| 185 |
+
"""
|
| 186 |
+
This property can be used as a prefix for any HTTP method call to return
|
| 187 |
+
the raw response object instead of the parsed content.
|
| 188 |
+
|
| 189 |
+
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
|
| 190 |
+
"""
|
| 191 |
+
return AsyncStepsWithRawResponse(self)
|
| 192 |
+
|
| 193 |
+
@cached_property
|
| 194 |
+
def with_streaming_response(self) -> AsyncStepsWithStreamingResponse:
|
| 195 |
+
"""
|
| 196 |
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
| 197 |
+
|
| 198 |
+
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
|
| 199 |
+
"""
|
| 200 |
+
return AsyncStepsWithStreamingResponse(self)
|
| 201 |
+
|
| 202 |
+
@typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
|
| 203 |
+
async def retrieve(
|
| 204 |
+
self,
|
| 205 |
+
step_id: str,
|
| 206 |
+
*,
|
| 207 |
+
thread_id: str,
|
| 208 |
+
run_id: str,
|
| 209 |
+
include: List[RunStepInclude] | NotGiven = NOT_GIVEN,
|
| 210 |
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
| 211 |
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
| 212 |
+
extra_headers: Headers | None = None,
|
| 213 |
+
extra_query: Query | None = None,
|
| 214 |
+
extra_body: Body | None = None,
|
| 215 |
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
| 216 |
+
) -> RunStep:
|
| 217 |
+
"""
|
| 218 |
+
Retrieves a run step.
|
| 219 |
+
|
| 220 |
+
Args:
|
| 221 |
+
include: A list of additional fields to include in the response. Currently the only
|
| 222 |
+
supported value is `step_details.tool_calls[*].file_search.results[*].content`
|
| 223 |
+
to fetch the file search result content.
|
| 224 |
+
|
| 225 |
+
See the
|
| 226 |
+
[file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
|
| 227 |
+
for more information.
|
| 228 |
+
|
| 229 |
+
extra_headers: Send extra headers
|
| 230 |
+
|
| 231 |
+
extra_query: Add additional query parameters to the request
|
| 232 |
+
|
| 233 |
+
extra_body: Add additional JSON properties to the request
|
| 234 |
+
|
| 235 |
+
timeout: Override the client-level default timeout for this request, in seconds
|
| 236 |
+
"""
|
| 237 |
+
if not thread_id:
|
| 238 |
+
raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}")
|
| 239 |
+
if not run_id:
|
| 240 |
+
raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}")
|
| 241 |
+
if not step_id:
|
| 242 |
+
raise ValueError(f"Expected a non-empty value for `step_id` but received {step_id!r}")
|
| 243 |
+
extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
|
| 244 |
+
return await self._get(
|
| 245 |
+
f"/threads/{thread_id}/runs/{run_id}/steps/{step_id}",
|
| 246 |
+
options=make_request_options(
|
| 247 |
+
extra_headers=extra_headers,
|
| 248 |
+
extra_query=extra_query,
|
| 249 |
+
extra_body=extra_body,
|
| 250 |
+
timeout=timeout,
|
| 251 |
+
query=await async_maybe_transform({"include": include}, step_retrieve_params.StepRetrieveParams),
|
| 252 |
+
),
|
| 253 |
+
cast_to=RunStep,
|
| 254 |
+
)
|
| 255 |
+
|
| 256 |
+
@typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
|
| 257 |
+
def list(
|
| 258 |
+
self,
|
| 259 |
+
run_id: str,
|
| 260 |
+
*,
|
| 261 |
+
thread_id: str,
|
| 262 |
+
after: str | NotGiven = NOT_GIVEN,
|
| 263 |
+
before: str | NotGiven = NOT_GIVEN,
|
| 264 |
+
include: List[RunStepInclude] | NotGiven = NOT_GIVEN,
|
| 265 |
+
limit: int | NotGiven = NOT_GIVEN,
|
| 266 |
+
order: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
|
| 267 |
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
| 268 |
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
| 269 |
+
extra_headers: Headers | None = None,
|
| 270 |
+
extra_query: Query | None = None,
|
| 271 |
+
extra_body: Body | None = None,
|
| 272 |
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
| 273 |
+
) -> AsyncPaginator[RunStep, AsyncCursorPage[RunStep]]:
|
| 274 |
+
"""
|
| 275 |
+
Returns a list of run steps belonging to a run.
|
| 276 |
+
|
| 277 |
+
Args:
|
| 278 |
+
after: A cursor for use in pagination. `after` is an object ID that defines your place
|
| 279 |
+
in the list. For instance, if you make a list request and receive 100 objects,
|
| 280 |
+
ending with obj_foo, your subsequent call can include after=obj_foo in order to
|
| 281 |
+
fetch the next page of the list.
|
| 282 |
+
|
| 283 |
+
before: A cursor for use in pagination. `before` is an object ID that defines your place
|
| 284 |
+
in the list. For instance, if you make a list request and receive 100 objects,
|
| 285 |
+
starting with obj_foo, your subsequent call can include before=obj_foo in order
|
| 286 |
+
to fetch the previous page of the list.
|
| 287 |
+
|
| 288 |
+
include: A list of additional fields to include in the response. Currently the only
|
| 289 |
+
supported value is `step_details.tool_calls[*].file_search.results[*].content`
|
| 290 |
+
to fetch the file search result content.
|
| 291 |
+
|
| 292 |
+
See the
|
| 293 |
+
[file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
|
| 294 |
+
for more information.
|
| 295 |
+
|
| 296 |
+
limit: A limit on the number of objects to be returned. Limit can range between 1 and
|
| 297 |
+
100, and the default is 20.
|
| 298 |
+
|
| 299 |
+
order: Sort order by the `created_at` timestamp of the objects. `asc` for ascending
|
| 300 |
+
order and `desc` for descending order.
|
| 301 |
+
|
| 302 |
+
extra_headers: Send extra headers
|
| 303 |
+
|
| 304 |
+
extra_query: Add additional query parameters to the request
|
| 305 |
+
|
| 306 |
+
extra_body: Add additional JSON properties to the request
|
| 307 |
+
|
| 308 |
+
timeout: Override the client-level default timeout for this request, in seconds
|
| 309 |
+
"""
|
| 310 |
+
if not thread_id:
|
| 311 |
+
raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}")
|
| 312 |
+
if not run_id:
|
| 313 |
+
raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}")
|
| 314 |
+
extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
|
| 315 |
+
return self._get_api_list(
|
| 316 |
+
f"/threads/{thread_id}/runs/{run_id}/steps",
|
| 317 |
+
page=AsyncCursorPage[RunStep],
|
| 318 |
+
options=make_request_options(
|
| 319 |
+
extra_headers=extra_headers,
|
| 320 |
+
extra_query=extra_query,
|
| 321 |
+
extra_body=extra_body,
|
| 322 |
+
timeout=timeout,
|
| 323 |
+
query=maybe_transform(
|
| 324 |
+
{
|
| 325 |
+
"after": after,
|
| 326 |
+
"before": before,
|
| 327 |
+
"include": include,
|
| 328 |
+
"limit": limit,
|
| 329 |
+
"order": order,
|
| 330 |
+
},
|
| 331 |
+
step_list_params.StepListParams,
|
| 332 |
+
),
|
| 333 |
+
),
|
| 334 |
+
model=RunStep,
|
| 335 |
+
)
|
| 336 |
+
|
| 337 |
+
|
| 338 |
+
class StepsWithRawResponse:
|
| 339 |
+
def __init__(self, steps: Steps) -> None:
|
| 340 |
+
self._steps = steps
|
| 341 |
+
|
| 342 |
+
self.retrieve = ( # pyright: ignore[reportDeprecated]
|
| 343 |
+
_legacy_response.to_raw_response_wrapper(
|
| 344 |
+
steps.retrieve, # pyright: ignore[reportDeprecated],
|
| 345 |
+
)
|
| 346 |
+
)
|
| 347 |
+
self.list = ( # pyright: ignore[reportDeprecated]
|
| 348 |
+
_legacy_response.to_raw_response_wrapper(
|
| 349 |
+
steps.list, # pyright: ignore[reportDeprecated],
|
| 350 |
+
)
|
| 351 |
+
)
|
| 352 |
+
|
| 353 |
+
|
| 354 |
+
class AsyncStepsWithRawResponse:
|
| 355 |
+
def __init__(self, steps: AsyncSteps) -> None:
|
| 356 |
+
self._steps = steps
|
| 357 |
+
|
| 358 |
+
self.retrieve = ( # pyright: ignore[reportDeprecated]
|
| 359 |
+
_legacy_response.async_to_raw_response_wrapper(
|
| 360 |
+
steps.retrieve, # pyright: ignore[reportDeprecated],
|
| 361 |
+
)
|
| 362 |
+
)
|
| 363 |
+
self.list = ( # pyright: ignore[reportDeprecated]
|
| 364 |
+
_legacy_response.async_to_raw_response_wrapper(
|
| 365 |
+
steps.list, # pyright: ignore[reportDeprecated],
|
| 366 |
+
)
|
| 367 |
+
)
|
| 368 |
+
|
| 369 |
+
|
| 370 |
+
class StepsWithStreamingResponse:
|
| 371 |
+
def __init__(self, steps: Steps) -> None:
|
| 372 |
+
self._steps = steps
|
| 373 |
+
|
| 374 |
+
self.retrieve = ( # pyright: ignore[reportDeprecated]
|
| 375 |
+
to_streamed_response_wrapper(
|
| 376 |
+
steps.retrieve, # pyright: ignore[reportDeprecated],
|
| 377 |
+
)
|
| 378 |
+
)
|
| 379 |
+
self.list = ( # pyright: ignore[reportDeprecated]
|
| 380 |
+
to_streamed_response_wrapper(
|
| 381 |
+
steps.list, # pyright: ignore[reportDeprecated],
|
| 382 |
+
)
|
| 383 |
+
)
|
| 384 |
+
|
| 385 |
+
|
| 386 |
+
class AsyncStepsWithStreamingResponse:
|
| 387 |
+
def __init__(self, steps: AsyncSteps) -> None:
|
| 388 |
+
self._steps = steps
|
| 389 |
+
|
| 390 |
+
self.retrieve = ( # pyright: ignore[reportDeprecated]
|
| 391 |
+
async_to_streamed_response_wrapper(
|
| 392 |
+
steps.retrieve, # pyright: ignore[reportDeprecated],
|
| 393 |
+
)
|
| 394 |
+
)
|
| 395 |
+
self.list = ( # pyright: ignore[reportDeprecated]
|
| 396 |
+
async_to_streamed_response_wrapper(
|
| 397 |
+
steps.list, # pyright: ignore[reportDeprecated],
|
| 398 |
+
)
|
| 399 |
+
)
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/beta/threads/threads.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/chat/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (734 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/chat/__pycache__/chat.cpython-312.pyc
ADDED
|
Binary file (5.03 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/chat/completions/__init__.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
| 2 |
+
|
| 3 |
+
from .messages import (
|
| 4 |
+
Messages,
|
| 5 |
+
AsyncMessages,
|
| 6 |
+
MessagesWithRawResponse,
|
| 7 |
+
AsyncMessagesWithRawResponse,
|
| 8 |
+
MessagesWithStreamingResponse,
|
| 9 |
+
AsyncMessagesWithStreamingResponse,
|
| 10 |
+
)
|
| 11 |
+
from .completions import (
|
| 12 |
+
Completions,
|
| 13 |
+
AsyncCompletions,
|
| 14 |
+
CompletionsWithRawResponse,
|
| 15 |
+
AsyncCompletionsWithRawResponse,
|
| 16 |
+
CompletionsWithStreamingResponse,
|
| 17 |
+
AsyncCompletionsWithStreamingResponse,
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
__all__ = [
|
| 21 |
+
"Messages",
|
| 22 |
+
"AsyncMessages",
|
| 23 |
+
"MessagesWithRawResponse",
|
| 24 |
+
"AsyncMessagesWithRawResponse",
|
| 25 |
+
"MessagesWithStreamingResponse",
|
| 26 |
+
"AsyncMessagesWithStreamingResponse",
|
| 27 |
+
"Completions",
|
| 28 |
+
"AsyncCompletions",
|
| 29 |
+
"CompletionsWithRawResponse",
|
| 30 |
+
"AsyncCompletionsWithRawResponse",
|
| 31 |
+
"CompletionsWithStreamingResponse",
|
| 32 |
+
"AsyncCompletionsWithStreamingResponse",
|
| 33 |
+
]
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/chat/completions/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (774 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/chat/completions/__pycache__/completions.cpython-312.pyc
ADDED
|
Binary file (78.6 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/chat/completions/__pycache__/messages.cpython-312.pyc
ADDED
|
Binary file (7.29 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/chat/completions/completions.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/chat/completions/messages.py
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
from typing_extensions import Literal
|
| 6 |
+
|
| 7 |
+
import httpx
|
| 8 |
+
|
| 9 |
+
from .... import _legacy_response
|
| 10 |
+
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
|
| 11 |
+
from ...._utils import maybe_transform
|
| 12 |
+
from ...._compat import cached_property
|
| 13 |
+
from ...._resource import SyncAPIResource, AsyncAPIResource
|
| 14 |
+
from ...._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
|
| 15 |
+
from ....pagination import SyncCursorPage, AsyncCursorPage
|
| 16 |
+
from ...._base_client import AsyncPaginator, make_request_options
|
| 17 |
+
from ....types.chat.completions import message_list_params
|
| 18 |
+
from ....types.chat.chat_completion_store_message import ChatCompletionStoreMessage
|
| 19 |
+
|
| 20 |
+
__all__ = ["Messages", "AsyncMessages"]
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
class Messages(SyncAPIResource):
|
| 24 |
+
@cached_property
|
| 25 |
+
def with_raw_response(self) -> MessagesWithRawResponse:
|
| 26 |
+
"""
|
| 27 |
+
This property can be used as a prefix for any HTTP method call to return
|
| 28 |
+
the raw response object instead of the parsed content.
|
| 29 |
+
|
| 30 |
+
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
|
| 31 |
+
"""
|
| 32 |
+
return MessagesWithRawResponse(self)
|
| 33 |
+
|
| 34 |
+
@cached_property
|
| 35 |
+
def with_streaming_response(self) -> MessagesWithStreamingResponse:
|
| 36 |
+
"""
|
| 37 |
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
| 38 |
+
|
| 39 |
+
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
|
| 40 |
+
"""
|
| 41 |
+
return MessagesWithStreamingResponse(self)
|
| 42 |
+
|
| 43 |
+
def list(
|
| 44 |
+
self,
|
| 45 |
+
completion_id: str,
|
| 46 |
+
*,
|
| 47 |
+
after: str | NotGiven = NOT_GIVEN,
|
| 48 |
+
limit: int | NotGiven = NOT_GIVEN,
|
| 49 |
+
order: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
|
| 50 |
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
| 51 |
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
| 52 |
+
extra_headers: Headers | None = None,
|
| 53 |
+
extra_query: Query | None = None,
|
| 54 |
+
extra_body: Body | None = None,
|
| 55 |
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
| 56 |
+
) -> SyncCursorPage[ChatCompletionStoreMessage]:
|
| 57 |
+
"""Get the messages in a stored chat completion.
|
| 58 |
+
|
| 59 |
+
Only Chat Completions that have
|
| 60 |
+
been created with the `store` parameter set to `true` will be returned.
|
| 61 |
+
|
| 62 |
+
Args:
|
| 63 |
+
after: Identifier for the last message from the previous pagination request.
|
| 64 |
+
|
| 65 |
+
limit: Number of messages to retrieve.
|
| 66 |
+
|
| 67 |
+
order: Sort order for messages by timestamp. Use `asc` for ascending order or `desc`
|
| 68 |
+
for descending order. Defaults to `asc`.
|
| 69 |
+
|
| 70 |
+
extra_headers: Send extra headers
|
| 71 |
+
|
| 72 |
+
extra_query: Add additional query parameters to the request
|
| 73 |
+
|
| 74 |
+
extra_body: Add additional JSON properties to the request
|
| 75 |
+
|
| 76 |
+
timeout: Override the client-level default timeout for this request, in seconds
|
| 77 |
+
"""
|
| 78 |
+
if not completion_id:
|
| 79 |
+
raise ValueError(f"Expected a non-empty value for `completion_id` but received {completion_id!r}")
|
| 80 |
+
return self._get_api_list(
|
| 81 |
+
f"/chat/completions/{completion_id}/messages",
|
| 82 |
+
page=SyncCursorPage[ChatCompletionStoreMessage],
|
| 83 |
+
options=make_request_options(
|
| 84 |
+
extra_headers=extra_headers,
|
| 85 |
+
extra_query=extra_query,
|
| 86 |
+
extra_body=extra_body,
|
| 87 |
+
timeout=timeout,
|
| 88 |
+
query=maybe_transform(
|
| 89 |
+
{
|
| 90 |
+
"after": after,
|
| 91 |
+
"limit": limit,
|
| 92 |
+
"order": order,
|
| 93 |
+
},
|
| 94 |
+
message_list_params.MessageListParams,
|
| 95 |
+
),
|
| 96 |
+
),
|
| 97 |
+
model=ChatCompletionStoreMessage,
|
| 98 |
+
)
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
class AsyncMessages(AsyncAPIResource):
|
| 102 |
+
@cached_property
|
| 103 |
+
def with_raw_response(self) -> AsyncMessagesWithRawResponse:
|
| 104 |
+
"""
|
| 105 |
+
This property can be used as a prefix for any HTTP method call to return
|
| 106 |
+
the raw response object instead of the parsed content.
|
| 107 |
+
|
| 108 |
+
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
|
| 109 |
+
"""
|
| 110 |
+
return AsyncMessagesWithRawResponse(self)
|
| 111 |
+
|
| 112 |
+
@cached_property
|
| 113 |
+
def with_streaming_response(self) -> AsyncMessagesWithStreamingResponse:
|
| 114 |
+
"""
|
| 115 |
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
| 116 |
+
|
| 117 |
+
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
|
| 118 |
+
"""
|
| 119 |
+
return AsyncMessagesWithStreamingResponse(self)
|
| 120 |
+
|
| 121 |
+
def list(
|
| 122 |
+
self,
|
| 123 |
+
completion_id: str,
|
| 124 |
+
*,
|
| 125 |
+
after: str | NotGiven = NOT_GIVEN,
|
| 126 |
+
limit: int | NotGiven = NOT_GIVEN,
|
| 127 |
+
order: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
|
| 128 |
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
| 129 |
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
| 130 |
+
extra_headers: Headers | None = None,
|
| 131 |
+
extra_query: Query | None = None,
|
| 132 |
+
extra_body: Body | None = None,
|
| 133 |
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
| 134 |
+
) -> AsyncPaginator[ChatCompletionStoreMessage, AsyncCursorPage[ChatCompletionStoreMessage]]:
|
| 135 |
+
"""Get the messages in a stored chat completion.
|
| 136 |
+
|
| 137 |
+
Only Chat Completions that have
|
| 138 |
+
been created with the `store` parameter set to `true` will be returned.
|
| 139 |
+
|
| 140 |
+
Args:
|
| 141 |
+
after: Identifier for the last message from the previous pagination request.
|
| 142 |
+
|
| 143 |
+
limit: Number of messages to retrieve.
|
| 144 |
+
|
| 145 |
+
order: Sort order for messages by timestamp. Use `asc` for ascending order or `desc`
|
| 146 |
+
for descending order. Defaults to `asc`.
|
| 147 |
+
|
| 148 |
+
extra_headers: Send extra headers
|
| 149 |
+
|
| 150 |
+
extra_query: Add additional query parameters to the request
|
| 151 |
+
|
| 152 |
+
extra_body: Add additional JSON properties to the request
|
| 153 |
+
|
| 154 |
+
timeout: Override the client-level default timeout for this request, in seconds
|
| 155 |
+
"""
|
| 156 |
+
if not completion_id:
|
| 157 |
+
raise ValueError(f"Expected a non-empty value for `completion_id` but received {completion_id!r}")
|
| 158 |
+
return self._get_api_list(
|
| 159 |
+
f"/chat/completions/{completion_id}/messages",
|
| 160 |
+
page=AsyncCursorPage[ChatCompletionStoreMessage],
|
| 161 |
+
options=make_request_options(
|
| 162 |
+
extra_headers=extra_headers,
|
| 163 |
+
extra_query=extra_query,
|
| 164 |
+
extra_body=extra_body,
|
| 165 |
+
timeout=timeout,
|
| 166 |
+
query=maybe_transform(
|
| 167 |
+
{
|
| 168 |
+
"after": after,
|
| 169 |
+
"limit": limit,
|
| 170 |
+
"order": order,
|
| 171 |
+
},
|
| 172 |
+
message_list_params.MessageListParams,
|
| 173 |
+
),
|
| 174 |
+
),
|
| 175 |
+
model=ChatCompletionStoreMessage,
|
| 176 |
+
)
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
class MessagesWithRawResponse:
|
| 180 |
+
def __init__(self, messages: Messages) -> None:
|
| 181 |
+
self._messages = messages
|
| 182 |
+
|
| 183 |
+
self.list = _legacy_response.to_raw_response_wrapper(
|
| 184 |
+
messages.list,
|
| 185 |
+
)
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
class AsyncMessagesWithRawResponse:
|
| 189 |
+
def __init__(self, messages: AsyncMessages) -> None:
|
| 190 |
+
self._messages = messages
|
| 191 |
+
|
| 192 |
+
self.list = _legacy_response.async_to_raw_response_wrapper(
|
| 193 |
+
messages.list,
|
| 194 |
+
)
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
class MessagesWithStreamingResponse:
|
| 198 |
+
def __init__(self, messages: Messages) -> None:
|
| 199 |
+
self._messages = messages
|
| 200 |
+
|
| 201 |
+
self.list = to_streamed_response_wrapper(
|
| 202 |
+
messages.list,
|
| 203 |
+
)
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
class AsyncMessagesWithStreamingResponse:
|
| 207 |
+
def __init__(self, messages: AsyncMessages) -> None:
|
| 208 |
+
self._messages = messages
|
| 209 |
+
|
| 210 |
+
self.list = async_to_streamed_response_wrapper(
|
| 211 |
+
messages.list,
|
| 212 |
+
)
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/containers/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (740 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/containers/__pycache__/containers.cpython-312.pyc
ADDED
|
Binary file (15.3 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/containers/files/__init__.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
| 2 |
+
|
| 3 |
+
from .files import (
|
| 4 |
+
Files,
|
| 5 |
+
AsyncFiles,
|
| 6 |
+
FilesWithRawResponse,
|
| 7 |
+
AsyncFilesWithRawResponse,
|
| 8 |
+
FilesWithStreamingResponse,
|
| 9 |
+
AsyncFilesWithStreamingResponse,
|
| 10 |
+
)
|
| 11 |
+
from .content import (
|
| 12 |
+
Content,
|
| 13 |
+
AsyncContent,
|
| 14 |
+
ContentWithRawResponse,
|
| 15 |
+
AsyncContentWithRawResponse,
|
| 16 |
+
ContentWithStreamingResponse,
|
| 17 |
+
AsyncContentWithStreamingResponse,
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
__all__ = [
|
| 21 |
+
"Content",
|
| 22 |
+
"AsyncContent",
|
| 23 |
+
"ContentWithRawResponse",
|
| 24 |
+
"AsyncContentWithRawResponse",
|
| 25 |
+
"ContentWithStreamingResponse",
|
| 26 |
+
"AsyncContentWithStreamingResponse",
|
| 27 |
+
"Files",
|
| 28 |
+
"AsyncFiles",
|
| 29 |
+
"FilesWithRawResponse",
|
| 30 |
+
"AsyncFilesWithRawResponse",
|
| 31 |
+
"FilesWithStreamingResponse",
|
| 32 |
+
"AsyncFilesWithStreamingResponse",
|
| 33 |
+
]
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/containers/files/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (725 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/openai/resources/containers/files/__pycache__/content.cpython-312.pyc
ADDED
|
Binary file (6.4 kB). View file
|
|
|