Tighten AI config autofill handling
This commit is contained in:
@@ -5,11 +5,12 @@ import { untrack } from 'svelte';
|
|||||||
* Specialized UI for managing site.cfg_json settings.
|
* Specialized UI for managing site.cfg_json settings.
|
||||||
* Supports General, AI, Performance, and IDAA-specific configurations.
|
* Supports General, AI, Performance, and IDAA-specific configurations.
|
||||||
*/
|
*/
|
||||||
import { Modal } from 'flowbite-svelte';
|
|
||||||
import {
|
import {
|
||||||
Brain,
|
Brain,
|
||||||
CodeXml,
|
CodeXml,
|
||||||
ExternalLink,
|
ExternalLink,
|
||||||
|
Eye,
|
||||||
|
EyeOff,
|
||||||
Globe,
|
Globe,
|
||||||
Mail,
|
Mail,
|
||||||
Minus,
|
Minus,
|
||||||
@@ -34,7 +35,7 @@ $effect(() => {
|
|||||||
if (typeof cfg_json === 'string') {
|
if (typeof cfg_json === 'string') {
|
||||||
try {
|
try {
|
||||||
cfg_json = JSON.parse(cfg_json);
|
cfg_json = JSON.parse(cfg_json);
|
||||||
} catch (e) {
|
} catch {
|
||||||
cfg_json = {};
|
cfg_json = {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,6 +46,7 @@ $effect(() => {
|
|||||||
let active_tab: 'visuals' | 'email' | 'ai' | 'refresh' | 'idaa' | 'raw' =
|
let active_tab: 'visuals' | 'email' | 'ai' | 'refresh' | 'idaa' | 'raw' =
|
||||||
$state('visuals');
|
$state('visuals');
|
||||||
let raw_json_str = $state('');
|
let raw_json_str = $state('');
|
||||||
|
let show_llm_api_token = $state(false);
|
||||||
|
|
||||||
// Ensure we have a valid object
|
// Ensure we have a valid object
|
||||||
if (!cfg_json) cfg_json = {};
|
if (!cfg_json) cfg_json = {};
|
||||||
@@ -74,7 +76,7 @@ $effect(() => {
|
|||||||
try {
|
try {
|
||||||
const parsed = JSON.parse(raw_json_str);
|
const parsed = JSON.parse(raw_json_str);
|
||||||
cfg_json = parsed;
|
cfg_json = parsed;
|
||||||
} catch (e) {
|
} catch {
|
||||||
// Ignore invalid JSON while typing
|
// Ignore invalid JSON while typing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -236,6 +238,14 @@ $effect(() => {
|
|||||||
>LLM Model</span>
|
>LLM Model</span>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
|
autocomplete="off"
|
||||||
|
autocapitalize="off"
|
||||||
|
autocorrect="off"
|
||||||
|
spellcheck="false"
|
||||||
|
name="site_llm_model"
|
||||||
|
data-bwignore="true"
|
||||||
|
data-lpignore="true"
|
||||||
|
data-1p-ignore="true"
|
||||||
bind:value={cfg_json.llm__api_model}
|
bind:value={cfg_json.llm__api_model}
|
||||||
class="input variant-form-material" />
|
class="input variant-form-material" />
|
||||||
</label>
|
</label>
|
||||||
@@ -243,10 +253,34 @@ $effect(() => {
|
|||||||
<label class="label">
|
<label class="label">
|
||||||
<span class="text-xs font-bold uppercase opacity-50"
|
<span class="text-xs font-bold uppercase opacity-50"
|
||||||
>API Token</span>
|
>API Token</span>
|
||||||
<input
|
<div class="flex gap-2">
|
||||||
type="password"
|
<input
|
||||||
bind:value={cfg_json.llm__api_token}
|
type={show_llm_api_token ? 'text' : 'password'}
|
||||||
class="input variant-form-material font-mono" />
|
autocomplete="off"
|
||||||
|
autocapitalize="off"
|
||||||
|
autocorrect="off"
|
||||||
|
spellcheck="false"
|
||||||
|
name="site_llm_api_token"
|
||||||
|
data-bwignore="true"
|
||||||
|
data-lpignore="true"
|
||||||
|
data-1p-ignore="true"
|
||||||
|
bind:value={cfg_json.llm__api_token}
|
||||||
|
class="input variant-form-material grow font-mono" />
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="btn btn-sm variant-soft-surface"
|
||||||
|
onclick={() =>
|
||||||
|
(show_llm_api_token = !show_llm_api_token)}
|
||||||
|
title={show_llm_api_token
|
||||||
|
? 'Hide API Token'
|
||||||
|
: 'Show API Token'}>
|
||||||
|
{#if show_llm_api_token}
|
||||||
|
<EyeOff size="1.1em" />
|
||||||
|
{:else}
|
||||||
|
<Eye size="1.1em" />
|
||||||
|
{/if}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</label>
|
</label>
|
||||||
<label class="label">
|
<label class="label">
|
||||||
<span class="text-xs font-bold uppercase opacity-50"
|
<span class="text-xs font-bold uppercase opacity-50"
|
||||||
|
|||||||
Reference in New Issue
Block a user