implement 2 strategies
This commit is contained in:
6
multi-agent-supervisor/custom_tools/__init__.py
Normal file
6
multi-agent-supervisor/custom_tools/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
||||
"""Custom tools for the multi-agent sysadmin system."""
|
||||
|
||||
from .log_tail_tool import LogTailTool
|
||||
from .shell_tool_wrapper import get_shell_tool
|
||||
|
||||
__all__ = ["LogTailTool", "get_shell_tool"]
|
24
multi-agent-supervisor/custom_tools/log_tail_tool.py
Normal file
24
multi-agent-supervisor/custom_tools/log_tail_tool.py
Normal file
@@ -0,0 +1,24 @@
|
||||
"""Log tail tool for reading log files."""
|
||||
|
||||
import subprocess
|
||||
from langchain_core.tools import BaseTool
|
||||
|
||||
|
||||
class LogTailTool(BaseTool):
|
||||
"""Tail the last N lines from a log file."""
|
||||
|
||||
name: str = "tail_log"
|
||||
description: str = "Tail the last N lines of a log file given its path and optional number of lines."
|
||||
|
||||
def _run(self, path: str, lines: int = 500): # type: ignore[override]
|
||||
"""Run the tool to tail log files."""
|
||||
try:
|
||||
return subprocess.check_output(["tail", "-n", str(lines), path], text=True)
|
||||
except subprocess.CalledProcessError as e:
|
||||
return f"Error reading log file {path}: {e}"
|
||||
except FileNotFoundError:
|
||||
return f"Log file not found: {path}"
|
||||
|
||||
async def _arun(self, *args, **kwargs): # noqa: D401
|
||||
"""Async version not implemented."""
|
||||
raise NotImplementedError("Use the synchronous version of this tool.")
|
@@ -0,0 +1,8 @@
|
||||
"""Shell tool wrapper for consistent access."""
|
||||
|
||||
from langchain_community.tools import ShellTool
|
||||
|
||||
|
||||
def get_shell_tool() -> ShellTool:
|
||||
"""Get a configured shell tool instance."""
|
||||
return ShellTool()
|
Reference in New Issue
Block a user