openai-agents 0.1.0__py3-none-any.whl → 0.2.0__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.

@@ -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
+ ]