1
0
mirror of https://github.com/hustcer/deepseek-review.git synced 2026-05-13 05:16:05 +08:00

fix: Improve error handling for API response in streaming-output (#117)

* fix: Improve error handling for API response in streaming-output

* Fix token error

* Fix error
This commit is contained in:
Justin Ma
2025-02-12 23:24:43 +08:00
committed by GitHub
parent c0d78b92b9
commit 84dbd263c9

View File

@@ -188,8 +188,17 @@ def streaming-output [
kv set content 0
kv set reasoning 0
http post -e -H $headers -t application/json $url $payload
| tee { let res = $in; if ($res | describe) =~ 'record' { $res | table -e | print; exit $ECODE.SERVER_ERROR } }
| lines
| tee {
let res = $in
let type = $res | describe
let record_error = $type =~ '^record'
let other_error = $type =~ '^string' and $res !~ 'data: '
if $record_error or $other_error {
$res | table -e | print
exit $ECODE.SERVER_ERROR
}
}
| try { lines } catch { print $'(ansi r)Error Happened ...(ansi reset)'; exit $ECODE.SERVER_ERROR }
| each {|line|
if $line == $RESPONSE_END { return }
if ($line | is-empty) { return }