Skip to content

Commit df5f0d3

Browse files
committed
pre-commit fixes
1 parent 4dbdad7 commit df5f0d3

File tree

8 files changed

+331
-352
lines changed

8 files changed

+331
-352
lines changed

python-sdk/.pre-commit-config.yaml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
11
repos:
2-
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v5.0.0
4-
hooks:
5-
- id: trailing-whitespace
6-
exclude_types: [ jupyter ]
7-
- id: end-of-file-fixer
8-
exclude_types: [ jupyter ]
9-
- id: check-docstring-first
10-
- id: debug-statements
11-
- id: check-ast
122
- repo: https://github.com/charliermarsh/ruff-pre-commit
133
rev: v0.11.8
144
hooks:
155
- id: ruff
166
args: [
177
--fix
188
]
9+
files: ^python-sdk/
1910
- id: ruff-format
11+
files: ^python-sdk/
2012
- repo: https://github.com/pre-commit/mirrors-mypy
2113
rev: v1.15.0
2214
hooks:
2315
- id: mypy
16+
files: ^python-sdk/
2417
args: [
2518
--python-version=3.12,
2619
--disallow-untyped-calls,
@@ -34,8 +27,4 @@ repos:
3427
additional_dependencies:
3528
- "types-pytz"
3629
exclude_types: [ jupyter ]
37-
exclude: "tests"
38-
- repo: https://github.com/kynan/nbstripout
39-
rev: 0.8.1
40-
hooks:
41-
- id: nbstripout
30+
exclude: "tests"

python-sdk/ag_ui/core/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
RunErrorEvent,
3030
StepStartedEvent,
3131
StepFinishedEvent,
32-
Event
32+
Event,
3333
)
3434

