generated from nhcarrigan/template
feat: support ollama
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
configStore,
|
||||
type HikariConfig,
|
||||
type Theme,
|
||||
type ProviderType,
|
||||
type CustomThemeColors,
|
||||
applyFontSize,
|
||||
applyCustomThemeColors,
|
||||
@@ -14,11 +15,14 @@
|
||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||
|
||||
let config: HikariConfig = $state({
|
||||
provider_type: "claude_cli",
|
||||
model: null,
|
||||
api_key: null,
|
||||
custom_instructions: null,
|
||||
mcp_servers_json: null,
|
||||
auto_granted_tools: [],
|
||||
ollama_base_url: "http://localhost:11434",
|
||||
ollama_model: null,
|
||||
theme: "dark",
|
||||
greeting_enabled: true,
|
||||
greeting_custom_prompt: null,
|
||||
@@ -72,12 +76,27 @@
|
||||
grantedTools = Array.from(tools);
|
||||
});
|
||||
|
||||
const availableProviders: { value: ProviderType; label: string; description: string }[] = [
|
||||
{ value: "claude_cli", label: "Claude CLI", description: "Use Claude Code CLI for AI assistance" },
|
||||
{ value: "ollama", label: "Ollama (Local)", description: "Use locally running Ollama models" },
|
||||
];
|
||||
|
||||
const availableModels = [
|
||||
{ value: "", label: "Default (from ~/.claude)" },
|
||||
{ value: "claude-sonnet-4-20250514", label: "Claude Sonnet 4" },
|
||||
{ value: "claude-opus-4-20250514", label: "Claude Opus 4" },
|
||||
];
|
||||
|
||||
const ollamaModels = [
|
||||
{ value: "", label: "Default (llama3.2)" },
|
||||
{ value: "llama3.2", label: "Llama 3.2" },
|
||||
{ value: "llama3.2:1b", label: "Llama 3.2 1B" },
|
||||
{ value: "qwen2.5-coder", label: "Qwen 2.5 Coder" },
|
||||
{ value: "deepseek-coder-v2", label: "DeepSeek Coder V2" },
|
||||
{ value: "mistral", label: "Mistral 7B" },
|
||||
{ value: "gemma2", label: "Gemma 2" },
|
||||
];
|
||||
|
||||
const commonTools = [
|
||||
"Read",
|
||||
"Write",
|
||||
@@ -207,6 +226,79 @@
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<!-- Provider Selection Section -->
|
||||
<section class="mb-6">
|
||||
<h3 class="text-sm font-medium text-[var(--accent-primary)] uppercase tracking-wider mb-3">
|
||||
AI Provider
|
||||
</h3>
|
||||
|
||||
<div class="space-y-2">
|
||||
{#each availableProviders as provider (provider.value)}
|
||||
<label class="flex items-start gap-3 p-3 rounded-lg border cursor-pointer transition-colors {config.provider_type === provider.value
|
||||
? 'border-[var(--accent-primary)] bg-[var(--accent-primary)]/10'
|
||||
: 'border-[var(--border-color)] bg-[var(--bg-primary)] hover:border-[var(--accent-primary)]/50'}">
|
||||
<input
|
||||
type="radio"
|
||||
name="provider"
|
||||
value={provider.value}
|
||||
checked={config.provider_type === provider.value}
|
||||
onchange={() => config.provider_type = provider.value}
|
||||
class="mt-1 w-4 h-4 text-[var(--accent-primary)] bg-[var(--bg-primary)] border-[var(--border-color)] focus:ring-[var(--accent-primary)]"
|
||||
/>
|
||||
<div class="flex-1">
|
||||
<div class="text-sm font-medium text-[var(--text-primary)]">{provider.label}</div>
|
||||
<div class="text-xs text-[var(--text-tertiary)]">{provider.description}</div>
|
||||
</div>
|
||||
</label>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<!-- Ollama-specific settings -->
|
||||
{#if config.provider_type === "ollama"}
|
||||
<div class="mt-4 p-3 bg-[var(--bg-primary)] rounded-lg border border-[var(--border-color)]">
|
||||
<h4 class="text-sm font-medium text-[var(--text-primary)] mb-3">Ollama Settings</h4>
|
||||
|
||||
<!-- Ollama Base URL -->
|
||||
<div class="mb-3">
|
||||
<label for="ollama-url" class="block text-xs text-[var(--text-secondary)] mb-1">
|
||||
Base URL
|
||||
</label>
|
||||
<input
|
||||
id="ollama-url"
|
||||
type="text"
|
||||
bind:value={config.ollama_base_url}
|
||||
placeholder="http://localhost:11434"
|
||||
class="w-full px-3 py-2 text-sm bg-[var(--bg-secondary)] border border-[var(--border-color)] rounded-lg text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-primary)]"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Ollama Model Selection -->
|
||||
<div class="mb-3">
|
||||
<label for="ollama-model" class="block text-xs text-[var(--text-secondary)] mb-1">
|
||||
Model
|
||||
</label>
|
||||
<select
|
||||
id="ollama-model"
|
||||
bind:value={config.ollama_model}
|
||||
class="w-full px-3 py-2 text-sm bg-[var(--bg-secondary)] border border-[var(--border-color)] rounded-lg text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-primary)]"
|
||||
>
|
||||
{#each ollamaModels as model (model.value)}
|
||||
<option value={model.value}>{model.label}</option>
|
||||
{/each}
|
||||
</select>
|
||||
<p class="text-xs text-[var(--text-tertiary)] mt-1">
|
||||
Make sure the model is downloaded via <code class="text-[var(--accent-secondary)]">ollama pull</code>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="p-2 bg-yellow-500/10 border border-yellow-500/30 rounded text-xs text-yellow-400">
|
||||
<strong>Note:</strong> Ollama doesn't support tools, MCP servers, or thinking blocks.
|
||||
For full Claude Code features, use the Claude CLI provider.
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
|
||||
<!-- Agent Settings Section -->
|
||||
<section class="mb-6">
|
||||
<h3 class="text-sm font-medium text-[var(--accent-primary)] uppercase tracking-wider mb-3">
|
||||
|
||||
@@ -43,11 +43,14 @@
|
||||
let showProfile = $state(false);
|
||||
const progress = $derived($achievementProgress);
|
||||
let currentConfig: HikariConfig = $state({
|
||||
provider_type: "claude_cli",
|
||||
model: null,
|
||||
api_key: null,
|
||||
custom_instructions: null,
|
||||
mcp_servers_json: null,
|
||||
auto_granted_tools: [],
|
||||
ollama_base_url: "http://localhost:11434",
|
||||
ollama_model: null,
|
||||
theme: "dark",
|
||||
greeting_enabled: true,
|
||||
greeting_custom_prompt: null,
|
||||
@@ -145,12 +148,15 @@
|
||||
await invoke("start_claude", {
|
||||
conversationId,
|
||||
options: {
|
||||
provider_type: currentConfig.provider_type || "claude_cli",
|
||||
working_dir: targetDir,
|
||||
model: currentConfig.model || null,
|
||||
api_key: currentConfig.api_key || null,
|
||||
custom_instructions: currentConfig.custom_instructions || null,
|
||||
mcp_servers_json: currentConfig.mcp_servers_json || null,
|
||||
allowed_tools: allAllowedTools,
|
||||
ollama_base_url: currentConfig.ollama_base_url || "http://localhost:11434",
|
||||
ollama_model: currentConfig.ollama_model || null,
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
|
||||
@@ -2,6 +2,7 @@ import { writable, derived } from "svelte/store";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
|
||||
export type Theme = "dark" | "light" | "high-contrast" | "custom";
|
||||
export type ProviderType = "claude_cli" | "ollama";
|
||||
|
||||
export interface CustomThemeColors {
|
||||
bg_primary: string | null;
|
||||
@@ -15,11 +16,14 @@ export interface CustomThemeColors {
|
||||
}
|
||||
|
||||
export interface HikariConfig {
|
||||
provider_type: ProviderType;
|
||||
model: string | null;
|
||||
api_key: string | null;
|
||||
custom_instructions: string | null;
|
||||
mcp_servers_json: string | null;
|
||||
auto_granted_tools: string[];
|
||||
ollama_base_url: string;
|
||||
ollama_model: string | null;
|
||||
theme: Theme;
|
||||
greeting_enabled: boolean;
|
||||
greeting_custom_prompt: string | null;
|
||||
@@ -40,11 +44,14 @@ export interface HikariConfig {
|
||||
}
|
||||
|
||||
const defaultConfig: HikariConfig = {
|
||||
provider_type: "claude_cli",
|
||||
model: null,
|
||||
api_key: null,
|
||||
custom_instructions: null,
|
||||
mcp_servers_json: null,
|
||||
auto_granted_tools: [],
|
||||
ollama_base_url: "http://localhost:11434",
|
||||
ollama_model: null,
|
||||
theme: "dark",
|
||||
greeting_enabled: true,
|
||||
greeting_custom_prompt: null,
|
||||
|
||||
Reference in New Issue
Block a user