Add experimental support for Claude AWS

This commit is contained in:
kwaroran
2024-01-11 21:50:04 +09:00
parent 6031ecea32
commit a319eedee1
3 changed files with 19 additions and 20 deletions

View File

@@ -150,6 +150,9 @@
{#if $DataBase.aiModel.startsWith('claude') || $DataBase.subModel.startsWith('claude')} {#if $DataBase.aiModel.startsWith('claude') || $DataBase.subModel.startsWith('claude')}
<span class="text-textcolor">Claude {language.apiKey}</span> <span class="text-textcolor">Claude {language.apiKey}</span>
<TextInput marginBottom={true} size={"sm"} placeholder="..." bind:value={$DataBase.claudeAPIKey}/> <TextInput marginBottom={true} size={"sm"} placeholder="..." bind:value={$DataBase.claudeAPIKey}/>
{#if $DataBase.useExperimental}
<Check name="Claude Aws" bind:check={$DataBase.claudeAws}> <Help key="experimental" /></Check>
{/if}
{/if} {/if}
{#if $DataBase.aiModel.startsWith('mistral') || $DataBase.subModel.startsWith('mistral')} {#if $DataBase.aiModel.startsWith('mistral') || $DataBase.subModel.startsWith('mistral')}
<span class="text-textcolor">Mistral {language.apiKey}</span> <span class="text-textcolor">Mistral {language.apiKey}</span>

View File

@@ -1427,27 +1427,23 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
}).join('') + '\n\nAssistant: ' }).join('') + '\n\nAssistant: '
//claude bedrock const bedrock = db.claudeAws
//placeholders
const bedrock = false
const region = ''
const AMZ_HOST = "invoke-bedrock.%REGION%.amazonaws.com";
const host = AMZ_HOST.replace("%REGION%", region);
function getCredentialParts(key:string) {
const [accessKeyId, secretAccessKey, region] = key.split(":");
if (!accessKeyId || !secretAccessKey || !region) {
throw new Error("The key assigned to this request is invalid.");
}
return { accessKeyId, secretAccessKey, region };
}
if(bedrock){ if(bedrock){
function getCredentialParts(key:string) {
const [accessKeyId, secretAccessKey, region] = key.split(":");
if (!accessKeyId || !secretAccessKey || !region) {
throw new Error("The key assigned to this request is invalid.");
}
return { accessKeyId, secretAccessKey, region };
}
const { accessKeyId, secretAccessKey, region } = getCredentialParts(apiKey);
const AMZ_HOST = "invoke-bedrock.%REGION%.amazonaws.com";
const host = AMZ_HOST.replace("%REGION%", region);
const stream = false const stream = false
const url = `https://${host}/model/${model}/invoke${stream ? "-with-response-stream" : ""}` const url = `https://${host}/model/${model}/invoke${stream ? "-with-response-stream" : ""}`
const params = { const params = {
@@ -1472,7 +1468,6 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
}); });
const { accessKeyId, secretAccessKey, region } = getCredentialParts(apiKey);
const signer = new SignatureV4({ const signer = new SignatureV4({
sha256: Sha256, sha256: Sha256,
credentials: { accessKeyId, secretAccessKey }, credentials: { accessKeyId, secretAccessKey },

View File

@@ -591,6 +591,7 @@ export interface Database{
} }
}, },
top_k:number top_k:number
claudeAws:boolean
} }
export interface customscript{ export interface customscript{