Add CLI, Docker setup, and quick start guide
- CLI tool for testing (cli.py) - Docker Compose for easy deployment - Dockerfile for backend - QUICKSTART.md with setup instructions Ready to deploy! Run: python cli.py or docker-compose up
This commit is contained in:
203
QUICKSTART.md
Normal file
203
QUICKSTART.md
Normal file
@@ -0,0 +1,203 @@
|
|||||||
|
# Grimlock Quick Start Guide
|
||||||
|
|
||||||
|
Get Grimlock running in 5 minutes.
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
- Python 3.11+
|
||||||
|
- Anthropic API key ([get one here](https://console.anthropic.com/))
|
||||||
|
- OR Docker + Docker Compose
|
||||||
|
|
||||||
|
## Option 1: Quick CLI Test (Fastest)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Clone the repo (if not already)
|
||||||
|
git clone https://gittea.979labs.com/amitis55/grimlock.git
|
||||||
|
cd grimlock
|
||||||
|
|
||||||
|
# Set up environment
|
||||||
|
cp backend/.env.example backend/.env
|
||||||
|
# Edit backend/.env and add your ANTHROPIC_API_KEY
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
pip install -r backend/requirements.txt
|
||||||
|
|
||||||
|
# Run CLI
|
||||||
|
python cli.py
|
||||||
|
```
|
||||||
|
|
||||||
|
You should see:
|
||||||
|
```
|
||||||
|
============================================================
|
||||||
|
GRIMLOCK CLI
|
||||||
|
============================================================
|
||||||
|
|
||||||
|
Initializing...
|
||||||
|
Context loaded: {'projects': 1, 'patterns': 0, 'anti_patterns': 0, 'cost_models': 0, 'repos': 0}
|
||||||
|
AI client ready
|
||||||
|
|
||||||
|
Grimlock is online. Type 'exit' to quit.
|
||||||
|
|
||||||
|
You:
|
||||||
|
```
|
||||||
|
|
||||||
|
## Option 2: Run Backend Server
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# From grimlock directory
|
||||||
|
cd backend
|
||||||
|
|
||||||
|
# Set up environment
|
||||||
|
cp .env.example .env
|
||||||
|
# Edit .env and add your ANTHROPIC_API_KEY
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
pip install -r requirements.txt
|
||||||
|
|
||||||
|
# Run server
|
||||||
|
python main.py
|
||||||
|
```
|
||||||
|
|
||||||
|
Server will start at http://localhost:8000
|
||||||
|
|
||||||
|
Test it:
|
||||||
|
```bash
|
||||||
|
curl http://localhost:8000/api/health
|
||||||
|
```
|
||||||
|
|
||||||
|
## Option 3: Docker Compose (Production-like)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# From grimlock directory
|
||||||
|
cp backend/.env.example backend/.env
|
||||||
|
# Edit backend/.env and add your ANTHROPIC_API_KEY
|
||||||
|
|
||||||
|
# Start services
|
||||||
|
docker-compose up -d
|
||||||
|
|
||||||
|
# Check logs
|
||||||
|
docker-compose logs -f grimlock-backend
|
||||||
|
|
||||||
|
# Test
|
||||||
|
curl http://localhost:8000/api/health
|
||||||
|
```
|
||||||
|
|
||||||
|
## Testing the Chat API
|
||||||
|
|
||||||
|
Using curl:
|
||||||
|
```bash
|
||||||
|
curl -X POST http://localhost:8000/api/chat \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{
|
||||||
|
"messages": [
|
||||||
|
{"role": "user", "content": "What is Grimlock?"}
|
||||||
|
]
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
Using Python:
|
||||||
|
```python
|
||||||
|
import requests
|
||||||
|
|
||||||
|
response = requests.post(
|
||||||
|
"http://localhost:8000/api/chat",
|
||||||
|
json={
|
||||||
|
"messages": [
|
||||||
|
{"role": "user", "content": "What projects does Vector Zulu have?"}
|
||||||
|
],
|
||||||
|
"role": "engineer"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
print(response.json()["response"])
|
||||||
|
```
|
||||||
|
|
||||||
|
## Adding Vector Zulu Context
|
||||||
|
|
||||||
|
Add your project summaries, patterns, and other context:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Create context files
|
||||||
|
mkdir -p backend/context/projects
|
||||||
|
mkdir -p backend/context/patterns
|
||||||
|
mkdir -p backend/context/anti_patterns
|
||||||
|
mkdir -p backend/context/cost_models
|
||||||
|
|
||||||
|
# Add UTILEN project
|
||||||
|
cp path/to/UTILEN-summary.md backend/context/projects/utilen.md
|
||||||
|
|
||||||
|
# Add Vector Zulu platform
|
||||||
|
cp path/to/VectorZulu-summary.md backend/context/projects/vector-zulu.md
|
||||||
|
|
||||||
|
# Add patterns
|
||||||
|
echo "# Multi-Tenant SaaS Pattern
|
||||||
|
|
||||||
|
Based on UTILEN architecture:
|
||||||
|
- FastAPI + PostgreSQL + Redis + Celery
|
||||||
|
- Tenant isolation at DB and storage level
|
||||||
|
- Background processing for heavy operations
|
||||||
|
- JWT auth (avoid Keycloak)
|
||||||
|
" > backend/context/patterns/multi-tenant-saas.md
|
||||||
|
```
|
||||||
|
|
||||||
|
Restart the server and Grimlock will have Vector Zulu context!
|
||||||
|
|
||||||
|
## Example Interactions
|
||||||
|
|
||||||
|
**Ask about projects:**
|
||||||
|
```
|
||||||
|
You: What projects has Vector Zulu built?
|
||||||
|
Grimlock: Vector Zulu has built several major projects including UTILEN (an AI-powered document management system), the Vector Zulu distributed cyber range platform, and a Layer 1 blockchain with stablecoin...
|
||||||
|
```
|
||||||
|
|
||||||
|
**Get architecture advice:**
|
||||||
|
```
|
||||||
|
You: I need to build a document processing system
|
||||||
|
Grimlock: Based on Vector Zulu patterns, this maps to the UTILEN architecture: FastAPI + PostgreSQL + Redis + Celery + MinIO + Claude Vision API...
|
||||||
|
```
|
||||||
|
|
||||||
|
**Role-specific responses:**
|
||||||
|
```python
|
||||||
|
# As engineer
|
||||||
|
response = requests.post("http://localhost:8000/api/chat", json={
|
||||||
|
"messages": [{"role": "user", "content": "How should I implement multi-tenancy?"}],
|
||||||
|
"role": "engineer"
|
||||||
|
})
|
||||||
|
|
||||||
|
# As BD person
|
||||||
|
response = requests.post("http://localhost:8000/api/chat", json={
|
||||||
|
"messages": [{"role": "user", "content": "What's our pricing for UTILEN?"}],
|
||||||
|
"role": "bd"
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
## Next Steps
|
||||||
|
|
||||||
|
1. **Add more context** - The more context you add, the smarter Grimlock becomes
|
||||||
|
2. **Build the web interface** - See `frontend/` directory
|
||||||
|
3. **Deploy to your infrastructure** - Use Docker Compose on your servers
|
||||||
|
4. **Integrate with your systems** - Build connectors for git, databases, etc.
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
**"ANTHROPIC_API_KEY not set"**
|
||||||
|
- Make sure you copied `.env.example` to `.env` and added your API key
|
||||||
|
|
||||||
|
**"Context manager not initialized"**
|
||||||
|
- The `backend/context` directory needs to exist
|
||||||
|
- Run `mkdir -p backend/context/{projects,patterns,anti_patterns,cost_models}`
|
||||||
|
|
||||||
|
**"Module not found"**
|
||||||
|
- Make sure you installed requirements: `pip install -r backend/requirements.txt`
|
||||||
|
|
||||||
|
**Docker issues**
|
||||||
|
- Make sure Docker daemon is running
|
||||||
|
- Check logs: `docker-compose logs -f`
|
||||||
|
|
||||||
|
## Support
|
||||||
|
|
||||||
|
Questions? Open an issue on the repo or contact the Vector Zulu team.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Built with ❤️ by Vector Zulu**
|
||||||
84
cli.py
Executable file
84
cli.py
Executable file
@@ -0,0 +1,84 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
Grimlock CLI - Simple command line interface for testing
|
||||||
|
"""
|
||||||
|
|
||||||
|
import asyncio
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
# Add backend to path
|
||||||
|
sys.path.insert(0, str(Path(__file__).parent / "backend"))
|
||||||
|
|
||||||
|
from core.ai_client import AIClient
|
||||||
|
from core.context_manager import ContextManager
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
|
load_dotenv("backend/.env")
|
||||||
|
|
||||||
|
async def main():
|
||||||
|
print("=" * 60)
|
||||||
|
print("GRIMLOCK CLI")
|
||||||
|
print("=" * 60)
|
||||||
|
|
||||||
|
# Initialize
|
||||||
|
api_key = os.getenv("ANTHROPIC_API_KEY")
|
||||||
|
if not api_key:
|
||||||
|
print("ERROR: ANTHROPIC_API_KEY not set")
|
||||||
|
print("Copy backend/.env.example to backend/.env and add your API key")
|
||||||
|
return
|
||||||
|
|
||||||
|
print("\nInitializing...")
|
||||||
|
context_manager = ContextManager("backend/context")
|
||||||
|
context_manager.load_all_context()
|
||||||
|
print(f"Context loaded: {context_manager.get_summary()}")
|
||||||
|
|
||||||
|
ai_client = AIClient(api_key=api_key)
|
||||||
|
print("AI client ready")
|
||||||
|
|
||||||
|
# Interactive loop
|
||||||
|
print("\nGrimlock is online. Type 'exit' to quit.\n")
|
||||||
|
|
||||||
|
messages = []
|
||||||
|
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
user_input = input("You: ").strip()
|
||||||
|
|
||||||
|
if not user_input:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if user_input.lower() in ['exit', 'quit', 'q']:
|
||||||
|
print("\nGoodbye!")
|
||||||
|
break
|
||||||
|
|
||||||
|
# Add user message
|
||||||
|
messages.append({"role": "user", "content": user_input})
|
||||||
|
|
||||||
|
# Get context
|
||||||
|
context = context_manager.get_context_for_query(user_input)
|
||||||
|
system_prompt = context_manager.get_system_prompt()
|
||||||
|
if context:
|
||||||
|
system_prompt += f"\n\n# Company Context\n{context}"
|
||||||
|
|
||||||
|
# Get response
|
||||||
|
print("\nGrimlock: ", end="", flush=True)
|
||||||
|
response = await ai_client.chat(
|
||||||
|
messages=messages,
|
||||||
|
system_prompt=system_prompt
|
||||||
|
)
|
||||||
|
print(response)
|
||||||
|
print()
|
||||||
|
|
||||||
|
# Add assistant message
|
||||||
|
messages.append({"role": "assistant", "content": response})
|
||||||
|
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print("\n\nGoodbye!")
|
||||||
|
break
|
||||||
|
except Exception as e:
|
||||||
|
print(f"\nError: {e}\n")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
asyncio.run(main())
|
||||||
27
docker-compose.yml
Normal file
27
docker-compose.yml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
grimlock-backend:
|
||||||
|
build:
|
||||||
|
context: ./backend
|
||||||
|
dockerfile: ../docker/Dockerfile.backend
|
||||||
|
container_name: grimlock-backend
|
||||||
|
ports:
|
||||||
|
- "8000:8000"
|
||||||
|
environment:
|
||||||
|
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
|
||||||
|
- HOST=0.0.0.0
|
||||||
|
- PORT=8000
|
||||||
|
- DEBUG=true
|
||||||
|
- CONTEXT_PATH=/app/context
|
||||||
|
- AI_MODEL=claude-sonnet-4-5-20250514
|
||||||
|
- LOG_LEVEL=INFO
|
||||||
|
volumes:
|
||||||
|
- ./backend/context:/app/context:ro
|
||||||
|
- ./backend:/app:ro
|
||||||
|
restart: unless-stopped
|
||||||
|
command: uvicorn main:app --host 0.0.0.0 --port 8000 --reload
|
||||||
|
|
||||||
|
networks:
|
||||||
|
default:
|
||||||
|
name: grimlock-network
|
||||||
25
docker/Dockerfile.backend
Normal file
25
docker/Dockerfile.backend
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
FROM python:3.11-slim
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install system dependencies for WeasyPrint (PDF generation)
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
libpango-1.0-0 \
|
||||||
|
libpangoft2-1.0-0 \
|
||||||
|
libgdk-pixbuf2.0-0 \
|
||||||
|
libffi-dev \
|
||||||
|
shared-mime-info \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Copy requirements and install Python dependencies
|
||||||
|
COPY backend/requirements.txt .
|
||||||
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
# Copy application code
|
||||||
|
COPY backend/ .
|
||||||
|
|
||||||
|
# Expose port
|
||||||
|
EXPOSE 8000
|
||||||
|
|
||||||
|
# Run the application
|
||||||
|
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||||
Reference in New Issue
Block a user