Commit 399311d
committed
refactor: improve error handling and streaming logic in LLM engine
- Wrap errors with `errbook.Wrap` for better error handling in `CreateCompletion` and `CreateStreamCompletion`.
- Add a conditional check for `e.config.Quiet` to control streaming output in `CreateStreamCompletion`.
- Modify the return value of `CreateStreamCompletion` to include `StreamCompletionOutput` instead of `nil`.
- Reorder the logic in the `Update` method to handle `StreamCompletionOutput` more effectively, ensuring content is appended before checking if it's the last message.
Signed-off-by: codiing-hui <wecoding@yeah.net>1 parent 6fdc89c commit 399311d
2 files changed
+23
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
203 | | - | |
| 203 | + | |
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
| |||
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
230 | | - | |
231 | | - | |
232 | | - | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
233 | 235 | | |
234 | 236 | | |
235 | 237 | | |
| |||
238 | 240 | | |
239 | 241 | | |
240 | 242 | | |
241 | | - | |
| 243 | + | |
242 | 244 | | |
243 | 245 | | |
244 | 246 | | |
| |||
250 | 252 | | |
251 | 253 | | |
252 | 254 | | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
257 | 261 | | |
258 | 262 | | |
259 | 263 | | |
260 | 264 | | |
261 | | - | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
262 | 270 | | |
263 | 271 | | |
264 | 272 | | |
| |||
276 | 284 | | |
277 | 285 | | |
278 | 286 | | |
279 | | - | |
| 287 | + | |
280 | 288 | | |
281 | 289 | | |
282 | 290 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | 115 | | |
120 | 116 | | |
121 | 117 | | |
122 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| |||
0 commit comments