Skip to main content

CLI agent for for running CodeAct agents, built with Huggingface Smolagents

Project description

Xerus

PyPI version Python License: MIT Downloads

A powerful command-line interface for running CodeAct AI agents powered by Huggingface's Smolagents. Xerus is an open-source alternative to OpenAI Codex and Claude Code that leverages cheaper open-source models like Deepseek-R1 to generate and execute Python code for your data science, machine learning, and analytics workflows.

๐ŸŽฏ Designed for Remote Servers: Xerus is primarily intended for use on your remote development servers, providing a seamless way to perform complex Python tasks, data analysis, and ML operations through natural language commands.

๐Ÿ”ฌ CodeAct Methodology: Built on the CodeAct research (first implemented by Manus AI), Xerus agents generate executable Python code as their primary action space, enabling more flexible and powerful automation compared to traditional tool-based approaches.

๐Ÿš€ Quick Start

Installation

pip install xerus-ai

Initialize with AI Provider

xerus init

Try It Out!

# Data analysis and visualization
xerus run --prompt "Load my CSV dataset and create correlation heatmaps"

# Machine learning workflows  
xerus run --prompt "Train a random forest classifier on my dataset and evaluate performance"

# Start interactive coding session
xerus chat

# Python development and debugging
xerus run --prompt "Optimize this pandas dataframe operation for better performance"

# Search for latest ML techniques
xerus run --prompt "Find the latest research on transformer architectures and summarize"

๐Ÿ“‹ Table of Contents

๐Ÿค” Why Xerus?

๐Ÿ’ฐ Cost-Effective Alternative

  • Use cheaper open-source models instead of expensive proprietary APIs
  • Mix and match different models for different tools based on your needs
  • Support for providers like Nebius, Novita, GMI Cloud with competitive pricing

๐Ÿ—๏ธ CodeAct Architecture

  • Agents generate executable Python code rather than just text responses
  • More flexible than pre-defined tool schemas used by other frameworks
  • Can compose complex workflows by chaining multiple code executions
  • Self-debugging capabilities through iterative code refinement

๐ŸŽ›๏ธ Multi-Model Flexibility

  • Use different models for different tasks (e.g., powerful model for complex reasoning, lightweight model for simple operations)
  • Connect MCP (Model Context Protocol) servers for extended functionality
  • Leverage Huggingface Smolagents for robust agent orchestration

๐Ÿ–ฅ๏ธ Remote Server Optimized

  • Designed specifically for headless server environments
  • Perfect for data science workstations, ML training servers, and cloud instances
  • Terminal-based interface that works seamlessly over SSH

๐Ÿ“ฆ Requirements

  • Python 3.10+
  • An API key from a supported AI provider

โœจ Features

  • ๐Ÿค– CodeAct Agents: Advanced agents that generate and execute Python code
  • ๐Ÿ’ฌ Interactive Chat: Persistent coding sessions with conversation history
  • ๐Ÿ” Web Search: Built-in research capabilities for latest techniques and documentation
  • ๐Ÿ Python Execution: Direct code generation and execution in your environment
  • ๐Ÿ”ง Multi-Model Support: Use different models for different tools and tasks
  • ๐ŸŒ Multiple Providers: Support for Nebius, Novita, GMI Cloud, and more open-source model providers
  • ๐Ÿ“Š Rich Output: Beautiful terminal output with progress indicators and code syntax highlighting
  • ๐Ÿ’พ Session Management: Save and restore your coding sessions
  • ๐Ÿ”Œ MCP Integration: Connect Model Context Protocol servers for extended functionality (MCP Setup Guide)

๐Ÿ Getting Started

Step 1: Install Xerus

Using pip (recommended):

pip install xerus-ai

Using uv:

uv add xerus-ai

Step 2: Initialize Xerus

Before using Xerus, initialize it with an AI provider:

xerus init

This will:

  1. Present you with available AI providers
  2. Prompt you to enter your API key securely
  3. Create configuration files in ~/.xerus/
  4. Set secure permissions on sensitive files

