Commit 613723b
Fix agui (#23)
* fix(credential): correct typo in access key secret parameter name
fix(agui_protocol): optimize import statements and event handling logic
- Move imports to local scope to avoid unnecessary dependencies
- Simplify conditional expressions and method calls
- Improve type hinting for better code clarity
修复凭据模型中的访问密钥参数拼写错误
优化 AGUI 协议处理器的导入语句和事件处理逻辑:
- 将部分导入移至函数内部以减少不必要的依赖
- 简化条件表达式与方法调用
- 改进类型提示以增强代码可读性
Change-Id: I1f4b89fa0a0ceeed09bcf1e6bb03370dfd1547de
Signed-off-by: OhYee <oyohyee@oyohyee.com>
* fix(agui_protocol): import run event classes directly
the runstartedevent and runfinishedevent classes are now imported directly from ag_ui.core to ensure proper event handling in the sse stream.
these events are essential for signaling the start and completion of runs within the agui protocol, improving reliability and maintainability of the streaming mechanism.
修复了 agui 协议中运行事件类的导入问题,确保 SSE 流能够正确处理运行开始和结束事件。此举增强了流机制的可靠性和可维护性。
Change-Id: Ied78843c9533c640a4706b379c8bd9109acc3b0b
Signed-off-by: OhYee <oyohyee@oyohyee.com>
* refactor(core): implement lazy loading for server module to handle optional dependencies
This change introduces a lazy loading mechanism for the server module to avoid import errors when optional dependencies are not installed. The server-related exports are now imported on-demand through __getattr__, with clear error messages when required optional dependencies are missing.
The implementation includes:
- TYPE_CHECKING import for type hints during development
- Delayed imports wrapped in TYPE_CHECKING blocks
- __getattr__ function to handle runtime imports
- Clear error messages directing users to install optional dependencies
- Server exports defined in _SERVER_EXPORTS set for tracking
This resolves issues where the package would fail to import when server optional dependencies were not available.
refactor(core): 实现服务器模块的延迟加载以处理可选依赖
此更改引入了服务器模块的延迟加载机制,以避免在未安装可选依赖项时出现导入错误。现在通过 __getattr__ 按需导入服务器相关导出,并在缺少必需的可选依赖项时提供清晰的错误消息。
实现包括:
- 用于开发期间类型提示的 TYPE_CHECKING 导入
- 包装在 TYPE_CHECKING 块中的延迟导入
- 用于处理运行时导入的 __getattr__ 函数
- 指向用户安装可选依赖项的清晰错误消息
- 定义在 _SERVER_EXPORTS 集合中用于跟踪的服务器导出
这解决了在服务器可选依赖项不可用时包导入失败的问题。
Change-Id: I9d8f7dd8e5c6d34dfd0619714ead5aea22105293
Signed-off-by: OhYee <oyohyee@oyohyee.com>
* refactor(core): use generic package mapping for optional dependency checks (#25)
* Initial plan
* fix(core): add 'ag_ui' to optional dependency error check
Add "ag_ui" to the error message checking logic in __getattr__ to properly
handle import errors when ag-ui-protocol is not installed. This ensures users
get helpful error messages when trying to use AGUIProtocolHandler or other
AG-UI related components without the server optional dependencies installed.
Addresses feedback from PR #23 review comment.
Co-authored-by: OhYee <13498329+OhYee@users.noreply.github.com>
* refactor(core): use generic package mapping for optional dependency checks
Refactor the import error handling to use a more maintainable and scalable
approach with a package mapping structure instead of hardcoded string checks.
Changes:
- Added _OPTIONAL_PACKAGES list with (import_name, install_name) tuples
- Refactored __getattr__ to iterate through the package mapping
- Now easier to add new optional dependencies in the future
- All three server optional dependencies (fastapi, uvicorn, ag_ui) registered
This makes the codebase more maintainable when adding new optional
dependencies in the future.
Addresses feedback from @OhYee on PR #23.
Co-authored-by: OhYee <13498329+OhYee@users.noreply.github.com>
* fix(core): restore specificity in error message and add clarifying comment
Address code review feedback:
- Restored "server" context in error message for better clarity
- Added comment clarifying that all entries are for server-related dependencies
- Maintains generic approach while preserving helpful context for users
This ensures users get clear, specific error messages while keeping the code
maintainable for future extensions.
Co-authored-by: OhYee <13498329+OhYee@users.noreply.github.com>
* refactor(core): use constant for server install command to reduce duplication
Extract the repeated install command string into a constant _SERVER_INSTALL_CMD
to make the code more maintainable and easier to update in the future.
This addresses code review feedback about reducing duplication in the package
mapping structure.
Co-authored-by: OhYee <13498329+OhYee@users.noreply.github.com>
* refactor(core): group packages by install command in _OPTIONAL_PACKAGES
Refactor _OPTIONAL_PACKAGES from a list of tuples to a dictionary that groups
packages by their installation command. This provides better organization when
multiple packages share the same installation command.
Changes:
- Changed from list of (package, install_cmd) tuples to dict of {install_cmd: [packages]}
- Removed _SERVER_INSTALL_CMD constant (now a dict key)
- Updated iteration logic to handle nested structure
- All three server packages (fastapi, uvicorn, ag_ui) grouped together
Benefits:
- Clearer relationship: install command -> packages it provides
- More compact when packages share the same install command
- Easier to see all packages for a given installation
- Scalable for future optional dependency groups
Addresses feedback from @OhYee about merging packages with the same command.
Co-authored-by: OhYee <13498329+OhYee@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: OhYee <13498329+OhYee@users.noreply.github.com>
---------
Signed-off-by: OhYee <oyohyee@oyohyee.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: OhYee <13498329+OhYee@users.noreply.github.com>1 parent 2582fa6 commit 613723b
File tree
4 files changed
+180
-56
lines changed- agentrun
- credential
- model
- server
4 files changed
+180
-56
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
87 | 89 | | |
88 | 90 | | |
89 | 91 | | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | 92 | | |
104 | 93 | | |
| 94 | + | |
105 | 95 | | |
106 | 96 | | |
107 | 97 | | |
108 | 98 | | |
109 | 99 | | |
110 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
111 | 136 | | |
112 | 137 | | |
113 | 138 | | |
| |||
185 | 210 | | |
186 | 211 | | |
187 | 212 | | |
188 | | - | |
| 213 | + | |
| 214 | + | |
189 | 215 | | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
190 | 222 | | |
191 | | - | |
| 223 | + | |
192 | 224 | | |
193 | | - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
194 | 239 | | |
195 | 240 | | |
196 | 241 | | |
197 | | - | |
198 | | - | |
| 242 | + | |
199 | 243 | | |
| 244 | + | |
| 245 | + | |
200 | 246 | | |
201 | | - | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
202 | 253 | | |
203 | | - | |
204 | 254 | | |
205 | 255 | | |
| 256 | + | |
206 | 257 | | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
| 137 | + | |
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
151 | | - | |
| 151 | + | |
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| 134 | + | |
134 | 135 | | |
135 | 136 | | |
136 | 137 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
52 | 28 | | |
53 | 29 | | |
54 | 30 | | |
| |||
101 | 77 | | |
102 | 78 | | |
103 | 79 | | |
104 | | - | |
| 80 | + | |
105 | 81 | | |
| 82 | + | |
| 83 | + | |
106 | 84 | | |
107 | 85 | | |
108 | 86 | | |
109 | 87 | | |
110 | 88 | | |
111 | 89 | | |
112 | 90 | | |
113 | | - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
114 | 94 | | |
115 | 95 | | |
116 | 96 | | |
| |||
123 | 103 | | |
124 | 104 | | |
125 | 105 | | |
126 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
127 | 109 | | |
128 | 110 | | |
129 | 111 | | |
| |||
168 | 150 | | |
169 | 151 | | |
170 | 152 | | |
| 153 | + | |
| 154 | + | |
171 | 155 | | |
172 | 156 | | |
173 | 157 | | |
| |||
363 | 347 | | |
364 | 348 | | |
365 | 349 | | |
| 350 | + | |
| 351 | + | |
366 | 352 | | |
367 | 353 | | |
368 | 354 | | |
| |||
420 | 406 | | |
421 | 407 | | |
422 | 408 | | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
423 | 421 | | |
424 | 422 | | |
425 | 423 | | |
| |||
703 | 701 | | |
704 | 702 | | |
705 | 703 | | |
706 | | - | |
| 704 | + | |
707 | 705 | | |
708 | 706 | | |
709 | 707 | | |
| |||
712 | 710 | | |
713 | 711 | | |
714 | 712 | | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
715 | 717 | | |
716 | 718 | | |
717 | 719 | | |
| |||
779 | 781 | | |
780 | 782 | | |
781 | 783 | | |
| 784 | + | |
| 785 | + | |
782 | 786 | | |
783 | 787 | | |
784 | 788 | | |
| |||
0 commit comments