AlexTrinityBlock's picture
feat(tools): add ocr_reader and list_files tools to expand agent capabilities
7a0b5ad
from pathlib import Path
from colorama import Fore, Style # type: ignore[import]
from langchain_core.tools import tool
WORKSPACE_DIR = Path(__file__).resolve().parents[2] / "workspace"
@tool
def list_files() -> str:
"""List all files in the workspace directory.
Returns:
A newline-separated list of filenames in the workspace directory,
or a message indicating the directory is empty or does not exist.
"""
if not WORKSPACE_DIR.exists():
return f"Workspace directory does not exist: {WORKSPACE_DIR}"
files = [f.name for f in WORKSPACE_DIR.iterdir() if f.is_file()]
if not files:
return "Workspace directory is empty."
print(f"{Fore.BLUE}[Workspace] {len(files)} file(s) found{Style.RESET_ALL}")
return "\n".join(sorted(files))