wip
This commit is contained in:
parent
d06dabfa3c
commit
7346f0739f
@ -3,14 +3,14 @@
|
||||
from langchain_openai import ChatOpenAI
|
||||
from langgraph.prebuilt import create_react_agent
|
||||
from langchain_community.tools.shell.tool import ShellTool
|
||||
from custom_tools import print_poem, configured_ssh_tool
|
||||
from custom_tools import print_poem, configured_remote_server
|
||||
|
||||
|
||||
def create_logs_analyzer_worker():
|
||||
"""Create a logs analyzer agent that investigates system and application logs."""
|
||||
|
||||
tools = [ShellTool(), configured_ssh_tool, print_poem]
|
||||
|
||||
|
||||
tools = [configured_remote_server, print_poem]
|
||||
|
||||
return create_react_agent(
|
||||
model=ChatOpenAI(model="gpt-4o-mini", temperature=0),
|
||||
tools=tools,
|
||||
|
@ -3,13 +3,13 @@
|
||||
from langchain_openai import ChatOpenAI
|
||||
from langgraph.prebuilt import create_react_agent
|
||||
from langchain_community.tools.shell.tool import ShellTool
|
||||
from custom_tools import print_poem, configured_ssh_tool
|
||||
from custom_tools import print_poem, configured_remote_server
|
||||
|
||||
|
||||
def create_os_detector_worker():
|
||||
"""Create an OS detector agent that identifies system information and environment."""
|
||||
|
||||
tools = [ShellTool(), configured_ssh_tool, print_poem]
|
||||
tools = [configured_remote_server, print_poem]
|
||||
|
||||
return create_react_agent(
|
||||
model=ChatOpenAI(model="gpt-4o-mini", temperature=0),
|
||||
|
@ -3,13 +3,13 @@
|
||||
from langchain_openai import ChatOpenAI
|
||||
from langgraph.prebuilt import create_react_agent
|
||||
from langchain_community.tools.shell.tool import ShellTool
|
||||
from custom_tools import print_poem, configured_ssh_tool
|
||||
from custom_tools import print_poem, configured_remote_server
|
||||
|
||||
|
||||
def create_performance_analyzer_worker():
|
||||
"""Create a performance analyzer agent that monitors and diagnoses performance issues."""
|
||||
|
||||
tools = [ShellTool(), configured_ssh_tool, print_poem]
|
||||
tools = [configured_remote_server, print_poem]
|
||||
|
||||
return create_react_agent(
|
||||
model=ChatOpenAI(model="gpt-4o-mini", temperature=0),
|
||||
|
@ -6,7 +6,7 @@ from langchain_community.tools.shell.tool import ShellTool
|
||||
|
||||
# Pre-configured SSH tool for your server - only connects when actually used
|
||||
# TODO: Update these connection details for your actual server
|
||||
configured_ssh_tool = SSHTool(
|
||||
configured_remote_server = SSHTool(
|
||||
host="157.90.211.119", # Replace with your server
|
||||
port=8081,
|
||||
username="g", # Replace with your username
|
||||
@ -15,4 +15,4 @@ configured_ssh_tool = SSHTool(
|
||||
)
|
||||
|
||||
|
||||
__all__ = ["print_poem", "SSHTool", "ShellTool", "configured_ssh_tool"]
|
||||
__all__ = ["print_poem", "SSHTool", "ShellTool", "configured_remote_server"]
|
||||
|
@ -77,6 +77,8 @@ class SSHSession:
|
||||
|
||||
def execute(self, command: str) -> str:
|
||||
"""Execute a single command, handling sudo automatically."""
|
||||
print(f"🔧 Executing command: {command}")
|
||||
|
||||
if not self.client:
|
||||
self.connect()
|
||||
|
||||
|
@ -6,6 +6,7 @@ A supervisor-based system that coordinates specialized agents for system adminis
|
||||
|
||||
import sys
|
||||
import warnings
|
||||
import readline # Enable arrow key support and command history in input()
|
||||
from langchain_openai import ChatOpenAI
|
||||
from langchain_core.messages import HumanMessage
|
||||
from langgraph_supervisor import create_supervisor
|
||||
@ -14,7 +15,7 @@ from agents import (
|
||||
create_logs_analyzer_worker,
|
||||
create_performance_analyzer_worker
|
||||
)
|
||||
from custom_tools import print_poem
|
||||
from custom_tools import print_poem, configured_remote_server
|
||||
|
||||
# Suppress the shell tool warning since worker agents use it intentionally for sysadmin tasks
|
||||
warnings.filterwarnings("ignore", message="The shell tool has no safeguards by default. Use at your own risk.")
|
||||
@ -93,7 +94,7 @@ Communication style:
|
||||
|
||||
Remember: Your goal is to solve system problems efficiently by leveraging your team's specialized skills while maintaining a positive debugging experience!
|
||||
|
||||
IMPORTANT: You do NOT have direct access to shell commands or SSH. You must delegate all system tasks to your specialized agents.""",
|
||||
IMPORTANT: You do NOT have direct access to shell commands or SSH. You must delegate all system tasks to your specialized agents. If you don't know which OS is running, use the OS Detector agent first.""",
|
||||
tools=[print_poem] # Supervisor only has poem tool - no shell/SSH access
|
||||
)
|
||||
|
||||
|
@ -6,7 +6,7 @@ from langchain_community.tools.shell.tool import ShellTool
|
||||
|
||||
# Pre-configured SSH tool for your server - only connects when actually used
|
||||
# TODO: Update these connection details for your actual server
|
||||
configured_ssh_tool = SSHTool(
|
||||
configured_remote_server = SSHTool(
|
||||
host="157.90.211.119", # Replace with your server
|
||||
port=8081,
|
||||
username="g", # Replace with your username
|
||||
@ -14,4 +14,4 @@ configured_ssh_tool = SSHTool(
|
||||
ask_human_input=True # Safety confirmation
|
||||
)
|
||||
|
||||
__all__ = ["print_poem", "SSHTool", "ShellTool", "configured_ssh_tool"]
|
||||
__all__ = ["print_poem", "SSHTool", "ShellTool", "configured_remote_server"]
|
||||
|
@ -77,6 +77,8 @@ class SSHSession:
|
||||
|
||||
def execute(self, command: str) -> str:
|
||||
"""Execute a single command, handling sudo automatically."""
|
||||
print(f"🔧 Executing command: {command}")
|
||||
|
||||
if not self.client:
|
||||
self.connect()
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
import os
|
||||
import warnings
|
||||
import readline # Enable arrow key support and command history in input()
|
||||
from langchain.chat_models import init_chat_model
|
||||
from langchain_community.tools.shell.tool import ShellTool
|
||||
from langgraph.prebuilt import create_react_agent
|
||||
from langchain_core.messages import HumanMessage
|
||||
from custom_tools import print_poem, configured_ssh_tool
|
||||
from custom_tools import print_poem, configured_remote_server
|
||||
|
||||
# Suppress the shell tool warning since we're using it intentionally for sysadmin tasks
|
||||
warnings.filterwarnings("ignore", message="The shell tool has no safeguards by default. Use at your own risk.")
|
||||
@ -20,7 +21,7 @@ def create_agent():
|
||||
|
||||
# Define the tools available to the agent
|
||||
shell_tool = ShellTool()
|
||||
tools = [shell_tool, configured_ssh_tool, print_poem]
|
||||
tools = [shell_tool, configured_remote_server, print_poem]
|
||||
|
||||
|
||||
# Create a ReAct agent with system administration debugging focus
|
||||
@ -31,7 +32,7 @@ def create_agent():
|
||||
|
||||
## CORE CAPABILITIES
|
||||
1. **Local System Analysis**: Execute shell commands on the local machine (terminal tool)
|
||||
2. **Remote System Analysis**: Execute commands on remote servers via SSH (configured_ssh_tool)
|
||||
2. **Remote System Analysis**: Execute commands on remote servers via SSH (configured_remote_server)
|
||||
3. **OS Detection**: Automatically detect the operating system and adapt commands accordingly
|
||||
4. **Issue Diagnosis**: Analyze symptoms and systematically investigate root causes
|
||||
5. **Problem Resolution**: Provide solutions and execute fixes when safe to do so
|
||||
@ -39,7 +40,7 @@ def create_agent():
|
||||
|
||||
## AVAILABLE TOOLS
|
||||
- **terminal**: Execute commands on the local machine
|
||||
- **configured_ssh_tool**: Execute commands on the pre-configured remote server
|
||||
- **configured_remote_server**: Execute commands on the pre-configured remote server
|
||||
- **print_poem**: Generate motivational poems for debugging sessions
|
||||
|
||||
## OPERATING SYSTEM AWARENESS
|
||||
|
Loading…
x
Reference in New Issue
Block a user