Skip to content

VaughnNguyen23/Llama-Term

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ollama TUI Chat 🦙💬

Rust CI License: MIT Rust

Features

  • Interactive Chat: Chat with any Ollama model in a clean TUI
  • Real-time Streaming: Tokens appear as they're generated from the LLM
  • Animated Spinner: Smooth thinking animation while waiting for responses
  • Non-blocking UI: The interface stays responsive during generation
  • Model Fine-tuning: Configure temperature, top_p, top_k, context window, system prompts, and more
  • Chat Management: Save, load, and clear chat sessions
  • Copy/Paste Support: Select and copy messages to clipboard
  • System Monitor: Real-time CPU, Memory, GPU monitoring with top processes
  • Model Management: Switch between installed models on the fly
  • Model Downloads: Download new models directly from the TUI
  • Docker Support: Run Ollama in a Docker container with GPU acceleration
  • Keyboard Navigation: Fully keyboard-driven interface
  • Vim Motions: Easy navigation with familiar keybingdings

Prerequisites

  • Rust (2021 edition or later)
  • Docker and Docker Compose (for containerized Ollama)
  • Or Ollama installed locally

Quick Start

1. Start Ollama (Docker)

# Start Ollama container
docker-compose up -d

# Pull a model (do this once)
docker exec -it ollama ollama pull llama2:latest

2. Build and Run the TUI

# Build the application
cargo build --release

# Run the application
cargo run --release

Usage

Keyboard Shortcuts

Chat Mode:

  • ** Moved to vim motions for navigation will update soon F1 to list keybind and help for now
  • Type your message and press Enter to send
  • Up/Down - Scroll through chat history
  • F1 - Show help
  • F2 - Open model selection
  • F3 - Download new model
  • F4 - Open system monitor
  • F5 - Browse chat history
  • F6 - Save current chat
  • F7 - Clear current chat
  • F8 - Open model configuration
  • Ctrl+S - Select last message
  • Ctrl+Y - Copy selected message to clipboard
  • Ctrl+C - Quit application

Model Selection Mode:

  • Up/Down - Navigate models
  • Enter - Select model
  • Esc - Return to chat

Model Download Mode:

  • Type the model name (e.g., llama2:latest, mistral:latest)
  • Enter - Start download
  • Esc - Cancel

System Monitor Mode:

  • Shows real-time CPU, Memory, GPU stats and top processes
  • Up/Down - Scroll through process list
  • Updates every 100ms
  • Esc - Return to chat

Chat History Mode:

  • Up/Down - Navigate saved chats
  • Enter - Load selected chat
  • Esc - Return to chat

Model Configuration Mode (F8):

  • Up/Down or Tab - Navigate between fields
  • Type value and press Enter - Update field
  • Auto-saves on Enter
  • Esc - Return to chat

Configurable Parameters

  • Temperature (0.0-2.0): Controls randomness. Lower = more focused, Higher = more creative
  • Top P (0.0-1.0): Nucleus sampling for diversity control
  • Top K (1+): Limits token selection to top K options
  • Repeat Penalty (0.0-2.0): Penalizes repetition. Higher = less repetition
  • Context Window (512-32768): Number of tokens in context
  • System Prompt: Custom instructions for the model's behavior

Docker Configuration

The docker-compose.yml file sets up Ollama with:

  • Port 11434 exposed for API access
  • Persistent volume for model storage
  • GPU support enabled by default (uses all available NVIDIA GPUs)

GPU Support

GPU support is already enabled in the docker-compose.yml file. To use it, you need:

  1. NVIDIA GPU in your system
  2. NVIDIA drivers installed on your host
  3. NVIDIA Container Toolkit installed

Verify GPU is Working

# Check if GPU is available in container
docker exec -it ollama nvidia-smi

# You should see your GPU listed

If you don't have a GPU or want to use CPU only, comment out the deploy section in docker-compose.yml.

Managing Docker Ollama

# View logs
docker-compose logs -f

# Stop Ollama
docker-compose down

# Stop and remove volumes (deletes downloaded models)
docker-compose down -v

# Pull models manually
docker exec -it ollama ollama pull <model-name>

# List installed models
docker exec -it ollama ollama list

Connecting to Remote Ollama

If Ollama is running on a different host, modify the Ollama connection in src/main.rs:

let ollama = Ollama::new("http://your-host:11434".to_string());

Troubleshooting

Connection refused error:

  • Ensure Ollama is running: docker-compose ps
  • Check if port 11434 is accessible: curl http://localhost:11434/api/tags

File Storage

  • Chat sessions: ~/.ollama_tui/chats/ - Saved when you press F6
  • Model config: ~/.ollama_tui/model_config.json - Auto-saved when you edit settings

Each chat session includes timestamp, model used, and all messages. Model configuration persists across sessions and is automatically loaded on startup.

Building for Production

# Build optimized binary
cargo build --release

## Support

If you encounter any issues or have questions:

- [Report a bug](https://github.com/yourusername/ollama-tui/issues/new?template=bug_report.md)
- [Request a feature](https://github.com/yourusername/ollama-tui/issues/new?template=feature_request.md)
- [Start a discussion](https://github.com/yourusername/ollama-tui/discussions)

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

---

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors