Skip to content

CosmonautCode/Tiny-Hyena-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tiny Hyena AI

Python License Status Made with UV

A lightweight, self-contained Python chat system with local AI agents and file operations. This system uses Hyena3-4B-Instruct(Custom Qwen Fork) and llama-cpp-python for inference, with Rich for a beautiful console interface. Features AI agents with workspace-based file operations and dynamic terminal sizing.

Empty Chat


Features

  • Out-of-the-box experience: Just run run_app.bat to install dependencies and start
  • Minimal dependencies: Uses UV for fast dependency resolution
  • AI Agent System: Multiple specialized agents with different personalities and capabilities
  • File Operations: AI can read, write, and list files in a designated workspace
  • Dynamic UI: Responsive interface that adapts to terminal size
  • Workspace Management: Secure file operations within user-defined directories
  • Conversation Management: Save, load, and export chat conversations
  • Rich Console UI: Beautiful terminal interface with formatted panels and colors
  • PEP 8 Compliant: Clean, documented codebase following Python standards

Project Structure

tiny-local-agent/
├── .venv/                           # Python virtual environment (auto-created)
├── app/
│   ├── llm_engine/                  # LLM inference engine
│   │   ├── __init__.py
│   │   └── engine.py               # Model loading and inference
│   ├── interface/                   # User interface and chat system
│   │   ├── chat.py                 # Main chat system orchestrator
│   │   └── chat_components/        # Modular UI components
│   │       ├── agent_management/    # AI agent configuration
│   │       │   ├── agent_handler.py
│   │       │   └── agents.json     # Agent personalities and prompts
│   │       ├── commands/           # Command processing
│   │       │   └── command_processor.py
│   │       ├── conversations/       # Chat history management
│   │       │   └── manager.py
│   │       ├── display/            # UI rendering
│   │       │   └── chat_display.py
│   │       ├── file_operations/     # AI file tools
│   │       │   ├── ai_tools.py      # AI-accessible file operations
│   │       │   ├── workspace_manager.py # Workspace management
│   │       │   └── file_manager.py  # Secure file operations
│   │       ├── header/              # System header display
│   │       │   └── header.py
│   │       ├── input_management/    # User input handling
│   │       │   └── manager.py
│   │       └── stats/               # Session statistics
│   │           └── manager.py
│   └── app.py                       # Main entry point
├── models/                          # Contains the GGUF model file
│   └── Hyena3-4B-Instruct-2507.Q6_K.gguf
├── pyproject.toml                   # Project metadata and dependencies
├── README.md                        # Project documentation
├── run_app.bat                      # Script to install dependencies and run the app
└── uv.lock                          # Lockfile for reproducible dependency resolution

Prerequisites

  • Windows OS (for .bat script compatibility)
  • Python 3.10+ (recommended: 3.11+)
  • Internet connection (only for initial dependency installation)
  • ~2GB disk space for the Hyena3-4B GGUF model

Getting Started

1. Download the Project

Download and extract the project to a folder of your choice.

2. Run the Application

Double-click run_app.bat or run from command line:

run_app.bat

This will:

  • Install UV (if not already installed)
  • Create a virtual environment (.venv)
  • Sync dependencies using uv sync
  • Run the application with uv run -m app.app

3. Start Using the System

  • Set workspace: /workspace test_files to enable file operations
  • Chat with AI: Type messages to interact with AI agents
  • Use commands: Type /help to see all available commands
  • File operations: Ask AI to read/write files in the workspace

Screenshots

System Startup

Empty Chat

Available Agents

Agent Selection

Setting Workspace

Workspace Setup

Commands Help

Commands

AI File Operations

AI Tool Example

Loading Files

Load File

AI Thinking

AI Thinking


How It Works

1. Dependency Management

The project uses UV for fast dependency resolution and virtual environment management. Dependencies are listed in pyproject.toml and installed automatically when you run run_app.bat.

2. Model Loading

engine.py loads the Hyena3-4B model from the models/ directory using llama-cpp-python. The model is configured with:

  • Context length: 8192 tokens (can do up to 200k with proper configuration)
  • Threads: 8 (adjustable based on your CPU)
  • GPU layers: -1 (full GPU acceleration)

3. AI Agent System

When you interact with the system:

  • Agent Selection: Choose from multiple specialized AI personalities
  • File Operations: AI can read, write, and list files in your workspace
  • Dynamic Responses: Each agent has unique capabilities and conversation style
  • Tool Integration: AI automatically uses file tools when needed

4. Workspace Management

The system provides secure file operations:

  • User-defined workspace: Set any directory as your AI workspace
  • AI file tools: @read_file(), @write_file(), @list_files() functions
  • Security restrictions: Files limited to workspace directory
  • Size limits: 2MB maximum file size for safety

5. User Interface

chat.py creates a rich console interface that:

  • Accepts user input with auto-completion and command history
  • Displays dynamic headers that adapt to terminal size
  • Shows conversation history in formatted panels
  • Provides real-time feedback for AI operations

Customization

Agent Configuration

Edit app/interface/chat_components/agent_management/agents.json to:

  • Add/remove AI agents
  • Define agent names, specialties, and system prompts
  • Configure file operation capabilities

File Operation Settings

Modify app/interface/chat_components/file_operations/workspace_manager.py to:

  • Change file size limits (default: 2MB)
  • Adjust allowed file extensions
  • Modify workspace behavior

UI Customization

Edit display components in app/interface/chat_components/ to:

  • Change colors and styling
  • Modify header layout
  • Adjust panel formatting

Troubleshooting

Common Issues

  • Missing dependencies: Ensure run_app.bat completes without errors
  • Model not found: Verify Hyena3-4B-Instruct-2507.Q6_K.gguf is in models/ directory
  • File access errors: Use /workspace <directory> to set a valid workspace
  • Display issues: Resize terminal window for better layout

Performance Tips

  • Slower responses: Reduce context length or use smaller model
  • Memory issues: Close other applications when running large models
  • File operations: Keep workspace directory small for better performance

Development

Code Quality

  • PEP 8 Compliant: All functions and classes have proper docstrings
  • Modular Design: Clean separation of concerns
  • Type Hints: Consistent type annotations throughout
  • Error Handling: Robust error handling and user feedback

Adding Features

The modular architecture makes it easy to add new features:

  1. Create new manager classes in chat_components/
  2. Add commands in command_processor.py
  3. Update agents in agents.json
  4. Modify display components as needed

License

This project is open-source and free to use. The Hyena3 model is licensed under its respective terms.


Acknowledgments

  • llama-cpp-python for LLM inference
  • Rich for the beautiful console UI
  • Hyena3 for the language model
  • UV for fast dependency management

⭐ Star this repo if you found it useful!

About

A lightweight, self-contained Python chat system with local AI agents and file operations. This system uses Hyena3-4B-Instruct(Custom Qwen Fork) and llama-cpp-python for inference, with Rich for a beautiful console interface.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors