diff --git a/API.md b/API.md index e59b64d..8839f4d 100644 --- a/API.md +++ b/API.md @@ -295,7 +295,7 @@ BYO-only) → else 428. Budgets are per user (`ai:user:`) or shared | Method | Path | Body / Returns | |---|---|---| | GET | `/api/ai/config` | The caller's masked config or `null` | -| PUT | `/api/ai/config` | `{provider,baseUrl?,model,apiKey,enabled?,version?}` → 201/200 masked; `version` required once a row exists (409 stale) | +| PUT | `/api/ai/config` | `{provider,baseUrl?,model,apiKey,enabled?,instructions?,version?}` → 201/200 masked; `version` required once a row exists (409 stale). `instructions` (≤4000 chars) are the user's custom assistant system instructions — full-replacement like `model`/`baseUrl`: omit to clear. They are appended to the assistant chat prompt only, never to the compiler/extraction prompts | | DELETE | `/api/ai/config` | `{ok:true}` | | POST | `/api/ai/test` | One probe completion through the resolved config → `{ok,source,model,reply}`; 428 when nothing is available; 502 with a truncated provider error | | GET | `/api/ai/status` | `{userConfigured,userEnabled,serverAvailable,effective,plan}` — `serverAvailable` is already plan-gated; no secrets | diff --git a/README.md b/README.md index 1e13321..66774ba 100644 --- a/README.md +++ b/README.md @@ -187,10 +187,12 @@ install it); the index-backed page search depends on it. set (no logins, no bookings, no deletes, no multi-step chains yet), every fetch goes through the same private-range network guard as previews, and email actions are hard-capped. AI is **bring-your-own-key** - per user (Settings → AI: provider, model, key — encrypted at rest) with - an optional server-wide key for plans that include it; without any key, - AI features report "not configured" and everything else keeps working. - Details: RUNNING.md → "AI automations". + per user (Settings → AI: provider, model picker, key with show/hide — + encrypted at rest — plus optional **custom instructions** that refine the + in-app assistant's tone and focus; the automation and page-reading prompts + stay server-owned) with an optional server-wide key for plans that include + it; without any key, AI features report "not configured" and everything + else keeps working. Details: RUNNING.md → "AI automations". ### Connecting Authelia (OIDC) diff --git a/db/migrations/016_ai_instructions.sql b/db/migrations/016_ai_instructions.sql new file mode 100644 index 0000000..d989eae --- /dev/null +++ b/db/migrations/016_ai_instructions.sql @@ -0,0 +1,11 @@ +-- 016_ai_instructions.sql — optional custom system instructions per user +-- (Settings → AI, mirroring the BYOK "instructions" field). Additive and +-- idempotent; schema.sql carries the identical column, so db-converge lands +-- the same shape on both paths. +-- +-- Applied ONLY to the in-app assistant chat prompt. The server-owned +-- automation compiler and page-extraction prompts deliberately never +-- include user instructions: those are contracts (ValidateSpec, untrusted +-- fetched content), not personas. + +ALTER TABLE "UserAiConfig" ADD COLUMN IF NOT EXISTS instructions text NOT NULL DEFAULT ''; diff --git a/db/schema.sql b/db/schema.sql index ff198f9..795cf2e 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -453,13 +453,16 @@ CREATE INDEX "AgentRun_taskId_createdAt_idx" ON "AgentRun"("taskId", "createdAt" -- internal/crypto (same versioned format as IMAP passwords and -- notification channel secrets) and masked in every API response. The -- server-wide env key (AI_API_KEY) is the fallback and is plan-gated by --- entitlements.AllowServerAI. +-- entitlements.AllowServerAI. "instructions" holds the user's optional +-- custom system instructions for the in-app assistant; server-owned +-- prompts (automation compiler, page extraction) never include them. CREATE TABLE "UserAiConfig" ( id text PRIMARY KEY, "ownerId" text NOT NULL UNIQUE REFERENCES "User"(id) ON DELETE CASCADE, provider text NOT NULL CHECK (provider IN ('openai-compatible','anthropic','gemini')), "baseUrl" text NOT NULL DEFAULT '', model text NOT NULL, + instructions text NOT NULL DEFAULT '', "apiKey" text NOT NULL, enabled boolean NOT NULL DEFAULT true, version integer NOT NULL DEFAULT 1, diff --git a/internal/ai/ai.go b/internal/ai/ai.go index 17016f6..6429f48 100644 --- a/internal/ai/ai.go +++ b/internal/ai/ai.go @@ -68,13 +68,18 @@ var ErrNoAI = errors.New("ai: no configuration available for this user") // Resolved is one usable endpoint. Source is "user" (BYO) or "server" // (env); it feeds budget keys and the status endpoint, never prompts. +// Instructions carries the user's optional custom system instructions +// (BYO configs only; the server key has none). They apply to the in-app +// assistant persona — server-owned contracts (automation compiler, page +// extraction) must never include them. type Resolved struct { - Provider string - BaseURL string - Model string - APIKey string - Source string - UserID string + Provider string + BaseURL string + Model string + APIKey string + Instructions string + Source string + UserID string } // client dials through netguard for every provider (public ranges + @@ -128,11 +133,11 @@ func serverConfig() (Resolved, bool) { // ResolveForUser applies the resolution chain: the user's enabled BYO // config first, then the server key iff the user's plan may spend it. func ResolveForUser(ctx context.Context, d *db.DB, userID string) (Resolved, error) { - var id, provider, baseURL, model, encKey string + var id, provider, baseURL, model, encKey, instructions string var enabled bool err := d.QueryRowContext(ctx, - `SELECT id, provider, "baseUrl", model, "apiKey", enabled FROM "UserAiConfig" WHERE "ownerId"=$1`, - userID).Scan(&id, &provider, &baseURL, &model, &encKey, &enabled) + `SELECT id, provider, "baseUrl", model, "apiKey", instructions, enabled FROM "UserAiConfig" WHERE "ownerId"=$1`, + userID).Scan(&id, &provider, &baseURL, &model, &encKey, &instructions, &enabled) if err == nil && enabled && encKey != "" { key, decErr := crypt.Decrypt(encKey, config.Load().EncryptionSecret()) if decErr != nil { @@ -140,7 +145,8 @@ func ResolveForUser(ctx context.Context, d *db.DB, userID string) (Resolved, err } return Resolved{ Provider: provider, BaseURL: strings.TrimRight(baseURL, "/"), - Model: model, APIKey: key, Source: "user", UserID: userID, + Model: model, APIKey: key, Instructions: instructions, + Source: "user", UserID: userID, }, nil } if err != nil && !errors.Is(err, sql.ErrNoRows) { diff --git a/internal/handlers/ai.go b/internal/handlers/ai.go index 1175715..cb5bb01 100644 --- a/internal/handlers/ai.go +++ b/internal/handlers/ai.go @@ -1,11 +1,13 @@ package handlers -// Per-user AI configuration (Settings → AI): provider, model, base URL and -// a bring-your-own API key. Config is data; internal/ai is the -// implementation. The key is encrypted at rest (internal/crypto, the same -// versioned format as every other stored credential), masked in every -// response, and a PUT echoing the mask keeps the stored key. The server -// env key remains the plan-gated fallback (entitlements.AllowServerAI). +// Per-user AI configuration (Settings → AI): provider, model, base URL, +// optional custom instructions and a bring-your-own API key. Config is +// data; internal/ai is the implementation. The key is encrypted at rest +// (internal/crypto, the same versioned format as every other stored +// credential), masked in every response, and a PUT echoing the mask keeps +// the stored key. Instructions ride along on the assistant chat prompt +// only. The server env key remains the plan-gated fallback +// (entitlements.AllowServerAI). import ( "context" @@ -43,11 +45,16 @@ func aiConfigProjection(row object) object { } return object{ "id": row["id"], "provider": row["provider"], "baseUrl": row["baseUrl"], - "model": row["model"], "apiKey": masked, "enabled": row["enabled"], + "model": row["model"], "instructions": row["instructions"], + "apiKey": masked, "enabled": row["enabled"], "version": row["version"], "createdAt": row["createdAt"], } } +// aiInstructionsMax bounds the custom system instructions (runes). They +// ride along in every assistant chat request, so they stay short by design. +const aiInstructionsMax = 4000 + // HandleAiConfigGet returns the caller's stored config (masked) or null. func HandleAiConfigGet(w http.ResponseWriter, r *http.Request) { row, e := db.One(r.Context(), database(r), @@ -88,6 +95,14 @@ func HandleAiConfigPut(w http.ResponseWriter, r *http.Request) { respond(w, 0, nil, bad("baseUrl must be an absolute http(s) URL")) return } + // Optional custom system instructions (BYOK "instructions" field). + // Full-replacement like provider/model/baseUrl: a PUT that omits them + // clears them. + instructions := strings.TrimSpace(str(b, "instructions")) + if len([]rune(instructions)) > aiInstructionsMax { + respond(w, 0, nil, bad("instructions must be at most 4000 characters")) + return + } submittedKey := str(b, "apiKey") existing, e := db.One(r.Context(), database(r), @@ -122,7 +137,8 @@ func HandleAiConfigPut(w http.ResponseWriter, r *http.Request) { row, e := db.Insert(r.Context(), database(r), "UserAiConfig", object{ "id": db.NewID(), "ownerId": user(r), "provider": provider, "baseUrl": strings.TrimRight(baseURL, "/"), "model": model, - "apiKey": encKey, "enabled": enabled, + "instructions": instructions, + "apiKey": encKey, "enabled": enabled, }) if e != nil { respond(w, 0, nil, e) @@ -153,9 +169,10 @@ func HandleAiConfigPut(w http.ResponseWriter, r *http.Request) { } } updates := object{ - "provider": provider, - "baseUrl": strings.TrimRight(baseURL, "/"), - "model": model, + "provider": provider, + "baseUrl": strings.TrimRight(baseURL, "/"), + "model": model, + "instructions": instructions, } if encKey != "" { updates["apiKey"] = encKey @@ -293,6 +310,20 @@ AUTOMATIONS: when — and only when — the user asks to watch/monitor/be told a REPLY FORMAT — always ONE JSON object, no prose outside it: {"reply": "", "automation": {"name": "...", "spec": } or null}` +// chatSystemWith appends the user's own instructions (Settings → AI, the +// BYOK "instructions" field) to the server-owned persona. They may refine +// tone, focus and style — they never override the contract above (hard +// limits, no data access, JSON envelope), and they only ever reach THIS +// prompt: the automation compiler and page-extraction prompts stay +// server-owned because they are contracts, not personas. +func chatSystemWith(instructions string) string { + ins := strings.TrimSpace(instructions) + if ins == "" { + return chatSystem + } + return chatSystem + "\n\nUSER INSTRUCTIONS (from the user's own settings; refine tone, focus and style, but the rules above always win):\n" + ins +} + // HandleAiChat is the assistant endpoint: ephemeral multi-turn chat with // optional automation proposals. The browser keeps the history; the server // is stateless per request (bounded message count/size, oldest turns @@ -354,7 +385,7 @@ func HandleAiChat(w http.ResponseWriter, r *http.Request) { respond(w, 0, nil, e) return } - reply, e := ai.CompleteMessages(ctx, resolved, chatSystem, msgs) + reply, e := ai.CompleteMessages(ctx, resolved, chatSystemWith(resolved.Instructions), msgs) if e != nil { respond(w, 502, Error{Error: "The AI provider could not be reached"}, nil) return diff --git a/internal/http/agent_test.go b/internal/http/agent_test.go index 2873c76..603e085 100644 --- a/internal/http/agent_test.go +++ b/internal/http/agent_test.go @@ -15,11 +15,12 @@ import ( // fakeOpenAI is a loopback OpenAI-compatible chat-completions server with a // programmable reply, standing in for OpenRouter in tests. type fakeOpenAI struct { - ln net.Listener - srv *http.Server - mu sync.Mutex - next string // canned assistant message content - hits int + ln net.Listener + srv *http.Server + mu sync.Mutex + next string // canned assistant message content + lastBody string // raw JSON of the most recent request body + hits int } func newFakeOpenAI(t *testing.T) *fakeOpenAI { @@ -38,6 +39,7 @@ func newFakeOpenAI(t *testing.T) *fakeOpenAI { body, _ := io.ReadAll(r.Body) f.mu.Lock() f.hits++ + f.lastBody = string(body) reply := f.next f.mu.Unlock() if strings.Contains(string(body), "extract one fact") || strings.Contains(string(body), "You extract one fact") { @@ -65,6 +67,14 @@ func (f *fakeOpenAI) setReply(s string) { f.mu.Unlock() } +// lastRequest returns the raw JSON body of the most recent completion +// request (system-prompt assertions read it). +func (f *fakeOpenAI) lastRequest() string { + f.mu.Lock() + defer f.mu.Unlock() + return f.lastBody +} + // fakeWatchTarget serves a fixed "flights" page for url_watch evaluation. func fakeWatchTarget(t *testing.T) string { t.Helper() diff --git a/internal/http/ai_chat_test.go b/internal/http/ai_chat_test.go index 16b1afb..b5c4528 100644 --- a/internal/http/ai_chat_test.go +++ b/internal/http/ai_chat_test.go @@ -4,6 +4,7 @@ import ( "net" "net/http" "net/http/cookiejar" + "strings" "testing" ) @@ -90,6 +91,26 @@ func TestAiChat(t *testing.T) { t.Setenv("AI_API_KEY", "") alice.request("POST", "/api/ai/chat", msgs("anything"), 428) + // --- user instructions ride along on the assistant system prompt --- + // A BYO config resolves even with the server key unset. Instructions + // apply to THIS prompt only — never to the compiler/extraction contracts. + alice.request("PUT", "/api/ai/config", map[string]any{ + "provider": "openai-compatible", "baseUrl": "http://" + host + ":" + port + "/v1", + "model": "byo-model", "apiKey": "sk-byo-chat", "instructions": "Answer like a pirate.", + }, 201) + fake.setReply(`{"reply":"Arr.","automation":null}`) + out = alice.request("POST", "/api/ai/chat", msgs("hello"), 200) + if out["reply"] != "Arr." { + t.Fatalf("byo chat reply = %v", out["reply"]) + } + body := fake.lastRequest() + if !strings.Contains(body, "Answer like a pirate.") { + t.Fatal("user instructions missing from the assistant system prompt") + } + if !strings.Contains(body, "USER INSTRUCTIONS") { + t.Fatal("instructions must be appended as a delimited user section") + } + // The chat route is session-authenticated like every /api/ai route. anon, _ := cookiejar.New(nil) stranger := apiClient{t, &http.Client{Jar: anon}, srv.URL} diff --git a/internal/http/ai_config_test.go b/internal/http/ai_config_test.go index b359aa3..4b82ddf 100644 --- a/internal/http/ai_config_test.go +++ b/internal/http/ai_config_test.go @@ -80,14 +80,22 @@ func TestAiConfig(t *testing.T) { // Compile inherits the same precondition. alice.request("POST", "/api/agent/compile", map[string]any{"text": "x"}, 428) - // --- PUT create: openai-compatible with a BYO key --- + // --- PUT create: openai-compatible with a BYO key + instructions --- created := alice.request("PUT", "/api/ai/config", map[string]any{ "provider": "openai-compatible", "baseUrl": base + "/v1", "model": "test-model", - "apiKey": "sk-byo-secret-123", + "apiKey": "sk-byo-secret-123", "instructions": "Answer like a pirate.", }, 201) if created["apiKey"] != "••••••••" { t.Fatalf("key leaked in response: %v", created["apiKey"]) } + if created["instructions"] != "Answer like a pirate." { + t.Fatalf("instructions not echoed: %v", created["instructions"]) + } + // GET returns the same projection (instructions are not a secret). + gotCfg := alice.request("GET", "/api/ai/config", nil, 200) + if gotCfg["instructions"] != "Answer like a pirate." || gotCfg["apiKey"] != "••••••••" { + t.Fatalf("GET projection wrong: %v", gotCfg) + } // Encrypted at rest, decryptable with the server secret. var storedKey string if e := d.QueryRow(`SELECT "apiKey" FROM "UserAiConfig" WHERE "ownerId"=(SELECT id FROM "User" WHERE email='alice@superbrain.test')`).Scan(&storedKey); e != nil { @@ -116,6 +124,10 @@ func TestAiConfig(t *testing.T) { "provider": "anthropic", "baseUrl": base, "model": "claude-x", "apiKey": "••••••••", "version": int(created["version"].(float64)), }, 200) + // Full-replacement semantics: omitting instructions clears them. + if updated["instructions"] != "" { + t.Fatalf("instructions must clear when omitted: %v", updated["instructions"]) + } alice.request("POST", "/api/ai/test", nil, 200) if got := fake.lastAuth["anthropic"]; got != "sk-byo-secret-123|2023-06-01" { t.Fatalf("anthropic adapter headers = %q (mask must preserve the stored key)", got) @@ -136,6 +148,7 @@ func TestAiConfig(t *testing.T) { alice.request("PUT", "/api/ai/config", map[string]any{"provider": "skynet", "model": "x", "apiKey": "k", "version": 3}, 400) alice.request("PUT", "/api/ai/config", map[string]any{"provider": "anthropic", "model": "", "apiKey": "k", "version": 3}, 400) alice.request("PUT", "/api/ai/config", map[string]any{"provider": "anthropic", "model": "m", "baseUrl": "ftp://x", "apiKey": "k", "version": 3}, 400) + alice.request("PUT", "/api/ai/config", map[string]any{"provider": "anthropic", "model": "m", "apiKey": "k", "instructions": strings.Repeat("x", 4001), "version": 3}, 400) // --- Plan gate on the SERVER key --- // Selfhosted (the harness default) may spend the operator's key. diff --git a/web/components/ai-settings.tsx b/web/components/ai-settings.tsx index 2262592..cfe562b 100644 --- a/web/components/ai-settings.tsx +++ b/web/components/ai-settings.tsx @@ -1,45 +1,66 @@ 'use client' -// Settings → AI: per-user BYO provider configuration. Config is data -// (UserAiConfig row), implementation is server-side adapters — the UI only -// ever sees masked keys and the resolved availability status. The server -// key (operator env) shows as a fallback the user's plan may or may not -// include; the UI never learns whether the key itself exists beyond that. +// Settings → AI: per-user BYO provider configuration ("Bring Your Own AI"). +// Config is data (UserAiConfig row), implementation is server-side adapters +// — the UI only ever sees masked keys and the resolved availability status. +// The server key (operator env) shows as a fallback the user's plan may or +// may not include; the UI never learns whether the key itself exists beyond +// that. The optional instructions field is the user's own system-prompt +// refinement for the in-app assistant (server contracts stay server-owned). import { useCallback, useEffect, useState } from 'react' import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' +import { Textarea } from '@/components/ui/textarea' import { Switch } from '@/components/ui/switch' import { Badge } from '@/components/ui/badge' import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select' -import { Bot, Loader2, Trash2, PlugZap } from 'lucide-react' +import { Bot, Loader2, Trash2, PlugZap, Eye, EyeOff } from 'lucide-react' import { toast } from 'sonner' const KEY_MASK = '••••••••' +const INSTRUCTIONS_MAX = 4000 // mirrors the server cap (handlers/ai.go) type AiConfig = { id: string; provider: string; baseUrl: string; model: string - apiKey: string; enabled: boolean; version: number + instructions: string; apiKey: string; enabled: boolean; version: number } type AiStatus = { userConfigured: boolean; userEnabled: boolean serverAvailable: boolean; effective: string; plan: string } -const PROVIDERS: Record = { +const PROVIDERS: Record = { 'openai-compatible': { label: 'OpenAI-compatible (OpenRouter, OpenAI, Grok, Groq, Ollama, …)', defaultBase: 'https://openrouter.ai/api/v1', - modelHint: 'e.g. recursive/flint-v1.0:free or gpt-4o-mini', + models: ['gpt-4o-mini', 'gpt-4o', 'recursive/flint-v1.0:free'], + }, + anthropic: { + label: 'Anthropic (Claude)', + defaultBase: 'https://api.anthropic.com', + models: ['claude-sonnet-4-5', 'claude-opus-4-1', 'claude-3-5-haiku-latest'], + }, + gemini: { + label: 'Google Gemini', + defaultBase: 'https://generativelanguage.googleapis.com', + models: ['gemini-2.5-flash', 'gemini-2.5-pro', 'gemini-2.0-flash'], }, - anthropic: { label: 'Anthropic (Claude)', defaultBase: 'https://api.anthropic.com', modelHint: 'e.g. claude-sonnet-4-5' }, - gemini: { label: 'Google Gemini', defaultBase: 'https://generativelanguage.googleapis.com', modelHint: 'e.g. gemini-2.0-flash' }, } +// Sentinel for "none of the suggested models — type your own" (OpenRouter +// catalogs, local Ollama names, …). The API itself accepts any model string; +// the dropdown is a convenience, not an allowlist. +const CUSTOM_MODEL = '__custom__' + async function api(path: string, init?: RequestInit): Promise { return fetch(path, { headers: { 'Content-Type': 'application/json' }, cache: 'no-store', ...init }) } +function FieldLabel({ children }: { children: React.ReactNode }) { + return +} + export function AiSettings() { const [config, setConfig] = useState(null) const [status, setStatus] = useState(null) @@ -49,8 +70,10 @@ export function AiSettings() { const [provider, setProvider] = useState('openai-compatible') const [baseUrl, setBaseUrl] = useState('') - const [model, setModel] = useState('') + const [model, setModel] = useState(PROVIDERS['openai-compatible'].models[0]) const [apiKey, setApiKey] = useState('') + const [showKey, setShowKey] = useState(false) + const [instructions, setInstructions] = useState('') // Promise-chain loading (house pattern: no synchronous setState in // effects — the SSR lint refuses cascading renders). @@ -65,6 +88,7 @@ export function AiSettings() { setProvider(cfg.provider) setBaseUrl(cfg.baseUrl ?? '') setModel(cfg.model ?? '') + setInstructions(cfg.instructions ?? '') setApiKey('') // never prefill secrets; empty keeps the stored key } else { setConfig(null) @@ -76,6 +100,14 @@ export function AiSettings() { useEffect(() => { reload() }, [reload]) + const changeProvider = (v: string) => { + setProvider(v) + setBaseUrl('') + // The suggested-model list is per provider; fall back to its first entry + // when the current model belongs to the old provider. + if (!PROVIDERS[v].models.includes(model)) setModel(PROVIDERS[v].models[0]) + } + const save = async () => { if (!model.trim()) { toast.error('Model is required'); return } if (!config && !apiKey.trim()) { toast.error('API key is required'); return } @@ -85,6 +117,7 @@ export function AiSettings() { provider, baseUrl: baseUrl.trim() || PROVIDERS[provider].defaultBase, model: model.trim(), + instructions: instructions.trim(), // Empty input on an existing config keeps the stored key (same // write-only contract as the mask). apiKey: apiKey.trim() || (config ? KEY_MASK : ''), @@ -94,6 +127,7 @@ export function AiSettings() { if (res.ok) { toast.success('AI settings saved') setApiKey('') + setShowKey(false) await reload() } else { const data = await res.json().catch(() => null) @@ -119,7 +153,8 @@ export function AiSettings() { const res = await api('/api/ai/config', { method: 'DELETE' }) if (res.ok) { toast.success('Your AI key was removed') - setConfig(null); setApiKey(''); setModel(''); setBaseUrl('') + setConfig(null); setApiKey(''); setShowKey(false); setInstructions('') + setBaseUrl(''); setModel(PROVIDERS[provider].models[0]) await reload() } else { const data = await res.json().catch(() => null) @@ -133,6 +168,7 @@ export function AiSettings() { method: 'PUT', body: JSON.stringify({ provider: config.provider, baseUrl: config.baseUrl, model: config.model, + instructions: config.instructions, apiKey: KEY_MASK, enabled, version: config.version, }), }) @@ -147,14 +183,17 @@ export function AiSettings() { return
Loading AI settings…
} + const suggested = PROVIDERS[provider].models + const modelChoice = suggested.includes(model) ? model : CUSTOM_MODEL + return (
-

Your AI provider

+

Bring your own AI

- Superbrain uses AI for Automations (compiling “hey superbrain” requests and - reading watched pages). Bring your own provider and key — it is stored encrypted, never - shown again, and used only for your requests. + Connect your own LLM API key so Superbrain can run AI features for your account. Your key + is stored encrypted in the server database — it is never shown again in the browser and is + only ever sent to the provider you choose. {status?.serverAvailable ? ' This server also provides a shared AI key included in your plan; your own key takes precedence.' : ' Your plan is bring-your-own-key, so automations need a key here.'} @@ -173,35 +212,90 @@ export function AiSettings() { )}

-
- - ) => setBaseUrl(e.target.value)} - aria-label="Base URL" - /> - ) => setModel(e.target.value)} - aria-label="Model" - /> - ) => setApiKey(e.target.value)} - aria-label="API key" - autoComplete="off" - /> +
+
+ Model providers + +
+ +
+ Base URL (optional) + ) => setBaseUrl(e.target.value)} + aria-label="Base URL" + /> +
+ +
+ API key {config && (leave blank to keep the current key)} +
+ ) => setApiKey(e.target.value)} + aria-label="API key" + autoComplete="off" + /> + +
+
+ +
+ Default model + + {modelChoice === CUSTOM_MODEL && ( + ) => setModel(e.target.value)} + aria-label="Custom model" + /> + )} +
+ +
+ Instructions (optional) +