[feat] google palm2 unicorn
This commit is contained in:
@@ -119,6 +119,13 @@
|
||||
<span class="text-textcolor">Palm2 {language.apiKey}</span>
|
||||
<TextInput marginBottom={true} size={"sm"} placeholder="..." bind:value={$DataBase.palmAPI}/>
|
||||
{/if}
|
||||
{#if $DataBase.aiModel === 'palm2_unicorn' || $DataBase.subModel === 'palm2_unicorn'}
|
||||
<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}
|
||||
{#if $DataBase.aiModel.startsWith('novellist') || $DataBase.subModel.startsWith('novellist')}
|
||||
<span class="text-textcolor">NovelList {language.apiKey}</span>
|
||||
<TextInput marginBottom={true} size={"sm"} placeholder="..." bind:value={$DataBase.novellistAPI}/>
|
||||
|
||||
@@ -67,6 +67,8 @@
|
||||
return "OpenRouter"
|
||||
case 'gptvi4_1106':
|
||||
return "GPT-4 Turbo 1106 Vision"
|
||||
case 'palm2_unicorn':
|
||||
return "PaLM2 Unicorn"
|
||||
default:
|
||||
if(name.startsWith("horde:::")){
|
||||
return name.replace(":::", " ")
|
||||
@@ -144,6 +146,7 @@
|
||||
<button class="hover:bg-selected px-6 py-2 text-lg" on:click={() => {changeModel('openrouter')}}>OpenRouter</button>
|
||||
{#if showUnrec}
|
||||
<button class="hover:bg-selected px-6 py-2 text-lg" on:click={() => {changeModel('palm2')}}>Google PaLM2</button>
|
||||
<button class="hover:bg-selected px-6 py-2 text-lg" on:click={() => {changeModel('palm2_unicorn')}}>Google PaLM2 Unicorn</button>
|
||||
<button class="hover:bg-selected px-6 py-2 text-lg" on:click={() => {changeModel('kobold')}}>Kobold</button>
|
||||
{/if}
|
||||
<Arcodion name="Novellist">
|
||||
|
||||
@@ -894,6 +894,64 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
||||
}
|
||||
}
|
||||
}
|
||||
case 'palm2_unicorn':{
|
||||
const bodyData = {
|
||||
"instances": [
|
||||
{
|
||||
"content": stringlizeChat(formated, currentChar?.name ?? '', arg.continue)
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"candidateCount": 1,
|
||||
"maxOutputTokens": maxTokens,
|
||||
"stopSequences": [
|
||||
"system:", "user:", "assistant:"
|
||||
],
|
||||
"temperature": temperature,
|
||||
}
|
||||
};
|
||||
|
||||
const API_ENDPOINT="us-central1-aiplatform.googleapis.com"
|
||||
const PROJECT_ID=db.google.projectId
|
||||
const MODEL_ID="text-unicorn"
|
||||
const LOCATION_ID="us-central1"
|
||||
|
||||
const url = `https://${API_ENDPOINT}/v1/projects/${PROJECT_ID}/locations/${LOCATION_ID}/publishers/google/models/${MODEL_ID}:predict`;
|
||||
const res = await globalFetch(url, {
|
||||
body: bodyData,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": "Bearer " + db.google.accessToken
|
||||
},
|
||||
abortSignal
|
||||
})
|
||||
if(res.ok){
|
||||
console.log(res.data)
|
||||
if(res.data.predictions){
|
||||
let output:string = res.data.predictions[0].content
|
||||
const ind = output.search(/(system note)|(user)|(assistant):/gi)
|
||||
if(ind >= 0){
|
||||
output = output.substring(0, ind)
|
||||
}
|
||||
return {
|
||||
type: 'success',
|
||||
result: output
|
||||
}
|
||||
}
|
||||
else{
|
||||
return {
|
||||
type: 'fail',
|
||||
result: `${JSON.stringify(res.data)}`
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
return {
|
||||
type: 'fail',
|
||||
result: `${JSON.stringify(res.data)}`
|
||||
}
|
||||
}
|
||||
}
|
||||
case "kobold":{
|
||||
const proompt = stringlizeChat(formated, currentChar?.name ?? '', arg.continue)
|
||||
const url = new URL(db.koboldURL)
|
||||
|
||||
@@ -352,6 +352,10 @@ export function setDatabase(data:Database){
|
||||
mode: 'instruct'
|
||||
}
|
||||
data.top_p ??= 1
|
||||
//@ts-ignore
|
||||
data.google ??= {}
|
||||
data.google.accessToken ??= ''
|
||||
data.google.projectId ??= ''
|
||||
changeLanguage(data.language)
|
||||
DataBase.set(data)
|
||||
}
|
||||
@@ -547,6 +551,10 @@ export interface Database{
|
||||
allowAllExtentionFiles?:boolean
|
||||
translatorPrompt:string
|
||||
top_p: number,
|
||||
google: {
|
||||
accessToken: string
|
||||
projectId: string
|
||||
}
|
||||
}
|
||||
|
||||
export interface customscript{
|
||||
@@ -937,7 +945,7 @@ export const presetTemplate:botPreset = {
|
||||
reverseProxyOobaArgs: {
|
||||
mode: 'instruct'
|
||||
},
|
||||
top_p: 1
|
||||
top_p: 1,
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user