Repository navigation
Go: implement Embed (embeddings) in TogetherAI driver - #15017
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 (2)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughAdds TogetherAI embeddings: updates config to add an embeddings route and models, and implements TogetherAIModel.Embed to POST /embeddings, parse and validate per-index embedding items, and return embeddings ordered to match inputs. ChangesTogetherAI Embeddings Feature
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
|
Hi @Magicbook1108, gentle ping for review when you have a moment. This follows the same OpenAI-compatible |
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/togetherai.go`:
- Around line 409-410: The validation for modelName currently only checks nil
and empty string but allows whitespace-only names; update the check in the
function that contains variable modelName to use strings.TrimSpace on *modelName
(importing the strings package if needed) and treat a trimmed empty string as
invalid (i.e., change the condition to nil OR strings.TrimSpace(*modelName) ==
""), and optionally assign the trimmed value back to *modelName so callers get
the normalized name; keep the same error return (fmt.Errorf("model name is
required")) when invalid.
🪄 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: f777a201-fcaa-448b-9b42-fc6ebcc39c1f
📒 Files selected for processing (2)
conf/models/togetherai.jsoninternal/entity/models/togetherai.go
|
Thanks @coderabbitai. Addressed in 279fdaf: the model-name check in |
|
Tip For best results, initiate chat on the files or code changes.
If you found this review helpful, would you consider giving us a shout-out on X? Thank you for using CodeRabbit! |
Haruko386
left a comment
There was a problem hiding this comment.
Hi @jack-stormentswe, all tests are passed, thank you for your contribution. ❤
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #15017 +/- ##
=======================================
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:
|
29d1c80 to
c5045a0
Compare
What problem does this PR solve?
Fixes #15015
The TogetherAI Go driver in
internal/entity/models/togetherai.goshipped a stubEmbedmethod that returned"TogetherAI, no such method", so TogetherAI could not be used as an embedding provider in RAGFlow. This PR fills that gap.TogetherAI exposes a public OpenAI-compatible embeddings endpoint at
POST https://api.together.ai/v1/embeddingsthat accepts the standard{model, input}shape withAuthorization: Bearer <api_key>(confirmed in TogetherAI's official docs: https://docs.together.ai/docs/embeddings-overview). Documented embedding models includeintfloat/multilingual-e5-large-instruct,BAAI/bge-large-en-v1.5, andBAAI/bge-base-en-v1.5.Changes
internal/entity/models/togetherai.go: implementTogetherAIModel.Embed.baseURLForRegionhelper.URLSuffix.Embedding.{model, input}POST body, adddimensionswhenembeddingConfig.Dimension > 0(matches the pattern in Go CLI: embed and rerank #14735).{data: [{embedding, index}]}and reorder byindex, rejecting out-of-range indices, duplicates, and missing entries so the output always lines up with the input. Same shape as the merged Mistral, Upstage, and Novita Embed implementations.conf/models/togetherai.json:"embedding": "embeddings"tourl_suffix.intfloat/multilingual-e5-large-instruct,BAAI/bge-large-en-v1.5, andBAAI/bge-base-en-v1.5.Type of change