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:
13
nu/review.nu
13
nu/review.nu
@@ -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 }
|
||||
|
||||
Reference in New Issue
Block a user