fix: enhance tool usage parsing with additional nil checks and error logging
This commit is contained in:
@@ -46,10 +46,13 @@ func OaiResponsesHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *http
|
|||||||
usage.PromptTokensDetails.CachedTokens = responsesResponse.Usage.InputTokensDetails.CachedTokens
|
usage.PromptTokensDetails.CachedTokens = responsesResponse.Usage.InputTokensDetails.CachedTokens
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if info == nil || info.ResponsesUsageInfo == nil || info.ResponsesUsageInfo.BuiltInTools == nil {
|
||||||
|
return &usage, nil
|
||||||
|
}
|
||||||
// 解析 Tools 用量
|
// 解析 Tools 用量
|
||||||
for _, tool := range responsesResponse.Tools {
|
for _, tool := range responsesResponse.Tools {
|
||||||
buildToolinfo, ok := info.ResponsesUsageInfo.BuiltInTools[common.Interface2String(tool["type"])]
|
buildToolinfo, ok := info.ResponsesUsageInfo.BuiltInTools[common.Interface2String(tool["type"])]
|
||||||
if !ok {
|
if !ok || buildToolinfo == nil {
|
||||||
logger.LogError(c, fmt.Sprintf("BuiltInTools not found for tool type: %v", tool["type"]))
|
logger.LogError(c, fmt.Sprintf("BuiltInTools not found for tool type: %v", tool["type"]))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user