feat: explicit provider field replaces URL sniffing
CI / frontend (push) Successful in 30s
CI / rust (push) Successful in 5m42s

LlmConfig.provider ("ollama" | "openai", empty = sniff URL so legacy
configs keep working). Settings presets set it — a custom-port Ollama
no longer falls into the OpenAI branch and fails confusingly.

Also: test_connection now accepts an optional config override — the
wizard was passing one that Rust silently ignored, so it tested the
saved config instead of the URL the user just typed.
This commit is contained in:
itsamejms
2026-09-06 23:27:20 +01:00
parent 624d82931b
commit 1e7301647d
4 changed files with 45 additions and 16 deletions
+2 -1
View File
@@ -26,7 +26,7 @@ export function FirstRunWizard({ onComplete }: { onComplete: () => void }) {
// Test connection to the default Ollama URL
const result = await invoke<{ ok: boolean; models: string[]; error: string }>(
"test_connection",
{ config: { api_url: apiUrl, api_key: apiKey, model: "", temperature: 0.7, max_tokens: 512, top_p: 0.9, image_api_url: "", embed_model: "" } }
{ config: { provider: "ollama", api_url: apiUrl, api_key: apiKey, model: "", temperature: 0.7, max_tokens: 512, top_p: 0.9, image_api_url: "", embed_model: "" } }
);
if (result.ok) {
setModels(result.models);
@@ -52,6 +52,7 @@ export function FirstRunWizard({ onComplete }: { onComplete: () => void }) {
// We'll just set the config and complete.
await invoke("set_llm_config", {
config: {
provider: "ollama",
api_url: apiUrl,
api_key: apiKey,
model: model,
+12 -8
View File
@@ -4,6 +4,8 @@ import { open } from "@tauri-apps/plugin-dialog";
import { useToast } from "./Toast";
interface LlmConfig {
/** "ollama" | "openai" — empty = let the backend sniff the URL. */
provider?: string;
api_url: string;
api_key: string;
model: string;
@@ -174,16 +176,17 @@ export function SettingsPanel() {
setImgTesting(false);
}
// ponytail: provider presets fill in the API URL pattern + default model.
const PRESETS: { label: string; url: string; model: string; key?: boolean }[] = [
{ label: "Ollama", url: "http://localhost:11434", model: "llama3.2" },
{ label: "LM Studio", url: "http://localhost:1234/v1", model: "local-model" },
{ label: "OpenAI", url: "https://api.openai.com", model: "gpt-4o-mini", key: true },
{ label: "Custom", url: "", model: "" },
// ponytail: provider presets fill in the API URL pattern + default model
// + the API dialect (provider), so a custom-port Ollama isn't sniffed wrong.
const PRESETS: { label: string; url: string; model: string; provider: string; key?: boolean }[] = [
{ label: "Ollama", url: "http://localhost:11434", model: "llama3.2", provider: "ollama" },
{ label: "LM Studio", url: "http://localhost:1234/v1", model: "local-model", provider: "openai" },
{ label: "OpenAI", url: "https://api.openai.com", model: "gpt-4o-mini", provider: "openai", key: true },
{ label: "Custom", url: "", model: "", provider: "" },
];
function applyPreset(p: { url: string; model: string }) {
function applyPreset(p: { url: string; model: string; provider: string }) {
if (!config) return;
setConfig({ ...config, api_url: p.url, model: p.model });
setConfig({ ...config, api_url: p.url, model: p.model, provider: p.provider });
setConn(null);
}
@@ -192,6 +195,7 @@ export function SettingsPanel() {
// backend re-default on save — but we can't send a partial, so mirror the
// known defaults here and toast.
const DEFAULTS: LlmConfig = {
provider: "",
api_url: "http://localhost:11434",
api_key: "",
model: "llama3.2",