Repository navigation
Go: implement provider: Xinference - #14938
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)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a Xinference model provider: config and factory routing, a new XinferenceModel driver (HTTP client, base-URL normalization), synchronous and SSE streaming chat (idle-timeout), model listing and connectivity, unsupported-method stubs, and comprehensive httptest coverage. ChangesXinference Model Driver
Sequence Diagram(s)sequenceDiagram
participant Client
participant XinferenceModel
participant XinferenceAPI as /v1/chat/completions
participant SenderCallback
participant Ticker as IdleTimeoutTicker
Client->>XinferenceModel: ChatStreamlyWithSender(messages, ChatConfig, sender)
XinferenceModel->>XinferenceAPI: POST with stream:true, Authorization (optional)
XinferenceAPI-->>XinferenceModel: SSE data: lines with JSON delta
XinferenceModel->>SenderCallback: emit delta.reasoning_content / delta.content fragments
Ticker->>XinferenceModel: cancel on inactivity
XinferenceModel->>SenderCallback: emit final [DONE]
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
🚥 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 |
|
Live Xinference test result (2026-05-14 UTC) Ran a temporary build-tagged live test against a real local Xinference server. The test file was removed afterward and is not part of this PR. Environment:
Passed live coverage:
Command that passed: XINFERENCE_BASE_URL=http://127.0.0.1:19997 go test -vet=off -tags xinference_live -run TestXinferenceLiveChatProvider -count=1 -v ./internal/entity/modelsRuntime note: the first model launch used Xinference's per-model virtualenv, which installed Committed regression checks also pass: go test -vet=off -run TestXinference -count=1 ./internal/entity/models/...
go test -vet=off -count=1 ./internal/entity/models/... |
There was a problem hiding this comment.
@tmimmanuel please read xinference docs for more information
|
@tmimmanuel would you please fix CI error? |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #14938 +/- ##
=======================================
Coverage 94.16% 94.16%
=======================================
Files 10 10
Lines 703 703
Branches 112 112
=======================================
Hits 662 662
Misses 25 25
Partials 16 16 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@JinHai-CN |
### What problem does this PR solve? Fixes #14816 The Xinference Go driver landed chat in #14938 and Embed is in review in #14932, but `Rerank` shipped as a stub that returns `"xinference, no such method"`. Tenants who launch a rerank model with `--model-type rerank` on their Xinference instance cannot route it through the Go API server. This PR fills the gap. Xinference exposes an OpenAI-compatible REST API. The rerank endpoint is at `POST <base>/v1/rerank` and accepts the Cohere-shaped body `{model, query, documents, top_n}`, returning `{results: [{index, relevance_score}]}` — the same wire shape used by the merged NVIDIA (#14778), Aliyun (#14676), Gitee (#14656), ZhipuAI (#14608), Novita (#15014), and LocalAI (#14813) Rerank implementations. Documented in [Xinference rerank docs](https://inference.readthedocs.io/en/v1.6.1/models/model_abilities/rerank.html); the [builtin rerank model catalog](https://inference.readthedocs.io/en/stable/models/builtin/rerank/) lists `bge-reranker-base`, `bge-reranker-large`, `bge-reranker-v2-m3`, and others.
What problem does this PR solve?
Closes #14808.
Adds a Go model driver for Xinference so self-hosted Xinference chat models can be used through the Go provider layer instead of falling through to the dummy driver. Xinference exposes an OpenAI-compatible API under
/v1; the driver accepts either a root endpoint such ashttp://127.0.0.1:9997or an OpenAI-compatible endpoint such ashttp://127.0.0.1:9997/v1and normalizes it before calling chat or model-listing routes.What is changed?
internal/entity/models/xinference.goimplementingModelDriverfor Xinference chat.xinferenceininternal/entity/models/factory.go.conf/models/xinference.jsonas a local provider config.internal/entity/models/xinference_test.go.Initial method coverage:
ChatWithMessages: POST/v1/chat/completions.ChatStreamlyWithSender: SSE streaming from/v1/chat/completions.ListModels: GET/v1/models.CheckConnection: lightweightListModelsprobe.Authorization: Bearer <api_key>only when a non-empty key is configured, matching Xinference no-auth and auth-enabled deployments.Balance,Embed,Rerank, ASR, TTS, and OCR returnno such methodfor this initial chat-provider PR.Type of change
Tests
go test -vet=off -run TestXinference -count=1 ./internal/entity/models/...go test -vet=off -count=1 ./internal/entity/models/...References