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.
|
||||
* Supports General, AI, Performance, and IDAA-specific configurations.
|
||||
*/
|
||||
import { Modal } from 'flowbite-svelte';
|
||||
import {
|
||||
Brain,
|
||||
CodeXml,
|
||||
ExternalLink,
|
||||
Eye,
|
||||
EyeOff,
|
||||
Globe,
|
||||
Mail,
|
||||
Minus,
|
||||
@@ -34,7 +35,7 @@ $effect(() => {
|
||||
if (typeof cfg_json === 'string') {
|
||||
try {
|
||||
cfg_json = JSON.parse(cfg_json);
|
||||
} catch (e) {
|
||||
} catch {
|
||||
cfg_json = {};
|
||||
}
|
||||
}
|
||||
@@ -45,6 +46,7 @@ $effect(() => {
|
||||
let active_tab: 'visuals' | 'email' | 'ai' | 'refresh' | 'idaa' | 'raw' =
|
||||
$state('visuals');
|
||||
let raw_json_str = $state('');
|
||||
let show_llm_api_token = $state(false);
|
||||
|
||||
// Ensure we have a valid object
|
||||
if (!cfg_json) cfg_json = {};
|
||||
@@ -74,7 +76,7 @@ $effect(() => {
|
||||
try {
|
||||
const parsed = JSON.parse(raw_json_str);
|
||||
cfg_json = parsed;
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// Ignore invalid JSON while typing
|
||||
}
|
||||
}
|
||||
@@ -236,6 +238,14 @@ $effect(() => {
|
||||
>LLM Model</span>
|
||||
<input
|
||||
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}
|
||||
class="input variant-form-material" />
|
||||
</label>
|
||||
@@ -243,10 +253,34 @@ $effect(() => {
|
||||
<label class="label">
|
||||
<span class="text-xs font-bold uppercase opacity-50"
|
||||
>API Token</span>
|
||||
<input
|
||||
type="password"
|
||||
bind:value={cfg_json.llm__api_token}
|
||||
class="input variant-form-material font-mono" />
|
||||
<div class="flex gap-2">
|
||||
<input
|
||||
type={show_llm_api_token ? 'text' : 'password'}
|
||||
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 class="label">
|
||||
<span class="text-xs font-bold uppercase opacity-50"
|
||||
|
||||
Reference in New Issue
Block a user