mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-07 03:48:44 +08:00
### What problem does this PR solve? This PR implement implement provider 302.AI and JieKouAI **The following functionalities are now supported:** **302.ai** - [x] chat / think chat / stream chat / stream think chat - [x] Embedding - [x] ASR - [x] ListModels - [x] Provider connection checking - [x] Balance - [x] Rerank - [x] OCR - [x] Doc Parse - [x] Show task - [ ] ~~List Tasks!~~ - [ ] TTS **JieKouAI** - [x] chat / think chat / stream chat / stream think chat - [x] Embedding - [x] Rerank - [x] ListModels **Verified examples from the CLI:** ```palintext # jiekouAI RAGFlow(user)> stream think chat with 'zai-org/glm-4.5@test@jiekouai' message 'Hi' Thinking: Let me think about how to respond to this simple greeting. The user just said "Hi", which is a basic and friendly way to start a conversation. I should respond in a similarly warm and welcoming manner.First, I need to acknowledge their greeting and reciprocate with enthusiasm. Something like "Hello!" or "Hi there!" would work well to create a positive atmosphere right from the start.Next, I should make it clear that I'm ready to help. Since they haven't asked anything specific yet, I'll keep it open-ended and inviting. Perhaps offering assistance with a question or task would encourage them to engage further.I should also maintain a professional yet approachable tone. Being an AI assistant, I want to convey that I'm knowledgeable and capable, but also friendly and easy to talk to.Let me put this all together into a concise response. I'll start with a cheerful greeting, express my readiness to help, and finish with an open invitation for them to share what's on their mind. This should create a welcoming environment for whatever they want to discuss next. Answer: ! I'm Claude, an AI assistant created by Anthropic. I'm here to help you with information, answer questions, or assist you with tasks. What can I help you with today? RAGFlow(user)> think chat with 'zai-org/glm-4.5@test@jiekouai' message 'Hi' Thinking: Let me consider how to respond to this greeting. The user initiated with a simple "Hi," so a friendly and open response would be most appropriate to encourage further conversation. I should maintain a welcoming tone while offering assistance. The response should accomplish a few key things: return the greeting warmly, show openness to conversation, and offer specific ways I can help. This approach demonstrates both approachability and usefulness. I'll start with a greeting in return, then express my availability to help, and finish by suggesting some areas where I can provide assistance. This creates a natural flow from acknowledgment to support. It's important to keep the response concise but inviting. Since the user hasn't specified their needs yet, I'll present a few broad categories of assistance to spark their thinking about what they might want to discuss or ask about. The response should end with an encouraging note that prompts them to share what's on their mind, keeping the conversational ball in their court while making it clear I'm ready to engage with whatever they need. Answer: Hello! How can I help you today? Whether you have questions, need information, or just want to chat, I'm here to assist. RAGFlow(user)> embed text 'walkerwhat' 'jumperwho' with 'text-embedding-3-large@test@jiekouai' dimension 16 +-----------+-------+ | dimension | index | +-----------+-------+ | 3072 | 0 | | 3072 | 1 | +-----------+-------+ RAGFlow(user)> rerank query 'what is rag' document 'rag is retrieval augment generation' 'rag need llm' 'famous rag project includes ragflow' with 'baai/bge-reranker-v2-m3@test@jiekouai' top 3 +-------+-----------------+ | index | relevance_score | +-------+-----------------+ | 0 | 0.9830034 | | 2 | 0.06399203 | | 1 | 0.04665664 | +-------+-----------------+ # 302.ai RAGFlow(user)> think chat with 'kimi-k2.6@test@302.ai' message 'who r u' Thinking: The user is asking "who r u" which is a casual way of asking "who are you." I need to identify myself as an AI assistant created by Moonshot AI. I should be friendly, concise, and helpful. Key points to include: - I am Kimi, an AI assistant made by Moonshot AI - I can help with various tasks like answering questions, writing, analysis, coding, etc. - Keep it casual but informative since the user used "r u" (text speak) I should not: - Pretend to be human - Claim to have personal experiences or emotions - Be overly formal or robotic Simple, friendly response is best. Answer: I'm Kimi, an AI assistant made by Moonshot AI. I can help you with answering questions, writing, coding, analysis, or just chatting. What can I do for you? Time: 17.687750 RAGFlow(user)> stream think chat with 'kimi-k2.6@test@302.ai' message 'who r u' Thinking: user asked "who r u" which is a casual way of asking "who are you." I should introduce myself as Kimi, an AI assistant developed by Moonshot AI. I need to be friendly, concise, and accurate. I should mention my capabilities briefly and keep the tone helpful. Since the user used casual text speak ("r u"), I can match that energy with a friendly but still informative tone.Key points:- I'm Kimi, an AI assistant made by Moonshot AI- I can help with various tasks like answering questions, writing, coding, analysis, etc.- Keep it brief but warm- Don't claim to be human- Don't over-explainDraft:"I'm Kimi, an AI assistant created by Moonshot AI. I can help with answering questions, writing, coding, analysis, brainstorming, and lots of other tasks. What can I do for you?"This is good - direct, accurate, and inviting. Answer: Kimi, an AI assistant made by Moonshot AI. I can help with answering questions, writing, coding, analysis, brainstorming, and lots of other stuff. What can I do for you? Time: 14.912576 RAGFlow(user)> asr with 'whisper-v3-turbo@test@302.ai' audio './internal/test.wav' param '' +---------------------------------------------------------------------------------------------------------------------+ | text | +---------------------------------------------------------------------------------------------------------------------+ | The examination and testimony of the experts enabled the Commission to conclude that five shots may have been fired | +---------------------------------------------------------------------------------------------------------------------+ RAGFlow(user)> ocr with 'mistral-ocr-latest@test@302.ai' file './internal/test.pdf' +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | text | +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | # Repurposing Diffusion-Based Image Generators for Monocular Depth Estimation Bingxin Ke Nando Metzger Anton Obukhov Rodrigo Caye Daudt Shengyu Huang Konrad Schindler Photogrammetry and Remote Sensing, ETH Zürich  Figur... | +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ RAGFlow(user)> parse with 'vlm@test@302.ai' file 'https://arxiv.org/pdf/2505.09358' +--------------------------------------+ | task_id | +--------------------------------------+ | 6de6eae6-c122-4b67-91e8-b061a0b8c087 | +--------------------------------------+ RAGFlow(user)> show 'test@302.ai' task '6de6eae6-c122-4b67-91e8-b061a0b8c087' +----------------------------------------------------------------------------+-------+ | content | index | +----------------------------------------------------------------------------+-------+ | https://file.302.ai/gpt/imgs/20260519/b340fdff4774699c287fe4ee4658b317.zip | 0 | +----------------------------------------------------------------------------+-------+ RAGFlow(user)> embed text 'walkerwhat' 'jumperwho' with 'jina-embeddings-v3@test@302.ai' dimension 16 +-----------+-------+ | dimension | index | +-----------+-------+ | 1024 | 0 | | 1024 | 1 | +-----------+-------+ RAGFlow(user)> rerank query 'what is rag' document 'rag is retrieval augment generation' 'rag need llm' 'famous rag project includes ragflow' with 'jina-reranker-v2-base-multilingual@test@302.ai' top 3; +-------+-----------------+ | index | relevance_score | +-------+-----------------+ | 0 | 0.74167407 | | 2 | 0.18832397 | | 1 | 0.15713684 | +-------+-----------------+ ``` ### Type of change - [x] New Feature (non-breaking change which adds functionality) - [x] Refactoring
120 lines
3.8 KiB
Go
120 lines
3.8 KiB
Go
//
|
|
// 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 (
|
|
"strings"
|
|
)
|
|
|
|
// ModelFactory creates ModelDriver instances based on provider name
|
|
type ModelFactory struct {
|
|
}
|
|
|
|
// NewModelFactory creates a new ModelFactory
|
|
func NewModelFactory() *ModelFactory {
|
|
return &ModelFactory{}
|
|
}
|
|
|
|
// CreateModelDriver creates a ModelDriver for the given provider and model
|
|
func (f *ModelFactory) CreateModelDriver(providerName string, baseURL map[string]string, urlSuffix URLSuffix) (ModelDriver, error) {
|
|
providerLower := strings.ToLower(providerName)
|
|
switch providerLower {
|
|
case "anthropic":
|
|
return NewAnthropicModel(baseURL, urlSuffix), nil
|
|
case "zhipu-ai":
|
|
return NewZhipuAIModel(baseURL, urlSuffix), nil
|
|
case "deepseek":
|
|
return NewDeepSeekModel(baseURL, urlSuffix), nil
|
|
case "moonshot":
|
|
return NewMoonshotModel(baseURL, urlSuffix), nil
|
|
case "minimax":
|
|
return NewMinimaxModel(baseURL, urlSuffix), nil
|
|
case "gitee":
|
|
return NewGiteeModel(baseURL, urlSuffix), nil
|
|
case "siliconflow":
|
|
return NewSiliconflowModel(baseURL, urlSuffix), nil
|
|
case "google":
|
|
return NewGoogleModel(baseURL, urlSuffix), nil
|
|
case "aliyun":
|
|
return NewAliyunModel(baseURL, urlSuffix), nil
|
|
case "volcengine":
|
|
return NewVolcEngine(baseURL, urlSuffix), nil
|
|
case "vllm":
|
|
return NewVllmModel(baseURL, urlSuffix), nil
|
|
case "xai":
|
|
return NewXAIModel(baseURL, urlSuffix), nil
|
|
case "lmstudio":
|
|
return NewLmStudioModel(baseURL, urlSuffix), nil
|
|
case "ollama":
|
|
return NewOllamaModel(baseURL, urlSuffix), nil
|
|
case "openai":
|
|
return NewOpenAIModel(baseURL, urlSuffix), nil
|
|
case "nvidia":
|
|
return NewNvidiaModel(baseURL, urlSuffix), nil
|
|
case "openrouter":
|
|
return NewOpenRouterModel(baseURL, urlSuffix), nil
|
|
case "huggingface":
|
|
return NewHuggingFaceModel(baseURL, urlSuffix), nil
|
|
case "baidu":
|
|
return NewBaiduModel(baseURL, urlSuffix), nil
|
|
case "cohere":
|
|
return NewCoHereModel(baseURL, urlSuffix), nil
|
|
case "cometapi":
|
|
return NewCometAPIModel(baseURL, urlSuffix), nil
|
|
case "fishaudio":
|
|
return NewFishAudioModel(baseURL, urlSuffix), nil
|
|
case "mistral":
|
|
return NewMistralModel(baseURL, urlSuffix), nil
|
|
case "upstage":
|
|
return NewUpstageModel(baseURL, urlSuffix), nil
|
|
case "stepfun":
|
|
return NewStepFunModel(baseURL, urlSuffix), nil
|
|
case "baichuan":
|
|
return NewBaichuanModel(baseURL, urlSuffix), nil
|
|
case "jina":
|
|
return NewJinaModel(baseURL, urlSuffix), nil
|
|
case "localai":
|
|
return NewLocalAIModel(baseURL, urlSuffix), nil
|
|
case "xinference":
|
|
return NewXinferenceModel(baseURL, urlSuffix), nil
|
|
case "longcat":
|
|
return NewLongCatModel(baseURL, urlSuffix), nil
|
|
case "novita":
|
|
return NewNovitaModel(baseURL, urlSuffix), nil
|
|
case "replicate":
|
|
return NewReplicateModel(baseURL, urlSuffix), nil
|
|
case "togetherai":
|
|
return NewTogetherAIModel(baseURL, urlSuffix), nil
|
|
case "voyage":
|
|
return NewVoyageModel(baseURL, urlSuffix), nil
|
|
case "paddleocr":
|
|
return NewPaddleOCRModel(baseURL, urlSuffix), nil
|
|
case "xunfei":
|
|
return NewXunFeiModel(baseURL, urlSuffix), nil
|
|
case "deepinfra":
|
|
return NewDeepInfraModel(baseURL, urlSuffix), nil
|
|
case "mineru":
|
|
return NewMinerUModel(baseURL, urlSuffix), nil
|
|
case "jiekouai":
|
|
return NewJieKouAIModel(baseURL, urlSuffix), nil
|
|
case "302.ai":
|
|
return NewAI302Model(baseURL, urlSuffix), nil
|
|
default:
|
|
return NewDummyModel(baseURL, urlSuffix), nil
|
|
}
|
|
}
|