73 lines
2.2 KiB
Python
73 lines
2.2 KiB
Python
#!/usr/bin/env python3
|
||
"""
|
||
Simple example showing the correct way to use SSH and Shell tools.
|
||
No wrappers, no complications - just import and use.
|
||
"""
|
||
|
||
# Multi-Agent Supervisor Example
|
||
def multi_agent_example():
|
||
"""How to use tools in multi-agent supervisor."""
|
||
from multi_agent_supervisor.custom_tools import ShellTool, configured_ssh_tool, print_poem
|
||
from multi_agent_supervisor.agents import create_os_detector_worker
|
||
from langchain.chat_models import init_chat_model
|
||
|
||
llm = init_chat_model("openai:gpt-4o-mini")
|
||
|
||
# Simple - just use the pre-configured tools
|
||
tools = [ShellTool(), configured_ssh_tool, print_poem]
|
||
|
||
# Add to any agent
|
||
os_detector = create_os_detector_worker(llm=llm, tools=tools)
|
||
|
||
print("✅ Multi-agent setup complete with SSH and Shell tools")
|
||
|
||
|
||
# Simple React Agent Example
|
||
def simple_agent_example():
|
||
"""How to use tools in simple react agent."""
|
||
from simple_react_agent.custom_tools import ShellTool, configured_ssh_tool, print_poem
|
||
from langgraph.prebuilt import create_react_agent
|
||
from langchain.chat_models import init_chat_model
|
||
|
||
llm = init_chat_model("openai:gpt-4o-mini")
|
||
|
||
# Simple - just use the pre-configured tools
|
||
tools = [ShellTool(), configured_ssh_tool, print_poem]
|
||
|
||
# Create agent
|
||
agent = create_react_agent(llm, tools)
|
||
|
||
print("✅ Simple react agent setup complete with SSH and Shell tools")
|
||
|
||
|
||
def main():
|
||
print("🚀 SIMPLE SSH + Shell Tools Usage")
|
||
print("="*50)
|
||
|
||
print("\n1️⃣ Configure once in custom_tools/__init__.py:")
|
||
print("""
|
||
configured_ssh_tool = SSHTool(
|
||
host="YOUR_SERVER_IP",
|
||
username="YOUR_USERNAME",
|
||
key_filename="~/.ssh/YOUR_KEY"
|
||
)
|
||
""")
|
||
|
||
print("2️⃣ Use everywhere:")
|
||
print("""
|
||
from custom_tools import ShellTool, configured_ssh_tool, print_poem
|
||
|
||
# That's it! No wrapper classes, no repeated configuration.
|
||
tools = [ShellTool(), configured_ssh_tool, print_poem]
|
||
""")
|
||
|
||
print("3️⃣ Your agents get both local and remote access automatically!")
|
||
|
||
# Show the examples (commented out to avoid import errors in this demo)
|
||
# multi_agent_example()
|
||
# simple_agent_example()
|
||
|
||
|
||
if __name__ == "__main__":
|
||
main()
|