Phase 2: Enhanced TUI/CLI with search, export/import, and custom tools for Proxmox and Ollama
This commit is contained in:
1 parent
f5026965f7
commit
9f3298fa13
7 files changed
+1353
-16
No files matched your search
@@ -2,13 +2,23 @@
|
||||
"""
|
||||
MaxClaw Agent - A configurable agent harness using DeepAgents
|
||||
Supports multiple LLM providers via LangChain's init_chat_model
|
||||
Enhanced with custom tools for Proxmox and Ollama management
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
from typing import Optional
|
||||
from typing import Optional, List
|
||||
from deepagents import create_deep_agent
|
||||
from langchain.chat_models import init_chat_model
|
||||
from langchain_core.messages import HumanMessage, SystemMessage
|
||||
from langchain.tools import Tool
|
||||
|
||||
# Import custom tools
|
||||
try:
|
||||
from tools import get_proxmox_tools, get_ollama_tools
|
||||
TOOLS_AVAILABLE = True
|
||||
except ImportError:
|
||||
TOOLS_AVAILABLE = False
|
||||
print("Warning: Custom tools not available. Install required dependencies.")
|
||||
|
||||
|
||||
def load_model_from_config():
|
||||
@@ -53,6 +63,49 @@ def load_model_from_config():
|
||||
return init_chat_model(f"openai:{model_name}")
|
||||
|
||||
|
||||
def get_custom_tools() -> List[Tool]:
|
||||
"""
|
||||
Get custom tools for the MaxClaw agent
|
||||
|
||||
Returns:
|
||||
List of custom tools
|
||||
"""
|
||||
custom_tools = []
|
||||
|
||||
if not TOOLS_AVAILABLE:
|
||||
return custom_tools
|
||||
|
||||
# Add Proxmox tools if configured
|
||||
proxmox_host = os.getenv("PROXMOX_HOST")
|
||||
if proxmox_host:
|
||||
proxmox_user = os.getenv("PROXMOX_USER", "root")
|
||||
proxmox_password = os.getenv("PROXMOX_PASSWORD")
|
||||
proxmox_token = os.getenv("PROXMOX_TOKEN")
|
||||
|
||||
try:
|
||||
proxmox_tools = get_proxmox_tools(
|
||||
host=proxmox_host,
|
||||
user=proxmox_user,
|
||||
password=proxmox_password,
|
||||
api_token=proxmox_token
|
||||
)
|
||||
custom_tools.extend(proxmox_tools)
|
||||
print(f"✅ Added {len(proxmox_tools)} Proxmox tools")
|
||||
except Exception as e:
|
||||
print(f"⚠️ Could not load Proxmox tools: {e}")
|
||||
|
||||
# Add Ollama tools if configured
|
||||
ollama_url = os.getenv("OLLAMA_BASE_URL", "http://localhost:11434")
|
||||
try:
|
||||
ollama_tools = get_ollama_tools(base_url=ollama_url)
|
||||
custom_tools.extend(ollama_tools)
|
||||
print(f"✅ Added {len(ollama_tools)} Ollama tools")
|
||||
except Exception as e:
|
||||
print(f"⚠️ Could not load Ollama tools: {e}")
|
||||
|
||||
return custom_tools
|
||||
|
||||
|
||||
def create_maxclaw_agent(system_prompt: Optional[str] = None):
|
||||
"""
|
||||
Create and return a DeepAgent instance with configurable model.
|
||||
@@ -60,13 +113,23 @@ def create_maxclaw_agent(system_prompt: Optional[str] = None):
|
||||
if system_prompt is None:
|
||||
system_prompt = """You are MaxClaw, a helpful AI agent that can plan, use tools,
|
||||
manage context, and delegate to subagents. You are designed to be configurable
|
||||
to work with various LLM providers."""
|
||||
to work with various LLM providers.
|
||||
|
||||
You have access to custom tools for managing Proxmox virtual machines and Ollama models.
|
||||
Use these tools when asked about system administration, virtualization, or AI model management."""
|
||||
|
||||
model = load_model_from_config()
|
||||
|
||||
# Get custom tools
|
||||
custom_tools = get_custom_tools()
|
||||
|
||||
# Create the agent with custom tools
|
||||
agent = create_deep_agent(
|
||||
model=model,
|
||||
tools=custom_tools, # Add custom tools to the agent
|
||||
system_prompt=system_prompt
|
||||
)
|
||||
|
||||
return agent
|
||||
|
||||
|
||||
@@ -82,6 +145,8 @@ def main():
|
||||
|
||||
# Simple test interaction
|
||||
print("\n💬 You can now interact with the agent. Type 'exit' to quit.")
|
||||
print("💡 Try asking about Proxmox VMs or Ollama models!")
|
||||
|
||||
while True:
|
||||
user_input = input("\n👤 You: ").strip()
|
||||
if user_input.lower() in ['exit', 'quit']:
|
||||
|
||||
Reference in new issue
Block a user