From 7e340a66494d95e4d43427c29f56f602786c58b4 Mon Sep 17 00:00:00 2001 From: Gaetan Hurel Date: Mon, 30 Jun 2025 16:55:41 +0200 Subject: [PATCH] use 4.1 --- simple-react-agent/main.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/simple-react-agent/main.py b/simple-react-agent/main.py index 17c317a..11b8069 100644 --- a/simple-react-agent/main.py +++ b/simple-react-agent/main.py @@ -5,7 +5,7 @@ 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_remote_server +from custom_tools import 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.") @@ -17,11 +17,11 @@ def create_agent(): # Initialize the chat model (using OpenAI GPT-4) # Make sure you have set your OPENAI_API_KEY environment variable - llm = init_chat_model("openai:gpt-4o-mini") + llm = init_chat_model("openai:gpt-4.1") # Define the tools available to the agent shell_tool = ShellTool() - tools = [shell_tool, configured_remote_server, print_poem] + tools = [shell_tool, configured_remote_server] # Create a ReAct agent with system administration debugging focus @@ -36,12 +36,10 @@ def create_agent(): 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 - 6. **Easter Egg**: Generate poems when users need a morale boost (use print_poem tool) ## AVAILABLE TOOLS - **terminal**: Execute commands on the local machine - **configured_remote_server**: Execute commands on the pre-configured remote server - - **print_poem**: Generate motivational poems for debugging sessions ## OPERATING SYSTEM AWARENESS - **First interaction**: Always detect the OS using appropriate commands (uname, systeminfo, etc.) @@ -103,9 +101,7 @@ def create_agent(): - Pipe long outputs through 'head' or 'tail' when appropriate - Use 'timeout' command for potentially long-running diagnostics - Always explain the output interpretation - - Suggest next steps based on findings - - Remember: Your primary goal is to help solve system problems efficiently and safely. The poem tool is just a nice bonus for when users need encouragement during stressful debugging sessions!""" + - Suggest next steps based on findings""" # Create the ReAct agent @@ -156,7 +152,6 @@ def main(): print(" - Analyze system logs and error messages") print(" - Network connectivity diagnostics") print(" - Cross-platform support (Linux, macOS, BSD, Windows)") - print(" - 🎭 Easter egg: Generate motivational poems when you need a break!") print("-" * 70) # Create the agent @@ -167,7 +162,6 @@ def main(): print("💡 Or: 'Check if my web server is running properly'") print("💡 Or: 'Connect to my remote server and check disk space'") print("💡 Or: 'Analyze recent system errors'") - print("💡 Need a break? Ask: 'Write me a motivational poem'") except Exception as e: print(f"❌ Error initializing agent: {e}") @@ -197,8 +191,6 @@ def main(): print(" - 'Troubleshoot network connectivity problems'") print(" - 'Check disk space and filesystem health'") print(" - 'Review recent system errors in logs'") - print("\nEaster Egg:") - print(" - 'Write me a motivational poem' (for when debugging gets tough!)") print("\nSafety Notes:") print(" - Agent will ask permission before running potentially harmful commands") print(" - All commands are explained before execution")