feat(python): add zeroclaw-tools companion package for LangGraph tool calling
- Add Python package with LangGraph-based agent for consistent tool calling - Provides reliable tool execution for providers with inconsistent native support - Includes tools: shell, file_read, file_write, web_search, http_request, memory - Discord bot integration included - CLI tool for quick interactions - Works with any OpenAI-compatible provider (Z.AI, OpenRouter, Groq, etc.) Why: Some LLM providers (e.g., GLM-5/Zhipu) have inconsistent tool calling behavior. LangGraph's structured approach guarantees reliable tool execution across all providers.
This commit is contained in:
parent
bc38994867
commit
e5ef8a3b62
17 changed files with 1371 additions and 0 deletions
46
python/zeroclaw_tools/tools/base.py
Normal file
46
python/zeroclaw_tools/tools/base.py
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
"""
|
||||
Base utilities for creating tools.
|
||||
"""
|
||||
|
||||
from typing import Any, Callable, Optional
|
||||
|
||||
from langchain_core.tools import tool as langchain_tool
|
||||
|
||||
|
||||
def tool(
|
||||
func: Optional[Callable] = None,
|
||||
*,
|
||||
name: Optional[str] = None,
|
||||
description: Optional[str] = None,
|
||||
) -> Any:
|
||||
"""
|
||||
Decorator to create a LangChain tool from a function.
|
||||
|
||||
This is a convenience wrapper around langchain_core.tools.tool that
|
||||
provides a simpler interface for ZeroClaw users.
|
||||
|
||||
Args:
|
||||
func: The function to wrap (when used without parentheses)
|
||||
name: Optional custom name for the tool
|
||||
description: Optional custom description
|
||||
|
||||
Returns:
|
||||
A BaseTool instance
|
||||
|
||||
Example:
|
||||
```python
|
||||
from zeroclaw_tools import tool
|
||||
|
||||
@tool
|
||||
def my_tool(query: str) -> str:
|
||||
\"\"\"Description of what this tool does.\"\"\"
|
||||
return f"Result: {query}"
|
||||
```
|
||||
"""
|
||||
if func is not None:
|
||||
return langchain_tool(func)
|
||||
|
||||
def decorator(f: Callable) -> Any:
|
||||
return langchain_tool(f, name=name)
|
||||
|
||||
return decorator
|
||||
Loading…
Add table
Add a link
Reference in a new issue