[feat] openrouter apis

This commit is contained in:
kwaroran
2023-07-21 17:41:48 +09:00
parent b0fa63a14b
commit 7d2860bf35
10 changed files with 51 additions and 18 deletions

View File

@@ -350,4 +350,5 @@ export const languageEnglish = {
animationSpeed: "Animation Speed",
screenshot: "Screenshot",
screenshotSaved: "Screenshot Saved",
inputBotGenerationPrompt: "Input Bot Generation Prompt",
}

View File

@@ -339,7 +339,7 @@
class="mr-2 bg-gray-500 flex justify-center items-center text-white w-12 h-12 rounded-md hover:bg-green-500 transition-colors"><MenuIcon />
</div>
</div>
{#if $DataBase.useAutoTranslateInput && $DataBase.useExperimental}
{#if $DataBase.useAutoTranslateInput}
<div class="flex items-center mt-2 mb-2 w-full">
<label for='messageInputTranslate' class="text-neutral-200 ml-4">
<LanguagesIcon />

View File

@@ -18,6 +18,7 @@
import Button from "src/lib/UI/GUI/Button.svelte";
import SelectInput from "src/lib/UI/GUI/SelectInput.svelte";
import OptionInput from "src/lib/UI/GUI/OptionInput.svelte";
import { openRouterModels } from "src/ts/model/openrouter";
let tokens = {
mainPrompt: 0,
@@ -145,18 +146,30 @@
<TextInput marginBottom={false} size={"sm"} bind:value={$DataBase.openrouterKey} />
<span class="text-neutral-200 mt-4">Openrouter Model</span>
<SelectInput className="mt-2 mb-4" bind:value={$DataBase.openrouterRequestModel}>
<OptionInput value="openai/gpt-3.5-turbo">GPT 3.5</OptionInput>
<OptionInput value="openai/gpt-3.5-turbo-16k">GPT 3.5 16k</OptionInput>
<OptionInput value="openai/gpt-4">GPT-4</OptionInput>
<OptionInput value="openai/gpt-4-32k">GPT-4 32k</OptionInput>
<OptionInput value="anthropic/claude-2">Claude 2</OptionInput>
<OptionInput value="anthropic/claude-instant-v1">Claude Instant v1</OptionInput>
<OptionInput value="anthropic/claude-instant-v1-100k">Claude Instant v1 100k</OptionInput>
<OptionInput value="anthropic/claude-v1">Claude v1</OptionInput>
<OptionInput value="anthropic/claude-v1-100k">Claude v1 100k</OptionInput>
<OptionInput value="anthropic/claude-1.2">Claude v1.2</OptionInput>
</SelectInput>
{#await openRouterModels()}
<SelectInput className="mt-2 mb-4" value="">
<OptionInput value="">Loading..</OptionInput>
</SelectInput>
{:then m}
<SelectInput className="mt-2 mb-4" bind:value={$DataBase.openrouterRequestModel}>
{#if (!m) || (m.length === 0)}
<OptionInput value="openai/gpt-3.5-turbo">GPT 3.5</OptionInput>
<OptionInput value="openai/gpt-3.5-turbo-16k">GPT 3.5 16k</OptionInput>
<OptionInput value="openai/gpt-4">GPT-4</OptionInput>
<OptionInput value="openai/gpt-4-32k">GPT-4 32k</OptionInput>
<OptionInput value="anthropic/claude-2">Claude 2</OptionInput>
<OptionInput value="anthropic/claude-instant-v1">Claude Instant v1</OptionInput>
<OptionInput value="anthropic/claude-instant-v1-100k">Claude Instant v1 100k</OptionInput>
<OptionInput value="anthropic/claude-v1">Claude v1</OptionInput>
<OptionInput value="anthropic/claude-v1-100k">Claude v1 100k</OptionInput>
<OptionInput value="anthropic/claude-1.2">Claude v1.2</OptionInput>
{:else}
{#each m as model}
<OptionInput value={model}>{model}</OptionInput>
{/each}
{/if}
</SelectInput>
{/await}
{/if}
{#if $DataBase.aiModel.startsWith('gpt') || $DataBase.subModel.startsWith('gpt')}
<span class="text-neutral-200">OpenAI {language.apiKey} <Help key="oaiapikey"/></span>

View File

@@ -37,7 +37,7 @@
import { v4 } from "uuid";
import { checkCharOrder } from "src/ts/storage/globalApi";
import { doingChat } from "src/ts/process";
import { BotCreator } from "src/ts/copyright/creator";
import { BotCreator } from "src/ts/creation/creator";
import Button from "../UI/GUI/Button.svelte";
import { fly } from "svelte/transition";
let openPresetList = false;

View File

@@ -27,7 +27,7 @@
<label
class="flex items-center space-x-2 cursor-pointer text-white"
class:mr-2={margin}
aria-describedby="{name}"
aria-describedby="{name} {check ? 'abled' : 'disabled'}"
>
<input
class="hidden"

View File

@@ -1,5 +1,5 @@
<script lang="ts">
import { CCLicenseData } from "src/ts/copyright/license";
import { CCLicenseData } from "src/ts/creation/license";
import { tooltip } from "src/ts/gui/tooltip";
import { openURL } from "src/ts/storage/globalApi";

View File

@@ -85,7 +85,7 @@
import TextAreaInput from "../GUI/TextAreaInput.svelte";
import Button from "../GUI/Button.svelte";
import SelectInput from "../GUI/SelectInput.svelte";
import { CCLicenseData } from "src/ts/copyright/license";
import { CCLicenseData } from "src/ts/creation/license";
import OptionInput from "../GUI/OptionInput.svelte";
export let close = () => {}
export let char:character

View File

@@ -200,7 +200,7 @@ async function createBotFromWebMain(prompt:string):Promise<{ ok: false; data:str
content: rqv
},{
role: 'system',
content: "\n\n*Name*:\n*Age*:\n*gender*: \n*race*:\n*Hair style, color*:\n*color, shape of eye*:\n*Personality*:\n*Dress*:\n*Height (cm)*:\n*weight(kg)*:\n*Job*:\n*Specialty*:\n*Features*: \n*Likes*:\n*Dislikes*:\n*Character's background*: \n\n[[This is a format that you must convert to. output the latest information If there is older information. If it is unknown, output as unknown. only output the converted result. now, output the converted result.]]"
content: "\n\n*Name*:\n*Age*:\n*gender*: \n*race*:\n*Hair style, color*:\n*color, shape of eye*:\n*Personality*:\n*Dress*:\n*Height (cm)*:\n*weight(kg)*:\n*Job*:\n*Specialty*:\n*Features*: \n*Likes*:\n*Dislikes*:\n*Character's background*: \n*Other informations*: \n\n[[This is a format that you must convert to. output the latest information If there is older information. If it is unknown, output as unknown. only output the converted result. now, output the converted result.]]"
}],
maxTokens: 600,
temperature: 0,
@@ -230,6 +230,14 @@ async function createBotFromWebMain(prompt:string):Promise<{ ok: false; data:str
}
async function createBotByAI() {
let search = await alertInput(language.inputBotGenerationPrompt)
if(search.length < 3){
return
}
}
async function createFirstMsg(charDesc:string) {
const v = await requestChatData({
formated: [{

View File

@@ -0,0 +1,11 @@
export async function openRouterModels() {
try {
const aim = fetch("https://openrouter.ai/api/v1/models")
const res = await (await aim).json()
return res.data.map((v:any) => {
return v.id
})
} catch (error) {
return []
}
}