From b241c47fd9beb9d8010ba3e065db864911719a93 Mon Sep 17 00:00:00 2001 From: Dave Date: Wed, 24 Dec 2025 17:32:46 +0000 Subject: [PATCH] fix: make llm provider async and add tool toggle --- .../stories/04_ollama_model_detection.md | 17 +++ src-tauri/Cargo.lock | 1 + src-tauri/Cargo.toml | 1 + src-tauri/src/commands/chat.rs | 13 +- src-tauri/src/llm/ollama.rs | 10 +- src-tauri/src/llm/types.rs | 4 +- src/components/Chat.tsx | 130 +++++++++++++++--- src/types.ts | 1 + 8 files changed, 149 insertions(+), 28 deletions(-) create mode 100644 .living_spec/stories/04_ollama_model_detection.md diff --git a/.living_spec/stories/04_ollama_model_detection.md b/.living_spec/stories/04_ollama_model_detection.md new file mode 100644 index 0000000..6d27c81 --- /dev/null +++ b/.living_spec/stories/04_ollama_model_detection.md @@ -0,0 +1,17 @@ +# Story: Ollama Model Detection + +## User Story +**As a** User +**I want to** select my Ollama model from a dropdown list of installed models +**So that** I don't have to manually type (and potentially mistype) the model names. + +## Acceptance Criteria +* [ ] Backend: Implement `get_ollama_models()` command. + * [ ] Call `GET /api/tags` on the Ollama instance. + * [ ] Parse the JSON response to extracting model names. +* [ ] Frontend: Replace the "Ollama Model" text input with a ` setModel(e.target.value)} + setModel(e.target.value)} placeholder="e.g. llama3, mistral" style={{ padding: "5px" }} /> + {/* Messages Area */} -
+
{messages.map((msg, idx) => ( -
- {msg.role === "user" ? "You" : msg.role === "tool" ? "Tool Output" : "Agent"} + + {msg.role === "user" + ? "You" + : msg.role === "tool" + ? "Tool Output" + : "Agent"} + {msg.role === "tool" ? ( -
{msg.content}
+
+ {msg.content} +
) : ( {msg.content} )} - + {/* Show Tool Calls if present */} {msg.tool_calls && ( -
+
{msg.tool_calls.map((tc, i) => ( -
- 🛠 {tc.function.name}({tc.function.arguments}) +
+ 🛠{" "} + + {tc.function.name}({tc.function.arguments}) +
))}
)}
))} - {loading &&
Thinking...
} + {loading && ( +
+ Thinking... +
+ )}
{/* Input Area */} -
+
setInput(e.target.value)} onKeyDown={(e) => e.key === "Enter" && sendMessage()} placeholder="Ask the agent to do something..." - style={{ flex: 1, padding: "10px", borderRadius: "4px", border: "1px solid #ccc" }} + style={{ + flex: 1, + padding: "10px", + borderRadius: "4px", + border: "1px solid #ccc", + }} disabled={loading} /> -
diff --git a/src/types.ts b/src/types.ts index f9d3ede..7619066 100644 --- a/src/types.ts +++ b/src/types.ts @@ -36,4 +36,5 @@ export interface ProviderConfig { provider: string; model: string; base_url?: string; + enable_tools?: boolean; }