[feat] google palm2 unicorn
This commit is contained in:
@@ -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