Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ Boot up the vector database and internal services:
docker compose up -d
```
> [!NOTE]
> This spins up **Qdrant** (our semantic memory vector store) alongside necessary backend supporting services.
> This spins up **Qdrant** (our semantic memory vector store) and the **Intelligence Layer**
> (the Python NLP service that extracts entities/relationships into your knowledge graph).
> The Intelligence Layer image is large on first build (bundled spaCy + sentence-transformers
> models), so the initial `docker compose up` can take a few minutes. It's optional at runtime —
> the agent calls it best-effort, so chat and memory keep working even while it's still starting.

### 4. Start Ollama
Start your local inference engine:
Expand Down
21 changes: 21 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,24 @@ services:
wait $$OLLAMA_PID
'

# Python Intelligence Layer (NLP): entity + relationship extraction that feeds
# the knowledge graph. The agent calls it best-effort, so the stack still works
# if this container is starting up or unavailable.
python-agent:
build:
context: ./services/python-agent
dockerfile: Dockerfile
container_name: torvaix-intelligence
ports:
- "8000:8000"
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 5
start_period: 40s

torvaix:
build:
context: .
Expand All @@ -57,6 +75,7 @@ services:
- NODE_ENV=production
- OLLAMA_URL=http://ollama:11434
- QDRANT_URL=http://qdrant:6333
- PYTHON_SERVICE_URL=http://python-agent:8000
- AGENT_PORT=3001
- JWT_SECRET=${JWT_SECRET:-change-me-in-production}
- TORVAIX_MODEL=${TORVAIX_MODEL:-llama3.2}
Expand All @@ -73,6 +92,8 @@ services:
condition: service_healthy
ollama:
condition: service_started
python-agent:
condition: service_started
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3001/api/health"]
Expand Down
8 changes: 8 additions & 0 deletions services/python-agent/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
__pycache__/
*.pyc
*.pyo
.venv/
venv/
.pytest_cache/
.mypy_cache/
*.egg-info/
29 changes: 29 additions & 0 deletions services/python-agent/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Torvaix Intelligence Layer (NLP) — spaCy + sentence-transformers behind FastAPI
FROM python:3.11-slim

WORKDIR /app

# curl is used by the container healthcheck
RUN apt-get update \
&& apt-get install -y --no-install-recommends curl \
&& rm -rf /var/lib/apt/lists/*

# Install CPU-only PyTorch first so the requirements install below does NOT pull the
# multi-GB CUDA build. This keeps the image ~800MB instead of ~2.5GB.
RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Bake the models into the image so the first request is instant and works offline.
RUN python -m spacy download en_core_web_sm \
&& python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-MiniLM-L6-v2')"

COPY app ./app

EXPOSE 8000

HEALTHCHECK --interval=30s --timeout=10s --retries=5 --start-period=40s \
CMD curl -f http://localhost:8000/health || exit 1

CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
Loading