fix(selfhost): attribute embed/vision/advisory AI usage to a real provider#5259
Conversation
…vider createOpenAiCompatibleAi's usage.provider fix (#5247) never took effect in production because src/server.ts's 3 call sites that construct the AI_EMBED/AI_VISION/AI_ADVISORY bindings never passed providerName at all -- confirmed live via a real RAG-indexing pass on edge-nl-01, which recorded correct model attribution (bge-m3:latest) but every row's provider column was still blank. These bindings accept any openai-compatible endpoint with no explicit provider selector, so classify the configured base URL's hostname into the existing ollama/openai/openai-compatible provider-name set instead of guessing or hardcoding one.
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5259 +/- ##
=======================================
Coverage 94.36% 94.36%
=======================================
Files 474 474
Lines 40081 40088 +7
Branches 14614 14617 +3
=======================================
+ Hits 37821 37828 +7
Misses 1585 1585
Partials 675 675
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-07-12 12:18:44 UTC
⏸️ Suggested Action - Manual Review
Review summary Nits — 5 non-blocking
Concerns raised — review before merging
Review context
Contributor next steps
Signal definitions
[BETA] Chat with GittensoryAsk Gittensory a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://gittensory.aethereal.dev/docs/gittensory-commands 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
Summary
Follow-up to #5247, found during its own live-deploy verification on edge-nl-01.
#5247 fixed
createOpenAiCompatibleAito return realusage.providerattribution, butsrc/server.ts's 3 call sites that actually construct theAI_EMBED/AI_VISION/AI_ADVISORYbindings never passed
providerNameat all — confirmed live by triggering a real RAG-indexingpass on edge-nl-01 right after deploying #5247: the new
embeddingsrows correctly showed thereal model (
bge-m3:latest, not the old hardcoded placeholder) butproviderwas still blank onevery row, since
opts.providerNamewasundefinedat the source.These 3 bindings deliberately accept any openai-compatible endpoint with no explicit provider
selector (unlike the main review chain's
AI_PROVIDER), so there's no existing knob to read aprovider name from. Added
providerNameFromBaseUrl()to classify the configured base URL into thesame closed
"ollama" | "openai" | "openai-compatible"setcreateOpenAiCompatibleAialready uses— recognizing the bundled docker-compose
ollamaservice and OpenAI's own endpoint, and fallingback to the honest generic bucket for anything else (vLLM, LM Studio, a custom hostname) rather than
guessing.
Test plan
npm run typecheck— cleannpm run test:ci— full local gate greenexact hostname, a generic other host, and the undefined/malformed-URL fallback)
produced a fresh
embeddingsrow withprovider = 'ollama', model = 'bge-m3:latest', and anorganic
screenshot_table_visionrow landed withprovider = 'ollama', model = 'qwen3-vl:8b-instruct'— both were previously always blank onprovider.