mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-05 15:20:30 +08:00
feat(go-models): migrate batch 4 model drivers to unified handlers (#17699)
## Summary Relate to #17284 Migrate 10 OpenAI-compatible drivers (`orcarouter`, `perplexity`, `ppio`, `qiniu`, `ragcon`, `stepfun`, `togetherai`, `tokenhub`, `tokenpony`, `upstage`) to use the unified response handlers (`HandleNonStreamingResponse` / `HandleStreamingResponse`), following the same pattern established by `deepseek` in #17634. - Cut ~150 lines per driver (1436 lines removed, 62 added across 10 files). - No functional changes — pure deduplication of HTTP plumbing. - Each driver now routes through `baseModel.doRequest()` and `HandleNonStreamingResponse()`. --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -38,6 +38,11 @@ func HandleNonStreamingResponse(
|
||||
return nil, fmt.Errorf("failed to parse response: %w", err)
|
||||
}
|
||||
|
||||
// Check for upstream error.
|
||||
if apiErr, ok := result["error"]; ok && apiErr != nil {
|
||||
return nil, fmt.Errorf("upstream error: %v", apiErr)
|
||||
}
|
||||
|
||||
// Extract usage via the protocol-specific parser.
|
||||
var usage *TokenUsage
|
||||
if u, ok := cfg.ResponseParser(result); ok {
|
||||
@@ -137,6 +142,9 @@ func HandleStreamingResponse(
|
||||
if finishReason, ok := firstChoice["finish_reason"].(string); ok && finishReason != "" {
|
||||
sawTerminal = true
|
||||
}
|
||||
if finishReason, ok := event["finish_reason"].(string); ok && finishReason != "" {
|
||||
sawTerminal = true
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user