RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
add support for Voyage AI (#2159)
黄腾99993e5026be
diff --git a/conf/llm_factories.json b/conf/llm_factories.jsonindex bd0ac30ab5..698443efd3 100644--- a/conf/llm_factories.json+++ b/conf/llm_factories.json@@ -2400,7 +2400,7 @@]},{- "name": "Lepton",+ "name": "LeptonAI","logo": "","tags": "LLM","status": "1",@@ -3290,6 +3290,68 @@"model_type": "chat"}]+ },+ {+ "name": "Voyage AI",+ "logo": "",+ "tags": "TEXT EMBEDDING, TEXT RE-RANK",+ "status": "1",+ "llm": [+ {+ "llm_name": "voyage-large-2-instruct",+ "tags": "TEXT EMBEDDING,16000",+ "max_tokens": 16000,+ "model_type": "embedding"+ },+ {+ "llm_name": "voyage-finance-2",+ "tags": "TEXT EMBEDDING,32000",+ "max_tokens": 32000,+ "model_type": "embedding"+ },+ {+ "llm_name": "voyage-multilingual-2",+ "tags": "TEXT EMBEDDING,32000",+ "max_tokens": 32000,+ "model_type": "embedding"+ },+ {+ "llm_name": "voyage-law-2",+ "tags": "TEXT EMBEDDING,16000",+ "max_tokens": 16000,+ "model_type": "embedding"+ },+ {+ "llm_name": "voyage-code-2",+ "tags": "TEXT EMBEDDING,16000",+ "max_tokens": 16000,+ "model_type": "embedding"+ },+ {+ "llm_name": "voyage-large-2",+ "tags": "TEXT EMBEDDING,16000",+ "max_tokens": 16000,+ "model_type": "embedding"+ },+ {+ "llm_name": "voyage-2",+ "tags": "TEXT EMBEDDING,4000",+ "max_tokens": 4000,+ "model_type": "embedding"+ },+ {+ "llm_name": "rerank-1",+ "tags": "RE-RANK, 8000",+ "max_tokens": 8000,+ "model_type": "rerank"+ },+ {+ "llm_name": "rerank-lite-1",+ "tags": "RE-RANK, 4000",+ "max_tokens": 4000,+ "model_type": "rerank"+ }+ ]}]}diff --git a/rag/llm/__init__.py b/rag/llm/__init__.pyindex ef37d6446f..b503b1762f 100644--- a/rag/llm/__init__.py+++ b/rag/llm/__init__.py@@ -45,7 +45,8 @@ EmbeddingModel = {"Upstage": UpstageEmbed,"SILICONFLOW": SILICONFLOWEmbed,"Replicate": ReplicateEmbed,- "BaiduYiyan": BaiduYiyanEmbed+ "BaiduYiyan": BaiduYiyanEmbed,+ "Voyage AI": VoyageEmbed}@@ -105,7 +106,7 @@ ChatModel = {"Tencent Hunyuan": HunyuanChat,"XunFei Spark": SparkChat,"BaiduYiyan": BaiduYiyanChat,- "Anthropic": AnthropicChat+ "Anthropic": VoyageChat,}@@ -120,7 +121,8 @@ RerankModel = {"cohere": CoHereRerank,"TogetherAI": TogetherAIRerank,"SILICONFLOW": SILICONFLOWRerank,- "BaiduYiyan": BaiduYiyanRerank+ "BaiduYiyan": BaiduYiyanRerank,+ "Voyage AI": VoyageRerank}diff --git a/rag/llm/embedding_model.py b/rag/llm/embedding_model.pyindex bc8241372e..257a32891c 100644--- a/rag/llm/embedding_model.py+++ b/rag/llm/embedding_model.py@@ -623,3 +623,24 @@ class BaiduYiyanEmbed(Base):np.array([r["embedding"] for r in res["data"]]),res["usage"]["total_tokens"],)+++class VoyageEmbed(Base):+ def __init__(self, key, model_name, base_url=None):+ import voyageai++ self.client = voyageai.Client(api_key=key)+ self.model_name = model_name++ def encode(self, texts: list, batch_size=32):+ res = self.client.embed(+ texts=texts, model=self.model_name, input_type="document"+ )+ return np.array(res.embeddings), res.total_tokens++ def encode_queries(self, text):+ res = self.client.embed+ res = self.client.embed(+ texts=text, model=self.model_name, input_type="query"+ )+ return np.array(res.embeddings), res.total_tokensdiff --git a/rag/llm/rerank_model.py b/rag/llm/rerank_model.pyindex cc7f5525ca..3a2a910920 100644--- a/rag/llm/rerank_model.py+++ b/rag/llm/rerank_model.py@@ -311,3 +311,19 @@ class BaiduYiyanRerank(Base):rank = np.array([d["relevance_score"] for d in res["results"]])indexs = [d["index"] for d in res["results"]]return rank[indexs], res["usage"]["total_tokens"]+++class VoyageRerank(Base):+ def __init__(self, key, model_name, base_url=None):+ import voyageai++ self.client = voyageai.Client(api_key=key)+ self.model_name = model_name++ def similarity(self, query: str, texts: list):+ res = self.client.rerank(+ query=query, documents=texts, model=self.model_name, top_k=len(texts)+ )+ rank = np.array([r.relevance_score for r in res.results])+ indexs = [r.index for r in res.results]+ return rank[indexs], res.total_tokensdiff --git a/requirements.txt b/requirements.txtindex 0bcd697af4..0f21366069 100644--- a/requirements.txt+++ b/requirements.txt@@ -86,6 +86,7 @@ torch==2.3.0transformers==4.38.1umap==0.1.1volcengine==1.0.146+voyageai==0.2.3webdriver_manager==4.0.1Werkzeug==3.0.3wikipedia==1.4.0diff --git a/requirements_arm.txt b/requirements_arm.txtindex 1207d6d8d2..01b9ce0e3f 100644--- a/requirements_arm.txt+++ b/requirements_arm.txt@@ -141,6 +141,7 @@ loguru==0.7.2umap-learnfasttext==0.9.2volcengine==1.0.141+voyageai==0.2.3opencv-python-headless==4.9.0.80readability-lxml==0.8.1html_text==0.6.2diff --git a/web/src/assets/svg/llm/lepton.svg b/web/src/assets/svg/llm/lepton-ai.svgsimilarity index 100%rename from web/src/assets/svg/llm/lepton.svgrename to web/src/assets/svg/llm/lepton-ai.svgdiff --git a/web/src/assets/svg/llm/voyage.svg b/web/src/assets/svg/llm/voyage.svgnew file mode 100644index 0000000000..88ffbdff91--- /dev/null+++ b/web/src/assets/svg/llm/voyage.svg@@ -0,0 +1,32 @@+<svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="100.000000pt" height="19.000000pt" viewBox="0 0 300.000000 57.000000" preserveAspectRatio="xMidYMid meet">+<g transform="translate(0.000000,57.000000) scale(0.100000,-0.100000)" fill="currentColor" stroke="none">+<path d="M2505 368 c-38 -84 -86 -188 -106 -230 l-38 -78 27 0 c24 0 30 7 55+75 l28 75 100 0 100 0 25 -55 c13 -31 24 -64 24 -75 0 -17 7 -20 44 -20 l43 0+-37 73 c-20 39 -68 143 -106 229 -38 87 -74 158 -80 158 -5 0 -41 -69 -79+-152z m110 -30 c22 -51 41 -95 42 -98 2 -3 -36 -6 -83 -7 -76 -1 -85 0 -81 15+12 40 72 182 77 182 3 0 24 -41 45 -92z"></path>+<path d="M63 493 c19 -61 197 -438 209 -440 10 -2 147 282 216 449 2 4 -10 8+-27 8 -23 0 -31 -5 -31 -17 0 -16 -142 -365 -146 -360 -8 11 -144 329 -149+350 -6 23 -12 27 -42 27 -29 0 -34 -3 -30 -17z"></path>+<path d="M2855 285 l0 -225 30 0 30 0 0 225 0 225 -30 0 -30 0 0 -225z"></path>+<path d="M588 380 c-55 -30 -82 -74 -86 -145 -3 -50 0 -66 20 -95 39 -58 82+-80 153 -80 68 0 110 21 149 73 32 43 30 150 -3 196 -47 66 -158 90 -233 51z+m133 -16 c59 -30 89 -156 54 -224 -45 -87 -162 -78 -201 16 -18 44 -18 128 1+164 28 55 90 73 146 44z"></path>+<path d="M935 303 l76 -98 -7 -72 -6 -73 33 0 34 0 -3 78 -4 77 71 93 c65 85+68 92 46 92 -15 0 -29 -9 -36 -22 -18 -33 -90 -128 -98 -128 -6 1 -67 85 -88+122 -8 15 -24 23 -53 25 l-41 4 76 -98z"></path>+<path d="M1257 230 c-82 -169 -83 -170 -57 -170 17 0 27 6 27 15 0 8 7 31 17+52 l17 38 79 0 78 1 16 -34 c9 -18 16 -42 16 -52 0 -17 7 -20 41 -20 22 0 39+3 37 8 -2 4 -39 80 -83 170 -43 89 -84 162 -92 162 -7 0 -50 -76 -96 -170z+m90 -38 c-33 -2 -61 -1 -63 1 -2 2 10 34 26 71 l31 68 33 -68 33 -69 -60 -3z"></path>+<path d="M1665 386 c-37 -16 -84 -63 -97 -96 -13 -35 -12 -104 2 -132 49 -94+182 -134 280 -83 24 12 29 22 32 64 3 49 3 49 -30 53 l-33 4 3 -45 c4 -61 -5+-71 -60 -71 -93 0 -142 57 -142 164 0 44 5 60 25 85 47 55 136 65 184 20 30+-28 35 -20 11 19 -19 31 -22 32 -82 32 -35 -1 -76 -7 -93 -14z"></path>+<path d="M1955 230 l0 -170 91 0 c76 0 93 3 98 16 4 9 5 18 4 20 -2 1 -31 -1+-66 -5 -34 -4 -64 -5 -67 -3 -3 3 -5 36 -5 73 l0 68 55 -6 c49 -5 55 -4 55 13+0 17 -6 19 -55 16 l-55 -4 0 61 0 61 64 0 c48 0 65 4 70 15 4 13 -10 15 -92+15 l-97 0 0 -170z"></path>+</g>+</svg>\ No newline at end of filediff --git a/web/src/pages/user-setting/setting-model/constant.ts b/web/src/pages/user-setting/setting-model/constant.tsindex 33cf76d86a..a644c21c86 100644--- a/web/src/pages/user-setting/setting-model/constant.ts+++ b/web/src/pages/user-setting/setting-model/constant.ts@@ -24,7 +24,7 @@ export const IconMap = {'LM-Studio': 'lm-studio','OpenAI-API-Compatible': 'openai-api',cohere: 'cohere',- Lepton: 'lepton',+ LeptonAI: 'lepton-ai',TogetherAI: 'together-ai',PerfXCloud: 'perfx-cloud',Upstage: 'upstage',@@ -38,6 +38,7 @@ export const IconMap = {'Fish Audio': 'fish-audio','Tencent Cloud': 'tencent-cloud',Anthropic: 'anthropic',+ 'Voyage AI': 'voyage',};export const BedrockRegionList = [