klaude-code 1.2.23__py3-none-any.whl → 1.2.24__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.
- klaude_code/command/prompt-jj-describe.md +32 -0
- klaude_code/{const/__init__.py → const.py} +4 -1
- klaude_code/core/executor.py +1 -1
- klaude_code/core/tool/file/read_tool.py +23 -1
- klaude_code/core/tool/file/write_tool.py +7 -3
- klaude_code/llm/openai_compatible/client.py +29 -102
- klaude_code/llm/openai_compatible/stream.py +272 -0
- klaude_code/llm/openrouter/client.py +29 -109
- klaude_code/llm/openrouter/{reasoning_handler.py → reasoning.py} +24 -2
- klaude_code/protocol/model.py +13 -1
- klaude_code/ui/core/stage_manager.py +0 -3
- klaude_code/ui/modes/repl/event_handler.py +94 -46
- klaude_code/ui/modes/repl/input_prompt_toolkit.py +13 -3
- klaude_code/ui/modes/repl/renderer.py +24 -17
- klaude_code/ui/renderers/assistant.py +1 -1
- klaude_code/ui/renderers/metadata.py +2 -6
- klaude_code/ui/renderers/sub_agent.py +28 -5
- klaude_code/ui/renderers/thinking.py +16 -10
- klaude_code/ui/renderers/tools.py +26 -2
- klaude_code/ui/rich/markdown.py +18 -3
- klaude_code/ui/rich/status.py +14 -6
- klaude_code/ui/rich/theme.py +63 -12
- {klaude_code-1.2.23.dist-info → klaude_code-1.2.24.dist-info}/METADATA +1 -1
- {klaude_code-1.2.23.dist-info → klaude_code-1.2.24.dist-info}/RECORD +26 -25
- klaude_code/llm/openai_compatible/stream_processor.py +0 -83
- {klaude_code-1.2.23.dist-info → klaude_code-1.2.24.dist-info}/WHEEL +0 -0
- {klaude_code-1.2.23.dist-info → klaude_code-1.2.24.dist-info}/entry_points.txt +0 -0
|
@@ -23,6 +23,7 @@ klaude_code/command/export_online_cmd.py,sha256=kOVmFEW7gEEFvaKnXL8suNenktLyTW-1
|
|
|
23
23
|
klaude_code/command/help_cmd.py,sha256=yQJnVtj6sgXQdGsi4u9aS7EcjJLSrXccUA-v_bqmsRw,1633
|
|
24
24
|
klaude_code/command/model_cmd.py,sha256=GmDln1N6u7eWLK15tm_lcdDJBY8qI0ih48h6AhijafI,1665
|
|
25
25
|
klaude_code/command/prompt-init.md,sha256=a4_FQ3gKizqs2vl9oEY5jtG6HNhv3f-1b5RSCFq0A18,1873
|
|
26
|
+
klaude_code/command/prompt-jj-describe.md,sha256=n-7hiXU8oodCMR3ipNyRR86pAUzXMz6seloU9a6QQnY,974
|
|
26
27
|
klaude_code/command/prompt_command.py,sha256=rMi-ZRLpUSt1t0IQVtwnzIYqcrXK-MwZrabbZ8dc8U4,2774
|
|
27
28
|
klaude_code/command/refresh_cmd.py,sha256=575eJ5IsOc1e_7CulMxvTu5GQ6BaXTG1k8IsAqzrwdQ,1244
|
|
28
29
|
klaude_code/command/registry.py,sha256=avTjsoyLv11SsLsY_qb3OpsRjsSyxIlu7uwJI0Nq6HE,6176
|
|
@@ -33,10 +34,10 @@ klaude_code/command/thinking_cmd.py,sha256=XDyq0q8eb3Os4FyWjr-moiKjmzGIaNhOC9h89
|
|
|
33
34
|
klaude_code/config/__init__.py,sha256=Qrqvi8nizkj6N77h2vDj0r4rbgCiqxvz2HLBPFuWulA,120
|
|
34
35
|
klaude_code/config/config.py,sha256=2jvM6a8zoC-TdRFaLIw3OW5paxxeXC6l-o05ds4RysA,7263
|
|
35
36
|
klaude_code/config/select_model.py,sha256=KCdFjaoHXyO9QidNna_OGdDrvlEXtRUXKfG-F8kdNLk,5188
|
|
36
|
-
klaude_code/const
|
|
37
|
+
klaude_code/const.py,sha256=H6CDlh1-AkV3TUe7pDOBA6VaS-81uuWG12NmqERetaA,4483
|
|
37
38
|
klaude_code/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
38
39
|
klaude_code/core/agent.py,sha256=bWm-UFX_0-KAy5j_YHH8X8o3MJT4-40Ni2EaDP2SL5k,5819
|
|
39
|
-
klaude_code/core/executor.py,sha256=
|
|
40
|
+
klaude_code/core/executor.py,sha256=E8IdgNEzcHnWoN9q9VMZljcXoCqWWRU7XzleCZ7jhtA,24907
|
|
40
41
|
klaude_code/core/manager/__init__.py,sha256=hdIbpnYj6i18byiWjtJIm5l7NYYDQMvafw8fePVPydc,562
|
|
41
42
|
klaude_code/core/manager/llm_clients.py,sha256=X2oMFWgJcP0tK8GEtMMDYR3HyR6_H8FuyCqpzWF5x2k,871
|
|
42
43
|
klaude_code/core/manager/llm_clients_builder.py,sha256=pPZ_xBh-_ipV66L-9a1fnwNos4iik82Zkq0E0y3WrfI,1521
|
|
@@ -64,9 +65,9 @@ klaude_code/core/tool/file/diff_builder.py,sha256=b53S4Ebw7aPmd9AZ97Pxu6MRcnUIdV
|
|
|
64
65
|
klaude_code/core/tool/file/edit_tool.md,sha256=rEcUjJuPC46t1nXWjTDxplDcxWDbzTWsr6_bYt5_aRI,1110
|
|
65
66
|
klaude_code/core/tool/file/edit_tool.py,sha256=wuXISJRTWobNCKjkQ01UpoA13I0Zxcg1r7hXErAQxnQ,10897
|
|
66
67
|
klaude_code/core/tool/file/read_tool.md,sha256=74SLSl1tq3L0por73M0QV_ws41MRIvGXQpfLb8dmtp0,1351
|
|
67
|
-
klaude_code/core/tool/file/read_tool.py,sha256=
|
|
68
|
+
klaude_code/core/tool/file/read_tool.py,sha256=HFA4lYaS_eV9C0UjXCuIVXhbD6OKrpkq4WN33z0EgP0,12877
|
|
68
69
|
klaude_code/core/tool/file/write_tool.md,sha256=CNnYgtieUasuHdpXLDpTEsqe492Pf7v75M4RQ3oIer8,613
|
|
69
|
-
klaude_code/core/tool/file/write_tool.py,sha256=
|
|
70
|
+
klaude_code/core/tool/file/write_tool.py,sha256=j9OCPnCXIg4RC-DF5yw7U5_X1KMNBnqxn1exF-XqFeo,5682
|
|
70
71
|
klaude_code/core/tool/report_back_tool.py,sha256=KRZzQAIxniwXe58SDJcfK_DCf9TFFAx8XC75wPEjmpY,3246
|
|
71
72
|
klaude_code/core/tool/shell/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
72
73
|
klaude_code/core/tool/shell/bash_tool.md,sha256=ILKpnRCBTkU2uSDEdZQjNYo1l6hsM4TO-3RD5zWC61c,3935
|
|
@@ -104,14 +105,14 @@ klaude_code/llm/codex/__init__.py,sha256=8vN2j2ezWB_UVpfqQ8ooStsBeLL5SY4SUMXOXdW
|
|
|
104
105
|
klaude_code/llm/codex/client.py,sha256=0BAOiLAdk2PxBEYuC_TGOs4_h6yfNZr1YWuf1lzkBxM,5329
|
|
105
106
|
klaude_code/llm/input_common.py,sha256=NxiYlhGRFntiLiKm5sKLCF0xGYW6DwcyvIhj6KAZoeU,8533
|
|
106
107
|
klaude_code/llm/openai_compatible/__init__.py,sha256=ACGpnki7k53mMcCl591aw99pm9jZOZk0ghr7atOfNps,81
|
|
107
|
-
klaude_code/llm/openai_compatible/client.py,sha256=
|
|
108
|
+
klaude_code/llm/openai_compatible/client.py,sha256=sMzHxaDZ4CRDgwSr1pZPqpG6YbHJA-Zk0cFyC_r-ihA,4396
|
|
108
109
|
klaude_code/llm/openai_compatible/input.py,sha256=rtWVjpwb9tLrinucezmncQXet8MerUxE5Gxc32sfDr4,3750
|
|
109
|
-
klaude_code/llm/openai_compatible/
|
|
110
|
+
klaude_code/llm/openai_compatible/stream.py,sha256=_OlnD5IBAq4xS5tb3mZUObZFGjXP-66lY4g8cxErRoo,10808
|
|
110
111
|
klaude_code/llm/openai_compatible/tool_call_accumulator.py,sha256=kuw3ceDgenQz2Ccc9KYqBkDo6F1sDb5Aga6m41AIECA,4071
|
|
111
112
|
klaude_code/llm/openrouter/__init__.py,sha256=_As8lHjwj6vapQhLorZttTpukk5ZiCdhFdGT38_ASPo,69
|
|
112
|
-
klaude_code/llm/openrouter/client.py,sha256=
|
|
113
|
+
klaude_code/llm/openrouter/client.py,sha256=zUkH7wkiYUJMGS_8iaVwdhzUnry7WLw4Q1IDQtncmK0,4864
|
|
113
114
|
klaude_code/llm/openrouter/input.py,sha256=aHVJCejkwzWaTM_EBbgmzKWyZfttAws2Y7QDW_NCnZk,5671
|
|
114
|
-
klaude_code/llm/openrouter/
|
|
115
|
+
klaude_code/llm/openrouter/reasoning.py,sha256=d6RU6twuGfdf0mXGQoxSNRzFaSa3GJFV8Eve5GzDXfU,4472
|
|
115
116
|
klaude_code/llm/registry.py,sha256=grgHetTd-lSxTXiY689QW_Zd6voaid7qBqSnulpg_fE,1734
|
|
116
117
|
klaude_code/llm/responses/__init__.py,sha256=WsiyvnNiIytaYcaAqNiB8GI-5zcpjjeODPbMlteeFjA,67
|
|
117
118
|
klaude_code/llm/responses/client.py,sha256=XEsVehevQJ0WFbEVxIkI-su7VwIcaeq0P9eSrIRcGug,10184
|
|
@@ -121,7 +122,7 @@ klaude_code/protocol/__init__.py,sha256=aGUgzhYqvhuT3Mk2vj7lrHGriH4h9TSbqV1RsRFA
|
|
|
121
122
|
klaude_code/protocol/commands.py,sha256=GN6GX9fo7YYtfumrBTpOmOvZofsnzZN2SAxP2X0BjTk,644
|
|
122
123
|
klaude_code/protocol/events.py,sha256=KUMf1rLNdHQO9cZiQ9Pa1VsKkP1PTMbUkp18bu_jGy8,3935
|
|
123
124
|
klaude_code/protocol/llm_param.py,sha256=cb4ubLq21PIsMOC8WJb0aid12z_sT1b7FsbNJMr-jLg,4255
|
|
124
|
-
klaude_code/protocol/model.py,sha256=
|
|
125
|
+
klaude_code/protocol/model.py,sha256=aJUavwtGWY-XiDF6qk2ZV6FwEfjTqOnXZeznB7_zc_4,13606
|
|
125
126
|
klaude_code/protocol/op.py,sha256=X3UeXxBOLf_jkEaYXhQSTpjtUV2u1Ot5f4bbPWNdQp4,4241
|
|
126
127
|
klaude_code/protocol/op_handler.py,sha256=qaWrm2rlskSyF7ukPtxFAKf8brgLsUaVzg6035N-7w0,1565
|
|
127
128
|
klaude_code/protocol/sub_agent/__init__.py,sha256=Abap5lPLgnSCQsVD3axfeqnj2UtxOcDLGX8e9HugfSU,3964
|
|
@@ -152,7 +153,7 @@ klaude_code/ui/__init__.py,sha256=XuEQsFUkJet8HI04cRmNLwnHOUqaPCRy4hF7PJnIfCY,27
|
|
|
152
153
|
klaude_code/ui/core/__init__.py,sha256=2NakrTDcxem5D0atyEY_Rxv1BbKCeZweF63L6AAq6r8,23
|
|
153
154
|
klaude_code/ui/core/display.py,sha256=NwFQ9oKi8i3T5EsYDRrTpGBr3BZI0Ggns37JuQEOH54,3540
|
|
154
155
|
klaude_code/ui/core/input.py,sha256=GqEos_VKRpfzQg0LQvr3210gzu2mw0_7OpPyNXmF3LI,2533
|
|
155
|
-
klaude_code/ui/core/stage_manager.py,sha256=
|
|
156
|
+
klaude_code/ui/core/stage_manager.py,sha256=5rJ7Fg3vf_4x9PTt6VOZ-SVRpg9jAZhZkCh_tQslLNg,1578
|
|
156
157
|
klaude_code/ui/modes/__init__.py,sha256=ByDPbyYYU4o5kdnEes3b1VEV173RI9XAXyzkFbrApEY,26
|
|
157
158
|
klaude_code/ui/modes/debug/__init__.py,sha256=1-1tAk7FtENdYzExSttYdHiJ-qH3DIQ5yYJ51ms2uSg,13
|
|
158
159
|
klaude_code/ui/modes/debug/display.py,sha256=7_j9NGZqL4wE2LWhF1TjDHac4MfaWlYN2RHZCTfQad8,1096
|
|
@@ -162,30 +163,30 @@ klaude_code/ui/modes/repl/__init__.py,sha256=35a6SUiL1SDi2i43X2VjHQw97rR7yhbLBzk
|
|
|
162
163
|
klaude_code/ui/modes/repl/clipboard.py,sha256=ZCpk7kRSXGhh0Q_BWtUUuSYT7ZOqRjAoRcg9T9n48Wo,5137
|
|
163
164
|
klaude_code/ui/modes/repl/completers.py,sha256=GIvUS9TAFMMPDpoXLuIupEccoqIMEpSEw4IZmKjVo4c,28560
|
|
164
165
|
klaude_code/ui/modes/repl/display.py,sha256=0u4ISeOoYjynF7InYyV-PMOZqP44QBbjYOLOL18V0c0,2245
|
|
165
|
-
klaude_code/ui/modes/repl/event_handler.py,sha256=
|
|
166
|
-
klaude_code/ui/modes/repl/input_prompt_toolkit.py,sha256=
|
|
166
|
+
klaude_code/ui/modes/repl/event_handler.py,sha256=UUJYhNRSTFj7CVi_IG-fe3B5-pv9odcBvqgbJxeoQp0,25161
|
|
167
|
+
klaude_code/ui/modes/repl/input_prompt_toolkit.py,sha256=Jbpk-jOmBNBhw3hKkB8YzGSXRduIH9YOGMhMIPzF3gk,8564
|
|
167
168
|
klaude_code/ui/modes/repl/key_bindings.py,sha256=Fxz9Ey2SnOHvfleMeSYVduxuofY0Yo-97hMRs-OMe-o,7800
|
|
168
|
-
klaude_code/ui/modes/repl/renderer.py,sha256=
|
|
169
|
+
klaude_code/ui/modes/repl/renderer.py,sha256=Apg_z6D7JTmzxGN9os64bjlG9LxfOAgqjAAmiXA8fMc,12247
|
|
169
170
|
klaude_code/ui/renderers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
170
|
-
klaude_code/ui/renderers/assistant.py,sha256=
|
|
171
|
+
klaude_code/ui/renderers/assistant.py,sha256=nO_QNJ2e9TwtU2IlojO9lCMWNFUNmcE9Ezz-WW748_w,743
|
|
171
172
|
klaude_code/ui/renderers/common.py,sha256=5RdXC3ngtlhfmxRlbwOPtHtbXhAoWwbHoGX78tZcaTc,2284
|
|
172
173
|
klaude_code/ui/renderers/developer.py,sha256=CawltuPSt_8s5lLoYKWYD9htwORbjgHeb4Ap0L2q7R4,6881
|
|
173
174
|
klaude_code/ui/renderers/diffs.py,sha256=A37Wuz1_UIg0-st5le68-DRGz4-kot6N-wy9xEMKdz0,10403
|
|
174
175
|
klaude_code/ui/renderers/errors.py,sha256=o9pOHRqZ0nxMPwkmV4CG81X7taW1-izvga6RY3fFRMI,516
|
|
175
|
-
klaude_code/ui/renderers/metadata.py,sha256=
|
|
176
|
-
klaude_code/ui/renderers/sub_agent.py,sha256
|
|
177
|
-
klaude_code/ui/renderers/thinking.py,sha256=
|
|
178
|
-
klaude_code/ui/renderers/tools.py,sha256=
|
|
176
|
+
klaude_code/ui/renderers/metadata.py,sha256=b1aNqLjyaqErP4O5YSEXg7ychJcNTKpZ6hTmdcNJX84,8190
|
|
177
|
+
klaude_code/ui/renderers/sub_agent.py,sha256=-8aDIIG4vmqwSSJepYy_tn2vmChAHOLjwmPWN2o_B_Y,5728
|
|
178
|
+
klaude_code/ui/renderers/thinking.py,sha256=y5ICt0eJvpn2rtv5-_x6FDWyOYAnJHkfTdBWCr4Y6Yk,1946
|
|
179
|
+
klaude_code/ui/renderers/tools.py,sha256=W24deCM4GhZT69gzo3FwZ0QVYbQ-x5Bo2-y5nFkOsdE,22268
|
|
179
180
|
klaude_code/ui/renderers/user_input.py,sha256=e2hZS7UUnzQuQ6UqzSKRDkFJMkKTLUoub1JclHMX40g,3941
|
|
180
181
|
klaude_code/ui/rich/__init__.py,sha256=zEZjnHR3Fnv_sFMxwIMjoJfwDoC4GRGv3lHJzAGRq_o,236
|
|
181
182
|
klaude_code/ui/rich/cjk_wrap.py,sha256=ncmifgTwF6q95iayHQyazGbntt7BRQb_Ed7aXc8JU6Y,7551
|
|
182
183
|
klaude_code/ui/rich/code_panel.py,sha256=MdUP4QSaQJQxX0MQJT0pvrkhpGYZx3gWdIRbZT_Uj_I,3938
|
|
183
184
|
klaude_code/ui/rich/live.py,sha256=Uid0QAZG7mHb4KrCF8p9c9n1nHLHzW75xSqcLZ4bLWY,2098
|
|
184
|
-
klaude_code/ui/rich/markdown.py,sha256=
|
|
185
|
+
klaude_code/ui/rich/markdown.py,sha256=_B7yWgBpSY8I8MBTX1_qvDCmyIZY0I-EnPrmoShQ2iQ,12126
|
|
185
186
|
klaude_code/ui/rich/quote.py,sha256=tZcxN73SfDBHF_qk0Jkh9gWBqPBn8VLp9RF36YRdKEM,1123
|
|
186
187
|
klaude_code/ui/rich/searchable_text.py,sha256=DCVZgEFv7_ergAvT2v7XrfQAUXUzhmAwuVAchlIx8RY,2448
|
|
187
|
-
klaude_code/ui/rich/status.py,sha256=
|
|
188
|
-
klaude_code/ui/rich/theme.py,sha256=
|
|
188
|
+
klaude_code/ui/rich/status.py,sha256=JOB-Yb3_HBwKb8K-NHFVkjxCPLkDuAJYboS6JzNqMVc,9590
|
|
189
|
+
klaude_code/ui/rich/theme.py,sha256=GpPd_BD7rkCpmWDjdOYoW65UgJSMxAjA28Sgv5GbUNg,13291
|
|
189
190
|
klaude_code/ui/terminal/__init__.py,sha256=GIMnsEcIAGT_vBHvTlWEdyNmAEpruyscUA6M_j3GQZU,1412
|
|
190
191
|
klaude_code/ui/terminal/color.py,sha256=M-i09DVlLAhAyhQjfeAi7OipoGi1p_OVkaZxeRfykY0,7135
|
|
191
192
|
klaude_code/ui/terminal/control.py,sha256=6SGNwxorP3jMW9xqnZy2BC0OsJd4DSrS13O3t6YlZzs,4916
|
|
@@ -193,7 +194,7 @@ klaude_code/ui/terminal/notifier.py,sha256=wkRM66d98Oh6PujnN4bB7NiQxIYEHqQXverMK
|
|
|
193
194
|
klaude_code/ui/terminal/progress_bar.py,sha256=MDnhPbqCnN4GDgLOlxxOEVZPDwVC_XL2NM5sl1MFNcQ,2133
|
|
194
195
|
klaude_code/ui/utils/__init__.py,sha256=YEsCLjbCPaPza-UXTPUMTJTrc9BmNBUP5CbFWlshyOQ,15
|
|
195
196
|
klaude_code/ui/utils/common.py,sha256=tqHqwgLtAyP805kwRFyoAL4EgMutcNb3Y-GAXJ4IeuM,2263
|
|
196
|
-
klaude_code-1.2.
|
|
197
|
-
klaude_code-1.2.
|
|
198
|
-
klaude_code-1.2.
|
|
199
|
-
klaude_code-1.2.
|
|
197
|
+
klaude_code-1.2.24.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
|
|
198
|
+
klaude_code-1.2.24.dist-info/entry_points.txt,sha256=7CWKjolvs6dZiYHpelhA_FRJ-sVDh43eu3iWuOhKc_w,53
|
|
199
|
+
klaude_code-1.2.24.dist-info/METADATA,sha256=2hkiGL2H3Kze2MNzy6FcrtEG0KSh-t6tPBpgwjJreDk,7725
|
|
200
|
+
klaude_code-1.2.24.dist-info/RECORD,,
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"""Shared stream processing utilities for OpenAI-compatible clients.
|
|
2
|
-
|
|
3
|
-
This module provides a reusable stream state manager that handles the common
|
|
4
|
-
logic for accumulating and flushing reasoning, assistant content, and tool calls
|
|
5
|
-
across different LLM providers (OpenAI-compatible, OpenRouter).
|
|
6
|
-
"""
|
|
7
|
-
|
|
8
|
-
from collections.abc import Callable
|
|
9
|
-
from typing import Literal
|
|
10
|
-
|
|
11
|
-
from klaude_code.llm.openai_compatible.tool_call_accumulator import BasicToolCallAccumulator, ToolCallAccumulatorABC
|
|
12
|
-
from klaude_code.protocol import model
|
|
13
|
-
|
|
14
|
-
StreamStage = Literal["waiting", "reasoning", "assistant", "tool"]
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class StreamStateManager:
|
|
18
|
-
"""Manages streaming state and provides flush operations for accumulated content.
|
|
19
|
-
|
|
20
|
-
This class encapsulates the common state management logic used by both
|
|
21
|
-
OpenAI-compatible and OpenRouter clients, reducing code duplication.
|
|
22
|
-
"""
|
|
23
|
-
|
|
24
|
-
def __init__(
|
|
25
|
-
self,
|
|
26
|
-
param_model: str,
|
|
27
|
-
response_id: str | None = None,
|
|
28
|
-
reasoning_flusher: Callable[[], list[model.ConversationItem]] | None = None,
|
|
29
|
-
):
|
|
30
|
-
self.param_model = param_model
|
|
31
|
-
self.response_id = response_id
|
|
32
|
-
self.stage: StreamStage = "waiting"
|
|
33
|
-
self.accumulated_reasoning: list[str] = []
|
|
34
|
-
self.accumulated_content: list[str] = []
|
|
35
|
-
self.accumulated_tool_calls: ToolCallAccumulatorABC = BasicToolCallAccumulator()
|
|
36
|
-
self.emitted_tool_start_indices: set[int] = set()
|
|
37
|
-
self._reasoning_flusher = reasoning_flusher
|
|
38
|
-
|
|
39
|
-
def set_response_id(self, response_id: str) -> None:
|
|
40
|
-
"""Set the response ID once received from the stream."""
|
|
41
|
-
self.response_id = response_id
|
|
42
|
-
self.accumulated_tool_calls.response_id = response_id # pyright: ignore[reportAttributeAccessIssue]
|
|
43
|
-
|
|
44
|
-
def flush_reasoning(self) -> list[model.ConversationItem]:
|
|
45
|
-
"""Flush accumulated reasoning content and return items."""
|
|
46
|
-
if self._reasoning_flusher is not None:
|
|
47
|
-
return self._reasoning_flusher()
|
|
48
|
-
if not self.accumulated_reasoning:
|
|
49
|
-
return []
|
|
50
|
-
item = model.ReasoningTextItem(
|
|
51
|
-
content="".join(self.accumulated_reasoning),
|
|
52
|
-
response_id=self.response_id,
|
|
53
|
-
model=self.param_model,
|
|
54
|
-
)
|
|
55
|
-
self.accumulated_reasoning = []
|
|
56
|
-
return [item]
|
|
57
|
-
|
|
58
|
-
def flush_assistant(self) -> list[model.ConversationItem]:
|
|
59
|
-
"""Flush accumulated assistant content and return items."""
|
|
60
|
-
if not self.accumulated_content:
|
|
61
|
-
return []
|
|
62
|
-
item = model.AssistantMessageItem(
|
|
63
|
-
content="".join(self.accumulated_content),
|
|
64
|
-
response_id=self.response_id,
|
|
65
|
-
)
|
|
66
|
-
self.accumulated_content = []
|
|
67
|
-
return [item]
|
|
68
|
-
|
|
69
|
-
def flush_tool_calls(self) -> list[model.ToolCallItem]:
|
|
70
|
-
"""Flush accumulated tool calls and return items."""
|
|
71
|
-
items: list[model.ToolCallItem] = self.accumulated_tool_calls.get()
|
|
72
|
-
if items:
|
|
73
|
-
self.accumulated_tool_calls.chunks_by_step = [] # pyright: ignore[reportAttributeAccessIssue]
|
|
74
|
-
return items
|
|
75
|
-
|
|
76
|
-
def flush_all(self) -> list[model.ConversationItem]:
|
|
77
|
-
"""Flush all accumulated content in order: reasoning, assistant, tool calls."""
|
|
78
|
-
items: list[model.ConversationItem] = []
|
|
79
|
-
items.extend(self.flush_reasoning())
|
|
80
|
-
items.extend(self.flush_assistant())
|
|
81
|
-
if self.stage == "tool":
|
|
82
|
-
items.extend(self.flush_tool_calls())
|
|
83
|
-
return items
|
|
File without changes
|
|
File without changes
|