Smart token management: OpenAI API for condensing + local LLM for expansion. Reduce AI costs 60-80%.
2.0K
TokenSage optimizes AI costs by using a hybrid approach: OpenAI API for intelligent summarization and local LLM for content expansion. This reduces token usage while maintaining quality output.
Note: This is currently a testing release with a single local model (LLaMA 3.2 1B). Full source code and multi-model support will be available on GitHub in future releases.
Problem: Large queries consume expensive API tokens
Solution: Condense with OpenAI → Expand with local LLM
1. Create docker-compose.yml file:
version: '3.8'
services:
ollama:
image: ollama/ollama:latest
container_name: tokensage-ollama
ports:
- "11434:11434"
volumes:
- ollama_data:/root/.ollama
environment:
- OLLAMA_HOST=0.0.0.0
restart: unless-stopped
tokensage-app:
image: alokdekadev/tokensage-app:latest
container_name: tokensage-app
ports:
- "8501:8501"
depends_on:
- ollama
environment:
- OLLAMA_BASE_URL=http://ollama:11434
restart: unless-stopped
volumes:
ollama_data:
2. Start everything:
docker compose up -d
3. Pull the local model:
docker exec tokensage-ollama ollama pull llama3.2:1b
4. Configure API key and use the app at http://localhost:8501
User Query → OpenAI API (Condense) → Local LLM (Expand) → Final Output
↓ ↓ ↓ ↓
Large Text Smart Summary Detailed Content Cost Savings
# Start services
docker compose up -d
# Stop services
docker compose down
# View logs
docker compose logs -f
# Check status
docker compose ps
alokdekadev/tokensage-app:latest (659MB)ollama/ollama:latestllama3.2:1b (~1.3GB)Python • Streamlit • DSPy • Ollama • OpenAI API • Docker
Content type
Image
Digest
sha256:1d0ee84c4…
Size
193.1 MB
Last updated
about 1 year ago
docker pull alokdekadev/tokensage-app