Skip to content

Commit 7fb3f10

Browse files
committed
add local embedding service
1 parent 5330f0e commit 7fb3f10

File tree

3 files changed

+121
-0
lines changed

3 files changed

+121
-0
lines changed

docker-compose.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,25 @@ services:
7171
volumes:
7272
- netbox-redis-cache-data:/data
7373

74+
embeddings:
75+
container_name: embeddings
76+
image: ghcr.io/huggingface/text-embeddings-inference:cpu-1.8
77+
command: --model-id sentence-transformers/all-MiniLM-L6-v2
78+
profiles:
79+
- embeddings
80+
env_file:
81+
- ./docker/embeddings/embeddings.env
82+
- path: ./docker/overrides/embeddings/embeddings.env
83+
required: false
84+
ports:
85+
- "8081:80"
86+
healthcheck:
87+
test: ["CMD", "curl", "-f", "http://localhost:80/health"]
88+
interval: 10s
89+
timeout: 5s
90+
retries: 5
91+
start_period: 30s
92+
7493
rover-compose:
7594
container_name: rover-compose
7695
build:
@@ -160,6 +179,7 @@ services:
160179
image: ${ORCH_BACKEND_TAG:-ghcr.io/workfloworchestrator/orchestrator-core:latest}
161180
env_file:
162181
- ./docker/orchestrator/orchestrator.env
182+
- ./docker/embeddings/embeddings.env
163183
- path: ./docker/overrides/orchestrator/orchestrator.env
164184
required: false
165185
environment:
@@ -193,6 +213,9 @@ services:
193213
condition: service_healthy
194214
redis:
195215
condition: service_healthy
216+
embeddings:
217+
condition: service_healthy
218+
required: false
196219
healthcheck:
197220
start_period: 15s
198221
timeout: 5s

docker/embeddings/README.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Embeddings Service
2+
3+
This directory configures a local embedding server using Hugging Face Text Embeddings Inference (TEI) with the `sentence-transformers/all-MiniLM-L6-v2` model.
4+
5+
## Overview
6+
7+
The embeddings service provides an OpenAI-compatible API for generating text embeddings locally.
8+
9+
- **Model**: sentence-transformers/all-MiniLM-L6-v2
10+
- **Embedding Dimension**: 384
11+
- **API Endpoint**: http://embeddings:80/v1 (internal), http://localhost:8081/v1 (external)
12+
13+
## Prerequisites
14+
15+
To use embeddings for search and agent features, add these to your `.env` file (see `.env.example`):
16+
17+
```env
18+
AGENT_ENABLED=True
19+
SEARCH_ENABLED=True
20+
OPENAI_API_KEY=your-api-key-here # Optional: only needed for agent features or when using OpenAI embeddings
21+
```
22+
23+
## Local Embeddings (Default)
24+
25+
This setup uses a local embedding service with no external API required. The default configuration in `embeddings.env` is:
26+
27+
- `OPENAI_BASE_URL=http://embeddings:80/v1`
28+
- `EMBEDDING_DIMENSION=384`
29+
30+
### Start the orchestrator
31+
32+
Start the orchestrator with the local embeddings service:
33+
34+
```bash
35+
docker compose --profile embeddings up orchestrator
36+
```
37+
38+
## Alternative: Using OpenAI Embeddings
39+
40+
If you prefer to use OpenAI's embedding service instead of running a local model:
41+
42+
### Configuration
43+
44+
Override the embedding settings by editing `docker/overrides/embeddings/embeddings.env`:
45+
46+
```env
47+
OPENAI_BASE_URL=https://api.openai.com/v1
48+
EMBEDDING_DIMENSION=1536
49+
```
50+
51+
### Start the orchestrator
52+
53+
Start only the orchestrator (skips the local embeddings service):
54+
55+
```bash
56+
docker compose up orchestrator
57+
```
58+
59+
## Post-Setup Steps
60+
61+
After starting the services and making sure you have data for the entity you want to index:
62+
63+
### 1. Apply the schema change
64+
65+
This will resize the vector dimension to match your embedding configuration (384 for local, 1536 for OpenAI) and delete existing records:
66+
67+
```bash
68+
docker compose exec orchestrator /home/orchestrator/.venv/bin/python main.py embedding resize
69+
```
70+
71+
⚠️ **Note**: This command will delete all existing embedding records.
72+
73+
### 2. Re-index your data
74+
75+
Example Index subscriptions:
76+
77+
```bash
78+
docker compose exec orchestrator /home/orchestrator/.venv/bin/python main.py index subscriptions
79+
```
80+
81+
## Advanced Configuration
82+
83+
The following configurations use conservative defaults for local/unknown models:
84+
85+
- `EMBEDDING_FALLBACK_MAX_TOKENS=512`: Maximum tokens per embedding request
86+
- `EMBEDDING_MAX_BATCH_SIZE=32`: Maximum batch size for embedding requests
87+
88+
**Note**: These settings are only used as fallbacks for local or unknown models (like the example in this setup). For known providers and models, the system automatically retrieves the correct values via LiteLLM. The fallback values are already configured safely for local models, but can be adjusted if needed in `docker/overrides/embeddings/embeddings.env`.

docker/embeddings/embeddings.env

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Default: Local embeddings service using sentence-transformers/all-MiniLM-L6-v2
2+
# Provides OpenAI-compatible embeddings API locally with no external dependencies
3+
4+
OPENAI_BASE_URL=http://embeddings:80/v1
5+
EMBEDDING_DIMENSION=384
6+
7+
# Alternative: Uncomment below to use OpenAI embeddings instead
8+
# (Requires OPENAI_API_KEY in your .env file)
9+
# OPENAI_BASE_URL=https://api.openai.com/v1
10+
# EMBEDDING_DIMENSION=1536

0 commit comments

Comments
 (0)