Repository navigation
feat(go): implement provider Astraflow (#15062) - #15064
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 an Astraflow provider: configuration, Go driver (sync + SSE streaming chat), ListModels/CheckConnection, factory wiring, unsupported-method stubs, and comprehensive tests validating sync and streaming behavior. ChangesAstraflow Provider Implementation
Sequence Diagram(s)sequenceDiagram
participant Client
participant AstraflowModel
participant AstraflowAPI
Client->>AstraflowModel: ChatWithMessages(...)
AstraflowModel->>AstraflowAPI: POST /v1/chat/completions (JSON)
AstraflowAPI-->>AstraflowModel: JSON reply (choices[0].message)
AstraflowModel-->>Client: ChatResponse{Answer, ReasonContent}
Client->>AstraflowModel: ChatStreamlyWithSender(..., sender)
AstraflowModel->>AstraflowAPI: POST /v1/chat/completions (stream=true)
AstraflowAPI-->>AstraflowModel: SSE stream (data: events)
loop per SSE event
AstraflowModel->>Client: sender(reasoningDelta?, contentDelta?)
end
AstraflowAPI-->>AstraflowModel: [DONE]
AstraflowModel->>Client: sender("[DONE]")
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 |
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/astraflow.go`:
- Around line 333-360: When processing SSE choice chunks, the code currently
ignores a terminal event if firstChoice contains "finish_reason" but no "delta";
update the logic in the chunk-processing loop that handles firstChoice/delta
(references: firstChoice, delta, sender, sawTerminal) to check for a
"finish_reason" on firstChoice even when delta is nil or not a map, set
sawTerminal = true and break out of the loop (honoring the terminal event)
before returning the "stream ended" error; ensure existing sender calls for
reasoning_content/content only run when delta is present and valid.
🪄 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: 00097e0a-6ab1-4478-af33-c580ae15486d
📒 Files selected for processing (4)
conf/models/astraflow.jsoninternal/entity/models/astraflow.gointernal/entity/models/astraflow_test.gointernal/entity/models/factory.go
… review) Astraflow can emit a terminal stream frame that carries finish_reason without a delta object. The previous loop bailed early when delta was absent, so the terminator was never observed and the method returned 'stream ended before [DONE] or finish_reason'. Guard the delta block so finish_reason is honored independently.
|
Hi @dripsmvcp, before I review your code, as far as I know, AstraFlow use dynamic API-KEY, would you please tell me how you handle it. |
|
Hey @Haruko386, thanks for jumping on this! Quick question back at you — what do you mean by "dynamic API-KEY"? I matched what the Python side already does in AstraflowChat (rag/llm/chat_model.py:1237): it just takes whatever key the user pastes into Add-Provider and sends it as Authorization: Bearer on every call, same as any OpenAI-compatible provider. No token refresh, no exchange step. So the Go driver does the exact same thing. But if Astraflow actually expects something fancier — like a short-lived token you have to mint from a client_id/secret, or a key that rotates and needs refreshing — that's news to me, and the Python driver wouldn't be handling it either. Got a doc link or an existing driver I can crib from? Happy to wire it up properly here (and probably patch the Python side too in a follow-up) rather than guess at the shape. |
|
@dripsmvcp According to this Docs, AstraFlow need a public Key and a private key to generate API-KEY. Have you test it? |
|
Just ran it against a live key, @Haruko386 — bearer-token auth works as-is, no public/private signing involved. GET https://api-us-ca.umodelverse.ai/v1/models POST https://api-us-ca.umodelverse.ai/v1/chat/completions UAPI (console.ucloud.cn/uapi/apikey) — issues a PublicKey + PrivateKey pair used to SHA1-sign requests against api.ucloud.cn (compute/storage/networking control plane). These are not inputs to a ModelVerse key — there's no derivation step, which is why using either one alone got you no response. |
|
wow, thank you :) @dripsmvcp |
Haruko386
left a comment
There was a problem hiding this comment.
@dripsmvcp thank you for your contribution
LGTM
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #15064 +/- ##
=======================================
Coverage 93.12% 93.12%
=======================================
Files 10 10
Lines 713 713
Branches 116 116
=======================================
Hits 664 664
Misses 29 29
Partials 20 20 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Adds an `Astraflow` Go driver so the new API server can route Astraflow (UCloud ModelVerse) chat instances, matching the existing Python `AstraflowChat` (`rag/llm/chat_model.py:1237`). Follows the same SaaS-driver shape used for Avian, Novita, TogetherAI, Replicate, DeepInfra, Upstage, and LongCat. Closes #15062 --------- Co-authored-by: Jin Hai <[email protected]>
AstraflowGo driver so the new API server can route Astraflow (UCloud ModelVerse) chat instances, matching the existing PythonAstraflowChat(rag/llm/chat_model.py:1237). Follows the same SaaS-driver shape used for Avian, Novita, TogetherAI, Replicate, DeepInfra, Upstage, and LongCat.Root Cause
conf/llm_factories.json:6234already registers theAstraflowfactory with 18 chat models and the default base URLhttps://api-us-ca.umodelverse.ai/v1, butinternal/entity/models/had noastraflow.godriver andconf/models/had noastraflow.json, so the Go API server fell back to the dummy driver for Astraflow instances.Fix
internal/entity/models/astraflow.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/astraflow.json— base URLhttps://api-us-ca.umodelverse.ai/v1+ the 18 chat models from the factory entry (claude-opus-4-7/4-6, claude-sonnet-4-5, claude-haiku-4-5, gpt-5.4/-mini/-nano, gpt-4o-mini, Qwen3-Max/-Coder/-32B/-VL, kimi-k2.6, glm-5.1, MiniMax-M2.7/M2, gemini-2.5-pro/-flash).internal/entity/models/factory.go— registers theastraflowcase.internal/entity/models/astraflow_test.go— 21 hermetic tests usinghttptest.Server(no network).Follow-on issues will add Embed (factory tags include
TEXT EMBEDDING) and the China-region siblingAstraflow-CN(Pythonchat_model.py:1246, basehttps://api.modelverse.cn/v1), in line with how Novita / NVIDIA / TogetherAI landed method-by-method.Test Plan
internal/entity/models/astraflow_test.gogo test ./internal/entity/models/ -run Astraflow -count=1 -vet=offCloses #15062