Add custom flags

This commit is contained in:
kwaroran
2024-12-03 21:34:55 +09:00
parent 9ac91190f9
commit 50d20bcc3f
4 changed files with 55 additions and 5 deletions

View File

@@ -815,4 +815,6 @@ export const languageEnglish = {
autoTranslateCachedOnly: "Auto Translate Cached Only",
notification: "Notification",
permissionDenied: "Permission Denied by Your Browser or OS",
customFlags: "Custom Flags",
enableCustomFlags: "Enable Custom Flags",
}

View File

@@ -596,6 +596,38 @@
}}/>
{/if}
</Arcodion>
{#snippet CustomFlagButton(name:string,flag:number)}
<Button className="mt-2" onclick={(e) => {
if(DBState.db.customFlags.includes(flag)){
DBState.db.customFlags = DBState.db.customFlags.filter((f) => f !== flag)
}
else{
DBState.db.customFlags.push(flag)
}
}} styled={DBState.db.customFlags.includes(flag) ? 'primary' : 'outlined'}>
{name}
</Button>
{/snippet}
<Arcodion styled name={language.customFlags}>
<Check bind:check={DBState.db.enableCustomFlags} name={language.enableCustomFlags}/>
{#if DBState.db.enableCustomFlags}
{@render CustomFlagButton('hasImageInput', 0)}
{@render CustomFlagButton('hasImageOutput', 1)}
{@render CustomFlagButton('hasAudioInput', 2)}
{@render CustomFlagButton('hasAudioOutput', 3)}
{@render CustomFlagButton('hasPrefill', 4)}
{@render CustomFlagButton('hasCache', 5)}
{@render CustomFlagButton('hasFullSystemPrompt', 6)}
{@render CustomFlagButton('hasFirstSystemPrompt', 7)}
{@render CustomFlagButton('hasStreaming', 8)}
{@render CustomFlagButton('requiresAlternateRole', 9)}
{@render CustomFlagButton('mustStartWithUserInput', 10)}
{/if}
</Arcodion>
<Arcodion styled name={language.moduleIntergration} help="moduleIntergration">
<TextAreaInput bind:value={DBState.db.moduleIntergration} fullwidth height={"32"} autocomplete="off"/>

View File

@@ -1,4 +1,5 @@
import type { Parameter } from "../process/request"
import { getDatabase } from "../storage/database.svelte"
export enum LLMFlags{
hasImageInput,
@@ -979,11 +980,16 @@ for(let model of LLMModels){
export function getModelInfo(id: string): LLMModel{
const found:LLMModel = LLMModels.find(model => model.id === id)
const db = getDatabase()
const found:LLMModel = safeStructuredClone(LLMModels.find(model => model.id === id))
if(found){
if(db.enableCustomFlags){
found.flags = db.customFlags
}
console.log('found', found)
if(found) return found
return found
}
if(id.startsWith('hf:::')){
const withoutPrefix = id.replace('hf:::', '')

View File

@@ -459,6 +459,8 @@ export function setDatabase(data:Database){
translate: {},
otherAx: {}
}
data.customFlags ??= []
data.enableCustomFlags ??= false
changeLanguage(data.language)
setDatabaseLite(data)
}
@@ -849,6 +851,8 @@ export interface Database{
autoTranslateCachedOnly:boolean
lightningRealmImport:boolean
notification: boolean
customFlags: LLMFlags[]
enableCustomFlags: boolean
}
interface SeparateParameters{
@@ -1168,6 +1172,8 @@ export interface botPreset{
systemContentReplacement?: string
systemRoleReplacement?: 'user'|'assistant'
openAIPrediction?: string
enableCustomFlags?: boolean
customFlags?: LLMFlags[]
}
@@ -1466,6 +1472,8 @@ export function saveCurrentPreset(){
customAPIFormat: safeStructuredClone(db.customAPIFormat),
systemContentReplacement: db.systemContentReplacement,
systemRoleReplacement: db.systemRoleReplacement,
customFlags: safeStructuredClone(db.customFlags),
enableCustomFlags: db.enableCustomFlags,
}
db.botPresets = pres
setDatabase(db)
@@ -1571,6 +1579,8 @@ export function setPreset(db:Database, newPres: botPreset){
db.customAPIFormat = safeStructuredClone(newPres.customAPIFormat) ?? LLMFormat.OpenAICompatible
db.systemContentReplacement = newPres.systemContentReplacement ?? ''
db.systemRoleReplacement = newPres.systemRoleReplacement ?? 'user'
db.customFlags = safeStructuredClone(newPres.customFlags) ?? []
db.enableCustomFlags = newPres.enableCustomFlags ?? false
return db
}
@@ -1581,7 +1591,7 @@ import type { RisuModule } from '../process/modules';
import type { HypaV2Data } from '../process/memory/hypav2';
import { decodeRPack, encodeRPack } from '../rpack/rpack_bg';
import { DBState, selectedCharID } from '../stores.svelte';
import { LLMFormat } from '../model/modellist';
import { LLMFlags, LLMFormat } from '../model/modellist';
import type { Parameter } from '../process/request';
export async function downloadPreset(id:number, type:'json'|'risupreset'|'return' = 'json'){