diff options
Diffstat (limited to 'makima/src/llm/contract_tools.rs')
| -rw-r--r-- | makima/src/llm/contract_tools.rs | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/makima/src/llm/contract_tools.rs b/makima/src/llm/contract_tools.rs index 0d6f9be..7a3d09a 100644 --- a/makima/src/llm/contract_tools.rs +++ b/makima/src/llm/contract_tools.rs @@ -407,6 +407,57 @@ pub static CONTRACT_TOOLS: once_cell::sync::Lazy<Vec<Tool>> = once_cell::sync::L "required": ["questions"] }), }, + // ============================================================================= + // Transcript Analysis Tools + // ============================================================================= + Tool { + name: "analyze_transcript".to_string(), + description: "Analyze a file's transcript to extract requirements, decisions, and action items. Returns structured analysis including speaker statistics.".to_string(), + parameters: json!({ + "type": "object", + "properties": { + "file_id": { + "type": "string", + "description": "ID of the file containing the transcript to analyze" + } + }, + "required": ["file_id"] + }), + }, + Tool { + name: "create_contract_from_transcript".to_string(), + description: "Create a new contract from an analyzed transcript. Will extract requirements, decisions, and action items and create appropriate files and tasks in the new contract.".to_string(), + parameters: json!({ + "type": "object", + "properties": { + "file_id": { + "type": "string", + "description": "ID of the file containing the transcript" + }, + "name": { + "type": "string", + "description": "Optional name for the contract (otherwise auto-generated from analysis)" + }, + "description": { + "type": "string", + "description": "Optional description for the contract (otherwise auto-generated)" + }, + "include_requirements": { + "type": "boolean", + "description": "Whether to create a requirements file (default: true)" + }, + "include_decisions": { + "type": "boolean", + "description": "Whether to create a decisions file (default: true)" + }, + "include_action_items": { + "type": "boolean", + "description": "Whether to create tasks from action items (default: true)" + } + }, + "required": ["file_id"] + }), + }, ] }); @@ -475,6 +526,17 @@ pub enum ContractToolRequest { task_id: Uuid, section_title: Option<String>, }, + + // Transcript analysis + AnalyzeTranscript { file_id: Uuid }, + CreateContractFromTranscript { + file_id: Uuid, + name: Option<String>, + description: Option<String>, + include_requirements: bool, + include_decisions: bool, + include_action_items: bool, + }, } /// Task definition for chained task creation @@ -540,6 +602,10 @@ pub fn parse_contract_tool_call(call: &super::tools::ToolCall) -> ContractToolEx // Interactive tools "ask_user" => parse_ask_user(call), + // Transcript analysis tools + "analyze_transcript" => parse_analyze_transcript(call), + "create_contract_from_transcript" => parse_create_contract_from_transcript(call), + _ => ContractToolExecutionResult { success: false, message: format!("Unknown contract tool: {}", call.name), @@ -1070,6 +1136,53 @@ fn parse_update_file_from_task(call: &super::tools::ToolCall) -> ContractToolExe } // ============================================================================= +// Transcript Analysis Tool Parsing +// ============================================================================= + +fn parse_analyze_transcript(call: &super::tools::ToolCall) -> ContractToolExecutionResult { + let file_id = parse_uuid_arg(call, "file_id"); + let Some(file_id) = file_id else { + return error_result("Missing or invalid required parameter: file_id"); + }; + + ContractToolExecutionResult { + success: true, + message: "Analyzing transcript...".to_string(), + data: None, + request: Some(ContractToolRequest::AnalyzeTranscript { file_id }), + pending_questions: None, + } +} + +fn parse_create_contract_from_transcript(call: &super::tools::ToolCall) -> ContractToolExecutionResult { + let file_id = parse_uuid_arg(call, "file_id"); + let Some(file_id) = file_id else { + return error_result("Missing or invalid required parameter: file_id"); + }; + + let name = call.arguments.get("name").and_then(|v| v.as_str()).map(|s| s.to_string()); + let description = call.arguments.get("description").and_then(|v| v.as_str()).map(|s| s.to_string()); + let include_requirements = call.arguments.get("include_requirements").and_then(|v| v.as_bool()).unwrap_or(true); + let include_decisions = call.arguments.get("include_decisions").and_then(|v| v.as_bool()).unwrap_or(true); + let include_action_items = call.arguments.get("include_action_items").and_then(|v| v.as_bool()).unwrap_or(true); + + ContractToolExecutionResult { + success: true, + message: "Creating contract from transcript...".to_string(), + data: None, + request: Some(ContractToolRequest::CreateContractFromTranscript { + file_id, + name, + description, + include_requirements, + include_decisions, + include_action_items, + }), + pending_questions: None, + } +} + +// ============================================================================= // Helper Functions // ============================================================================= |
