Skip to content

Go: implement Embed (embeddings) in Novita driver - #14895

Merged
JinHai-CN merged 4 commits into
infiniflow:mainfrom
pandadev66:feat/go-novita-embed
May 18, 2026
Merged

JinHai-CN merged 4 commits into
infiniflow:mainfrom
pandadev66:feat/go-novita-embed

Conversation

@pandadev66

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Fixes #14893

The Novita Go driver landed in #14850 and shipped a stub Embed method that returned "novita, no such method", so Novita could not be used as an embedding provider in RAGFlow. This PR fills that gap.

Novita exposes a public embeddings endpoint at POST https://api.novita.ai/v3/embeddings that accepts the standard OpenAI-compatible request shape ({model, input}) with Authorization: Bearer <api_key>. Two embedding models are documented in Novita's model library: baai/bge-m3 (multilingual, 8192 tokens) and baai/bge-large-en-v1.5.

Changes

  • internal/entity/models/novita.go: implement NovitaModel.Embed.
    • Validate inputs (api key, model name) and short-circuit on empty texts.
    • Resolve region with the existing baseURLForRegion helper.
    • Build URL from URLSuffix.Embedding (the embeddings path lives under /v3/, separate from the chat path under /openai/v1/).
    • Send {model, input} POST body, add dimensions when embeddingConfig.Dimension > 0 (matches the pattern in Go CLI: embed and rerank #14735).
    • Bearer auth + JSON content type, mirroring the chat path.
    • Parse {data: [{embedding, index}]} and reorder by index, rejecting out-of-range indices, duplicates, and missing entries so the output always lines up with the input. Same shape as the merged Mistral and Upstage Embed implementations.
  • conf/models/novita.json:
    • Add "embedding": "v3/embeddings" to url_suffix.
    • Add default embedding model entries for baai/bge-m3 and baai/bge-large-en-v1.5 so they appear in the model picker.

Type of change

  • New Feature (non-breaking change which adds functionality)

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label May 13, 2026
@coderabbitai

coderabbitai Bot commented May 13, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d7dcb11c-26f7-4740-b426-e39534847cc6

📥 Commits

Reviewing files that changed from the base of the PR and between 2c59bae and ee688eb.

📒 Files selected for processing (1)
  • internal/entity/models/novita.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/entity/models/novita.go

📝 Walkthrough

Walkthrough

Adds Novita embedding URL/model config and implements NovitaModel.Embed to POST to Novita's embeddings endpoint, parse and validate the JSON response, and return embeddings aligned to the input order.

Changes

Novita Embeddings Implementation

Layer / File(s) Summary
Configuration and Model Definitions
conf/models/novita.json
Adds url_suffix.models and url_suffix.embedding and registers the baai/bge-m3 embedding model with max_tokens and model_types: ["embedding"].
Embed Method Implementation
internal/entity/models/novita.go
Adds internal embedding response structs and replaces the Embed stub with a full implementation: input/API key validation, regional POST to the embeddings endpoint (optional dimensions), HTTP status checks, JSON parsing, index bounds/duplicate/missing checks, and returns embeddings in original input order.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

  • #14806: Both changes implement the provider-specific Embed method and add an embedding URL suffix/config and model entry (similar provider embedding driver work).
  • #14699: Implements embeddings support in a provider driver and adds an embeddings URL suffix and real Embed implementation (similar pattern).

Possibly related PRs

  • infiniflow/ragflow#14850: Prior Novita driver work that introduced Novita support; this PR implements the Embed method and config additions building on that.

Suggested labels

size:M

Suggested reviewers

  • Haruko386

Poem

🐇 In Novita fields I hop and write,
Vectors bloom from morning light.
Config tweaked and code set free,
Embeddings march in tidy key.
A rabbit cheers: "Now RAG can see!"

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and concisely describes the main change: implementing the Embed method for the Novita driver in Go.
Description check ✅ Passed The PR description fully addresses the template structure with comprehensive explanation of the problem, detailed changes, and correct type classification.
Linked Issues check ✅ Passed All coding requirements from issue #14893 are met: NovitaModel.Embed implemented with input validation, region resolution, OpenAI-compatible API calls, response parsing with index validation, dimension support, and model configuration added.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing embeddings support for Novita: the Embed method implementation and configuration updates align with issue #14893 requirements.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pandadev66

Copy link
Copy Markdown
Contributor Author

Hi @Magicbook1108, gentle ping for review when you have a moment. This follows the same OpenAI-compatible /embeddings shape that the merged Mistral, Upstage, Aliyun, Ollama, vLLM, LM Studio, and OpenAI Embed drivers already use, scope is two files (one config, one driver), and it closes #14893. The driver also honors embeddingConfig.Dimension (the field added in #14735). Thanks!

@JinHai-CN
JinHai-CN requested a review from Haruko386 May 14, 2026 06:47

@Haruko386 Haruko386 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @pandadev66, please refer novita API reference for right url_suffix

Comment thread conf/models/novita.json Resolved
Comment thread conf/models/novita.json Resolved
@pandadev66

Copy link
Copy Markdown
Contributor Author

Thanks for the review @Haruko386. Addressed in 2c59bae:

  • Changed url_suffix.embedding from v3/embeddings to openai/v1/embeddings. Confirmed via Novita's official docs (https://novita.ai/docs/api-reference/model-apis-llm-create-embeddings) that the embeddings endpoint sits under the same OpenAI-compatible base as chat (https://api.novita.ai/openai), so it now lines up with the existing openai/v1/chat/completions and openai/v1/models suffixes.
  • Dropped baai/bge-large-en-v1.5 from the model list. The docs only list baai/bge-m3 as a supported model, which matches the 404 MODEL_NOT_FOUND you saw on bge-large-en-v1.5.

Could you re-run the test against baai/bge-m3@test@novita when you have a moment? Expected output should look like:

RAGFlow(user)> embed text 'walker' 'jumper' with 'baai/bge-m3@test@novita' dimension 16;
+-----------+-------+
| dimension | index |
+-----------+-------+
| 16        | 0     |
| 16        | 1     |
+-----------+-------+

Thanks again for catching the wrong path.

@pandadev66
pandadev66 requested a review from Haruko386 May 14, 2026 10:04

@Haruko386 Haruko386 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pandadev66 thank you for your contribution.

@JinHai-CN JinHai-CN added the ci Continue Integration label May 15, 2026
@codecov

codecov Bot commented May 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.16%. Comparing base (e194027) to head (0f6fbaf).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #14895   +/-   ##
=======================================
  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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JinHai-CN
JinHai-CN merged commit 6794ad2 into infiniflow:main May 18, 2026
1 check passed
@whitepicker whitepicker mentioned this pull request May 20, 2026
4 tasks done
JinHai-CN pushed a commit that referenced this pull request May 21, 2026
### What problem does this PR solve?

Fixes #15012

The Novita Go driver landed in #14850 and shipped a stub `Rerank` method
that returned `"novita, no such method"`, so Novita could not be used as
a rerank provider in RAGFlow. This PR fills that gap, in the same way
#14895 filled the Embed gap on the same driver.

Novita exposes a public rerank endpoint at `POST
https://api.novita.ai/openai/v1/rerank` that accepts the
Cohere-compatible request shape (`{model, query, documents, top_n}`)
with `Authorization: Bearer <api_key>`. `baai/bge-reranker-v2-m3` is
documented in Novita's model library with a 1024-token limit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Implement Embed (embeddings) in the Novita Go driver

3 participants