3
3
"""
4
4
5
5
from enum import Enum
6
- from typing import Any , List , Literal , Optional , Union , Annotated
6
+ from typing import Annotated , Any , List , Literal , Optional , Union
7
+
7
8
from pydantic import Field
8
9
9
- from .types import Message , State , ConfiguredBaseModel , Role
10
+ from .types import ConfiguredBaseModel , Message , State
10
11
11
12
12
13
class EventType (str , Enum ):
@@ -46,16 +47,16 @@ class TextMessageStartEvent(BaseEvent):
46
47
"""
47
48
Event indicating the start of a text message.
48
49
"""
49
- type : Literal [EventType .TEXT_MESSAGE_START ] = Field ( EventType .TEXT_MESSAGE_START , init = False ) # pyright: ignore[reportIncompatibleVariableOverride]
50
+ type : Literal [EventType .TEXT_MESSAGE_START ] = EventType .TEXT_MESSAGE_START # pyright: ignore[reportIncompatibleVariableOverride]
50
51
message_id : str
51
- role : Literal [Role . ASSISTANT ] = Field ( Role . ASSISTANT , init = False )
52
+ role : Literal ["assistant" ] = "assistant"
52
53
53
54
54
55
class TextMessageContentEvent (BaseEvent ):
55
56
"""
56
57
Event containing a piece of text message content.
57
58
"""
58
- type : Literal [EventType .TEXT_MESSAGE_CONTENT ] = Field ( EventType .TEXT_MESSAGE_CONTENT , init = False ) # pyright: ignore[reportIncompatibleVariableOverride]
59
+ type : Literal [EventType .TEXT_MESSAGE_CONTENT ] = EventType .TEXT_MESSAGE_CONTENT # pyright: ignore[reportIncompatibleVariableOverride]
59
60
message_id : str
60
61
delta : str = Field (min_length = 1 )
61
62
@@ -64,14 +65,14 @@ class TextMessageEndEvent(BaseEvent):
64
65
"""
65
66
Event indicating the end of a text message.
66
67
"""
67
- type : Literal [EventType .TEXT_MESSAGE_END ] = Field ( EventType .TEXT_MESSAGE_END , init = False ) # pyright: ignore[reportIncompatibleVariableOverride]
68
+ type : Literal [EventType .TEXT_MESSAGE_END ] = EventType .TEXT_MESSAGE_END # pyright: ignore[reportIncompatibleVariableOverride]
68
69
message_id : str
69
70
70
71
class TextMessageChunkEvent (BaseEvent ):
71
72
"""
72
73
Event containing a chunk of text message content.
73
74
"""
74
- type : Literal [EventType .TEXT_MESSAGE_CHUNK ] = Field ( EventType .TEXT_MESSAGE_CHUNK , init = False ) # pyright: ignore[reportIncompatibleVariableOverride]
75
+ type : Literal [EventType .TEXT_MESSAGE_CHUNK ] = EventType .TEXT_MESSAGE_CHUNK # pyright: ignore[reportIncompatibleVariableOverride]
75
76
message_id : Optional [str ] = None
76
77
role : Optional [Literal ["assistant" ]] = None
77
78
delta : Optional [str ] = None
@@ -80,7 +81,7 @@ class ToolCallStartEvent(BaseEvent):
80
81
"""
81
82
Event indicating the start of a tool call.
82
83
"""
83
- type : Literal [EventType .TOOL_CALL_START ] = Field ( EventType .TOOL_CALL_START , init = False ) # pyright: ignore[reportIncompatibleVariableOverride]
84
+ type : Literal [EventType .TOOL_CALL_START ] = EventType .TOOL_CALL_START # pyright: ignore[reportIncompatibleVariableOverride]
84
85
tool_call_id : str
85
86
tool_call_name : str
86
87
parent_message_id : Optional [str ] = None
@@ -90,7 +91,7 @@ class ToolCallArgsEvent(BaseEvent):
90
91
"""
91
92
Event containing tool call arguments.
92
93
"""
93
- type : Literal [EventType .TOOL_CALL_ARGS ] = Field ( EventType .TOOL_CALL_ARGS , init = False ) # pyright: ignore[reportIncompatibleVariableOverride]
94
+ type : Literal [EventType .TOOL_CALL_ARGS ] = EventType .TOOL_CALL_ARGS # pyright: ignore[reportIncompatibleVariableOverride]
94
95
tool_call_id : str
95
96
delta : str
96
97
@@ -99,14 +100,14 @@ class ToolCallEndEvent(BaseEvent):
99
100
"""
100
101
Event indicating the end of a tool call.
101
102
"""
102
- type : Literal [EventType .TOOL_CALL_END ] = Field ( EventType .TOOL_CALL_END , init = False ) # pyright: ignore[reportIncompatibleVariableOverride]
103
+ type : Literal [EventType .TOOL_CALL_END ] = EventType .TOOL_CALL_END # pyright: ignore[reportIncompatibleVariableOverride]
103
104
tool_call_id : str
104
105
105
106
class ToolCallChunkEvent (BaseEvent ):
106
107
"""
107
108
Event containing a chunk of tool call content.
108
109
"""
109
- type : Literal [EventType .TOOL_CALL_CHUNK ] = Field ( EventType .TOOL_CALL_CHUNK , init = False ) # pyright: ignore[reportIncompatibleVariableOverride]
110
+ type : Literal [EventType .TOOL_CALL_CHUNK ] = EventType .TOOL_CALL_CHUNK # pyright: ignore[reportIncompatibleVariableOverride]
110
111
tool_call_id : Optional [str ] = None
111
112
tool_call_name : Optional [str ] = None
112
113
parent_message_id : Optional [str ] = None
@@ -116,31 +117,31 @@ class StateSnapshotEvent(BaseEvent):
116
117
"""
117
118
Event containing a snapshot of the state.
118
119
"""
119
- type : Literal [EventType .STATE_SNAPSHOT ] = Field ( EventType .STATE_SNAPSHOT , init = False ) # pyright: ignore[reportIncompatibleVariableOverride]
120
+ type : Literal [EventType .STATE_SNAPSHOT ] = EventType .STATE_SNAPSHOT # pyright: ignore[reportIncompatibleVariableOverride]
120
121
snapshot : State
121
122
122
123
123
124
class StateDeltaEvent (BaseEvent ):
124
125
"""
125
126
Event containing a delta of the state.
126
127
"""
127
- type : Literal [EventType .STATE_DELTA ] = Field ( EventType .STATE_DELTA , init = False ) # pyright: ignore[reportIncompatibleVariableOverride]
128
+ type : Literal [EventType .STATE_DELTA ] = EventType .STATE_DELTA # pyright: ignore[reportIncompatibleVariableOverride]
128
129
delta : List [Any ] # JSON Patch (RFC 6902)
129
130
130
131
131
132
class MessagesSnapshotEvent (BaseEvent ):
132
133
"""
133
134
Event containing a snapshot of the messages.
134
135
"""
135
- type : Literal [EventType .MESSAGES_SNAPSHOT ] = Field ( EventType .MESSAGES_SNAPSHOT , init = False ) # pyright: ignore[reportIncompatibleVariableOverride]
136
+ type : Literal [EventType .MESSAGES_SNAPSHOT ] = EventType .MESSAGES_SNAPSHOT # pyright: ignore[reportIncompatibleVariableOverride]
136
137
messages : List [Message ]
137
138
138
139
139
140
class RawEvent (BaseEvent ):
140
141
"""
141
142
Event containing a raw event.
142
143
"""
143
- type : Literal [EventType .RAW ] = Field ( EventType .RAW , init = False ) # pyright: ignore[reportIncompatibleVariableOverride]
144
+ type : Literal [EventType .RAW ] = EventType .RAW # pyright: ignore[reportIncompatibleVariableOverride]
144
145
event : Any
145
146
source : Optional [str ] = None
146
147
@@ -149,7 +150,7 @@ class CustomEvent(BaseEvent):
149
150
"""
150
151
Event containing a custom event.
151
152
"""
152
- type : Literal [EventType .CUSTOM ] = Field ( EventType .CUSTOM , init = False ) # pyright: ignore[reportIncompatibleVariableOverride]
153
+ type : Literal [EventType .CUSTOM ] = EventType .CUSTOM # pyright: ignore[reportIncompatibleVariableOverride]
153
154
name : str
154
155
value : Any
155
156
@@ -158,7 +159,7 @@ class RunStartedEvent(BaseEvent):
158
159
"""
159
160
Event indicating that a run has started.
160
161
"""
161
- type : Literal [EventType .RUN_STARTED ] = Field ( EventType .RUN_STARTED , init = False ) # pyright: ignore[reportIncompatibleVariableOverride]
162
+ type : Literal [EventType .RUN_STARTED ] = EventType .RUN_STARTED # pyright: ignore[reportIncompatibleVariableOverride]
162
163
thread_id : str
163
164
run_id : str
164
165
@@ -167,7 +168,7 @@ class RunFinishedEvent(BaseEvent):
167
168
"""
168
169
Event indicating that a run has finished.
169
170
"""
170
- type : Literal [EventType .RUN_FINISHED ] = Field ( EventType .RUN_FINISHED , init = False ) # pyright: ignore[reportIncompatibleVariableOverride]
171
+ type : Literal [EventType .RUN_FINISHED ] = EventType .RUN_FINISHED # pyright: ignore[reportIncompatibleVariableOverride]
171
172
thread_id : str
172
173
run_id : str
173
174
@@ -176,7 +177,7 @@ class RunErrorEvent(BaseEvent):
176
177
"""
177
178
Event indicating that a run has encountered an error.
178
179
"""
179
- type : Literal [EventType .RUN_ERROR ] = Field ( EventType .RUN_ERROR , init = False ) # pyright: ignore[reportIncompatibleVariableOverride]
180
+ type : Literal [EventType .RUN_ERROR ] = EventType .RUN_ERROR # pyright: ignore[reportIncompatibleVariableOverride]
180
181
message : str
181
182
code : Optional [str ] = None
182
183
@@ -185,15 +186,15 @@ class StepStartedEvent(BaseEvent):
185
186
"""
186
187
Event indicating that a step has started.
187
188
"""
188
- type : Literal [EventType .STEP_STARTED ] = Field ( EventType .STEP_STARTED , init = False ) # pyright: ignore[reportIncompatibleVariableOverride]
189
+ type : Literal [EventType .STEP_STARTED ] = EventType .STEP_STARTED # pyright: ignore[reportIncompatibleVariableOverride]
189
190
step_name : str
190
191
191
192
192
193
class StepFinishedEvent (BaseEvent ):
193
194
"""
194
195
Event indicating that a step has finished.
195
196
"""
196
- type : Literal [EventType .STEP_FINISHED ] = Field ( EventType .STEP_FINISHED , init = False ) # pyright: ignore[reportIncompatibleVariableOverride]
197
+ type : Literal [EventType .STEP_FINISHED ] = EventType .STEP_FINISHED # pyright: ignore[reportIncompatibleVariableOverride]
197
198
step_name : str
198
199
199
200
0 commit comments