Repository navigation
Go: implement provider: TokenPony - #15091
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds TokenPony provider: new config and factory case, TokenPonyModel driver implementing chat (sync + SSE), ListModels/CheckConnection, unsupported-method stubs, and comprehensive unit tests. ChangesTokenPony Provider Implementation
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 well-structured and follows the established pattern for OpenAI-compatible SaaS drivers in RAGFlow. A few observations: Alignment with existing patterns: The implementation matches the approach used by the 6+ existing Go drivers (Novita, DeepInfra, Upstage, TogetherAI, Replicate, LongCat) in Factory config confirmed: The Test coverage: 21 hermetic tests using One note: The PR description mentions "Astraflow" and "Avian" as reference drivers, but those don't appear to be merged into the main branch yet — only Novita, DeepInfra, Upstage, TogetherAI, Replicate, and LongCat are currently present [1]. This doesn't affect the PR itself, just a heads-up that those references may point to other in-flight PRs. To reply, just mention @dosu. Docs are dead. Just use Dosu. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/entity/models/tokenpony_test.go (1)
160-160: 💤 Low valueOptional: Consider nil for absent reasoning content.
The test expects
ReasonContentto be a non-nil pointer to an empty string when reasoning is absent, rather than nil. While this works, the more idiomatic Go pattern is to use nil pointers to indicate absence. This would simplify client code by avoiding dereferences when checking for empty content.Example of idiomatic pattern:
if resp.ReasonContent != nil && *resp.ReasonContent != "" { // use reasoning }vs current pattern requiring:
if resp.ReasonContent != nil && *resp.ReasonContent != "" { // this check is always needed even though ReasonContent is never nil }🤖 Prompt for 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. In `@internal/entity/models/tokenpony_test.go` at line 160, The test currently asserts that resp.ReasonContent is a non-nil pointer to an empty string; change it to the idiomatic nil-for-absent pattern by ensuring the fixture or constructor that builds resp leaves ReasonContent as nil when no reasoning exists and update the assertion to check resp.ReasonContent == nil (or use if resp.ReasonContent != nil && *resp.ReasonContent != "" where appropriate). Locate usages of ReasonContent in tokenpony_test.go and the helper that constructs the response (the resp variable) and set ReasonContent = nil for absent reasoning, then replace the existing non-nil/empty-string check with a nil check.
🤖 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.
Nitpick comments:
In `@internal/entity/models/tokenpony_test.go`:
- Line 160: The test currently asserts that resp.ReasonContent is a non-nil
pointer to an empty string; change it to the idiomatic nil-for-absent pattern by
ensuring the fixture or constructor that builds resp leaves ReasonContent as nil
when no reasoning exists and update the assertion to check resp.ReasonContent ==
nil (or use if resp.ReasonContent != nil && *resp.ReasonContent != "" where
appropriate). Locate usages of ReasonContent in tokenpony_test.go and the helper
that constructs the response (the resp variable) and set ReasonContent = nil for
absent reasoning, then replace the existing non-nil/empty-string check with a
nil check.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ee1f6630-c37f-4643-80a1-2d524aa62fba
📒 Files selected for processing (4)
conf/models/tokenpony.jsoninternal/entity/models/factory.gointernal/entity/models/tokenpony.gointernal/entity/models/tokenpony_test.go
Haruko386
left a comment
There was a problem hiding this comment.
Hi @dripsmvcp, thank you for your contribution
please fix the wrong url
Haruko386
left a comment
There was a problem hiding this comment.
@dripsmvcp LGTM
Thank you for your contribution
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #15091 +/- ##
==========================================
- 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
TokenPonyGo driver so the new API server can route TokenPony chat instances, matching the existing PythonTokenPonyChat(rag/llm/chat_model.py:1210). Follows the same SaaS-driver shape used for Astraflow, Avian, Novita, TogetherAI, Replicate, DeepInfra, Upstage, and LongCat.Root Cause
conf/llm_factories.json:282already registers theTokenPonyfactory with 16 chat models and the default base URLhttps://ragflow.vip-api.tokenpony.cn/v1, butinternal/entity/models/had notokenpony.godriver andconf/models/had notokenpony.json, so the Go API server fell back to the dummy driver for TokenPony instances.Fix
internal/entity/models/tokenpony.go— OpenAI-compatible driver implementingChatWithMessages,ChatStreamlyWithSender,ListModels, andCheckConnection(delegates toListModels). Forwards documented fields only (model,messages,stream,max_tokens,temperature,top_p,stop). Reasoning models surfacereasoning_contentseparately fromcontent. SSE handling rejects malformed frames, surfaces upstream{"error": …}frames, and requires a[DONE]/finish_reasonterminator.conf/models/tokenpony.json— base URLhttps://ragflow.vip-api.tokenpony.cn/v1+ the 16 chat models from the factory entry (qwen3-8b/-32b/-coder-480b/-next-80b/-235b/-vl-*, deepseek-v3-0324/-r1-0528/-v3.2-exp/-v3.1-terminus/-ocr, kimi-k2-instruct-0905, hunyuan-a13b-instruct, glm-4.6, minimax-m2).internal/entity/models/factory.go— registers thetokenponycase.internal/entity/models/tokenpony_test.go— 21 hermetic tests usinghttptest.Server(no network).Test Plan
internal/entity/models/tokenpony_test.gogo test ./internal/entity/models/ -run TokenPony -count=1 -vet=offCloses #15086