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:
jay77721
2026-08-03 17:48:45 +08:00
committed by GitHub
parent 3e86227a14
commit 31264bafb2
16 changed files with 96 additions and 1587 deletions

View File

@@ -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
})