[feat] gemini non-vertex support
This commit is contained in:
@@ -119,8 +119,19 @@
|
||||
<span class="text-textcolor">Google Bearer Token</span>
|
||||
<TextInput marginBottom={true} size={"sm"} placeholder="..." bind:value={$DataBase.google.accessToken}/>
|
||||
|
||||
<span class="text-textcolor">Google Project ID</span>
|
||||
<TextInput marginBottom={true} size={"sm"} placeholder="..." bind:value={$DataBase.google.projectId}/>
|
||||
{#if $DataBase.google.projectId !== 'aigoogle'}
|
||||
<span class="text-textcolor">Google Project ID</span>
|
||||
<TextInput marginBottom={true} size={"sm"} placeholder="..." bind:value={$DataBase.google.projectId}/>
|
||||
{/if}
|
||||
|
||||
<Check check={$DataBase.google.projectId !== 'aigoogle'} className="mb-2" name={'Use Vertex AI'} onChange={(v) => {
|
||||
if(!v){
|
||||
$DataBase.google.projectId = 'aigoogle'
|
||||
}
|
||||
else{
|
||||
$DataBase.google.projectId = ''
|
||||
}
|
||||
}}/>
|
||||
{/if}
|
||||
{#if $DataBase.aiModel.startsWith('novellist') || $DataBase.subModel.startsWith('novellist')}
|
||||
<span class="text-textcolor">NovelList {language.apiKey}</span>
|
||||
|
||||
@@ -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"
|
||||
if(PROJECT_ID !== 'aigoogle'){
|
||||
headers['Authorization'] = "Bearer " + db.google.accessToken
|
||||
}
|
||||
|
||||
const url = `https://${REGION}-aiplatform.googleapis.com/v1/projects/${PROJECT_ID}/locations/us-central1/publishers/google/models/${aiModel}:streamGenerateContent`
|
||||
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,
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user