add: enhance HunYuan AI API response structure and implement token usage tracking and handle error situations

This commit is contained in:
dashen
2024-12-27 18:39:03 +08:00
parent 64252213a5
commit 716bc3bf94

View File

@@ -86,6 +86,7 @@ func (c *Chat) RequestConvert(ctx eocontext.EoContext, extender map[string]inter
body, err = json.Marshal(baseCfg)
if err != nil {
// handle error
return err
}
// Unmarshal body to map
@@ -93,6 +94,7 @@ func (c *Chat) RequestConvert(ctx eocontext.EoContext, extender map[string]inter
err = json.Unmarshal(body, &bodyMap)
if err != nil {
// handle error
return err
}
// Delete the "messages" field
@@ -102,6 +104,7 @@ func (c *Chat) RequestConvert(ctx eocontext.EoContext, extender map[string]inter
body, err = json.Marshal(bodyMap)
if err != nil {
// handle error
return err
}
httpContext.Proxy().Body().SetRaw("application/json", body)