Repository navigation
Go: implement provider: CoHere and FishAudio - #14790
Conversation
|
ℹ️ 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 Cohere and FishAudio provider JSON configs and Go driver implementations, registers them in the model factory, and updates Nvidia and VolcEngine model catalog entries. ChangesCohere and FishAudio Provider Integration
Sequence Diagram(s)sequenceDiagram
participant Client
participant CoHereModel
participant CoHereAPI
Client->>CoHereModel: ChatWithMessages or ChatStreamlyWithSender
CoHereModel->>CoHereAPI: POST /chat with Bearer token
CoHereAPI-->>CoHereModel: JSON response or event stream
alt stream
CoHereAPI-->>CoHereModel: data event
CoHereModel->>Client: send text/thinking delta
CoHereAPI-->>CoHereModel: message-end
CoHereModel->>Client: send [DONE]
else non-stream
CoHereModel->>Client: return ChatResponse
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
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. 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.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
conf/models/nvidia.json (1)
266-303:⚠️ Potential issue | 🔴 Critical | ⚡ Quick winUnresolved Git merge conflict markers — file is invalid JSON.
Lines 266 (
<<<<<<< HEAD), 302 (=======), and 303 (>>>>>>> 0f4fb1da2 ...) are leftover conflict markers that make this config unparseable, so the Nvidia provider will fail to load at startup.Additionally, while resolving, note that
nvidia/nv-embed-v1is duplicated: once at lines 43–48 (max_tokens: 8192, the correct value per Nvidia's docs) and again at lines 267–272 inside the conflict region (max_tokens: 32768). Keep only one entry — preferably the 8192 one — and drop the duplicate to avoid ambiguous catalog entries.🛠️ Proposed fix
{ - <<<<<<< HEAD - "name": "nvidia/nv-embed-v1", - "max_tokens": 32768, - "model_types": [ - "embedding" - ] - }, - { "name": "nvidia/nv-embedqa-e5-v5", "max_tokens": 512, "model_types": [ "embedding" ] }, { "name": "nvidia/nv-embedqa-mistral-7b-v2", "max_tokens": 512, "model_types": [ "embedding" ] }, { "name": "nvidia/nv-rerankqa-mistral-4b-v3", "max_tokens": 4096, "model_types": [ "rerank" ] }, { "name": "nvidia/llama-3.2-nv-rerankqa-1b-v2", "max_tokens": 4096, "model_types": [ "rerank" ] }, { - ======= - >>>>>>> 0f4fb1da2 (Go: implement provider: CoHere and FishAudio) "name": "nvidia/nvidia-nemotron-nano-9b-v2",🤖 Prompt for 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. In `@conf/models/nvidia.json` around lines 266 - 303, Remove the unresolved Git conflict markers (<<<<<<<, =======, >>>>>>>) and the duplicate model entry for "nvidia/nv-embed-v1" inside that conflict block so the JSON becomes valid; keep the single correct "nvidia/nv-embed-v1" entry that has max_tokens: 8192 (remove the duplicate with max_tokens: 32768), and ensure the remaining entries ("nvidia/nv-embedqa-e5-v5", "nvidia/nv-embedqa-mistral-7b-v2", "nvidia/nv-rerankqa-mistral-4b-v3", "nvidia/llama-3.2-nv-rerankqa-1b-v2") are preserved in a proper JSON array/object structure with commas and no extra merge markers.
🧹 Nitpick comments (3)
internal/entity/models/cohere.go (2)
515-515: ⚡ Quick winUse consistent casing for Authorization header.
Line 515 uses lowercase
"bearer", while theEmbedmethod (line 367) uses"Bearer"with proper casing. This should be consistent across all methods in the file.♻️ Proposed fix
- req.Header.Set("Authorization", fmt.Sprintf("bearer %s", strings.TrimSpace(*apiConfig.ApiKey))) + req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", strings.TrimSpace(*apiConfig.ApiKey)))🤖 Prompt for 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. In `@internal/entity/models/cohere.go` at line 515, The Authorization header in the request uses lowercase "bearer" in the req.Header.Set call that sets fmt.Sprintf("bearer %s", strings.TrimSpace(*apiConfig.ApiKey)); change it to use "Bearer" (capital B) to match the Embed method and keep header casing consistent across internal/entity/models/cohere.go (look for the req.Header.Set call and the Embed method around line 367).
116-118: ⚡ Quick winFix header casing for consistency.
Line 116 uses
"content-Type"with inconsistent casing, and line 118 uses lowercase"bearer". While many APIs accept various casings, following standard HTTP header conventions improves consistency.♻️ Proposed fix
- req.Header.Set("content-Type", "application/json") + req.Header.Set("Content-Type", "application/json") req.Header.Set("accept", "application/json") - req.Header.Set("Authorization", fmt.Sprintf("bearer %s", strings.TrimSpace(*apiConfig.ApiKey))) + req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", strings.TrimSpace(*apiConfig.ApiKey)))🤖 Prompt for 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. In `@internal/entity/models/cohere.go` around lines 116 - 118, The HTTP headers set on the request use inconsistent casing and an incorrect auth scheme string: update the req.Header.Set calls to use standard header names "Content-Type" and "Accept" and change the Authorization value scheme to "Bearer" (capital B) when formatting with fmt.Sprintf and strings.TrimSpace(*apiConfig.ApiKey); keep using req.Header.Set, fmt.Sprintf, apiConfig.ApiKey, and strings.TrimSpace to locate and modify the existing lines.internal/entity/models/fishaudio.go (1)
51-52: 💤 Low valueMinor inconsistency in error message format.
The
Embedmethod returns"no such method"without the provider name prefix, while other stub methods usef.Name() + " no such method"for consistency.♻️ Proposed fix for consistency
- return nil, fmt.Errorf("no such method") + return nil, fmt.Errorf(f.Name() + " no such method")🤖 Prompt for 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. In `@internal/entity/models/fishaudio.go` around lines 51 - 52, The Embed method on FishAudioModel returns a plain "no such method" error; change it to include the provider name like the other stubs by using f.Name() as a prefix (e.g., f.Name() + " no such method") so the error message is consistent with other methods in FishAudioModel.
🤖 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 `@conf/models/cohere.json`:
- Around line 13-42: Update the incorrect max_tokens values in
conf/models/cohere.json: change the "rerank-v4.0-pro" entry's max_tokens from
128000 to 32768 and change the "embed-v4.0" entry's max_tokens from 8192 to
128000 so the entries for "rerank-v4.0-pro" and "embed-v4.0" match the Cohere V2
API context lengths.
In `@conf/models/volcengine.json`:
- Line 9: The config removed the "models" key used by ListModels(), which causes
z.URLSuffix.Models to be empty and build a malformed endpoint; fix by either
restoring the key in conf/models/volcengine.json (add "models": "models" in the
url_suffix object) or make the internal/entity/models/volcengine.go ListModels
function resilient by checking z.URLSuffix.Models and defaulting to "models"
when empty before constructing the URL (update the code path that references
z.URLSuffix.Models in ListModels to use a fallback value).
In `@internal/entity/models/cohere.go`:
- Around line 202-242: Remove the duplicated modelConfig handling: delete the
first block that sets reqBody["max_tokens"], reqBody["temperature"], and
reqBody["p"] (the redundant if modelConfig != nil block) so there’s a single
configuration section that also handles streaming and thinking; in the remaining
block (where modelConfig.TopP is set) change the key from "top_p" to "p" so both
places consistently use "p" per Cohere V2, and ensure all conditional
assignments target reqBody using the symbols modelConfig and reqBody.
In `@internal/entity/models/fishaudio.go`:
- Line 129: The request header code dereferences apiConfig.ApiKey without nil
checks; update the function using req.Header.Set(...) to first validate that
apiConfig != nil and apiConfig.ApiKey != nil (and that *apiConfig.ApiKey is
non-empty), returning an error or skipping header set if validation fails;
specifically guard the use of apiConfig.ApiKey before fmt.Sprintf("Bearer %s",
*apiConfig.ApiKey) so you avoid a nil pointer dereference.
- Around line 111-152: The Balance method currently hardcodes the path
"/wallet/self/api-credit"; change it to construct the URL using the configured
suffix by replacing the hardcoded segment with f.URLSuffix.Balance (same pattern
as ListModels), i.e., use baseURL + "/" +
strings.TrimPrefix(f.URLSuffix.Balance, "/") (or similar) when building url, and
keep the existing region selection, Authorization header, httpClient call,
response handling, and error wrapping in Balance(apiConfig *APIConfig) so the
method uses the model's URLSuffix.Balance value from the FishAudioModel struct.
---
Outside diff comments:
In `@conf/models/nvidia.json`:
- Around line 266-303: Remove the unresolved Git conflict markers (<<<<<<<,
=======, >>>>>>>) and the duplicate model entry for "nvidia/nv-embed-v1" inside
that conflict block so the JSON becomes valid; keep the single correct
"nvidia/nv-embed-v1" entry that has max_tokens: 8192 (remove the duplicate with
max_tokens: 32768), and ensure the remaining entries ("nvidia/nv-embedqa-e5-v5",
"nvidia/nv-embedqa-mistral-7b-v2", "nvidia/nv-rerankqa-mistral-4b-v3",
"nvidia/llama-3.2-nv-rerankqa-1b-v2") are preserved in a proper JSON
array/object structure with commas and no extra merge markers.
---
Nitpick comments:
In `@internal/entity/models/cohere.go`:
- Line 515: The Authorization header in the request uses lowercase "bearer" in
the req.Header.Set call that sets fmt.Sprintf("bearer %s",
strings.TrimSpace(*apiConfig.ApiKey)); change it to use "Bearer" (capital B) to
match the Embed method and keep header casing consistent across
internal/entity/models/cohere.go (look for the req.Header.Set call and the Embed
method around line 367).
- Around line 116-118: The HTTP headers set on the request use inconsistent
casing and an incorrect auth scheme string: update the req.Header.Set calls to
use standard header names "Content-Type" and "Accept" and change the
Authorization value scheme to "Bearer" (capital B) when formatting with
fmt.Sprintf and strings.TrimSpace(*apiConfig.ApiKey); keep using req.Header.Set,
fmt.Sprintf, apiConfig.ApiKey, and strings.TrimSpace to locate and modify the
existing lines.
In `@internal/entity/models/fishaudio.go`:
- Around line 51-52: The Embed method on FishAudioModel returns a plain "no such
method" error; change it to include the provider name like the other stubs by
using f.Name() as a prefix (e.g., f.Name() + " no such method") so the error
message is consistent with other methods in FishAudioModel.
🪄 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: 06db2eee-7bf9-4198-9565-9fec4980fde6
📒 Files selected for processing (7)
conf/models/cohere.jsonconf/models/fishaudio.jsonconf/models/nvidia.jsonconf/models/volcengine.jsoninternal/entity/models/cohere.gointernal/entity/models/factory.gointernal/entity/models/fishaudio.go
| "models": [ | ||
| { | ||
| "name": "command-a-03-2025", | ||
| "max_tokens": 256000, | ||
| "model_types": [ | ||
| "chat" | ||
| ] | ||
| }, | ||
| { | ||
| "name": "command-a-reasoning-08-2025", | ||
| "max_tokens": 256000, | ||
| "model_types": [ | ||
| "chat" | ||
| ] | ||
| }, | ||
| { | ||
| "name": "rerank-v4.0-pro", | ||
| "max_tokens": 128000, | ||
| "model_types": [ | ||
| "rerank" | ||
| ] | ||
| }, | ||
| { | ||
| "name": "embed-v4.0", | ||
| "max_tokens": 8192, | ||
| "model_types": [ | ||
| "embedding" | ||
| ] | ||
| } | ||
| ] |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
What are the current Cohere V2 API model names and their token limits for command-a-03-2025, command-a-reasoning-08-2025, rerank-v4.0-pro, and embed-v4.0?
💡 Result:
Current Cohere V2 API model names and token limits (as of 2026-05-11): 1) command-a-03-2025 — 256K token context length (max prompt+response length per run: 256,000 tokens; on-demand response capped at 4,000 tokens) [1]. 2) command-a-reasoning-08-2025 — 256K token context length; maximum output 32K tokens [2][3]. 3) rerank-v4.0-pro — 32,768 token context length (query+document combined; query can be up to half the context, i.e., up to 16,384 tokens before truncation for query) [4]. 4) embed-v4.0 — 128K token context length (max tokens / context length: 128k) [5][6].
Citations:
- 1: https://docs.oracle.com/iaas/Content/generative-ai/cohere-command-a-03-2025.htm
- 2: https://docs.cohere.com/docs/command-a-reasoning
- 3: https://docs.cohere.com/changelog/2025-08-21-command-a-reasoning
- 4: https://docs.cohere.com/v2/docs/reranking-best-practices
- 5: https://docs.cohere.com/docs/cohere-embed
- 6: https://docs.cohere.com/v2/changelog/embed-multimodal-v4
Correct token limits for rerank-v4.0-pro and embed-v4.0 models.
The configuration has incorrect max_tokens values for two models:
rerank-v4.0-pro: Currently 128000, should be 32768 (32,768 token context length per Cohere V2 API)embed-v4.0: Currently 8192, should be 128000 (128K token context length per Cohere V2 API)
The token limits for command-a-03-2025 and command-a-reasoning-08-2025 are correct.
🤖 Prompt for 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.
In `@conf/models/cohere.json` around lines 13 - 42, Update the incorrect
max_tokens values in conf/models/cohere.json: change the "rerank-v4.0-pro"
entry's max_tokens from 128000 to 32768 and change the "embed-v4.0" entry's
max_tokens from 8192 to 128000 so the entries for "rerank-v4.0-pro" and
"embed-v4.0" match the Cohere V2 API context lengths.
| "files": "files", | ||
| "embedding": "embeddings/multimodal", | ||
| "models": "models" | ||
| "embedding": "embeddings/multimodal" |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Verify usage of url_suffix.models and ensure model listing still works
# Search for url_suffix usage in VolcEngine provider code
rg -n --type=go -C5 'url_suffix' --iglob '*volcengine*'
# Search for model listing implementation
rg -n --type=go -C5 'ListModels|list.*model' --iglob '*volcengine*'Repository: infiniflow/ragflow
Length of output: 1588
🏁 Script executed:
rg -n --type=go -A 20 'func (z \*VolcEngine) ListModels' conf/internal/entity/models/volcengine.goRepository: infiniflow/ragflow
Length of output: 144
🏁 Script executed:
rg -n 'url_suffix.*models|models.*url_suffix' --type=go --type=jsonRepository: infiniflow/ragflow
Length of output: 142
🏁 Script executed:
rg -n 'doubao-embedding-vision-250615'Repository: infiniflow/ragflow
Length of output: 44
🏁 Script executed:
fd -t f volcengine.goRepository: infiniflow/ragflow
Length of output: 99
🏁 Script executed:
cat -n internal/entity/models/volcengine.go | sed -n '513,540p'Repository: infiniflow/ragflow
Length of output: 1146
🏁 Script executed:
cat -n conf/models/volcengine.jsonRepository: infiniflow/ragflow
Length of output: 909
🏁 Script executed:
rg -n --type=go 'type URLSuffix struct' -A 10Repository: infiniflow/ragflow
Length of output: 808
Fix missing "models" endpoint in url_suffix.
The ListModels() function at line 527 in internal/entity/models/volcengine.go directly references z.URLSuffix.Models to construct the API endpoint. Removing the "models" key from the url_suffix configuration will cause this function to fail, as it will construct a malformed URL with an empty endpoint suffix. Either restore the missing "models" endpoint in the configuration or update the function to handle its absence.
🤖 Prompt for 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.
In `@conf/models/volcengine.json` at line 9, The config removed the "models" key
used by ListModels(), which causes z.URLSuffix.Models to be empty and build a
malformed endpoint; fix by either restoring the key in
conf/models/volcengine.json (add "models": "models" in the url_suffix object) or
make the internal/entity/models/volcengine.go ListModels function resilient by
checking z.URLSuffix.Models and defaulting to "models" when empty before
constructing the URL (update the code path that references z.URLSuffix.Models in
ListModels to use a fallback value).
| if modelConfig != nil { | ||
| if modelConfig.MaxTokens != nil { | ||
| reqBody["max_tokens"] = *modelConfig.MaxTokens | ||
| } | ||
| if modelConfig.Temperature != nil { | ||
| reqBody["temperature"] = *modelConfig.Temperature | ||
| } | ||
| if modelConfig.TopP != nil { | ||
| reqBody["p"] = *modelConfig.TopP | ||
| } | ||
| } | ||
|
|
||
| if modelConfig != nil { | ||
| if modelConfig.Stream != nil { | ||
| reqBody["stream"] = *modelConfig.Stream | ||
| } | ||
|
|
||
| if modelConfig.MaxTokens != nil { | ||
| reqBody["max_tokens"] = *modelConfig.MaxTokens | ||
| } | ||
|
|
||
| if modelConfig.Temperature != nil { | ||
| reqBody["temperature"] = *modelConfig.Temperature | ||
| } | ||
|
|
||
| if modelConfig.TopP != nil { | ||
| reqBody["top_p"] = *modelConfig.TopP | ||
| } | ||
|
|
||
| if modelConfig.Thinking != nil { | ||
| if *modelConfig.Thinking { | ||
| reqBody["thinking"] = map[string]interface{}{ | ||
| "type": "enabled", | ||
| } | ||
| } else { | ||
| reqBody["thinking"] = map[string]interface{}{ | ||
| "type": "disabled", | ||
| } | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
What is the correct field name for top_p parameter in Cohere V2 Chat API - is it "p" or "top_p"?
💡 Result:
In Cohere V2 Chat API, the field name for the “top_p” (nucleus sampling) parameter is “p” (not “top_p”). Cohere’s generation docs describe using parameter p (e.g., code snippet shows co.chat(..., p=0.75)), and the Cohere Python v2 client exposes a request parameter named p (not top_p). [1][2][3] So: use “p”: <float between 0 and 1> in the /v2/chat request body.
Citations:
- 1: https://docs.cohere.com/docs/advanced-generation-hyperparameters
- 2: https://docs.cohere.ai/docs/advanced-generation-hyperparameters
- 3: https://github.com/cohere-ai/cohere-python/blob/main/src/cohere/v2/client.py
🏁 Script executed:
fd -t f "cohere.go" | grep -E "internal/entity/models"Repository: infiniflow/ragflow
Length of output: 95
🏁 Script executed:
cat -n internal/entity/models/cohere.go | sed -n '195,245p'Repository: infiniflow/ragflow
Length of output: 1522
Remove duplicate configuration block and fix TopP field name.
Lines 202-212 and 214-242 contain duplicate logic for applying modelConfig settings (max_tokens, temperature, TopP). The second block completely overrides the first, making the initial block redundant. Additionally, there's a critical field name inconsistency: line 210 uses "p" while line 228 uses "top_p". Per the Cohere V2 Chat API documentation, the correct parameter name is "p", not "top_p".
Remove the first config block (lines 202-212) and update line 228 to use "p" instead of "top_p":
🔧 Correct fix
reqBody := map[string]interface{}{
"model": modelName,
"messages": apiMessages,
"stream": true,
"temperature": 1,
}
- if modelConfig != nil {
- if modelConfig.MaxTokens != nil {
- reqBody["max_tokens"] = *modelConfig.MaxTokens
- }
- if modelConfig.Temperature != nil {
- reqBody["temperature"] = *modelConfig.Temperature
- }
- if modelConfig.TopP != nil {
- reqBody["p"] = *modelConfig.TopP
- }
- }
-
if modelConfig != nil {
if modelConfig.Stream != nil {
reqBody["stream"] = *modelConfig.Stream
}
if modelConfig.MaxTokens != nil {
reqBody["max_tokens"] = *modelConfig.MaxTokens
}
if modelConfig.Temperature != nil {
reqBody["temperature"] = *modelConfig.Temperature
}
if modelConfig.TopP != nil {
- reqBody["top_p"] = *modelConfig.TopP
+ reqBody["p"] = *modelConfig.TopP
}
if modelConfig.Thinking != nil {
if *modelConfig.Thinking {
reqBody["thinking"] = map[string]interface{}{
"type": "enabled",
}
} else {
reqBody["thinking"] = map[string]interface{}{
"type": "disabled",
}
}
}
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if modelConfig != nil { | |
| if modelConfig.MaxTokens != nil { | |
| reqBody["max_tokens"] = *modelConfig.MaxTokens | |
| } | |
| if modelConfig.Temperature != nil { | |
| reqBody["temperature"] = *modelConfig.Temperature | |
| } | |
| if modelConfig.TopP != nil { | |
| reqBody["p"] = *modelConfig.TopP | |
| } | |
| } | |
| if modelConfig != nil { | |
| if modelConfig.Stream != nil { | |
| reqBody["stream"] = *modelConfig.Stream | |
| } | |
| if modelConfig.MaxTokens != nil { | |
| reqBody["max_tokens"] = *modelConfig.MaxTokens | |
| } | |
| if modelConfig.Temperature != nil { | |
| reqBody["temperature"] = *modelConfig.Temperature | |
| } | |
| if modelConfig.TopP != nil { | |
| reqBody["top_p"] = *modelConfig.TopP | |
| } | |
| if modelConfig.Thinking != nil { | |
| if *modelConfig.Thinking { | |
| reqBody["thinking"] = map[string]interface{}{ | |
| "type": "enabled", | |
| } | |
| } else { | |
| reqBody["thinking"] = map[string]interface{}{ | |
| "type": "disabled", | |
| } | |
| } | |
| } | |
| } | |
| if modelConfig != nil { | |
| if modelConfig.Stream != nil { | |
| reqBody["stream"] = *modelConfig.Stream | |
| } | |
| if modelConfig.MaxTokens != nil { | |
| reqBody["max_tokens"] = *modelConfig.MaxTokens | |
| } | |
| if modelConfig.Temperature != nil { | |
| reqBody["temperature"] = *modelConfig.Temperature | |
| } | |
| if modelConfig.TopP != nil { | |
| reqBody["p"] = *modelConfig.TopP | |
| } | |
| if modelConfig.Thinking != nil { | |
| if *modelConfig.Thinking { | |
| reqBody["thinking"] = map[string]interface{}{ | |
| "type": "enabled", | |
| } | |
| } else { | |
| reqBody["thinking"] = map[string]interface{}{ | |
| "type": "disabled", | |
| } | |
| } | |
| } | |
| } |
🤖 Prompt for 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.
In `@internal/entity/models/cohere.go` around lines 202 - 242, Remove the
duplicated modelConfig handling: delete the first block that sets
reqBody["max_tokens"], reqBody["temperature"], and reqBody["p"] (the redundant
if modelConfig != nil block) so there’s a single configuration section that also
handles streaming and thinking; in the remaining block (where modelConfig.TopP
is set) change the key from "top_p" to "p" so both places consistently use "p"
per Cohere V2, and ensure all conditional assignments target reqBody using the
symbols modelConfig and reqBody.
| func (f *FishAudioModel) Balance(apiConfig *APIConfig) (map[string]interface{}, error) { | ||
| var region = "default" | ||
| if apiConfig != nil && apiConfig.Region != nil && *apiConfig.Region != "" { | ||
| region = *apiConfig.Region | ||
| } | ||
|
|
||
| baseURL := f.BaseURL[region] | ||
| if baseURL == "" { | ||
| baseURL = f.BaseURL["default"] | ||
| } | ||
|
|
||
| url := fmt.Sprintf("%s/wallet/self/api-credit", strings.TrimSuffix(baseURL, "/")) | ||
|
|
||
| req, err := http.NewRequest("GET", url, nil) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to create request: %w", err) | ||
| } | ||
|
|
||
| req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey)) | ||
|
|
||
| resp, err := f.httpClient.Do(req) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to send request: %w", err) | ||
| } | ||
| defer resp.Body.Close() | ||
|
|
||
| body, err := io.ReadAll(resp.Body) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to read response body: %w", err) | ||
| } | ||
|
|
||
| if resp.StatusCode != http.StatusOK { | ||
| return nil, fmt.Errorf("Fish Audio balance API error: status %d, body: %s", resp.StatusCode, string(body)) | ||
| } | ||
|
|
||
| var result map[string]interface{} | ||
| if err := json.Unmarshal(body, &result); err != nil { | ||
| return nil, fmt.Errorf("failed to parse response: %w", err) | ||
| } | ||
|
|
||
| return result, nil | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify the configured balance URL suffix in fishaudio.json
cat conf/models/fishaudio.json | jq -r '.url_suffix.balance'Repository: infiniflow/ragflow
Length of output: 75
🏁 Script executed:
# Find the FishAudioModel struct definition
rg -n "type FishAudioModel struct" internal/entity/models/fishaudio.go -A 20Repository: infiniflow/ragflow
Length of output: 673
🏁 Script executed:
# Check other methods in the file to see how they use URLSuffix
rg -n "URLSuffix\." internal/entity/models/fishaudio.goRepository: infiniflow/ragflow
Length of output: 133
🏁 Script executed:
# Check the full FishAudioModel implementation to see all methods
wc -l internal/entity/models/fishaudio.goRepository: infiniflow/ragflow
Length of output: 102
🏁 Script executed:
# Show all method definitions in the file to understand the pattern
rg -n "^func \(f \*FishAudioModel\)" internal/entity/models/fishaudio.goRepository: infiniflow/ragflow
Length of output: 1093
🏁 Script executed:
# Check the URLSuffix type definition
rg -n "type URLSuffix struct" -A 20 internal/entity/models/Repository: infiniflow/ragflow
Length of output: 1345
Balance endpoint hardcoded instead of using configured URL suffix.
The Balance method hardcodes /wallet/self/api-credit, but conf/models/fishaudio.json defines url_suffix.balance as "self/package", and the FishAudioModel struct has a URLSuffix field available. Other methods like ListModels follow the pattern of using f.URLSuffix.MethodName. Update the method to use f.URLSuffix.Balance for consistency.
Proposed fix
- url := fmt.Sprintf("%s/wallet/self/api-credit", strings.TrimSuffix(baseURL, "/"))
+ url := fmt.Sprintf("%s/%s", strings.TrimSuffix(baseURL, "/"), f.URLSuffix.Balance)🤖 Prompt for 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.
In `@internal/entity/models/fishaudio.go` around lines 111 - 152, The Balance
method currently hardcodes the path "/wallet/self/api-credit"; change it to
construct the URL using the configured suffix by replacing the hardcoded segment
with f.URLSuffix.Balance (same pattern as ListModels), i.e., use baseURL + "/" +
strings.TrimPrefix(f.URLSuffix.Balance, "/") (or similar) when building url, and
keep the existing region selection, Authorization header, httpClient call,
response handling, and error wrapping in Balance(apiConfig *APIConfig) so the
method uses the model's URLSuffix.Balance value from the FishAudioModel struct.
| return nil, fmt.Errorf("failed to create request: %w", err) | ||
| } | ||
|
|
||
| req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey)) |
There was a problem hiding this comment.
Add nil checks for API key before dereferencing.
The code dereferences apiConfig.ApiKey without validating that apiConfig and apiConfig.ApiKey are non-nil, which could cause a nil pointer dereference panic.
🛡️ Proposed fix to add validation
+ if apiConfig == nil || apiConfig.ApiKey == nil || *apiConfig.ApiKey == "" {
+ return nil, fmt.Errorf("Fish Audio API key is missing")
+ }
+
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))🤖 Prompt for 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.
In `@internal/entity/models/fishaudio.go` at line 129, The request header code
dereferences apiConfig.ApiKey without nil checks; update the function using
req.Header.Set(...) to first validate that apiConfig != nil and apiConfig.ApiKey
!= nil (and that *apiConfig.ApiKey is non-empty), returning an error or skipping
header set if validation fails; specifically guard the use of apiConfig.ApiKey
before fmt.Sprintf("Bearer %s", *apiConfig.ApiKey) so you avoid a nil pointer
dereference.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
conf/models/nvidia.json (1)
13-372: ⚡ Quick winAdd catalog validation to block duplicate model names
A lightweight validation step for
conf/models/*.json(uniquenameper provider file) would prevent this class of breakage from reaching runtime.🤖 Prompt for 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. In `@conf/models/nvidia.json` around lines 13 - 372, Duplicate model "name" entries exist in the provider model catalog; add a lightweight validation step to reject or warn on duplicates when loading conf/models/*.json by implementing a function (e.g., validateModelCatalogNames or validateModelsFile) that reads each file's "models" array, collects the "name" values, detects duplicates, and fails fast (throw error or return non-zero exit) with a clear message including duplicated names and source file; wire this function into the config load path (where model catalogs are parsed/loaded, e.g., the code that currently reads conf/models/*.json) so any provider file with non-unique model names is caught during startup/CI.
🤖 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 `@conf/models/nvidia.json`:
- Around line 43-47: There is a duplicate model entry for "nvidia/nv-embed-v1"
with conflicting max_tokens (8192 here vs a different value later); remove the
duplicate and keep a single canonical entry for "nvidia/nv-embed-v1" in
conf/models/nvidia.json, or if 8192 is the intended limit update the existing
later entry for "nvidia/nv-embed-v1" to max_tokens: 8192 so the loader has one
unambiguous configuration.
---
Nitpick comments:
In `@conf/models/nvidia.json`:
- Around line 13-372: Duplicate model "name" entries exist in the provider model
catalog; add a lightweight validation step to reject or warn on duplicates when
loading conf/models/*.json by implementing a function (e.g.,
validateModelCatalogNames or validateModelsFile) that reads each file's "models"
array, collects the "name" values, detects duplicates, and fails fast (throw
error or return non-zero exit) with a clear message including duplicated names
and source file; wire this function into the config load path (where model
catalogs are parsed/loaded, e.g., the code that currently reads
conf/models/*.json) so any provider file with non-unique model names is caught
during startup/CI.
🪄 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: 16248413-af3e-4da1-a805-3ad999d1816c
📒 Files selected for processing (1)
conf/models/nvidia.json
| "name": "nvidia/nv-embed-v1", | ||
| "max_tokens": 8192, | ||
| "model_types": [ | ||
| "chat" | ||
| ], | ||
| "thinking": { | ||
| "default_value": true, | ||
| "clear_thinking": true | ||
| } | ||
| "embedding" | ||
| ] |
There was a problem hiding this comment.
Duplicate model ID introduces ambiguous config resolution
Line 43 adds nvidia/nv-embed-v1, but the same model already exists at Line 266 with a different max_tokens value. This can cause inconsistent behavior depending on which entry is picked by the loader.
Suggested fix (keep one canonical entry)
- {
- "name": "nvidia/nv-embed-v1",
- "max_tokens": 8192,
- "model_types": [
- "embedding"
- ]
- },If 8192 is the intended limit, update the existing entry at Line 266 instead of duplicating the model name.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "name": "nvidia/nv-embed-v1", | |
| "max_tokens": 8192, | |
| "model_types": [ | |
| "chat" | |
| ], | |
| "thinking": { | |
| "default_value": true, | |
| "clear_thinking": true | |
| } | |
| "embedding" | |
| ] |
🤖 Prompt for 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.
In `@conf/models/nvidia.json` around lines 43 - 47, There is a duplicate model
entry for "nvidia/nv-embed-v1" with conflicting max_tokens (8192 here vs a
different value later); remove the duplicate and keep a single canonical entry
for "nvidia/nv-embed-v1" in conf/models/nvidia.json, or if 8192 is the intended
limit update the existing later entry for "nvidia/nv-embed-v1" to max_tokens:
8192 so the loader has one unambiguous configuration.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #14790 +/- ##
=======================================
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:
|
Cross-applying the lessons from the merged infiniflow#14790 sample driver and from the maintainer's reviews on infiniflow#14809 and infiniflow#14850: conf/models/voyage.json: - name: "VoyageAI" -> "Voyage" (the maintainer's "remove AI suffix" guidance from infiniflow#14850). - baseURL: "https://api.voyageai.com/v1" -> "https://api.voyageai.com" (bare URL; version moves into the suffix), matching the pattern used on Novita and the Cohere sample (api.cohere.com + v2/chat, v1/models). - url_suffix.embedding: "embeddings" -> "v1/embeddings". - url_suffix.rerank: "rerank" -> "v1/rerank". internal/entity/models/voyage.go: - Embed: forward EmbeddingConfig.Dimension as Voyage's documented `output_dimension` body field. This is the singular spelling per https://docs.voyageai.com/reference/embeddings-api ; Voyage rejects unknown fields with HTTP 400 (live-verified — sending "dimensions" returns "Argument 'dimensions' is not supported by our API"), so matching the docs spelling exactly is load-bearing. Live test against voyage-3.5 with output_dimension=256 trims the vector from the default 1024 to 256. internal/entity/models/voyage_test.go: - New: TestVoyageEmbedPropagatesOutputDimension pins the wire field name and guards against re-adding "dimensions" / "dimension". - New: TestVoyageEmbedOmitsOutputDimensionWhenUnset — Voyage 400s on output_dimension: 0, so the key must be absent when Dimension is unset rather than sent as zero. - All existing path-asserting tests updated to expect the new versioned suffixes (/v1/embeddings, /v1/rerank).
Per infiniflow#14809 (review): conf/models/longcat.json — move `openai` from base URL into the chat suffix. The platform docs at https://longcat.chat/platform/docs/APIDocs.html#endpoints publish the base host as `https://api.longcat.chat` and the full chat URL as `https://api.longcat.chat/openai/v1/chat/completions`, so the `/openai` prefix belongs in `url_suffix.chat`, not in `url.default`. Matches the same split the maintainer asked for on Novita (infiniflow#14850). internal/entity/models/longcat.go: - Drop the hardcoded `longcatKnownModels` catalog and the `longcatPingModel` constant. Maintainer flagged "no hard code" and noted "there is no need to implement the interface that is not officially given." The LongCat platform does not publish a /models endpoint, so synthesizing a catalog in the driver is wrong; the shipped catalog in conf/models/longcat.json is sufficient. - ListModels returns the documented `"<name>, no such method"` sentinel (the convention every other driver in this package uses for unsupported interface methods, including the merged Cohere sample in infiniflow#14790). - CheckConnection also returns the sentinel. The previous chat-ping implementation would have burned a real completion against a tenant's quota; with no documented /models or /health endpoint there is no cheap way to verify the key, so pretending is worse than declining. internal/entity/models/longcat_test.go: - Update path expectations: `/v1/chat/completions` -> `/openai/v1/chat/completions` in the test helper and in every test using newLongCatServer / newLongCatSSEServer. - Replace TestLongCatListModelsReturnsKnownCatalog, TestLongCatListModelsRequiresAPIKey, TestLongCatListModelsRejectsUnknownRegion, TestLongCatCheckConnectionChatPings, and TestLongCatCheckConnectionPropagatesAuthError with two new tests pinning the "no such method" sentinel for both stubs. Live re-verified end-to-end against api.longcat.chat: chat reply "Pong!" via the new URL split.
Cross-applying the maintainer guidance from infiniflow#14809 (review): "There is no need to implement the interface that is not officially given." The Voyage AI docs at https://docs.voyageai.com publish embeddings and rerank endpoints only. There is no /v1/models surface (404 live- confirmed) and no documented /health endpoint. ListModels and CheckConnection were therefore inventing behaviour the upstream does not expose: - ListModels was returning a hardcoded voyageKnownModels slice that duplicated the shipped conf/models/voyage.json catalog. - CheckConnection was burning a one-input embed call against voyage-3.5 per probe, which costs tenant quota and only retroactively validates the integration. Both methods now return the standard `"<name>, no such method"` sentinel, matching the convention every merged driver in this package uses (including the Cohere sample in infiniflow#14790). The shipped catalog in conf/models/voyage.json is unchanged and remains the source of truth for which Voyage models RAGFlow knows about. Dropped the corresponding sentinel-pinning tests; they were the lowest-signal entries in the suite (asserting a constant string return from an unimplemented method). 16 tests covering the actual Embed and Rerank behaviour remain and pass.
Cross-applying the lessons from the merged infiniflow#14790 sample driver and from the maintainer's reviews on infiniflow#14809 and infiniflow#14850: conf/models/voyage.json: - name: "VoyageAI" -> "Voyage" (the maintainer's "remove AI suffix" guidance from infiniflow#14850). - baseURL: "https://api.voyageai.com/v1" -> "https://api.voyageai.com" (bare URL; version moves into the suffix), matching the pattern used on Novita and the Cohere sample (api.cohere.com + v2/chat, v1/models). - url_suffix.embedding: "embeddings" -> "v1/embeddings". - url_suffix.rerank: "rerank" -> "v1/rerank". internal/entity/models/voyage.go: - Embed: forward EmbeddingConfig.Dimension as Voyage's documented `output_dimension` body field. This is the singular spelling per https://docs.voyageai.com/reference/embeddings-api ; Voyage rejects unknown fields with HTTP 400 (live-verified — sending "dimensions" returns "Argument 'dimensions' is not supported by our API"), so matching the docs spelling exactly is load-bearing. Live test against voyage-3.5 with output_dimension=256 trims the vector from the default 1024 to 256. internal/entity/models/voyage_test.go: - New: TestVoyageEmbedPropagatesOutputDimension pins the wire field name and guards against re-adding "dimensions" / "dimension". - New: TestVoyageEmbedOmitsOutputDimensionWhenUnset — Voyage 400s on output_dimension: 0, so the key must be absent when Dimension is unset rather than sent as zero. - All existing path-asserting tests updated to expect the new versioned suffixes (/v1/embeddings, /v1/rerank).
Cross-applying the maintainer guidance from infiniflow#14809 (review): "There is no need to implement the interface that is not officially given." The Voyage AI docs at https://docs.voyageai.com publish embeddings and rerank endpoints only. There is no /v1/models surface (404 live- confirmed) and no documented /health endpoint. ListModels and CheckConnection were therefore inventing behaviour the upstream does not expose: - ListModels was returning a hardcoded voyageKnownModels slice that duplicated the shipped conf/models/voyage.json catalog. - CheckConnection was burning a one-input embed call against voyage-3.5 per probe, which costs tenant quota and only retroactively validates the integration. Both methods now return the standard `"<name>, no such method"` sentinel, matching the convention every merged driver in this package uses (including the Cohere sample in infiniflow#14790). The shipped catalog in conf/models/voyage.json is unchanged and remains the source of truth for which Voyage models RAGFlow knows about. Dropped the corresponding sentinel-pinning tests; they were the lowest-signal entries in the suite (asserting a constant string return from an unimplemented method). 16 tests covering the actual Embed and Rerank behaviour remain and pass.
Per infiniflow#14809 (review): conf/models/longcat.json — move `openai` from base URL into the chat suffix. The platform docs at https://longcat.chat/platform/docs/APIDocs.html#endpoints publish the base host as `https://api.longcat.chat` and the full chat URL as `https://api.longcat.chat/openai/v1/chat/completions`, so the `/openai` prefix belongs in `url_suffix.chat`, not in `url.default`. Matches the same split the maintainer asked for on Novita (infiniflow#14850). internal/entity/models/longcat.go: - Drop the hardcoded `longcatKnownModels` catalog and the `longcatPingModel` constant. Maintainer flagged "no hard code" and noted "there is no need to implement the interface that is not officially given." The LongCat platform does not publish a /models endpoint, so synthesizing a catalog in the driver is wrong; the shipped catalog in conf/models/longcat.json is sufficient. - ListModels returns the documented `"<name>, no such method"` sentinel (the convention every other driver in this package uses for unsupported interface methods, including the merged Cohere sample in infiniflow#14790). - CheckConnection also returns the sentinel. The previous chat-ping implementation would have burned a real completion against a tenant's quota; with no documented /models or /health endpoint there is no cheap way to verify the key, so pretending is worse than declining. internal/entity/models/longcat_test.go: - Update path expectations: `/v1/chat/completions` -> `/openai/v1/chat/completions` in the test helper and in every test using newLongCatServer / newLongCatSSEServer. - Replace TestLongCatListModelsReturnsKnownCatalog, TestLongCatListModelsRequiresAPIKey, TestLongCatListModelsRejectsUnknownRegion, TestLongCatCheckConnectionChatPings, and TestLongCatCheckConnectionPropagatesAuthError with two new tests pinning the "no such method" sentinel for both stubs. Live re-verified end-to-end against api.longcat.chat: chat reply "Pong!" via the new URL split.
## Summary Ports the MCP (Model Context Protocol) server management endpoints that power `web/src/pages/user-setting/mcp/` from Python (`api/apps/restful_apis/mcp_api.py`) to Go. There were no MCP routes in the Go server before this change. Closes #15275 (subtask of #15240). ## Endpoints implemented (base path `/api/v1`) | Method | Path | Description | |--------|------|-------------| | GET | `/mcp/servers` | List tenant servers (keyword / order / pagination) | | POST | `/mcp/servers` | Create a server | | GET | `/mcp/servers/{mcp_id}` | Get one (`?mode=download` exports config) | | PUT | `/mcp/servers/{mcp_id}` | Update a server | | DELETE | `/mcp/servers/{mcp_id}` | Delete a server | | POST | `/mcp/import` | Bulk import from JSON config | | POST | `/mcp/servers/{mcp_id}/test` | Connect + list tools (see notes) | ## Implementation Follows the existing `handler → service → dao` layering (per PR #14790): - **entity** (`internal/entity/mcp.go`): added `MCPServerType` constants and `IsValidMCPServerType` over the existing `MCPServer` model. - **dao** (`internal/dao/mcp.go`): new `MCPServerDAO` with tenant-scoped CRUD, a keyword filter, and a **whitelisted order-column map** (guards against SQL injection via the caller-supplied `orderby`). - **service** (`internal/service/mcp.go`): new `MCPService` — list/get/export/create/update/delete/import/test — mirroring `MCPServerService` and the `mcp_api` request validation, with sentinel errors for clean code mapping. - **handler** (`internal/handler/mcp.go`): new `MCPHandler` with the seven handlers and Python-compatible response codes. - **router / server_main**: registered the `/mcp` group and wired the handler. ## Deviations from Python (documented in code) 1. **Bulk import is at `POST /mcp/import`, not `/mcp/servers/import`.** gin (v1.9.1) cannot register a static segment and a path param at the same tree node, so `/mcp/servers/import` would collide with `/mcp/servers/:mcp_id` and panic at startup. The frontend should call `/mcp/import`. 2. **No live tool discovery on create/update/import.** The Python path runs `get_mcp_tools` over SSE / streamable-HTTP and stores `variables.tools`. The Go server has no MCP client yet, so these persist `variables`/`headers` but leave `variables.tools` unpopulated. 3. **`/test` returns a data error (`ErrMCPTestUnsupported`)** until a Go MCP client lands. Per the issue, the live-connection path is scoped as a follow-up; the handler still validates `url` + `server_type`. ## Testing - Added `internal/service/mcp_test.go` covering `IsValidMCPServerType` and the `TestServer` validation/short-circuit paths (no DB required). - No Go toolchain was available in the dev environment, so `go build ./...` / `go vet ./...` verification is left to CI. ## Follow-ups - Go MCP client (SSE / streamable-HTTP) to enable live tool discovery and the real `/test` behavior. - Reconcile the `/mcp/import` vs `/mcp/servers/import` path with the frontend. ---------
### What problem does this PR solve?
This PR completes the Cohere provider integration (upgrading to the new
Cohere V2 API) and enhances the Fish Audio provider in RAGFlow.
**The following functionalities are now supported:**
**Cohere:**
- [x] Chat / Think Chat / Stream Chat / Stream Think Chat
- [x] Embedding
- [x] Rerank
- [x] Model listing
- [x] Provider connection checking
- [ ] Balance
**Fish Audio:**
- [x] Model listing (`ListModels`)
- [x] Balance (`Balance`)
-----
**Verified examples from the CLI:**
```plaintext
# Cohere
RAGFlow(user)> think chat with 'command-a-reasoning-08-2025@test3@cohere' message 'jumperwho'
Thinking: Okay, the user wrote "jumperwho". Let me try to figure out what they might be asking. First, I'll check if it's a misspelling. "Jumper" ...... Hmm. Since the query is unclear, the best approach is to ask the user to provide more context or correct any possible typos.
Answer: It seems there might be a typo or missing context in your query "jumperwho." Could you clarify what you're referring to? For example:
- Are you asking about a **jumper** (a type of sweater, a person who jumps, or a component in electronics)?
- Is this related to a specific context, like a movie (e.g., the 2008 film *Jumper*) or a game?
- Did you mean to ask about a person ("who") associated with jumping (e.g., a parachutist)?
Let me know so I can provide a helpful response! 😊
Time: 6.710331
RAGFlow(user)> stream think chat with 'command-a-reasoning-08-2025@test3@cohere' message 'jumperwho'
Thinking: , the user mentioned "jumperwho". Let me try to figure out what they're referring to. First, I'll check if it's a misspelling. "Jumper" could be a typo for "jumper" or maybe a username. Alternatively, it might be a combination of words like "jumper who",....... the best approach is to inform the user that I don't recognize the term and ask if they can provide more context or clarify what they mean by "jumperwho". That way, I can assist them better once I have more information.
Answer: seems "jumperwho" isn't a widely recognized term, proper noun, or acronym in common usage. Could you provide more context or clarify what you mean by "jumperwho"? This will help me understand your question or request better!
Time: 4.513596
RAGFlow(user)> embed text 'walkerwhat' 'jumperwho' with 'embed-v4.0@test3@cohere' dimension 16;
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------+
| embedding | index |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------+
| [-0.016643638 -0.001957038 0.0055713872 0.009027058 0.05275187 -0.024542313 -0.044006906 0.024119169 0.0014192933 0.006558722 0.0019129605 -0.021016119 -0.026516981 -0.017489925 0.021298215 0.017772019 0.04569948 0.008886009 0.012059584 -0.0014721862 0.... | 0 |
| [0.018778935 -0.0063459855 -0.0006839742 0.0046623563 0.0067668925 -0.018001877 -0.03963003 0.035744734 -0.014246088 -0.0020721585 -0.006313608 0.025124922 -0.010749322 0.01217393 -0.010231283 -0.025254432 0.021498645 -0.028880708 0.019167464 -0.0058279... | 1 |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------+
RAGFlow(user)> rerank query 'what is rag' document 'rag is retrieval augment generation' 'rag need llm' 'famous rag project includes ragflow' with 'rerank-v4.0-pro@test@cohere' top 3;
+-------+-----------------+
| index | relevance_score |
+-------+-----------------+
| 0 | 0.91744334 |
| 1 | 0.7458429 |
| 2 | 0.68729424 |
+-------+-----------------+
RAGFlow(user)> list supported models from 'cohere' 'test'
+-------------------------------------+
| model_name |
+-------------------------------------+
| c4ai-aya-expanse-32b |
| c4ai-aya-vision-32b |
| cohere-transcribe-03-2026 |
| command-a-03-2025 |
| command-a-reasoning-08-2025 |
| command-a-translate-08-2025 |
| command-a-vision-07-2025 |
| command-r-08-2024 |
| command-r-plus-08-2024 |
| command-r7b-12-2024 |
| command-r7b-arabic-02-2025 |
| embed-english-light-v3.0 |
| embed-english-light-v3.0-image |
| embed-english-v3.0 |
| embed-english-v3.0-image |
| embed-multilingual-light-v3.0 |
| embed-multilingual-light-v3.0-image |
| embed-multilingual-v3.0 |
| embed-multilingual-v3.0-image |
| embed-v4.0 |
+-------------------------------------+
RAGFlow(user)> check instance 'test' from 'cohere'
SUCCESS
# FishAudio
RAGFlow(user)> list supported models from 'fishaudio' 'test'
+----------------------------------------+
| model_name |
+----------------------------------------+
| Valentino Narración Biblica Fer |
| Super Smash Bros. 4/Ultimate Announcer |
| Farid Dieck |
| عصام الشوالي |
| ALEX_CHIKNA |
| Energetic Male |
| voz de locutor k |
| يي |
| ELITE |
| Mortal Kombat |
+----------------------------------------+
RAGFlow(user)> show balance from 'fishaudio' 'test'
+----------------------------------+-----------------------------+--------+-----------------+------------------+-----------------------------+----------------------------------+
| _id | created_at | credit | has_free_credit | has_phone_sha256 | updated_at | user_id |
+----------------------------------+-----------------------------+--------+-----------------+------------------+-----------------------------+----------------------------------+
| 82ffec12cf984d88a30ec504d7909812 | 2026-05-09T07:52:16.119000Z | 0 | | false | 2026-05-09T07:52:16.119000Z | 2578ab1126804d6eaa630552400d7ff3 |
+----------------------------------+-----------------------------+--------+-----------------+------------------+-----------------------------+----------------------------------+
```
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- [x] Refactoring
What problem does this PR solve?
This PR completes the Cohere provider integration (upgrading to the new Cohere V2 API) and enhances the Fish Audio provider in RAGFlow.
The following functionalities are now supported:
Cohere:
Fish Audio:
ListModels)Balance)Verified examples from the CLI:
Type of change