friend.zip - Mobile LLM Project
friend.zip
Mobile/On-Device LLM Infrastructure
A self-contained LLM implementation designed for edge devices and mobile environments. This is a complete AI assistant system that runs entirely locally with minimal dependencies.
Overview
friend.zip contains a portable, self-contained LLM system built entirely in Bash. It’s designed to run on resource-constrained devices (mobile, edge, embedded) where traditional Python-based LLM systems would be too heavy.
Contents
The archive contains 8 files totaling ~16KB:
| File | Size | Purpose |
|---|---|---|
setup.sh | 1.5KB | Installation and initialization |
config.sh | 778B | Configuration management |
llm_call.sh | 2.7KB | Core LLM calling interface |
memory.sh | 2.5KB | Memory/conversation management |
tools.sh | 2.1KB | Utility functions and helpers |
dream.sh | 3.1KB | Memory consolidation (similar to Aurora’s) |
talk.sh | 3.0KB | Main conversation interface |
system_prompt.txt | 602B | Default system prompt |
Architecture
Component Overview
┌─────────────────────────────────────────────────────────┐
│ FRIEND SYSTEM │
├─────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────┐ ┌─────────────┐ ┌────────────┐ │
│ │ talk.sh │────►│ llm_call.sh │────►│ LLM │ │
│ │ (Interface) │ │ (Core) │ │ (Backend) │ │
│ └─────────────┘ └─────────────┘ └────────────┘ │
│ ▲ ▲ │
│ │ │ │
│ ┌──────┴──────┐ ┌──────┴──────┐ │
│ │ memory.sh │ │ config.sh │ │
│ │ (State) │ │ (Settings) │ │
│ └──────┬──────┘ └─────────────┘ │
│ │ │
│ ┌──────▼──────┐ │
│ │ dream.sh │ │
│ │ (Consolidation) │
│ └─────────────┘ │
│ │
└─────────────────────────────────────────────────────────┘
Data Flow
User Input → talk.sh → memory.sh (load context) → llm_call.sh → LLM
↑
dream.sh (consolidate)
↓
memory.sh (save context)
Components
1. talk.sh (3.0KB)
Main conversation interface — The entry point for interacting with the LLM.
Features:
- Interactive chat mode
- Single-question mode
- Memory integration (loads/saves conversation)
- Clean, simple interface
Example Usage:
# Start interactive chat
./talk.sh
# Ask a single question
./talk.sh "What is the capital of France?"
2. llm_call.sh (2.7KB)
Core LLM calling interface — Handles communication with the underlying LLM backend.
Features:
- Abstraction layer over LLM backend
- JSON mode support
- Temperature and parameter control
- Error handling and retries
- Response formatting
Supported Backends:
- llama.cpp
- Any HTTP-based LLM API
- Local inference servers
3. memory.sh (2.5KB)
Conversation memory management — Maintains conversation history and context.
Features:
- Load conversation history
- Save new interactions
- Context window management
- Token counting
- Memory compression
Memory Format:
[User] message 1
[Assistant] response 1
[User] message 2
[Assistant] response 2
...
4. dream.sh (3.1KB)
Memory consolidation — Similar to Aurora’s dream.sh, but simpler.
Features:
- Compresses conversation history
- Extracts key insights
- Maintains long-term memory
- Periodic consolidation
Note: This is a simplified version of Aurora’s full dream.sh. It lacks the system prompt evolution feature but provides the same core memory consolidation.
5. config.sh (778B)
Configuration management — Centralized settings for the entire system.
Managed Settings:
- Model paths
- API endpoints
- Temperature and parameters
- Memory limits
- Logging configuration
Example:
# config.sh
MODEL_PATH="./models/llama-2-7b.Q4_K_M.gguf"
TEMPERATURE=0.7
MAX_TOKENS=2048
MEMORY_FILE="./memory.txt"
6. tools.sh (2.1KB)
Utility functions — Common helpers used throughout the system.
Includes:
- String manipulation
- File I/O helpers
- Logging functions
- Validation routines
- Shell utilities
7. setup.sh (1.5KB)
Installation and initialization — Sets up the friend system.
Actions:
- Creates directory structure
- Sets up configuration
- Downloads required models (optional)
- Verifies dependencies
- Creates initial memory file
8. system_prompt.txt (602B)
Default system prompt — The initial prompt for the LLM.
This can be customized for different personas or use cases.
Use Cases
1. Edge AI Devices
Run LLMs on devices with limited resources:
- Raspberry Pi
- Mobile phones (via Termux)
- Embedded Linux devices
- IoT gateways
2. Offline AI Assistants
Full AI capabilities without internet access:
- Field work
- Travel
- Low-connectivity environments
- Privacy-sensitive applications
3. Mobile Development
Integrate AI into mobile apps:
- Android (via Termux or native)
- iOS (via iSH or native)
- Cross-platform applications
4. Embedded Systems
Lightweight AI for embedded applications:
- Robotics
- Automation
- Smart devices
- Sensor networks
Technical Details
Dependencies
Minimal dependencies:
bash— Primary execution environmentcurlorwget— For HTTP requests (optional)jq— For JSON processing (optional)- LLM backend — llama.cpp, local API, or HTTP endpoint
Memory Requirements
- Base system: ~10KB (the scripts themselves)
- Model memory: Varies by model size (100MB - 10GB)
- Conversation memory: Typically <1MB
Performance
- Startup time: <1 second
- Response time: Depends on LLM backend
- Throughput: 1-10 tokens/second (depends on hardware)
Setup Instructions
Quick Start
# Extract the archive
unzip friend.zip
# Make scripts executable
chmod +x *.sh
# Run setup
./setup.sh
# Start chatting
./talk.sh
Manual Setup
# 1. Create directory
mkdir -p friend && cd friend
# 2. Extract files
unzip ../friend.zip
# 3. Make executable
chmod +x *.sh
# 4. Configure (edit config.sh)
nano config.sh
# 5. Download a model (optional)
# See your LLM backend documentation
# 6. Start using
./talk.sh "Hello, AI!"
Configuration
Edit config.sh to customize your setup:
# Model configuration
MODEL_PATH="/path/to/your/model.gguf"
MODEL_TYPE="llama" # or "mistral", "phi", etc.
# Generation parameters
TEMPERATURE=0.7
TOP_P=0.9
TOP_K=40
MAX_TOKENS=2048
# Memory settings
MEMORY_FILE="./memory.txt"
MAX_MEMORY_TOKENS=8192
# Logging
LOG_FILE="./friend.log"
DEBUG_MODE=false
Integration Examples
With llama.cpp
# In config.sh
LLM_BACKEND="llamacpp"
LLAMA_CPP_PATH="/usr/local/bin/llama-cli"
# Then talk.sh will use:
# $LLAMA_CPP_PATH --model $MODEL_PATH --temp $TEMPERATURE --top-p $TOP_P ...
With HTTP API
# In config.sh
LLM_BACKEND="http"
API_ENDPOINT="https://api.your-llm-provider.com/v1/chat/completions"
API_KEY="your-api-key"
# talk.sh will send HTTP requests to the endpoint
# Replace with your actual LLM API endpoint URL
With Custom Backend
# Create a custom llm_call.sh wrapper
cat > llm_call.sh << 'EOF'
#!/bin/bash
# Your custom LLM calling logic here
# Reads from stdin, outputs to stdout
EOF
chmod +x llm_call.sh
File Reference
talk.sh
The main entry point. Handles:
- Command-line arguments
- Interactive vs. single-question mode
- Memory loading/saving
- Error handling
Key Functions:
interactive_mode()— Main chat loopsingle_question()— One-shot question answeringload_memory()— Load conversation historysave_memory()— Save conversation history
llm_call.sh
Core LLM interface. Handles:
- Request formatting
- Parameter passing
- Response parsing
- Error handling
Key Functions:
call_llm()— Main calling functionformat_prompt()— Builds the full promptparse_response()— Processes LLM output
memory.sh
Memory management. Handles:
- Context window management
- Token counting
- Memory compression
- History trimming
Key Functions:
load_context()— Loads relevant contextsave_context()— Saves current contextcount_tokens()— Estimates token countcompress_memory()— Reduces memory size
dream.sh
Memory consolidation. Handles:
- Periodic memory compression
- Insight extraction
- Long-term memory updates
Key Functions:
consolidate()— Main consolidation functionextract_insights()— Identifies patternsupdate_memory()— Updates long-term storage
Comparison with Aurora’s System
| Feature | friend.zip | Aurora System |
|---|---|---|
| Language | Bash | Bash + Python |
| LLM Backend | Any | Mistral Vibe CLI |
| Memory | Simple file-based | Multi-layer (RAG, KG, etc.) |
| Dream | Basic consolidation | Full system evolution |
| Planner/Worker | ❌ No | ✅ Yes |
| Beads Integration | ❌ No | ✅ Yes |
| Size | ~16KB | ~100KB+ |
| Dependencies | Minimal | Moderate |
| Use Case | Mobile/Edge | Full Lab Automation |
friend.zip is essentially a lightweight, portable version of Aurora’s core capabilities.
Source Code
Complete source available:
Extract and explore:
# Download
cp /opt/aurora/work/friend.zip .
# Extract
unzip friend.zip
# Browse
ls -la
# Read any file
cat talk.sh
cat llm_call.sh
# etc.
License
This tool is provided as-is for educational and production use. No warranty is provided. Use at your own risk.
Related
- LLM Infrastructure Overview — Other LLM tools
- fetch_models.py — Model discovery and categorization
- Aurora Tools — Full AI agent system
- dream.sh (Aurora version) — More sophisticated memory consolidation
Sometimes, the best AI is the one you can run anywhere.