3535
from ag_ui.core.types import (

python-sdk/ag_ui/core/events.py

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class EventType(str, Enum):
1414
"""
1515
The type of event.
1616
"""
17+
1718
TEXT_MESSAGE_START = "TEXT_MESSAGE_START"
1819
TEXT_MESSAGE_CONTENT = "TEXT_MESSAGE_CONTENT"
1920
TEXT_MESSAGE_END = "TEXT_MESSAGE_END"
@@ -44,6 +45,7 @@ class BaseEvent(ConfiguredBaseModel):
4445
"""
4546
Base event for all events in the Agent User Interaction Protocol.
4647
"""
48+
4749
type: EventType
4850
timestamp: Optional[int] = None
4951
raw_event: Optional[JSONValue] = None
@@ -53,6 +55,7 @@ class TextMessageStartEvent(BaseEvent):
5355
"""
5456
Event indicating the start of a text message.
5557
"""
58+
5659
type: Literal[EventType.TEXT_MESSAGE_START] = EventType.TEXT_MESSAGE_START # pyright: ignore[reportIncompatibleVariableOverride]
5760
message_id: str
5861
role: Literal["assistant"] = "assistant"
@@ -62,6 +65,7 @@ class TextMessageContentEvent(BaseEvent):
6265
"""
6366
Event containing a piece of text message content.
6467
"""
68+
6569
type: Literal[EventType.TEXT_MESSAGE_CONTENT] = EventType.TEXT_MESSAGE_CONTENT # pyright: ignore[reportIncompatibleVariableOverride]
6670
message_id: str
6771
delta: str = Field(min_length=1)
@@ -71,41 +75,58 @@ class TextMessageEndEvent(BaseEvent):
7175
"""
7276
Event indicating the end of a text message.
7377
"""
78+
7479
type: Literal[EventType.TEXT_MESSAGE_END] = EventType.TEXT_MESSAGE_END # pyright: ignore[reportIncompatibleVariableOverride]
7580
message_id: str
7681

82+
7783
class TextMessageChunkEvent(BaseEvent):
7884
"""
7985
Event containing a chunk of text message content.
8086
"""
87+
8188
type: Literal[EventType.TEXT_MESSAGE_CHUNK] = EventType.TEXT_MESSAGE_CHUNK # pyright: ignore[reportIncompatibleVariableOverride]
8289
message_id: Optional[str] = None
8390
role: Optional[Literal["assistant"]] = None
8491
delta: Optional[str] = None
8592

93+
8694
class ThinkingTextMessageStartEvent(BaseEvent):
8795
"""
8896
Event indicating the start of a thinking text message.
8997
"""
90-
type: Literal[EventType.THINKING_TEXT_MESSAGE_START] = EventType.THINKING_TEXT_MESSAGE_START # pyright: ignore[reportIncompatibleVariableOverride]
98+
99+
type: Literal[EventType.THINKING_TEXT_MESSAGE_START] = (
100+
EventType.THINKING_TEXT_MESSAGE_START
101+
) # pyright: ignore[reportIncompatibleVariableOverride]
102+
91103

92104
class ThinkingTextMessageContentEvent(BaseEvent):
93105
"""
94106
Event indicating a piece of a thinking text message.
95107
"""
96-
type: Literal[EventType.THINKING_TEXT_MESSAGE_CONTENT] = EventType.THINKING_TEXT_MESSAGE_CONTENT # pyright: ignore[reportIncompatibleVariableOverride]
108+
109+
type: Literal[EventType.THINKING_TEXT_MESSAGE_CONTENT] = (
110+
EventType.THINKING_TEXT_MESSAGE_CONTENT
111+
) # pyright: ignore[reportIncompatibleVariableOverride]
97112
delta: str = Field(min_length=1)
98113

114+
99115
class ThinkingTextMessageEndEvent(BaseEvent):
100116
"""
101117
Event indicating the end of a thinking text message.
102118
"""
103-
type: Literal[EventType.THINKING_TEXT_MESSAGE_END] = EventType.THINKING_TEXT_MESSAGE_END # pyright: ignore[reportIncompatibleVariableOverride]
119+
120+
type: Literal[EventType.THINKING_TEXT_MESSAGE_END] = (
121+
EventType.THINKING_TEXT_MESSAGE_END
122+
) # pyright: ignore[reportIncompatibleVariableOverride]
123+
104124

105125
class ToolCallStartEvent(BaseEvent):
106126
"""
107127
Event indicating the start of a tool call.
108128
"""
129+
109130
type: Literal[EventType.TOOL_CALL_START] = EventType.TOOL_CALL_START # pyright: ignore[reportIncompatibleVariableOverride]
110131
tool_call_id: str
111132
tool_call_name: str
@@ -116,6 +137,7 @@ class ToolCallArgsEvent(BaseEvent):
116137
"""
117138
Event containing tool call arguments.
118139
"""
140+
119141
type: Literal[EventType.TOOL_CALL_ARGS] = EventType.TOOL_CALL_ARGS # pyright: ignore[reportIncompatibleVariableOverride]
120142
tool_call_id: str
121143
delta: str
@@ -125,46 +147,57 @@ class ToolCallEndEvent(BaseEvent):
125147
"""
126148
Event indicating the end of a tool call.
127149
"""
150+
128151
type: Literal[EventType.TOOL_CALL_END] = EventType.TOOL_CALL_END # pyright: ignore[reportIncompatibleVariableOverride]
129152
tool_call_id: str
130153

154+
131155
class ToolCallChunkEvent(BaseEvent):
132156
"""
133157
Event containing a chunk of tool call content.
134158
"""
159+
135160
type: Literal[EventType.TOOL_CALL_CHUNK] = EventType.TOOL_CALL_CHUNK # pyright: ignore[reportIncompatibleVariableOverride]
136161
tool_call_id: Optional[str] = None
137162
tool_call_name: Optional[str] = None
138163
parent_message_id: Optional[str] = None
139164
delta: Optional[str] = None
140165

166+
141167
class ToolCallResultEvent(BaseEvent):
142168
"""
143169
Event containing the result of a tool call.
144170
"""
171+
145172
message_id: str
146173
type: Literal[EventType.TOOL_CALL_RESULT] = EventType.TOOL_CALL_RESULT # pyright: ignore[reportIncompatibleVariableOverride]
147174
tool_call_id: str
148175
content: str
149176
role: Optional[Literal["tool"]] = None
150177

178+
151179
class ThinkingStartEvent(BaseEvent):
152180
"""
153181
Event indicating the start of a thinking step event.
154182
"""
183+
155184
type: Literal[EventType.THINKING_START] = EventType.THINKING_START # pyright: ignore[reportIncompatibleVariableOverride]
156185
title: Optional[str] = None
157186

187+
158188
class ThinkingEndEvent(BaseEvent):
159189
"""
160190
Event indicating the end of a thinking step event.
161191
"""
192+
162193
type: Literal[EventType.THINKING_END] = EventType.THINKING_END # pyright: ignore[reportIncompatibleVariableOverride]
163194

195+
164196
class StateSnapshotEvent(BaseEvent, Generic[AgentStateT]):
165197
"""
166198
Event containing a snapshot of the state.
167199
"""
200+
168201
type: Literal[EventType.STATE_SNAPSHOT] = EventType.STATE_SNAPSHOT # pyright: ignore[reportIncompatibleVariableOverride]
169202
snapshot: AgentStateT
170203

@@ -173,6 +206,7 @@ class StateDeltaEvent(BaseEvent):
173206
"""
174207
Event containing a delta of the state.
175208
"""
209+
176210
type: Literal[EventType.STATE_DELTA] = EventType.STATE_DELTA # pyright: ignore[reportIncompatibleVariableOverride]
177211
delta: JSONValue # JSON Patch (RFC 6902)
178212

@@ -181,6 +215,7 @@ class MessagesSnapshotEvent(BaseEvent):
181215
"""
182216
Event containing a snapshot of the messages.
183217
"""
218+
184219
type: Literal[EventType.MESSAGES_SNAPSHOT] = EventType.MESSAGES_SNAPSHOT # pyright: ignore[reportIncompatibleVariableOverride]
185220
messages: List[Message]
186221

@@ -189,6 +224,7 @@ class RawEvent(BaseEvent):
189224
"""
190225
Event containing a raw event.
191226
"""
227+
192228
type: Literal[EventType.RAW] = EventType.RAW # pyright: ignore[reportIncompatibleVariableOverride]
193229
event: JSONValue
194230
source: Optional[str] = None
@@ -198,6 +234,7 @@ class CustomEvent(BaseEvent):
198234
"""
199235
Event containing a custom event.
200236
"""
237+
201238
type: Literal[EventType.CUSTOM] = EventType.CUSTOM # pyright: ignore[reportIncompatibleVariableOverride]
202239
name: str
203240
value: JSONValue
@@ -207,6 +244,7 @@ class RunStartedEvent(BaseEvent):
207244
"""
208245
Event indicating that a run has started.
209246
"""
247+
210248
type: Literal[EventType.RUN_STARTED] = EventType.RUN_STARTED # pyright: ignore[reportIncompatibleVariableOverride]
211249
thread_id: str
212250
run_id: str
@@ -216,6 +254,7 @@ class RunFinishedEvent(BaseEvent):
216254
"""
217255
Event indicating that a run has finished.
218256
"""
257+
219258
type: Literal[EventType.RUN_FINISHED] = EventType.RUN_FINISHED # pyright: ignore[reportIncompatibleVariableOverride]
220259
thread_id: str
221260
run_id: str
@@ -226,6 +265,7 @@ class RunErrorEvent(BaseEvent):
226265
"""
227266
Event indicating that a run has encountered an error.
228267
"""
268+
229269
type: Literal[EventType.RUN_ERROR] = EventType.RUN_ERROR # pyright: ignore[reportIncompatibleVariableOverride]
230270
message: str
231271
code: Optional[str] = None
@@ -235,6 +275,7 @@ class StepStartedEvent(BaseEvent):
235275
"""
236276
Event indicating that a step has started.
237277
"""
278+
238279
type: Literal[EventType.STEP_STARTED] = EventType.STEP_STARTED # pyright: ignore[reportIncompatibleVariableOverride]
239280
step_name: str
240281

@@ -243,6 +284,7 @@ class StepFinishedEvent(BaseEvent):
243284
"""
244285
Event indicating that a step has finished.
245286
"""
287+
246288
type: Literal[EventType.STEP_FINISHED] = EventType.STEP_FINISHED # pyright: ignore[reportIncompatibleVariableOverride]
247289
step_name: str
248290

@@ -269,5 +311,5 @@ class StepFinishedEvent(BaseEvent):
269311
StepStartedEvent,
270312
StepFinishedEvent,
271313
],
272-
Field(discriminator="type")
314+
Field(discriminator="type"),
273315
]

0 commit comments

Comments
 (0)