Major enhancements to Clover CLI: ✨ New Features: - AI agent with multi-turn conversation capabilities - Tool calling system with 11+ tools for file operations, Git, linting, etc. - Step-by-step AI assistance with play-by-play commentary - Enhanced interactive mode with better UX 🔧 Core Components Added: - ai_agent.py: Main AI agent with conversation management - models/: API client and model management system - Comprehensive tool system for development tasks 🛠️ Tools Available: - File operations (create, read, update, delete) - Command execution with safety checks - Git operations (status, diff, commit, push) - Code linting and formatting - Project structure analysis - Security scanning and dependency management 💡 User Experience: - Real-time tool execution summaries - File creation with full path visibility - Error handling and retry mechanisms - Clean conversation flow until task completion 🧹 Repository Cleanup: - Added comprehensive .gitignore - Removed __pycache__ directories and build artifacts - Organized project structure The AI can now actually create files, run commands, and work through complex development tasks step-by-step with full transparency.
107 lines
3.0 KiB
Python
107 lines
3.0 KiB
Python
"""
|
|
Model manager for Clover - A terminal assistant for AI-powered project management
|
|
Handles switching between different language models and manages API connections
|
|
"""
|
|
|
|
import json
|
|
import os
|
|
from typing import Any, Dict, Optional
|
|
|
|
from config.settings import load_config
|
|
from models.api_client import APIClient
|
|
|
|
|
|
class ModelManager:
|
|
"""
|
|
Manages different language models for Clover CLI tool
|
|
"""
|
|
|
|
def __init__(self):
|
|
"""Initialize the model manager with configuration"""
|
|
self.config = load_config()
|
|
self.api_client = APIClient()
|
|
|
|
def list_models(self) -> Dict[str, Any]:
|
|
"""
|
|
List available models on the server
|
|
|
|
Returns:
|
|
dict: Available models information
|
|
"""
|
|
try:
|
|
result = self.api_client.list_models()
|
|
if "error" in result:
|
|
return {
|
|
"error": result.get("error", "Failed to list models"),
|
|
"models": [],
|
|
}
|
|
|
|
models_list = result.get("models", [])
|
|
|
|
return {
|
|
"models": models_list,
|
|
"active_model": self.config.get("model", "qwen2.5-coder:7b"),
|
|
"base_url": self.config.get("base_url", "http://192.168.8.223:11434"),
|
|
}
|
|
except Exception as e:
|
|
return {"error": f"Failed to list models: {str(e)}", "models": []}
|
|
|
|
def get_model(self, model_name: str = None) -> str:
|
|
"""
|
|
Get the active model name
|
|
|
|
Args:
|
|
model_name (str): Specific model name to use
|
|
|
|
Returns:
|
|
str: Model name to use
|
|
"""
|
|
if model_name:
|
|
return model_name
|
|
return self.config.get("model", "gpt-oss:20b")
|
|
|
|
def set_model(self, model_name: str) -> bool:
|
|
"""
|
|
Set the active model for future operations
|
|
|
|
Args:
|
|
model_name (str): Name of the model to use
|
|
|
|
Returns:
|
|
bool: True if successful
|
|
"""
|
|
try:
|
|
self.config["model"] = model_name
|
|
# In a full implementation, we would save this to config file
|
|
return True
|
|
except Exception as e:
|
|
print(f"Error setting model: {e}")
|
|
return False
|
|
|
|
def get_active_model_info(self) -> Dict[str, Any]:
|
|
"""
|
|
Get information about the currently active model
|
|
|
|
Returns:
|
|
dict: Information about active model
|
|
"""
|
|
return {
|
|
"model": self.config.get("model", "gpt-oss:20b"),
|
|
"base_url": self.config.get("base_url", "http://192.168.8.223:11434"),
|
|
"timeout": self.config.get("timeout", 300),
|
|
}
|
|
|
|
def get_available_models(self) -> list:
|
|
"""
|
|
Get list of available models from the LLM server
|
|
|
|
Returns:
|
|
list: List of model names
|
|
"""
|
|
result = self.list_models()
|
|
if "error" in result:
|
|
return []
|
|
|
|
models = result.get("models", [])
|
|
return [model.get("name", "") for model in models]
|