From 57c43d4738fec0116b63b1a8c477473172f3e655 Mon Sep 17 00:00:00 2001 From: opencode Date: Mon, 23 Mar 2026 19:09:28 +0100 Subject: [PATCH] =?UTF-8?q?Correzione=20pattern=20write=5Ffile:=20usa=20fi?= =?UTF-8?q?le=5Fpath=20gi=C3=A0=20estratto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ollama_agent.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/ollama_agent.py b/ollama_agent.py index 251c554..160c499 100644 --- a/ollama_agent.py +++ b/ollama_agent.py @@ -391,21 +391,20 @@ For other questions, just answer normally without tools.""" 'write', 'create', 'save', 'make file'] has_write_keyword = any(k in text_lower for k in write_keywords) - if has_write_keyword: - # Try to extract path and content - path_match = re.search(r'(?:file|file\s+)(\S+\.\w+)', text_lower) + if has_write_keyword and file_path: + # Extract content from quoted text content_match = re.search(r'["\']([^"\']+)["\']', text) - - if path_match: - file_path = path_match.group(1) - # Try to get content from quoted text or description + if content_match: + content = content_match.group(1) + else: + # Try to extract content between "con dentro" and quotes + content_match = re.search(r'con dentro ["\']([^"\']+)["\']', text) if content_match: content = content_match.group(1) else: - # Try to extract content from the text - content = text.replace('"', "'").split("'")[1] if "'" in text else "Content not specified" - - return ToolCall(id='intent', name='write_file', arguments={'path': file_path, 'content': content}) + content = "Content not specified" + + return ToolCall(id='intent', name='write_file', arguments={'path': file_path, 'content': content}) # Execute command patterns exec_patterns = [