feat: Implement Trillium notes executor for searching and creating notes via ETAPI

- Added `trillium.py` for searching and creating notes with Trillium's ETAPI.
- Implemented `search_notes` and `create_note` functions with appropriate error handling and validation.

feat: Add web search functionality using DuckDuckGo

- Introduced `web_search.py` for performing web searches without API keys.
- Implemented `search_web` function with result handling and validation.

feat: Create provider-agnostic function caller for iterative tool calling

- Developed `function_caller.py` to manage LLM interactions with tools.
- Implemented iterative calling logic with error handling and tool execution.

feat: Establish a tool registry for managing available tools

- Created `registry.py` to define and manage tool availability and execution.
- Integrated feature flags for enabling/disabling tools based on environment variables.

feat: Implement event streaming for tool calling processes

- Added `stream_events.py` to manage Server-Sent Events (SSE) for tool calling.
- Enabled real-time updates during tool execution for enhanced user experience.

test: Add tests for tool calling system components

- Created `test_tools.py` to validate functionality of code execution, web search, and tool registry.
- Implemented asynchronous tests to ensure proper execution and result handling.

chore: Add Dockerfile for sandbox environment setup

- Created `Dockerfile` to set up a Python environment with necessary dependencies for code execution.

chore: Add debug regex script for testing XML parsing

- Introduced `debug_regex.py` to validate regex patterns against XML tool calls.

chore: Add HTML template for displaying thinking stream events

- Created `test_thinking_stream.html` for visualizing tool calling events in a user-friendly format.

test: Add tests for OllamaAdapter XML parsing

- Developed `test_ollama_parser.py` to validate XML parsing with various test cases, including malformed XML.
This commit is contained in:
serversdwn
2025-12-26 03:49:20 -05:00
parent f1471cde84
commit 64429b19e6
37 changed files with 3238 additions and 23 deletions

26
debug_regex.py Normal file
View File

@@ -0,0 +1,26 @@
#!/usr/bin/env python3
import re
xml = """<tool_call>
<name>execute_code</name>
<arguments>
<language>python</language>
<code>print(50 / 2)</code>
<reason>To calculate the result of dividing 50 by 2.</reason>
</arguments>
</olith>"""
pattern = r'<tool_call>(.*?)</(?:tool_call|[a-zA-Z]+)>'
matches = re.findall(pattern, xml, re.DOTALL)
print(f"Pattern: {pattern}")
print(f"Number of matches: {len(matches)}")
print("\nMatches:")
for idx, match in enumerate(matches):
print(f"\nMatch {idx + 1}:")
print(f"Length: {len(match)} chars")
print(f"Content:\n{match[:200]}")
# Now test what gets removed
clean_content = re.sub(pattern, '', xml, flags=re.DOTALL).strip()
print(f"\n\nCleaned content:\n{clean_content}")