Step 3: Start Using Xerus

# Interactive chat
xerus chat

# One-time prompt
xerus run --prompt "Your question here"

Step 4: Customize Your Setup (Optional)

  • ๐Ÿ”ง Advanced Configuration: See the Config Customization Guide to customize models, tools, and providers
  • ๐Ÿ”Œ Add MCP Tools: Follow the MCP Setup Guide to extend capabilities with file system access, GitHub integration, and more

๐ŸŒŸ Supported AI Providers

Provider Website Environment Variable
Nebius studio.nebius.com NEBIUS_API_KEY
Novita novita.ai NOVITA_API_KEY
GMI Cloud gmicloud.ai GMI_CLOUD_API_KEY

See LiteLLM providers for the complete list of supported providers.

๐Ÿ› ๏ธ Built-in Tools

Xerus comes with powerful built-in tools:

  • web_search - Search the web for real-time information
  • python_interpreter - Execute Python code
  • duckduckgo_search - Search using DuckDuckGo
  • visit_webpage - Load and extract content from URLs
  • final_answer - Provide definitive answers
  • user_input - Request additional information

๐Ÿ“– Example Use Cases

Data Science & Analytics

# Exploratory data analysis
xerus run --prompt "Load my sales data, identify trends, and create interactive dashboards"

# Statistical analysis and hypothesis testing
xerus run --prompt "Perform A/B testing analysis on my conversion data with statistical significance tests"

# Time series forecasting
xerus run --prompt "Build ARIMA and Prophet models to forecast next quarter's revenue"

Machine Learning & AI

# Model development and training
xerus run --prompt "Create and train a neural network for image classification using my dataset"

# Hyperparameter optimization  
xerus run --prompt "Set up Optuna hyperparameter tuning for my XGBoost model"

# Model deployment preparation
xerus run --prompt "Convert my PyTorch model to ONNX and create a FastAPI serving endpoint"

# MLOps and monitoring
xerus run --prompt "Set up MLflow experiment tracking and model versioning for my project"

Python Development & Optimization

# Code optimization and profiling
xerus run --prompt "Profile my pandas pipeline and optimize for memory efficiency"

# Testing and validation
xerus run --prompt "Generate comprehensive unit tests for my data processing functions"

# Documentation and analysis
xerus run --prompt "Analyze my codebase and generate API documentation with usage examples"

Research & Learning

# Stay updated with latest research
xerus run --prompt "Find and summarize recent papers on transformer efficiency techniques"

# Implementation of research papers
xerus run --prompt "Implement the attention mechanism from the 'Attention Is All You Need' paper"

# Comparative analysis
xerus run --prompt "Compare different optimization algorithms on my dataset and benchmark performance"

๐ŸŽฏ Command Reference

Initialize Xerus

xerus init [--provider PROVIDER] [--api-key KEY] [--force]

Run a Single Prompt

xerus run --prompt "Your prompt" [--save-session] [--session-name NAME]

Interactive Chat

xerus chat [--session-name NAME] [--no-history]

Session Management

xerus sessions          # List all sessions
xerus load SESSION_FILE # Load a session

Model Parameters

You can pass custom parameters to control model behavior:

xerus run --prompt "Write a story" temperature=0.9 top_p=0.95 max_tokens=1000

โš™๏ธ Configuration

Xerus uses ~/.xerus/config.json for configuration. After running xerus init, you can customize:

  • Manager agent settings (model, parameters)
  • Tool configurations (each tool can use different models/providers)
  • Custom tools (add your own tools)
  • MCP servers (connect external tools and services)

For detailed configuration options, see the Config Customization Guide.

๐Ÿ”’ Python Library Import Configuration

โš ๏ธ Important Security Note: Xerus CodeAct agents execute Python code directly on your machine's operating system using your local Python runtime. This provides powerful capabilities but requires careful security configuration.

๐Ÿ›ก๏ธ Authorized Imports Security

The python_interpreter_agent controls which Python libraries can be imported and executed. This is configured in your ~/.xerus/config.json:

