mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-11-10 21:32:43 +08:00
feat: add Synap as a model provider (#21818)
This commit is contained in:
1 parent
1cc1eaed32
commit
19e5abc971
10 files changed
+281
No files matched your search
@@ -3511,6 +3511,14 @@
|
||||
"llm": [],
|
||||
"url": "https://inference.runanywhere.ai/v1"
|
||||
},
|
||||
{
|
||||
"name": "Synap",
|
||||
"logo": "",
|
||||
"tags": "LLM,IMAGE2TEXT",
|
||||
"status": "1",
|
||||
"llm": [],
|
||||
"url": "https://pool.linkrra.com/v1"
|
||||
},
|
||||
{
|
||||
"name": "StepFun",
|
||||
"logo": "",
|
||||
|
||||
@@ -199,6 +199,7 @@ The following providers are **aggregators** — they host models from multiple u
|
||||
| **Replicate** | Open-source model hosting |
|
||||
| **Runcrate** | GPU cloud with an OpenAI-compatible inference API for open models |
|
||||
| **SiliconFlow** | Chinese aggregator |
|
||||
| **Synap** | Linkrra's OpenAI-compatible router for open-weight models served on self-operated GPUs |
|
||||
| **TogetherAI** | Open-source model hosting |
|
||||
| **TokenHub** | Multi-provider aggregator |
|
||||
| **TrustedRouter** | OpenAI-compatible router |
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"name": "Synap",
|
||||
"url": {
|
||||
"default": "https://pool.linkrra.com/v1"
|
||||
},
|
||||
"url_suffix": {
|
||||
"chat": "chat/completions",
|
||||
"models": "models"
|
||||
},
|
||||
"class": "synap",
|
||||
"models": [
|
||||
{
|
||||
"name": "gpt-oss-20b",
|
||||
"context_length": 131072,
|
||||
"max_output": 131072,
|
||||
"model_types": [
|
||||
"chat"
|
||||
],
|
||||
"tools": {
|
||||
"support": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "gemma-4-26b-a4b-it",
|
||||
"context_length": 131072,
|
||||
"max_output": 131072,
|
||||
"model_types": [
|
||||
"chat"
|
||||
],
|
||||
"tools": {
|
||||
"support": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "qwen3-coder-30b",
|
||||
"context_length": 98304,
|
||||
"max_output": 98304,
|
||||
"model_types": [
|
||||
"chat"
|
||||
],
|
||||
"tools": {
|
||||
"support": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "qwen/qwen3-30b-a3b",
|
||||
"context_length": 98304,
|
||||
"max_output": 98304,
|
||||
"model_types": [
|
||||
"chat"
|
||||
],
|
||||
"tools": {
|
||||
"support": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "qwen/qwen3-vl-30b-a3b-instruct",
|
||||
"context_length": 65536,
|
||||
"max_output": 65536,
|
||||
"model_types": [
|
||||
"chat",
|
||||
"vision"
|
||||
],
|
||||
"tools": {
|
||||
"support": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -217,6 +217,8 @@ func (f *ModelFactory) CreateModelDriver(providerName string, baseURL map[string
|
||||
return NewHostingerRouterModel(baseURL, urlSuffix), nil
|
||||
case "wally":
|
||||
return NewWallyModel(baseURL, urlSuffix), nil
|
||||
case "synap":
|
||||
return NewSynapModel(baseURL, urlSuffix), nil
|
||||
default:
|
||||
return NewDummyModel(baseURL, urlSuffix), nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
package models
|
||||
|
||||
// SynapModel drives Synap (https://pool.linkrra.com/v1), which serves
|
||||
// open-weight models on self-operated GPUs through OpenAI-compatible chat
|
||||
// and model-list endpoints, so the embedded OpenAIAPICompatibleModel covers
|
||||
// every call.
|
||||
type SynapModel struct {
|
||||
*OpenAIAPICompatibleModel
|
||||
}
|
||||
|
||||
// NewSynapModel creates a Synap driver.
|
||||
func NewSynapModel(baseURL map[string]string, urlSuffix URLSuffix) *SynapModel {
|
||||
return &SynapModel{
|
||||
OpenAIAPICompatibleModel: NewOpenAIAPICompatibleModel(baseURL, urlSuffix),
|
||||
}
|
||||
}
|
||||
|
||||
// Name returns the driver name.
|
||||
func (m *SynapModel) Name() string {
|
||||
return "synap"
|
||||
}
|
||||
|
||||
// NewInstance returns a driver bound to the given base URL.
|
||||
func (m *SynapModel) NewInstance(baseURL map[string]string) ModelDriver {
|
||||
return NewSynapModel(baseURL, m.baseModel.URLSuffix)
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
//
|
||||
// Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"ragflow/internal/common"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// newSynapForTest creates a SynapModel instance for testing.
|
||||
func newSynapForTest(baseURL string) *SynapModel {
|
||||
return NewSynapModel(
|
||||
map[string]string{"default": baseURL},
|
||||
URLSuffix{Chat: "chat/completions", Models: "models"},
|
||||
)
|
||||
}
|
||||
|
||||
// TestSynapName tests the driver name.
|
||||
func TestSynapName(t *testing.T) {
|
||||
if got := newSynapForTest("http://unused").Name(); got != "synap" {
|
||||
t.Errorf("Name()=%q", got)
|
||||
}
|
||||
}
|
||||
|
||||
// TestSynapFactory tests creating the driver from factory.
|
||||
func TestSynapFactory(t *testing.T) {
|
||||
driver, err := NewModelFactory().CreateModelDriver("synap", map[string]string{"default": "http://unused"}, URLSuffix{})
|
||||
if err != nil {
|
||||
t.Fatalf("CreateModelDriver: %v", err)
|
||||
}
|
||||
if _, ok := driver.(*SynapModel); !ok {
|
||||
t.Fatalf("driver type=%T, want *SynapModel", driver)
|
||||
}
|
||||
if _, ok := driver.NewInstance(map[string]string{"default": "http://other"}).(*SynapModel); !ok {
|
||||
t.Fatal("NewInstance did not return *SynapModel")
|
||||
}
|
||||
}
|
||||
|
||||
// The shipped config must resolve to the Synap driver. CreateModelDriver
|
||||
// dispatches on strings.ToLower(name), so the "Synap" provider name has
|
||||
// to match the "synap" case; anything else silently falls through to
|
||||
// DummyModel.
|
||||
func TestSynapProviderConfig(t *testing.T) {
|
||||
dir, restore := setupProviderTestDir(t, "synap.json")
|
||||
defer restore()
|
||||
|
||||
if err := InitProviderManager(dir); err != nil {
|
||||
t.Fatalf("InitProviderManager: %v", err)
|
||||
}
|
||||
|
||||
provider := GetProviderManager().FindProvider("Synap")
|
||||
if provider == nil {
|
||||
t.Fatal("Synap provider not found")
|
||||
}
|
||||
if _, ok := provider.ModelDriver.(*SynapModel); !ok {
|
||||
t.Fatalf("ModelDriver=%T, want *models.SynapModel", provider.ModelDriver)
|
||||
}
|
||||
}
|
||||
|
||||
// TestSynapChatSendsAPIKey tests chat completion authentication and that
|
||||
// the model id reaches the API unchanged.
|
||||
func TestSynapChatSendsAPIKey(t *testing.T) {
|
||||
withSSRFBypass(t)
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path != "/chat/completions" {
|
||||
t.Errorf("path=%s", r.URL.Path)
|
||||
}
|
||||
if got := r.Header.Get("Authorization"); got != "Bearer sk-gw-test" {
|
||||
t.Errorf("Authorization=%q", got)
|
||||
}
|
||||
var body struct {
|
||||
Model string `json:"model"`
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
|
||||
t.Errorf("decode request: %v", err)
|
||||
}
|
||||
if body.Model != "qwen3-coder-30b" {
|
||||
t.Errorf("model=%q", body.Model)
|
||||
}
|
||||
_ = json.NewEncoder(w).Encode(map[string]any{
|
||||
"id": "chat-synap",
|
||||
"choices": []map[string]any{{"message": map[string]any{"content": "pong"}}},
|
||||
"usage": map[string]any{"prompt_tokens": 3, "completion_tokens": 5, "total_tokens": 8},
|
||||
})
|
||||
}))
|
||||
defer srv.Close()
|
||||
|
||||
usage := &common.ModelUsage{}
|
||||
resp, err := newSynapForTest(srv.URL).ChatWithMessages(
|
||||
t.Context(),
|
||||
"qwen3-coder-30b",
|
||||
[]Message{{Role: "user", Content: "ping"}},
|
||||
&APIConfig{ApiKey: &testAPIKey},
|
||||
nil,
|
||||
usage,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("ChatWithMessages: %v", err)
|
||||
}
|
||||
if *resp.Answer != "pong" {
|
||||
t.Errorf("Answer=%q", *resp.Answer)
|
||||
}
|
||||
assertModelUsage(t, usage, 3, 5, 8)
|
||||
}
|
||||
|
||||
// TestSynapListModelsAndCheckConnection tests model listing and connectivity check.
|
||||
func TestSynapListModelsAndCheckConnection(t *testing.T) {
|
||||
withSSRFBypass(t)
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodGet || r.URL.Path != "/models" {
|
||||
t.Errorf("%s %s", r.Method, r.URL.Path)
|
||||
}
|
||||
if got := r.Header.Get("Authorization"); got != "Bearer sk-gw-test" {
|
||||
t.Errorf("Authorization=%q", got)
|
||||
}
|
||||
_ = json.NewEncoder(w).Encode(map[string]any{
|
||||
"data": []map[string]any{
|
||||
{"id": "qwen3-coder-30b"},
|
||||
{"id": "gpt-oss-20b"},
|
||||
},
|
||||
})
|
||||
}))
|
||||
defer srv.Close()
|
||||
|
||||
model := newSynapForTest(srv.URL)
|
||||
list, err := model.ListModels(t.Context(), &APIConfig{ApiKey: &testAPIKey})
|
||||
if err != nil {
|
||||
t.Fatalf("ListModels: %v", err)
|
||||
}
|
||||
if joinModelNames(list, ",") != "qwen3-coder-30b,gpt-oss-20b" {
|
||||
t.Errorf("models=%v", list)
|
||||
}
|
||||
if err := model.CheckConnection(t.Context(), &APIConfig{ApiKey: &testAPIKey}); err != nil {
|
||||
t.Fatalf("CheckConnection: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><rect width="32" height="32" rx="8" fill="#050608"/><g stroke="#fff" stroke-width="1.7" stroke-linecap="round" transform="translate(4 4) scale(1)"><line x1="12" y1="11" x2="5" y2="7"/><line x1="12" y1="11" x2="12" y2="4"/><line x1="12" y1="11" x2="19" y2="8"/><line x1="12" y1="11" x2="8" y2="18"/><line x1="12" y1="11" x2="17" y2="17"/></g><g fill="#fff" transform="translate(4 4)"><circle cx="5" cy="7" r="1.8"/><circle cx="12" cy="4" r="1.8"/><circle cx="19" cy="8" r="1.8"/><circle cx="8" cy="18" r="1.8"/><circle cx="17" cy="17" r="1.8"/><circle cx="12" cy="11" r="2.7"/></g></svg>
|
||||
|
After Width: | Height: | Size: 647 B |
@@ -128,6 +128,7 @@ const svgIcons = [
|
||||
LLMFactory.HostingerRouter,
|
||||
LLMFactory.Cheapaimodel,
|
||||
LLMFactory.Wally,
|
||||
LLMFactory.Synap,
|
||||
];
|
||||
|
||||
export const LlmIcon = ({
|
||||
|
||||
@@ -124,6 +124,7 @@ export enum LLMFactory {
|
||||
SystemOne = 'SystemOne',
|
||||
HostingerRouter = 'Hostinger Router',
|
||||
Wally = 'Wally',
|
||||
Synap = 'Synap',
|
||||
}
|
||||
|
||||
// Please lowercase the file name
|
||||
@@ -229,6 +230,7 @@ export const IconMap = {
|
||||
[LLMFactory.HostingerRouter]: 'hostinger-router',
|
||||
[LLMFactory.Cheapaimodel]: 'cheapaimodel',
|
||||
[LLMFactory.Wally]: 'wally',
|
||||
[LLMFactory.Synap]: 'synap',
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -285,6 +287,7 @@ export const APIMapUrl = {
|
||||
[LLMFactory.Cheapaimodel]:
|
||||
'https://console.cheapaimodel.ai/keys?utm_source=ragflow',
|
||||
[LLMFactory.Wally]: 'https://console.runanywhere.ai',
|
||||
[LLMFactory.Synap]: 'https://synap.linkrra.com/pricing',
|
||||
[LLMFactory.MWS]:
|
||||
'https://mws.ru/docs/cloud-platform/gpt/general/inference-text.html',
|
||||
[LLMFactory.Anthropic]: 'https://console.anthropic.com/settings/keys',
|
||||
|
||||
@@ -49,6 +49,7 @@ export const LIST_MODEL_PROVIDERS = new Set<string>([
|
||||
LLMFactory.RAGcon,
|
||||
LLMFactory.SoMark,
|
||||
LLMFactory.HostingerRouter,
|
||||
LLMFactory.Synap,
|
||||
|
||||
// LLMFactory.HuggingFace,
|
||||
// LLMFactory.GoogleCloud,
|
||||
|
||||
Reference in new issue
Block a user