Skip to content

Commit ddafcab

Browse files
authored
Merge pull request #4915 from zhyhang/feat/some-ehance-202504
add google gemini-2.5-pro-exp-03-25 and others; lift siliconflow to reranker model provider
2 parents febd4eb + feced11 commit ddafcab

File tree

7 files changed

+177
-3
lines changed

7 files changed

+177
-3
lines changed

core/context/allRerankers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Cohere from "../llm/llms/Cohere";
33
import FreeTrial from "../llm/llms/FreeTrial";
44
import HuggingFaceTEI from "../llm/llms/HuggingFaceTEI";
55
import { LLMReranker } from "../llm/llms/llm";
6+
import SiliconFlow from "../llm/llms/SiliconFlow";
67
import ContinueProxy from "../llm/llms/stubs/ContinueProxy";
78
import Voyage from "../llm/llms/Voyage";
89
import WatsonX from "../llm/llms/WatsonX";
@@ -16,4 +17,5 @@ export const AllRerankers: { [key: string]: any } = {
1617
"free-trial": FreeTrial,
1718
"huggingface-tei": HuggingFaceTEI,
1819
"continue-proxy": ContinueProxy,
20+
siliconflow: SiliconFlow,
1921
};

core/llm/llms/SiliconFlow.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CompletionOptions, LLMOptions } from "../../index.js";
1+
import { Chunk, CompletionOptions, LLMOptions } from "../../index.js";
22
import { streamSse } from "../stream.js";
33
import { osModelsEditPrompt } from "../templates/edit.js";
44

@@ -52,6 +52,41 @@ class SiliconFlow extends OpenAI {
5252
yield chunk.choices[0].text;
5353
}
5454
}
55+
56+
async rerank(query: string, chunks: Chunk[]): Promise<number[]> {
57+
if (!query || query.trim() === "") {
58+
console.warn("[SiliconFlow] rerank: query is empty");
59+
return [];
60+
}
61+
62+
if (!chunks || chunks.length === 0) {
63+
console.warn("[SiliconFlow] rerank: chunks is empty");
64+
return [];
65+
}
66+
67+
const endpoint = new URL("rerank", this.apiBase);
68+
const resp = await this.fetch(endpoint, {
69+
method: "POST",
70+
headers: {
71+
"Content-Type": "application/json",
72+
Accept: "application/json",
73+
Authorization: `Bearer ${this.apiKey}`,
74+
},
75+
body: JSON.stringify({
76+
model: this.model,
77+
query,
78+
documents: chunks.map((chunk) => chunk.content),
79+
}),
80+
});
81+
82+
if (!resp.ok) {
83+
throw new Error(await resp.text());
84+
}
85+
86+
const data = (await resp.json()) as any;
87+
const results = data.results.sort((a: any, b: any) => a.index - b.index);
88+
return results.map((result: any) => result.relevance_score);
89+
}
5590
}
5691

5792
export default SiliconFlow;

extensions/vscode/config_schema.json

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,10 @@
956956
"gemini-2.0-flash",
957957
"gemini-2.0-flash-thinking-exp-01-21",
958958
"gemini-2.0-pro-exp-02-05",
959-
"gemini-2.0-flash-lite-preview-02-05"
959+
"gemini-2.0-flash-lite-preview-02-05",
960+
"gemini-2.0-flash-lite",
961+
"gemini-2.0-flash-exp-image-generation",
962+
"gemini-2.5-pro-exp-03-25"
960963
]
961964
}
962965
}
@@ -2886,7 +2889,8 @@
28862889
"watsonx",
28872890
"llm",
28882891
"free-trial",
2889-
"huggingface-tei"
2892+
"huggingface-tei",
2893+
"siliconflow"
28902894
]
28912895
},
28922896
"params": {
@@ -3053,6 +3057,40 @@
30533057
"required": ["truncation_direction"]
30543058
}
30553059
}
3060+
},
3061+
{
3062+
"if": {
3063+
"properties": {
3064+
"name": {
3065+
"enum": ["siliconflow"]
3066+
}
3067+
},
3068+
"required": ["name"]
3069+
},
3070+
"then": {
3071+
"properties": {
3072+
"params": {
3073+
"type": "object",
3074+
"properties": {
3075+
"model": {
3076+
"enum": [
3077+
"BAAI/bge-reranker-v2-m3",
3078+
"netease-youdao/bce-reranker-base_v1",
3079+
"Pro/BAAI/bge-reranker-v2-m3"
3080+
],
3081+
"default": "BAAI/bge-reranker-v2-m3"
3082+
},
3083+
"apiBase": {
3084+
"type": "string"
3085+
},
3086+
"apiKey": {
3087+
"type": "string"
3088+
}
3089+
},
3090+
"required": ["apiKey"]
3091+
}
3092+
}
3093+
}
30563094
}
30573095
]
30583096
},

