simplify multi-agents approach
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
"""Custom tools for the multi-agent sysadmin system."""
|
||||
|
||||
from .log_tail_tool import LogTailTool
|
||||
from .shell_tool_wrapper import get_shell_tool
|
||||
from .poem_tool import print_poem
|
||||
|
||||
__all__ = ["LogTailTool", "get_shell_tool"]
|
||||
__all__ = ["print_poem"]
|
||||
|
@@ -1,24 +0,0 @@
|
||||
"""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.")
|
46
multi-agent-supervisor/custom_tools/poem_tool.py
Normal file
46
multi-agent-supervisor/custom_tools/poem_tool.py
Normal file
@@ -0,0 +1,46 @@
|
||||
import random
|
||||
from langchain.tools import tool
|
||||
|
||||
|
||||
@tool
|
||||
def print_poem(poem_type: str = "random") -> str:
|
||||
"""
|
||||
Generate a motivational poem to boost morale during debugging sessions.
|
||||
|
||||
Args:
|
||||
poem_type: Type of poem to generate. Options: 'haiku', 'limerick', 'free_verse', or 'random'
|
||||
|
||||
Returns:
|
||||
A string containing a motivational poem about debugging or system administration
|
||||
"""
|
||||
|
||||
haikus = [
|
||||
"Logs flow like rivers,\nErrors hidden in the stream—\nDebugger finds truth.",
|
||||
"System calls at night,\nAdmin answers with coffee—\nUptime restored, peace.",
|
||||
"Kernel panics not,\nWhen sysadmin stands ready—\nBackups save the day."
|
||||
]
|
||||
|
||||
limericks = [
|
||||
"There once was a bug in the code,\nThat made the CPU explode.\nBut a sysadmin keen,\nWith skills so pristine,\nFixed it before overload!",
|
||||
"A server went down with a crash,\nThe logs were just digital trash.\nBut debugging with care,\nAnd some grep here and there,\nThe admin restored it in a flash!"
|
||||
]
|
||||
|
||||
free_verses = [
|
||||
"In the quiet hum of the server room,\nWhere LEDs blink like digital stars,\nThe sysadmin works their magic—\nTransforming chaos into order,\nOne command at a time.",
|
||||
|
||||
"Debug mode activated,\nFingers dancing across keyboards,\nEach error message a puzzle piece,\nEach solution a small victory,\nIn the endless quest for five nines."
|
||||
]
|
||||
|
||||
poems = {
|
||||
'haiku': haikus,
|
||||
'limerick': limericks,
|
||||
'free_verse': free_verses
|
||||
}
|
||||
|
||||
if poem_type == 'random' or poem_type not in poems:
|
||||
all_poems = haikus + limericks + free_verses
|
||||
selected_poem = random.choice(all_poems)
|
||||
else:
|
||||
selected_poem = random.choice(poems[poem_type])
|
||||
|
||||
return f"\n🎭 Here's a motivational poem for you:\n\n{selected_poem}\n\n💪 Keep debugging, you've got this!"
|
@@ -1,8 +0,0 @@
|
||||
"""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