"python_interpreter_agent": {
  "parameters": {
    "authorized_imports": ["math", "random", "datetime", "json", "re"]
  }
}

๐Ÿ“š Configuration Options

๐Ÿ” Restricted Mode (Default - Recommended for Local Development)

"authorized_imports": ["math", "pandas", "numpy", "sklearn", "matplotlib"]
  • Safe for local development machines
  • Limits imports to specific, trusted libraries
  • Prevents execution of potentially dangerous system operations

โš ๏ธ Full Access Mode (Use with Extreme Caution)

"authorized_imports": ["*"]
  • โš ๏ธ WARNING: Use ONLY on remote servers or Docker containers
  • Allows importing ANY Python library available in your environment
  • Enables full system access, file operations, network requests

๐Ÿ—๏ธ Runtime Environment

Xerus CodeAct agents execute code using:

  • Your machine's operating system (Linux, macOS, Windows)
  • Your local Python installation and all installed packages
  • Your user permissions and file system access
  • Your network connection and environment variables

๐Ÿ“– For comprehensive security guidelines and configuration examples, see the Security & Import Configuration Guide.

Example Configuration

{
  "manager_agent": {
    "model_id": "meta-llama/Meta-Llama-3.1-70B-Instruct",
    "api_key": "${NEBIUS_API_KEY}",
    "api_base": "https://api.studio.nebius.ai/v1"
  },
  "tools": {
    "web_search_agent": {
      "model_id": "meta-llama/Meta-Llama-3.1-8B-Instruct",
      "api_key": "${NOVITA_API_KEY}",
      "api_base": "https://api.novita.ai/v3/openai"
    }
  },
  "mcpServers": {
    "filesystem": {
      "command": "uvx",
      "args": ["mcp-server-filesystem", "/projects"],
      "description": "File system access"
    }
  }
}

๐Ÿ’ก Tips

  • Save important sessions: Use --save-session or --session-name to keep track of your work
  • Use specific prompts: More detailed prompts generally yield better results
  • Try different providers: Each provider has different strengths and pricing
  • Experiment with parameters: Adjust temperature, top_p, etc. for different behavior
  • Configure for your needs: Use the Config Guide to optimize your setup
  • Extend with MCP: Add powerful external tools with MCP servers

๐Ÿ”’ Security

  • API keys are stored securely with 600 permissions
  • Environment variables are supported for CI/CD
  • Hidden input when entering sensitive information
  • Configuration files are created in your home directory

๐Ÿšง Development

From Source

git clone https://github.com/ylankgz/xerus.git
cd xerus
uv sync --dev  # or pip install -e .

Running Tests

uv run pytest  # or pytest

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ“š Documentation

๐Ÿ†˜ Support

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xerus_ai-0.0.7.tar.gz (32.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xerus_ai-0.0.7-py3-none-any.whl (35.0 kB view details)

Uploaded Python 3

File details

Details for the file xerus_ai-0.0.7.tar.gz.

File metadata

  • Download URL: xerus_ai-0.0.7.tar.gz
  • Upload date:
  • Size: 32.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.14

File hashes

Hashes for xerus_ai-0.0.7.tar.gz
Algorithm Hash digest
SHA256 3ae6c7446303c46094aeb80254b93df5a015b49794d09b1eb22f301b6342ab5a
MD5 2bf7a52419af1281a7eaa140872a8a1d
BLAKE2b-256 e36735d47f5f52c72c1bb47e83eb55023073e4dc3ceb6839b64634f5ec0fc6c3

See more details on using hashes here.

File details

Details for the file xerus_ai-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: xerus_ai-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 35.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.14

File hashes

Hashes for xerus_ai-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 65f220bacea1eddc7fb17ea8fa8ba0bf65974aa2f59e4e00147270c7e61d08d8
MD5 2ce61b0268cadaacabfc066d5db02679
BLAKE2b-256 9503263d9cb3549d21499ae3984d829c9a76289669e268ba139ad20a765dc4f5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page