[feat] gemini non-vertex support

This commit is contained in:
kwaroran
2023-12-21 13:39:00 +09:00
parent bb8d7506f3
commit 438ab1349c
2 changed files with 22 additions and 11 deletions

View File

@@ -1169,19 +1169,19 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
safetySettings: uncensoredCatagory
}
let headers:{[key:string]:string} = {}
const PROJECT_ID=db.google.projectId
const MODEL_ID= aiModel === 'palm2' ? 'text-bison' :
'palm2_unicorn' ? 'text-unicorn' :
''
const REGION="us-central1"
const url = `https://${REGION}-aiplatform.googleapis.com/v1/projects/${PROJECT_ID}/locations/us-central1/publishers/google/models/${aiModel}:streamGenerateContent`
if(PROJECT_ID !== 'aigoogle'){
headers['Authorization'] = "Bearer " + db.google.accessToken
}
const url = PROJECT_ID !== 'aigoogle' ?
`https://${REGION}-aiplatform.googleapis.com/v1/projects/${PROJECT_ID}/locations/us-central1/publishers/google/models/${aiModel}:streamGenerateContent`
: `https://generativelanguage.googleapis.com/v1beta/models/${aiModel}:generateContent?key=${db.google.accessToken}`
const res = await globalFetch(url, {
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer " + db.google.accessToken
},
headers: headers,
body: body,
})