gui/src/pages/AddNewModel/configs/models.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,48 @@ export const models: { [key: string]: ModelPackage } = {
887887
providerOptions: ["gemini"],
888888
isOpenSource: false,
889889
},
890+
gemini20FlashLite: {
891+
title: "Gemini 2.0 Flash Lite",
892+
description:
893+
"A more efficient version of Gemini 2.0 Flash optimized for faster responses and lower resource usage.",
894+
params: {
895+
title: "Gemini 2.0 Flash Lite",
896+
model: "gemini-2.0-flash-lite",
897+
contextLength: 1_048_576,
898+
apiKey: "<API_KEY>",
899+
},
900+
icon: "gemini.png",
901+
providerOptions: ["gemini"],
902+
isOpenSource: false,
903+
},
904+
gemini20FlashImageGeneration: {
905+
title: "Gemini 2.0 Flash Image Generation",
906+
description:
907+
"A version of Gemini 2.0 Flash optimized for image generation capabilities.",
908+
params: {
909+
title: "Gemini 2.0 Flash Image Generation",
910+
model: "gemini-2.0-flash-exp-image-generation",
911+
contextLength: 32_768,
912+
apiKey: "<API_KEY>",
913+
},
914+
icon: "gemini.png",
915+
providerOptions: ["gemini"],
916+
isOpenSource: false,
917+
},
918+
gemini25ProExp: {
919+
title: "Gemini 2.5 Pro Experimental",
920+
description:
921+
"Experimental version of Gemini 2.5 Pro with enhanced capabilities and larger output limits.",
922+
params: {
923+
title: "Gemini 2.5 Pro Experimental",
924+
model: "gemini-2.5-pro-exp-03-25",
925+
contextLength: 1_048_576,
926+
apiKey: "<API_KEY>",
927+
},
928+
icon: "gemini.png",
929+
providerOptions: ["gemini"],
930+
isOpenSource: false,
931+
},
890932
commandR: {
891933
title: "Command R",
892934
description:

gui/src/pages/AddNewModel/configs/providers.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,9 @@ Select the \`GPT-4o\` model below to complete your provider configuration, but n
495495
],
496496
packages: [
497497
models.gemini20Flash,
498+
models.gemini20FlashLite,
499+
models.gemini20FlashImageGeneration,
500+
models.gemini25ProExp,
498501
models.gemini15Pro,
499502
models.geminiPro,
500503
models.gemini15Flash,

packages/llm-info/src/providers/gemini.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,33 @@ export const Gemini: ModelProvider = {
1111
regex: /gemini-2\.0-flash/i,
1212
recommendedFor: ["chat"]
1313
},
14+
{
15+
model: "gemini-2.0-flash-lite",
16+
displayName: "Gemini 2.0 Flash Lite",
17+
contextLength: 1048576,
18+
maxCompletionTokens: 8192,
19+
mediaTypes: AllMediaTypes,
20+
regex: /gemini-2\.0-flash-lite/i,
21+
recommendedFor: ["chat"]
22+
},
23+
{
24+
model: "gemini-2.0-flash-exp-image-generation",
25+
displayName: "Gemini 2.0 Flash Image Generation",
26+
contextLength: 32768,
27+
maxCompletionTokens: 8192,
28+
mediaTypes: AllMediaTypes,
29+
regex: /gemini-2\.0-flash-exp-image-generation/i,
30+
recommendedFor: ["chat"]
31+
},
32+
{
33+
model: "gemini-2.5-pro-exp-03-25",
34+
displayName: "Gemini 2.5 Pro Exp",
35+
contextLength: 1048576,
36+
maxCompletionTokens: 65536,
37+
mediaTypes: AllMediaTypes,
38+
regex: /gemini-2\.5-pro-exp-03-25/i,
39+
recommendedFor: ["chat"]
40+
},
1441
{
1542
model: "gemini-1.5-flash",
1643
displayName: "Gemini 1.5 Flash",

packages/llm-info/src/providers/vertexai.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,33 @@ export const Gemini: ModelProvider = {
1111
regex: /gemini-2\.0-flash/i,
1212
recommendedFor: ["chat"]
1313
},
14+
{
15+
model: "gemini-2.0-flash-lite",
16+
displayName: "Gemini 2.0 Flash Lite",
17+
contextLength: 1048576,
18+
maxCompletionTokens: 8192,
19+
mediaTypes: AllMediaTypes,
20+
regex: /gemini-2\.0-flash-lite/i,
21+
recommendedFor: ["chat"]
22+
},
23+
{
24+
model: "gemini-2.0-flash-exp-image-generation",
25+
displayName: "Gemini 2.0 Flash Image Generation",
26+
contextLength: 32768,
27+
maxCompletionTokens: 8192,
28+
mediaTypes: AllMediaTypes,
29+
regex: /gemini-2\.0-flash-exp-image-generation/i,
30+
recommendedFor: ["chat"]
31+
},
32+
{
33+
model: "gemini-2.5-pro-exp-03-25",
34+
displayName: "Gemini 2.5 Pro Exp",
35+
contextLength: 1048576,
36+
maxCompletionTokens: 65536,
37+
mediaTypes: AllMediaTypes,
38+
regex: /gemini-2\.5-pro-exp-03-25/i,
39+
recommendedFor: ["chat"]
40+
},
1441
{
1542
model: "gemini-1.5-flash",
1643
displayName: "Gemini 1.5 Flash",

0 commit comments

Comments
 (0)