openai-agents 0.1.0__py3-none-any.whl → 0.2.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of openai-agents might be problematic. Click here for more details.
- agents/__init__.py +5 -1
- agents/_run_impl.py +5 -1
- agents/agent.py +62 -30
- agents/agent_output.py +2 -2
- agents/function_schema.py +11 -1
- agents/guardrail.py +5 -1
- agents/handoffs.py +32 -14
- agents/lifecycle.py +26 -17
- agents/mcp/server.py +82 -11
- agents/mcp/util.py +16 -9
- agents/memory/__init__.py +3 -0
- agents/memory/session.py +369 -0
- agents/model_settings.py +15 -7
- agents/models/chatcmpl_converter.py +20 -3
- agents/models/chatcmpl_stream_handler.py +134 -43
- agents/models/openai_responses.py +12 -5
- agents/realtime/README.md +3 -0
- agents/realtime/__init__.py +177 -0
- agents/realtime/agent.py +89 -0
- agents/realtime/config.py +188 -0
- agents/realtime/events.py +216 -0
- agents/realtime/handoffs.py +165 -0
- agents/realtime/items.py +184 -0
- agents/realtime/model.py +69 -0
- agents/realtime/model_events.py +159 -0
- agents/realtime/model_inputs.py +100 -0
- agents/realtime/openai_realtime.py +670 -0
- agents/realtime/runner.py +118 -0
- agents/realtime/session.py +535 -0
- agents/run.py +106 -4
- agents/tool.py +6 -7
- agents/tool_context.py +16 -3
- agents/voice/models/openai_stt.py +1 -1
- agents/voice/pipeline.py +6 -0
- agents/voice/workflow.py +8 -0
- {openai_agents-0.1.0.dist-info → openai_agents-0.2.1.dist-info}/METADATA +121 -4
- {openai_agents-0.1.0.dist-info → openai_agents-0.2.1.dist-info}/RECORD +39 -24
- {openai_agents-0.1.0.dist-info → openai_agents-0.2.1.dist-info}/WHEEL +0 -0
- {openai_agents-0.1.0.dist-info → openai_agents-0.2.1.dist-info}/licenses/LICENSE +0 -0
agents/realtime/items.py
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Annotated, Literal, Union
|
|
4
|
+
|
|
5
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class InputText(BaseModel):
|
|
9
|
+
"""Text input content for realtime messages."""
|
|
10
|
+
|
|
11
|
+
type: Literal["input_text"] = "input_text"
|
|
12
|
+
"""The type identifier for text input."""
|
|
13
|
+
|
|
14
|
+
text: str | None = None
|
|
15
|
+
"""The text content."""
|
|
16
|
+
|
|
17
|
+
# Allow extra data
|
|
18
|
+
model_config = ConfigDict(extra="allow")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class InputAudio(BaseModel):
|
|
22
|
+
"""Audio input content for realtime messages."""
|
|
23
|
+
|
|
24
|
+
type: Literal["input_audio"] = "input_audio"
|
|
25
|
+
"""The type identifier for audio input."""
|
|
26
|
+
|
|
27
|
+
audio: str | None = None
|
|
28
|
+
"""The base64-encoded audio data."""
|
|
29
|
+
|
|
30
|
+
transcript: str | None = None
|
|
31
|
+
"""The transcript of the audio, if available."""
|
|
32
|
+
|
|
33
|
+
# Allow extra data
|
|
34
|
+
model_config = ConfigDict(extra="allow")
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class AssistantText(BaseModel):
|
|
38
|
+
"""Text content from the assistant in realtime responses."""
|
|
39
|
+
|
|
40
|
+
type: Literal["text"] = "text"
|
|
41
|
+
"""The type identifier for text content."""
|
|
42
|
+
|
|
43
|
+
text: str | None = None
|
|
44
|
+
"""The text content from the assistant."""
|
|
45
|
+
|
|
46
|
+
# Allow extra data
|
|
47
|
+
model_config = ConfigDict(extra="allow")
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class AssistantAudio(BaseModel):
|
|
51
|
+
"""Audio content from the assistant in realtime responses."""
|
|
52
|
+
|
|
53
|
+
type: Literal["audio"] = "audio"
|
|
54
|
+
"""The type identifier for audio content."""
|
|
55
|
+
|
|
56
|
+
audio: str | None = None
|
|
57
|
+
"""The base64-encoded audio data from the assistant."""
|
|
58
|
+
|
|
59
|
+
transcript: str | None = None
|
|
60
|
+
"""The transcript of the audio response."""
|
|
61
|
+
|
|
62
|
+
# Allow extra data
|
|
63
|
+
model_config = ConfigDict(extra="allow")
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class SystemMessageItem(BaseModel):
|
|
67
|
+
"""A system message item in realtime conversations."""
|
|
68
|
+
|
|
69
|
+
item_id: str
|
|
70
|
+
"""Unique identifier for this message item."""
|
|
71
|
+
|
|
72
|
+
previous_item_id: str | None = None
|
|
73
|
+
"""ID of the previous item in the conversation."""
|
|
74
|
+
|
|
75
|
+
type: Literal["message"] = "message"
|
|
76
|
+
"""The type identifier for message items."""
|
|
77
|
+
|
|
78
|
+
role: Literal["system"] = "system"
|
|
79
|
+
"""The role identifier for system messages."""
|
|
80
|
+
|
|
81
|
+
content: list[InputText]
|
|
82
|
+
"""List of text content for the system message."""
|
|
83
|
+
|
|
84
|
+
# Allow extra data
|
|
85
|
+
model_config = ConfigDict(extra="allow")
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class UserMessageItem(BaseModel):
|
|
89
|
+
"""A user message item in realtime conversations."""
|
|
90
|
+
|
|
91
|
+
item_id: str
|
|
92
|
+
"""Unique identifier for this message item."""
|
|
93
|
+
|
|
94
|
+
previous_item_id: str | None = None
|
|
95
|
+
"""ID of the previous item in the conversation."""
|
|
96
|
+
|
|
97
|
+
type: Literal["message"] = "message"
|
|
98
|
+
"""The type identifier for message items."""
|
|
99
|
+
|
|
100
|
+
role: Literal["user"] = "user"
|
|
101
|
+
"""The role identifier for user messages."""
|
|
102
|
+
|
|
103
|
+
content: list[Annotated[InputText | InputAudio, Field(discriminator="type")]]
|
|
104
|
+
"""List of content items, can be text or audio."""
|
|
105
|
+
|
|
106
|
+
# Allow extra data
|
|
107
|
+
model_config = ConfigDict(extra="allow")
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
class AssistantMessageItem(BaseModel):
|
|
111
|
+
"""An assistant message item in realtime conversations."""
|
|
112
|
+
|
|
113
|
+
item_id: str
|
|
114
|
+
"""Unique identifier for this message item."""
|
|
115
|
+
|
|
116
|
+
previous_item_id: str | None = None
|
|
117
|
+
"""ID of the previous item in the conversation."""
|
|
118
|
+
|
|
119
|
+
type: Literal["message"] = "message"
|
|
120
|
+
"""The type identifier for message items."""
|
|
121
|
+
|
|
122
|
+
role: Literal["assistant"] = "assistant"
|
|
123
|
+
"""The role identifier for assistant messages."""
|
|
124
|
+
|
|
125
|
+
status: Literal["in_progress", "completed", "incomplete"] | None = None
|
|
126
|
+
"""The status of the assistant's response."""
|
|
127
|
+
|
|
128
|
+
content: list[Annotated[AssistantText | AssistantAudio, Field(discriminator="type")]]
|
|
129
|
+
"""List of content items from the assistant, can be text or audio."""
|
|
130
|
+
|
|
131
|
+
# Allow extra data
|
|
132
|
+
model_config = ConfigDict(extra="allow")
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
RealtimeMessageItem = Annotated[
|
|
136
|
+
Union[SystemMessageItem, UserMessageItem, AssistantMessageItem],
|
|
137
|
+
Field(discriminator="role"),
|
|
138
|
+
]
|
|
139
|
+
"""A message item that can be from system, user, or assistant."""
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
class RealtimeToolCallItem(BaseModel):
|
|
143
|
+
"""A tool call item in realtime conversations."""
|
|
144
|
+
|
|
145
|
+
item_id: str
|
|
146
|
+
"""Unique identifier for this tool call item."""
|
|
147
|
+
|
|
148
|
+
previous_item_id: str | None = None
|
|
149
|
+
"""ID of the previous item in the conversation."""
|
|
150
|
+
|
|
151
|
+
call_id: str | None
|
|
152
|
+
"""The call ID for this tool invocation."""
|
|
153
|
+
|
|
154
|
+
type: Literal["function_call"] = "function_call"
|
|
155
|
+
"""The type identifier for function call items."""
|
|
156
|
+
|
|
157
|
+
status: Literal["in_progress", "completed"]
|
|
158
|
+
"""The status of the tool call execution."""
|
|
159
|
+
|
|
160
|
+
arguments: str
|
|
161
|
+
"""The JSON string arguments passed to the tool."""
|
|
162
|
+
|
|
163
|
+
name: str
|
|
164
|
+
"""The name of the tool being called."""
|
|
165
|
+
|
|
166
|
+
output: str | None = None
|
|
167
|
+
"""The output result from the tool execution."""
|
|
168
|
+
|
|
169
|
+
# Allow extra data
|
|
170
|
+
model_config = ConfigDict(extra="allow")
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
RealtimeItem = Union[RealtimeMessageItem, RealtimeToolCallItem]
|
|
174
|
+
"""A realtime item that can be a message or tool call."""
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
class RealtimeResponse(BaseModel):
|
|
178
|
+
"""A response from the realtime model."""
|
|
179
|
+
|
|
180
|
+
id: str
|
|
181
|
+
"""Unique identifier for this response."""
|
|
182
|
+
|
|
183
|
+
output: list[RealtimeMessageItem]
|
|
184
|
+
"""List of message items in the response."""
|
agents/realtime/model.py
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import abc
|
|
4
|
+
from typing import Callable
|
|
5
|
+
|
|
6
|
+
from typing_extensions import NotRequired, TypedDict
|
|
7
|
+
|
|
8
|
+
from ..util._types import MaybeAwaitable
|
|
9
|
+
from .config import (
|
|
10
|
+
RealtimeSessionModelSettings,
|
|
11
|
+
)
|
|
12
|
+
from .model_events import RealtimeModelEvent
|
|
13
|
+
from .model_inputs import RealtimeModelSendEvent
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class RealtimeModelListener(abc.ABC):
|
|
17
|
+
"""A listener for realtime transport events."""
|
|
18
|
+
|
|
19
|
+
@abc.abstractmethod
|
|
20
|
+
async def on_event(self, event: RealtimeModelEvent) -> None:
|
|
21
|
+
"""Called when an event is emitted by the realtime transport."""
|
|
22
|
+
pass
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class RealtimeModelConfig(TypedDict):
|
|
26
|
+
"""Options for connecting to a realtime model."""
|
|
27
|
+
|
|
28
|
+
api_key: NotRequired[str | Callable[[], MaybeAwaitable[str]]]
|
|
29
|
+
"""The API key (or function that returns a key) to use when connecting. If unset, the model will
|
|
30
|
+
try to use a sane default. For example, the OpenAI Realtime model will try to use the
|
|
31
|
+
`OPENAI_API_KEY` environment variable.
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
url: NotRequired[str]
|
|
35
|
+
"""The URL to use when connecting. If unset, the model will use a sane default. For example,
|
|
36
|
+
the OpenAI Realtime model will use the default OpenAI WebSocket URL.
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
initial_model_settings: NotRequired[RealtimeSessionModelSettings]
|
|
40
|
+
"""The initial model settings to use when connecting."""
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class RealtimeModel(abc.ABC):
|
|
44
|
+
"""Interface for connecting to a realtime model and sending/receiving events."""
|
|
45
|
+
|
|
46
|
+
@abc.abstractmethod
|
|
47
|
+
async def connect(self, options: RealtimeModelConfig) -> None:
|
|
48
|
+
"""Establish a connection to the model and keep it alive."""
|
|
49
|
+
pass
|
|
50
|
+
|
|
51
|
+
@abc.abstractmethod
|
|
52
|
+
def add_listener(self, listener: RealtimeModelListener) -> None:
|
|
53
|
+
"""Add a listener to the model."""
|
|
54
|
+
pass
|
|
55
|
+
|
|
56
|
+
@abc.abstractmethod
|
|
57
|
+
def remove_listener(self, listener: RealtimeModelListener) -> None:
|
|
58
|
+
"""Remove a listener from the model."""
|
|
59
|
+
pass
|
|
60
|
+
|
|
61
|
+
@abc.abstractmethod
|
|
62
|
+
async def send_event(self, event: RealtimeModelSendEvent) -> None:
|
|
63
|
+
"""Send an event to the model."""
|
|
64
|
+
pass
|
|
65
|
+
|
|
66
|
+
@abc.abstractmethod
|
|
67
|
+
async def close(self) -> None:
|
|
68
|
+
"""Close the session."""
|
|
69
|
+
pass
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from typing import Any, Literal, Union
|
|
5
|
+
|
|
6
|
+
from typing_extensions import TypeAlias
|
|
7
|
+
|
|
8
|
+
from .items import RealtimeItem
|
|
9
|
+
|
|
10
|
+
RealtimeConnectionStatus: TypeAlias = Literal["connecting", "connected", "disconnected"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@dataclass
|
|
14
|
+
class RealtimeModelErrorEvent:
|
|
15
|
+
"""Represents a transport‑layer error."""
|
|
16
|
+
|
|
17
|
+
error: Any
|
|
18
|
+
|
|
19
|
+
type: Literal["error"] = "error"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@dataclass
|
|
23
|
+
class RealtimeModelToolCallEvent:
|
|
24
|
+
"""Model attempted a tool/function call."""
|
|
25
|
+
|
|
26
|
+
name: str
|
|
27
|
+
call_id: str
|
|
28
|
+
arguments: str
|
|
29
|
+
|
|
30
|
+
id: str | None = None
|
|
31
|
+
previous_item_id: str | None = None
|
|
32
|
+
|
|
33
|
+
type: Literal["function_call"] = "function_call"
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@dataclass
|
|
37
|
+
class RealtimeModelAudioEvent:
|
|
38
|
+
"""Raw audio bytes emitted by the model."""
|
|
39
|
+
|
|
40
|
+
data: bytes
|
|
41
|
+
response_id: str
|
|
42
|
+
|
|
43
|
+
type: Literal["audio"] = "audio"
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@dataclass
|
|
47
|
+
class RealtimeModelAudioInterruptedEvent:
|
|
48
|
+
"""Audio interrupted."""
|
|
49
|
+
|
|
50
|
+
type: Literal["audio_interrupted"] = "audio_interrupted"
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@dataclass
|
|
54
|
+
class RealtimeModelAudioDoneEvent:
|
|
55
|
+
"""Audio done."""
|
|
56
|
+
|
|
57
|
+
type: Literal["audio_done"] = "audio_done"
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
@dataclass
|
|
61
|
+
class RealtimeModelInputAudioTranscriptionCompletedEvent:
|
|
62
|
+
"""Input audio transcription completed."""
|
|
63
|
+
|
|
64
|
+
item_id: str
|
|
65
|
+
transcript: str
|
|
66
|
+
|
|
67
|
+
type: Literal["input_audio_transcription_completed"] = "input_audio_transcription_completed"
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
@dataclass
|
|
71
|
+
class RealtimeModelTranscriptDeltaEvent:
|
|
72
|
+
"""Partial transcript update."""
|
|
73
|
+
|
|
74
|
+
item_id: str
|
|
75
|
+
delta: str
|
|
76
|
+
response_id: str
|
|
77
|
+
|
|
78
|
+
type: Literal["transcript_delta"] = "transcript_delta"
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
@dataclass
|
|
82
|
+
class RealtimeModelItemUpdatedEvent:
|
|
83
|
+
"""Item added to the history or updated."""
|
|
84
|
+
|
|
85
|
+
item: RealtimeItem
|
|
86
|
+
|
|
87
|
+
type: Literal["item_updated"] = "item_updated"
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
@dataclass
|
|
91
|
+
class RealtimeModelItemDeletedEvent:
|
|
92
|
+
"""Item deleted from the history."""
|
|
93
|
+
|
|
94
|
+
item_id: str
|
|
95
|
+
|
|
96
|
+
type: Literal["item_deleted"] = "item_deleted"
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
@dataclass
|
|
100
|
+
class RealtimeModelConnectionStatusEvent:
|
|
101
|
+
"""Connection status changed."""
|
|
102
|
+
|
|
103
|
+
status: RealtimeConnectionStatus
|
|
104
|
+
|
|
105
|
+
type: Literal["connection_status"] = "connection_status"
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
@dataclass
|
|
109
|
+
class RealtimeModelTurnStartedEvent:
|
|
110
|
+
"""Triggered when the model starts generating a response for a turn."""
|
|
111
|
+
|
|
112
|
+
type: Literal["turn_started"] = "turn_started"
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
@dataclass
|
|
116
|
+
class RealtimeModelTurnEndedEvent:
|
|
117
|
+
"""Triggered when the model finishes generating a response for a turn."""
|
|
118
|
+
|
|
119
|
+
type: Literal["turn_ended"] = "turn_ended"
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
@dataclass
|
|
123
|
+
class RealtimeModelOtherEvent:
|
|
124
|
+
"""Used as a catchall for vendor-specific events."""
|
|
125
|
+
|
|
126
|
+
data: Any
|
|
127
|
+
|
|
128
|
+
type: Literal["other"] = "other"
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
@dataclass
|
|
132
|
+
class RealtimeModelExceptionEvent:
|
|
133
|
+
"""Exception occurred during model operation."""
|
|
134
|
+
|
|
135
|
+
exception: Exception
|
|
136
|
+
context: str | None = None
|
|
137
|
+
|
|
138
|
+
type: Literal["exception"] = "exception"
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
# TODO (rm) Add usage events
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
RealtimeModelEvent: TypeAlias = Union[
|
|
145
|
+
RealtimeModelErrorEvent,
|
|
146
|
+
RealtimeModelToolCallEvent,
|
|
147
|
+
RealtimeModelAudioEvent,
|
|
148
|
+
RealtimeModelAudioInterruptedEvent,
|
|
149
|
+
RealtimeModelAudioDoneEvent,
|
|
150
|
+
RealtimeModelInputAudioTranscriptionCompletedEvent,
|
|
151
|
+
RealtimeModelTranscriptDeltaEvent,
|
|
152
|
+
RealtimeModelItemUpdatedEvent,
|
|
153
|
+
RealtimeModelItemDeletedEvent,
|
|
154
|
+
RealtimeModelConnectionStatusEvent,
|
|
155
|
+
RealtimeModelTurnStartedEvent,
|
|
156
|
+
RealtimeModelTurnEndedEvent,
|
|
157
|
+
RealtimeModelOtherEvent,
|
|
158
|
+
RealtimeModelExceptionEvent,
|
|
159
|
+
]
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from typing import Any, Literal, Union
|
|
5
|
+
|
|
6
|
+
from typing_extensions import NotRequired, TypeAlias, TypedDict
|
|
7
|
+
|
|
8
|
+
from .config import RealtimeSessionModelSettings
|
|
9
|
+
from .model_events import RealtimeModelToolCallEvent
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class RealtimeModelRawClientMessage(TypedDict):
|
|
13
|
+
"""A raw message to be sent to the model."""
|
|
14
|
+
|
|
15
|
+
type: str # explicitly required
|
|
16
|
+
other_data: NotRequired[dict[str, Any]]
|
|
17
|
+
"""Merged into the message body."""
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class RealtimeModelInputTextContent(TypedDict):
|
|
21
|
+
"""A piece of text to be sent to the model."""
|
|
22
|
+
|
|
23
|
+
type: Literal["input_text"]
|
|
24
|
+
text: str
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class RealtimeModelUserInputMessage(TypedDict):
|
|
28
|
+
"""A message to be sent to the model."""
|
|
29
|
+
|
|
30
|
+
type: Literal["message"]
|
|
31
|
+
role: Literal["user"]
|
|
32
|
+
content: list[RealtimeModelInputTextContent]
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
RealtimeModelUserInput: TypeAlias = Union[str, RealtimeModelUserInputMessage]
|
|
36
|
+
"""A user input to be sent to the model."""
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
# Model messages
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
@dataclass
|
|
43
|
+
class RealtimeModelSendRawMessage:
|
|
44
|
+
"""Send a raw message to the model."""
|
|
45
|
+
|
|
46
|
+
message: RealtimeModelRawClientMessage
|
|
47
|
+
"""The message to send."""
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@dataclass
|
|
51
|
+
class RealtimeModelSendUserInput:
|
|
52
|
+
"""Send a user input to the model."""
|
|
53
|
+
|
|
54
|
+
user_input: RealtimeModelUserInput
|
|
55
|
+
"""The user input to send."""
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@dataclass
|
|
59
|
+
class RealtimeModelSendAudio:
|
|
60
|
+
"""Send audio to the model."""
|
|
61
|
+
|
|
62
|
+
audio: bytes
|
|
63
|
+
commit: bool = False
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@dataclass
|
|
67
|
+
class RealtimeModelSendToolOutput:
|
|
68
|
+
"""Send tool output to the model."""
|
|
69
|
+
|
|
70
|
+
tool_call: RealtimeModelToolCallEvent
|
|
71
|
+
"""The tool call to send."""
|
|
72
|
+
|
|
73
|
+
output: str
|
|
74
|
+
"""The output to send."""
|
|
75
|
+
|
|
76
|
+
start_response: bool
|
|
77
|
+
"""Whether to start a response."""
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
@dataclass
|
|
81
|
+
class RealtimeModelSendInterrupt:
|
|
82
|
+
"""Send an interrupt to the model."""
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
@dataclass
|
|
86
|
+
class RealtimeModelSendSessionUpdate:
|
|
87
|
+
"""Send a session update to the model."""
|
|
88
|
+
|
|
89
|
+
session_settings: RealtimeSessionModelSettings
|
|
90
|
+
"""The updated session settings to send."""
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
RealtimeModelSendEvent: TypeAlias = Union[
|
|
94
|
+
RealtimeModelSendRawMessage,
|
|
95
|
+
RealtimeModelSendUserInput,
|
|
96
|
+
RealtimeModelSendAudio,
|
|
97
|
+
RealtimeModelSendToolOutput,
|
|
98
|
+
RealtimeModelSendInterrupt,
|
|
99
|
+
RealtimeModelSendSessionUpdate,
|
|
100
|
+
]
|