Add pools
This commit is contained in:
@@ -906,6 +906,7 @@ async function fetchWithProxy(url: string, arg: GlobalFetchArgs): Promise<Global
|
||||
"risu-url": encodeURIComponent(url),
|
||||
"Content-Type": arg.body instanceof URLSearchParams ? "application/x-www-form-urlencoded" : "application/json",
|
||||
...(arg.useRisuToken && { "x-risu-tk": "use" }),
|
||||
"risu-pool": DBState.db.risuPool ? 'true' : 'false'
|
||||
};
|
||||
|
||||
const body = arg.body instanceof URLSearchParams ? arg.body.toString() : JSON.stringify(arg.body);
|
||||
|
||||
@@ -13,6 +13,7 @@ export enum LLMFlags{
|
||||
hasStreaming,
|
||||
requiresAlternateRole,
|
||||
mustStartWithUserInput,
|
||||
poolSupported
|
||||
}
|
||||
|
||||
export enum LLMProvider{
|
||||
@@ -766,16 +767,16 @@ export const LLMModels: LLMModel[] = [
|
||||
id: 'gemini-exp-1121',
|
||||
provider: LLMProvider.GoogleCloud,
|
||||
format: LLMFormat.GoogleCloud,
|
||||
flags: [LLMFlags.hasImageInput, LLMFlags.hasFirstSystemPrompt],
|
||||
flags: [LLMFlags.hasImageInput, LLMFlags.hasFirstSystemPrompt, LLMFlags.poolSupported],
|
||||
parameters: ['temperature', 'top_k', 'top_p'],
|
||||
tokenizer: LLMTokenizer.GoogleCloud
|
||||
tokenizer: LLMTokenizer.GoogleCloud,
|
||||
},
|
||||
{
|
||||
name: "Gemini Exp 1206",
|
||||
id: 'gemini-exp-1206',
|
||||
provider: LLMProvider.GoogleCloud,
|
||||
format: LLMFormat.GoogleCloud,
|
||||
flags: [LLMFlags.hasImageInput, LLMFlags.hasFirstSystemPrompt],
|
||||
flags: [LLMFlags.hasImageInput, LLMFlags.hasFirstSystemPrompt, LLMFlags.poolSupported],
|
||||
recommended: true,
|
||||
parameters: ['temperature', 'top_k', 'top_p'],
|
||||
tokenizer: LLMTokenizer.GoogleCloud
|
||||
|
||||
@@ -1578,14 +1578,29 @@ async function requestGoogleCloudVertex(arg:RequestDataArgumentExtended):Promise
|
||||
}
|
||||
}
|
||||
|
||||
const url = arg.customURL ?? (arg.modelInfo.format === LLMFormat.VertexAIGemini ?
|
||||
`https://${REGION}-aiplatform.googleapis.com/v1/projects/${PROJECT_ID}/locations/us-central1/publishers/google/models/${arg.modelInfo.internalID}:streamGenerateContent`
|
||||
: `https://generativelanguage.googleapis.com/v1beta/models/${arg.modelInfo.internalID}:generateContent?key=${(arg.aiModel === 'reverse_proxy') ? db.proxyKey : db.google.accessToken}`)
|
||||
let url = ''
|
||||
const pool = arg.modelInfo.flags.includes(LLMFlags.poolSupported) && db.risuPool && (!arg.customURL) && arg.modelInfo.format !== LLMFormat.VertexAIGemini
|
||||
|
||||
if(arg.customURL){
|
||||
const u = new URL(arg.customURL)
|
||||
u.searchParams.set('key', db.proxyKey)
|
||||
url = u.toString()
|
||||
}
|
||||
else if(arg.modelInfo.format === LLMFormat.VertexAIGemini){
|
||||
url =`https://${REGION}-aiplatform.googleapis.com/v1/projects/${PROJECT_ID}/locations/us-central1/publishers/google/models/${arg.modelInfo.internalID}:streamGenerateContent`
|
||||
}
|
||||
else if(pool){
|
||||
url = `https://sv.risuai.xyz/rapi/pool?model=${arg.modelInfo.internalID}&key=${db.google.accessToken}&type=google`
|
||||
}
|
||||
else{
|
||||
url = `https://generativelanguage.googleapis.com/v1beta/models/${arg.modelInfo.internalID}:generateContent?key=${db.google.accessToken}`
|
||||
}
|
||||
const res = await globalFetch(url, {
|
||||
headers: headers,
|
||||
body: body,
|
||||
chatId: arg.chatId,
|
||||
abortSignal: arg.abortSignal
|
||||
abortSignal: arg.abortSignal,
|
||||
plainFetchForce: pool
|
||||
})
|
||||
|
||||
if(!res.ok){
|
||||
|
||||
@@ -854,6 +854,7 @@ export interface Database{
|
||||
customFlags: LLMFlags[]
|
||||
enableCustomFlags: boolean
|
||||
googleClaudeTokenizing: boolean
|
||||
risuPool: boolean
|
||||
}
|
||||
|
||||
interface SeparateParameters{
|
||||
|
||||
Reference in New Issue
Block a user