From 857e717e6343fa5c2ae96664bdc64741d5ba6830 Mon Sep 17 00:00:00 2001 From: soryu Date: Sun, 17 May 2026 21:22:34 +0100 Subject: chore: remove LLM module + all dependent surfaces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wholesale removal of the LLM integration layer. ~14,200 LOC deleted across backend and frontend. All chat-driven UIs go with it. ## Backend - Delete `src/llm/` (7,400 LOC): claude/groq clients, contract_tools, contract_evaluator, discuss_tools, mesh_tools, phase_guidance, task_output, templates, markdown round-trip, tools, transcript_analyzer. - Delete handlers wholly dependent on LLM: - `chat.rs` (file-level LLM chat at /files/{id}/chat) - `mesh_chat.rs` (mesh & task LLM chat + history) - `templates.rs` (/contract-types listing) - Strip LLM uses from `mesh_daemon.rs`: - `compute_action_directive` (used phase_guidance::check_deliverables_met to nudge supervisors with "all tasks done" messages). The auto-PR path below still fires when all tasks finish, so no behaviour lost. - `crate::llm::markdown_to_body` → inline 1-line replacement that wraps markdown content in a single BodyElement::Markdown. The editor re-parses on display, so round-trip is preserved. - Drop routes: /files/{id}/chat, /mesh/chat, /mesh/chat/history, /mesh/tasks/{id}/chat, /contract-types. - Drop the matching openapi registrations. ## Frontend - Delete components that were LLM-only: - `mesh/UnifiedMeshChatInput.tsx` - `listen/DiscussContractModal.tsx` - `listen/TranscriptAnalysisPanel.tsx` - `listen/ContractPickerModal.tsx` - `files/CliInput.tsx` - Delete the entire /listen page (its primary value-add was voice → LLM analysis → contract creation; without LLM the page is just a transcript display with no obvious user purpose). - Delete `hooks/useMeshChatHistory.ts` and `lib/listenApi.ts` (transcript-analysis API client to the already-Phase-5-removed listen handlers). - Strip api.ts of LLM exports: LlmModel, ChatMessage/Request/Response, UserQuestion/Answer, chatWithFile, MeshChat* types & functions, getMeshChatHistory, clearMeshChatHistory, chatWithMeshContext, ContractTypeTemplate, listContractTypes, chatWithContract, getContractChatHistory, clearContractChatHistory, discussContract, PhaseDefinition, DeliverableDefinition. - mesh.tsx: drop UnifiedMeshChatInput render + the chatContext memo + handleTaskUpdatedFromCli (only consumer was the input). - files.tsx: drop CliInput render + handleGenerateFromElement + handleBodyUpdate + handleClearFocus + suggestedPrompt state (all CliInput-only). - NavStrip: drop the /listen link. - main.tsx: drop the /listen route. ## Net diff: 37 files changed, 58 insertions, 14,281 deletions. Co-Authored-By: Claude Opus 4.7 (1M context) --- makima/src/llm/groq.rs | 177 ------------------------------------------------- 1 file changed, 177 deletions(-) delete mode 100644 makima/src/llm/groq.rs (limited to 'makima/src/llm/groq.rs') diff --git a/makima/src/llm/groq.rs b/makima/src/llm/groq.rs deleted file mode 100644 index ee01fcf..0000000 --- a/makima/src/llm/groq.rs +++ /dev/null @@ -1,177 +0,0 @@ -//! Groq API client for LLM tool calling. - -use serde::{Deserialize, Serialize}; -use thiserror::Error; - -use super::tools::{Tool, ToolCall}; - -const GROQ_API_URL: &str = "https://api.groq.com/openai/v1/chat/completions"; -const MODEL: &str = "moonshotai/kimi-k2-instruct-0905"; - -#[derive(Debug, Error)] -pub enum GroqError { - #[error("HTTP request failed: {0}")] - Request(#[from] reqwest::Error), - #[error("API error: {0}")] - Api(String), - #[error("Missing API key")] - MissingApiKey, -} - -#[derive(Debug, Clone)] -pub struct GroqClient { - api_key: String, - client: reqwest::Client, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct Message { - pub role: String, - pub content: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub tool_calls: Option>, - #[serde(skip_serializing_if = "Option::is_none")] - pub tool_call_id: Option, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct ToolCallResponse { - pub id: String, - #[serde(rename = "type")] - pub call_type: String, - pub function: FunctionCall, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct FunctionCall { - pub name: String, - pub arguments: String, -} - -#[derive(Debug, Serialize)] -struct ChatRequest { - model: String, - messages: Vec, - tools: Vec, - tool_choice: String, -} - -#[derive(Debug, Serialize)] -struct ToolDefinition { - #[serde(rename = "type")] - tool_type: String, - function: FunctionDefinition, -} - -#[derive(Debug, Serialize)] -struct FunctionDefinition { - name: String, - description: String, - parameters: serde_json::Value, -} - -#[derive(Debug, Deserialize)] -struct ChatResponse { - choices: Vec, -} - -#[derive(Debug, Deserialize)] -struct Choice { - message: MessageResponse, - finish_reason: String, -} - -#[derive(Debug, Deserialize)] -struct MessageResponse { - role: String, - content: Option, - tool_calls: Option>, -} - -#[derive(Debug)] -pub struct ChatResult { - pub content: Option, - pub tool_calls: Vec, - /// Raw tool call responses for including in subsequent messages - pub raw_tool_calls: Vec, - pub finish_reason: String, -} - -impl GroqClient { - pub fn new(api_key: String) -> Self { - Self { - api_key, - client: reqwest::Client::new(), - } - } - - pub fn from_env() -> Result { - let api_key = std::env::var("GROQ_API_KEY").map_err(|_| GroqError::MissingApiKey)?; - Ok(Self::new(api_key)) - } - - pub async fn chat_with_tools( - &self, - messages: Vec, - tools: &[Tool], - ) -> Result { - let tool_definitions: Vec = tools - .iter() - .map(|t| ToolDefinition { - tool_type: "function".to_string(), - function: FunctionDefinition { - name: t.name.clone(), - description: t.description.clone(), - parameters: t.parameters.clone(), - }, - }) - .collect(); - - let request = ChatRequest { - model: MODEL.to_string(), - messages, - tools: tool_definitions, - tool_choice: "auto".to_string(), - }; - - let response = self - .client - .post(GROQ_API_URL) - .header("Authorization", format!("Bearer {}", self.api_key)) - .header("Content-Type", "application/json") - .json(&request) - .send() - .await?; - - if !response.status().is_success() { - let error_text = response.text().await.unwrap_or_default(); - return Err(GroqError::Api(error_text)); - } - - let chat_response: ChatResponse = response.json().await?; - - let choice = chat_response - .choices - .into_iter() - .next() - .ok_or_else(|| GroqError::Api("No choices in response".to_string()))?; - - let raw_tool_calls = choice.message.tool_calls.unwrap_or_default(); - - let tool_calls = raw_tool_calls - .iter() - .map(|tc| ToolCall { - id: tc.id.clone(), - name: tc.function.name.clone(), - arguments: serde_json::from_str(&tc.function.arguments).unwrap_or_default(), - }) - .collect(); - - Ok(ChatResult { - content: choice.message.content, - tool_calls, - raw_tool_calls, - finish_reason: choice.finish_reason, - }) - } -} -- cgit v1.2.3