Mirror Zhanlu client: GLM tool_stream, shared v4 UUID request id, drop chat state:ERROR
build / build (push) Successful in 2m26s

This commit is contained in:
2026-08-21 14:27:37 +08:00
parent a0a2049440
commit b9a3f8d5cd
4 changed files with 32 additions and 17 deletions
+1 -5
View File
@@ -440,7 +440,7 @@ func (s *Server) postPhoneAPI(endpoint string, payload map[string]string, out *p
req.Header.Set("Content-Type", "application/json")
req.Header.Set("plugin_type", "zhanlu_ide")
req.Header.Set("plugin_version", s.cfg.PluginVersion)
req.Header.Set("request", randomRequestID())
req.Header.Set("request", util.RandomRequestID())
resp, err := s.upstreamHTTPClient().Do(req)
if err != nil {
return err
@@ -1093,10 +1093,6 @@ func forEachSSEChunk(r io.Reader, fn func([]byte) error) error {
if payload == "" || payload == "[DONE]" {
continue
}
var upstreamError map[string]any
if json.Unmarshal([]byte(payload), &upstreamError) == nil && upstreamError["state"] == "ERROR" {
return fmt.Errorf("zhanlu upstream error: %v", upstreamError["errorMessage"])
}
if err := fn([]byte(payload)); err != nil {
return err
}