49 lines
2.9 KiB
Python
49 lines
2.9 KiB
Python
from core.config import AGENT_NAME
|
|
from core.tools.file_operations import (
|
|
read_file, write_file, replace_in_file, delete_in_file,
|
|
delete_file, copy_file, move_file, create_directory,
|
|
delete_directory, list_directory, get_file_info,
|
|
)
|
|
|
|
# Categorize tools here so you can easily plug in new domains like web_tools
|
|
TOOL_CATEGORIES = {
|
|
"File Operations": [
|
|
read_file, write_file, replace_in_file, delete_in_file,
|
|
delete_file, copy_file, move_file, create_directory,
|
|
delete_directory, list_directory, get_file_info,
|
|
],
|
|
# "Web Tools": [], # e.g., [web_search, fetch_url]
|
|
# "Knowledge Tools": [], # e.g., [query_vector_db]
|
|
}
|
|
|
|
# Dynamically generate the string of tool names grouped by category
|
|
tools_list_parts = []
|
|
for category, cat_tools in TOOL_CATEGORIES.items():
|
|
if cat_tools:
|
|
tools_list_parts.append(f"[{category}]")
|
|
for tool in cat_tools:
|
|
first_line_desc = tool.description.strip().splitlines()[0]
|
|
tools_list_parts.append(f"- {tool.name}: {first_line_desc}")
|
|
tools_list_parts.append("") # Empty line for spacing
|
|
|
|
tools_list_str = "\n".join(tools_list_parts).strip()
|
|
|
|
todo_prompt_template = f"""You are {AGENT_NAME}, a helpful assistant. Based on the user's task, generate a to-do list with actionable steps. Make sure you are detailed about your plan, honest, and helpful.
|
|
Be proactive and make educated guesses if the user's request has minor ambiguities, leaving room for adjustments. Only ask for clarification if the request is entirely unclear or lacks crucial context.
|
|
|
|
IMPORTANT: Once you create this to-do list, you will execute it step-by-step using a set of available tools. You MUST tailor your plan knowing that the following tools will be accessible to you during the execution phase:
|
|
|
|
Available Tools:
|
|
{tools_list_str}
|
|
|
|
Here are a few things to keep in mind: your plan must be actionable and detailed. You should break down the task into smaller steps and provide a clear plan for how to accomplish the task utilizing the tools above.
|
|
If you are reading files, make sure to plan to read them carefully and extract the relevant information. If you are writing code, make sure to plan to write clean,
|
|
well-documented code that is secure, following the principle of least privilege and secure coding practices.
|
|
If you are doing research, make sure to provide a clear summary of your findings.
|
|
"""
|
|
|
|
review_todo_prompt_template = f"""You are {AGENT_NAME}, a helpful assistant. You have created the following to-do list based on the user's task.
|
|
Please review the to-do list and make sure it is actionable, detailed, clear, and effectively utilizes your available tools (such as file reading, writing, directory listing, etc.).
|
|
If there are any issues with the to-do list, please provide feedback and suggestions for improvement and return the updated to-do list.
|
|
If the to-do list looks good, please return the same to-do list."""
|