Repository navigation
Go: implement provider: Tencent Hunyuan - #15092
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds Tencent Hunyuan as a Go model provider: configuration and factory wiring, a HunyuanModel driver with sync chat, SSE streaming (separating reasoning/content), model listing and CheckConnection, unimplemented stubs for other capabilities, and comprehensive tests. ChangesTencent Hunyuan Model Driver Integration
Sequence DiagramsequenceDiagram
participant Client as Chat caller
participant Hunyuan as Hunyuan API
participant Sender as Sender callback
Client->>Hunyuan: POST /v1/chat/completions (stream? true/false, model, messages)
alt non-stream
Hunyuan-->>Client: 200 JSON (choices[0].message.content, reasoning_content)
Client->>Sender: send(content, reasoning_content) (final)
else stream (SSE)
Hunyuan-->>Client: SSE data: {delta.content}, {delta.reasoning_content}, ... , [DONE]
Client->>Sender: send(reasoning_delta, nil) per reasoning frames
Client->>Sender: send(nil, content_delta) per content frames
Client->>Sender: send("[DONE]", "[DONE]") on terminal event
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
This PR looks like a solid implementation that follows the established SaaS-driver pattern used by the other OpenAI-compatible providers (TogetherAI, DeepInfra, Novita, etc.) [1]. A few observations:
The referenced feature request (#15087) confirms this was the expected implementation path [5]. Looks good overall — nice addition to the Go driver set. To reply, just mention @dosu. Share context across your team and agents. Try Dosu. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/entity/models/hunyuan_test.go`:
- Around line 12-44: The test helper newHunyuanServer currently only asserts
method for POST but not for other endpoints; update newHunyuanServer to accept
an expected HTTP method (or add an expectedMethod string) and assert r.Method ==
expectedMethod before handling the request (returning an error or t.Errorf on
mismatch), then update the ListModels and CheckConnection tests to call
newHunyuanServer with the appropriate expected method (e.g., "GET") so the
helper enforces the verb for non-POST calls; reference the newHunyuanServer
function and the tests invoking ListModels/CheckConnection to locate where to
add the expectedMethod parameter and assertions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ef08e924-f5ce-4276-81ac-9d737965fe77
📒 Files selected for processing (4)
conf/models/hunyuan.jsoninternal/entity/models/factory.gointernal/entity/models/hunyuan.gointernal/entity/models/hunyuan_test.go
Per CodeRabbit review on infiniflow#15092: newHunyuanServer asserted path, Authorization, and body, but not the HTTP verb. A future bug that flipped ListModels from GET to POST (or vice versa) would silently pass the existing tests. Add an expectedMethod parameter, assert r.Method matches up front, and update all six call sites: - 3 chat-completions tests pass http.MethodPost - 3 /models tests pass http.MethodGet All 14 TestHunyuan* tests still pass.
Fixes Applied SuccessfullyFixed 1 file based on 1 CodeRabbit feedback item. Files modified:
Commit: The latest autofix changes are on the Addressed: assert HTTP method ( |
Haruko386
left a comment
There was a problem hiding this comment.
Hi @dripsmvcp, thank you for your contribution.
All tests are passed, just do a small change
| @@ -0,0 +1,33 @@ | |||
| { | |||
| "name": "Tencent Hunyuan", | |||
|
FIxed it, thanks for the review @Haruko386 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #15092 +/- ##
==========================================
- Coverage 94.53% 93.12% -1.41%
==========================================
Files 10 10
Lines 713 713
Branches 116 116
==========================================
- Hits 674 664 -10
- Misses 25 29 +4
- Partials 14 20 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
HunyuanGo driver so the new API server can route Tencent Hunyuan chat instances (registered inconf/llm_factories.json:3830asTencent Hunyuan). Follows the same SaaS-driver shape used for Astraflow, Avian, Novita, TogetherAI, Replicate, DeepInfra, Upstage, and LongCat.Root Cause
conf/llm_factories.json:3830already registers theTencent Hunyuanfactory with 5 preconfigured models and the default base URLhttps://api.hunyuan.cloud.tencent.com/v1, butinternal/entity/models/had nohunyuan.godriver andconf/models/had nohunyuan.json, so the Go API server fell back to the dummy driver for Hunyuan instances.Fix
internal/entity/models/hunyuan.go— OpenAI-compatible driver implementingChatWithMessages,ChatStreamlyWithSender,ListModels, andCheckConnection(delegates toListModels). Forwards documented fields only (model,messages,stream,max_tokens,temperature,top_p,stop). SSE handling rejects malformed frames, surfaces upstream{"error": …}frames, and requires a[DONE]/finish_reasonterminator.conf/models/hunyuan.json— base URL + the 4 chat models from the factory entry (hunyuan-pro,hunyuan-standard,hunyuan-standard-256K,hunyuan-lite).hunyuan-visionis deliberately omitted from this initial driver; Image2Text support (factory tags includeIMAGE2TEXT) lands in a follow-up issue, mirroring how Novita / TogetherAI / DeepInfra landed method-by-method.internal/entity/models/factory.go— registers thehunyuancase.internal/entity/models/hunyuan_test.go— 21 hermetic tests usinghttptest.Server(no network).Test Plan
internal/entity/models/hunyuan_test.gogo test ./internal/entity/models/ -run Hunyuan -count=1 -vet=offCloses #15087