forked from cleveragents/cleveragents-core
docs(examples): add tool_actor.yaml
- Demonstrates inline tool definitions - Shows read_file and search_files tools with Python code - References built-in tools via metadata - Executor context view for focused file analysis Refs: C1.5b
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
# Tool Actor Example
|
||||
#
|
||||
# Demonstrates an LLM actor with inline tool definitions.
|
||||
# Tools allow the actor to perform actions like reading files, searching
|
||||
# content, and manipulating data.
|
||||
#
|
||||
# Use case: File operations, data analysis, code inspection
|
||||
|
||||
version: "3"
|
||||
name: file-reader
|
||||
description: Actor that can read and search files using inline tools
|
||||
type: llm
|
||||
|
||||
# LLM Configuration
|
||||
provider: openai
|
||||
model: gpt-4-turbo
|
||||
temperature: 0.5
|
||||
|
||||
system_prompt: |
|
||||
You are a file analysis assistant. You can read files, search for patterns,
|
||||
and answer questions about codebases.
|
||||
|
||||
When asked about files:
|
||||
1. Use read_file to examine specific files
|
||||
2. Use search_files to find patterns across the codebase
|
||||
3. Use list_directory to explore directory structure
|
||||
|
||||
Provide clear, actionable insights based on the files you examine.
|
||||
|
||||
# Inline tool definitions - Python code that runs in sandboxed environment
|
||||
tools:
|
||||
- name: read_file
|
||||
description: Read the complete contents of a file
|
||||
parameters:
|
||||
- name: path
|
||||
type: string
|
||||
description: Path to the file to read (relative to project root)
|
||||
required: true
|
||||
code: |
|
||||
# context provides access to SkillContext with file operations
|
||||
# input_data contains the parameters passed by the LLM
|
||||
file_content = context.get_file(input_data["path"])
|
||||
result = {
|
||||
"path": input_data["path"],
|
||||
"content": file_content,
|
||||
"size_bytes": len(file_content)
|
||||
}
|
||||
timeout: 10
|
||||
|
||||
- name: search_files
|
||||
description: Search for a regex pattern across files in the project
|
||||
parameters:
|
||||
- name: pattern
|
||||
type: string
|
||||
description: Regular expression pattern to search for
|
||||
required: true
|
||||
- name: file_pattern
|
||||
type: string
|
||||
description: Glob pattern for files to search (default "**/*.py")
|
||||
required: false
|
||||
default: "**/*.py"
|
||||
code: |
|
||||
import re
|
||||
# Search files matching the glob pattern
|
||||
matches = context.search_files(
|
||||
input_data.get("file_pattern", "**/*.py"),
|
||||
input_data["pattern"]
|
||||
)
|
||||
result = {
|
||||
"pattern": input_data["pattern"],
|
||||
"matches_found": len(matches),
|
||||
"matches": matches[:50] # Limit to first 50 matches
|
||||
}
|
||||
timeout: 30
|
||||
|
||||
# Reference to built-in tools (implemented in CleverAgents core)
|
||||
# These don't need inline code - they're pre-implemented
|
||||
metadata:
|
||||
builtin_tools:
|
||||
- list_directory
|
||||
- get_file_info
|
||||
|
||||
# Memory configuration
|
||||
memory:
|
||||
enabled: true
|
||||
max_turns: 20
|
||||
|
||||
# Context configuration - executor view for focused file analysis
|
||||
context:
|
||||
view: executor
|
||||
include_files:
|
||||
- "src/**/*.py"
|
||||
- "tests/**/*.py"
|
||||
- "*.md"
|
||||
exclude_files:
|
||||
- "**/__pycache__/**"
|
||||
- "**/node_modules/**"
|
||||
- "**/.git/**"
|
||||
max_file_size_kb: 200
|
||||
|
||||
Reference in New Issue
Block a user