Add fal.ai support

This commit is contained in:
kwaroran
2024-09-01 01:50:21 +09:00
parent a5061a3b3e
commit de6c90cbc4
7 changed files with 105 additions and 4 deletions

View File

@@ -432,6 +432,8 @@ export function setDatabase(data:Database){
data.unformatQuotes ??= false
data.ttsAutoSpeech ??= false
data.translatorInputLanguage ??= 'auto'
data.falModel ??= 'fal-ai/flux/dev'
data.falLoraScale ??= 1
changeLanguage(data.language)
DataBase.set(data)
}
@@ -718,6 +720,11 @@ export interface Database{
hideApiKey: boolean
unformatQuotes: boolean
enableDevTools: boolean
falToken: string
falModel: string
falLora: string
falLoraName: string
falLoraScale: number
}
export interface customscript{

View File

@@ -577,6 +577,7 @@ const knownHostes = ["localhost","127.0.0.1","0.0.0.0"]
interface GlobalFetchArgs {
plainFetchForce?: boolean;
plainFetchDeforce?: boolean;
body?: any;
headers?: { [key: string]: string };
rawResponse?: boolean;
@@ -625,7 +626,7 @@ export async function globalFetch(url: string, arg: GlobalFetchArgs = {}): Promi
if (arg.abortSignal?.aborted) { return { ok: false, data: 'aborted', headers: {} }}
const urlHost = new URL(url).hostname
const forcePlainFetch = (knownHostes.includes(urlHost) && !isTauri) || db.usePlainFetch || arg.plainFetchForce
const forcePlainFetch = ((knownHostes.includes(urlHost) && !isTauri) || db.usePlainFetch || arg.plainFetchForce) && !arg.plainFetchDeforce
if (knownHostes.includes(urlHost) && !isTauri && !isNodeServer){
return { ok: false, headers: {}, data: 'You are trying local request on web version. This is not allowed due to browser security policy. Use the desktop version instead, or use a tunneling service like ngrok and set the CORS to allow all.' }