Skip to main content

Hanzo AI - Complete AI Infrastructure Platform with CLI, Router, MCP, and Agent Runtime

Project description

Hanzo CLI and Orchestration Tools

PyPI Python Version

Core CLI and orchestration tools for the Hanzo AI platform.

Installation

pip install hanzo

Features

  • Interactive Chat: Chat with AI models through CLI
  • Node Management: Run local AI inference nodes
  • Router Control: Manage LLM proxy router
  • REPL Interface: Interactive Python REPL with AI
  • Batch Orchestration: Orchestrate multiple AI tasks
  • Memory Management: Persistent conversation memory

Usage

CLI Commands

# Interactive chat
hanzo chat

# Use specific model
hanzo chat --model gpt-4

# Use router (local proxy)
hanzo chat --router

# Use cloud API
hanzo chat --cloud

Node Management

# Start local node
hanzo node start

# Check status
hanzo node status

# List available models
hanzo node models

# Load specific model
hanzo node load llama2:7b

# Stop node
hanzo node stop

Router Management

# Start router proxy
hanzo router start

# Check router status
hanzo router status

# List available models
hanzo router models

# View configuration
hanzo router config

# Stop router
hanzo router stop

Interactive REPL

# Start REPL
hanzo repl

# In REPL:
> /help              # Show help
> /models            # List models
> /model gpt-4       # Switch model
> /clear             # Clear context
> What is Python?    # Ask questions

Python API

Batch Orchestration

from hanzo.batch_orchestrator import BatchOrchestrator

orchestrator = BatchOrchestrator()
results = await orchestrator.run_batch([
    "Summarize quantum computing",
    "Explain machine learning",
    "Define artificial intelligence"
])

Memory Management

from hanzo.memory_manager import MemoryManager

memory = MemoryManager()
memory.add_to_context("user", "What is Python?")
memory.add_to_context("assistant", "Python is...")
context = memory.get_context()

Fallback Handling

from hanzo.fallback_handler import FallbackHandler

handler = FallbackHandler()
result = await handler.handle_with_fallback(
    primary_fn=api_call,
    fallback_fn=local_inference
)

Configuration

Environment Variables

# API settings
HANZO_API_KEY=your-api-key
HANZO_BASE_URL=https://api.hanzo.ai

# Router settings
HANZO_ROUTER_URL=http://localhost:4000/v1

# Node settings
HANZO_NODE_URL=http://localhost:8000/v1
HANZO_NODE_WORKERS=4

# Model preferences
HANZO_DEFAULT_MODEL=gpt-4
HANZO_FALLBACK_MODEL=llama2:7b

Configuration File

Create ~/.hanzo/config.yaml:

api:
  key: your-api-key
  base_url: https://api.hanzo.ai

router:
  url: http://localhost:4000/v1
  auto_start: true

node:
  url: http://localhost:8000/v1
  workers: 4
  models:
    - llama2:7b
    - mistral:7b

models:
  default: gpt-4
  fallback: llama2:7b

Architecture

Components

  • CLI: Command-line interface (cli.py)
  • Chat: Interactive chat interface (commands/chat.py)
  • Node: Local AI node management (commands/node.py)
  • Router: LLM proxy management (commands/router.py)
  • REPL: Interactive Python REPL (interactive/repl.py)
  • Orchestrator: Batch task orchestration (batch_orchestrator.py)
  • Memory: Conversation memory (memory_manager.py)
  • Fallback: Resilient API handling (fallback_handler.py)

Port Allocation

  • 4000: Router (LLM proxy)
  • 8000: Node (local AI)
  • 9550-9553: Desktop app integration

Development

Setup

cd pkg/hanzo
uv sync --all-extras

Testing

# Run tests
pytest tests/

# With coverage
pytest tests/ --cov=hanzo

Building

uv build

License

Apache License 2.0

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

hanzo-0.3.48.tar.gz (225.3 kB view details)

Uploaded Source

Built Distribution

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

hanzo-0.3.48-py3-none-any.whl (274.2 kB view details)

Uploaded Python 3

File details

Details for the file hanzo-0.3.48.tar.gz.

File metadata

  • Download URL: hanzo-0.3.48.tar.gz
  • Upload date:
  • Size: 225.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for hanzo-0.3.48.tar.gz
Algorithm Hash digest
SHA256 45171dfdb28128622bde0f7888d2ffb81dc355b9b775c3cb326f71f0fc2ca27e
MD5 e5f73414b5e7bb7857c97987679a7ce2
BLAKE2b-256 da6e61571a92a56c7be701eb0f5e027e86e9f98bc78e02ce7962d7bc6d97a170

See more details on using hashes here.

File details

Details for the file hanzo-0.3.48-py3-none-any.whl.

File metadata

  • Download URL: hanzo-0.3.48-py3-none-any.whl
  • Upload date:
  • Size: 274.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for hanzo-0.3.48-py3-none-any.whl
Algorithm Hash digest
SHA256 475c8c3eccadd907e956027d5b3815bcfb8dff98ede6764372a865ce01762080
MD5 e9a2b104b1c6e52c7dd6ca5bf370c533
BLAKE2b-256 63f44db8ce30f87f21f4fadd2c4a6bd0b0598d11e68053ee258cdcfe54340010

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