Skip to content

Commit 7b2b282

Browse files
authored
Merge pull request #52 from workfloworchestrator/support-llm-features
Support for search/agent features in the core package
2 parents f36efd9 + bfeabb3 commit 7b2b282

File tree

5 files changed

+155
-7
lines changed

5 files changed

+155
-7
lines changed

.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,8 @@ export PYTHONUNBUFFERED=1
33
export OAUTH2_ACTIVE=0
44
export LOG_LEVEL=DEBUG
55
export WEBSOCKET_BROADCASTER_URL="redis://localhost:6379"
6+
7+
export OPENAI_API_KEY=None
8+
export AGENT_ENABLED=False
9+
export SEARCH_ENABLED=False
610
# export COMPOSE_PROFILES=lso # unhash the start of this line to also start up lso container

docker-compose.yml

Lines changed: 26 additions & 1 deletion
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,10 +179,13 @@ 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:
166186
LSO_ENABLED: ${COMPOSE_PROFILES:+True}
187+
AGENT_ENABLED: ${AGENT_ENABLED:-False}
188+
SEARCH_ENABLED: ${SEARCH_ENABLED:-False}
167189
ports:
168190
- "8080:8080"
169191
- "5678:5678" #Enable Python debugger
@@ -179,7 +201,7 @@ services:
179201
- ./graphql_federation.py:/home/orchestrator/graphql_federation.py
180202
- ./utils:/home/orchestrator/utils
181203
- ./services:/home/orchestrator/services
182-
- ./requirements.txt:/home/orchestrator/requirements.txt
204+
- ./pyproject.toml:/home/orchestrator/pyproject.toml
183205
- ./alembic.ini:/home/orchestrator/alembic.ini
184206
- ./translations:/home/orchestrator/translations
185207
- ./templates:/home/orchestrator/templates
@@ -191,6 +213,9 @@ services:
191213
condition: service_healthy
192214
redis:
193215
condition: service_healthy
216+
embeddings:
217+
condition: service_healthy
218+
required: false
194219
healthcheck:
195220
start_period: 15s
196221
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: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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+
EMBEDDING_MAX_BATCH_SIZE=32 # Not required when using OpenAI
7+
8+
# Alternative: Uncomment below to use OpenAI embeddings instead
9+
# (Requires OPENAI_API_KEY in your .env file)
10+
# OPENAI_BASE_URL=https://api.openai.com/v1
11+
# EMBEDDING_DIMENSION=1536

docker/orchestrator/entrypoint.sh

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,40 @@
44
PATH=$PATH:~/.local/bin
55

66
# Install extra requirements for orchestrator
7-
pip install -r requirements.txt
7+
pip install uv
8+
uv sync
9+
source .venv/bin/activate
810

911
if [ -f ${CORE_OVERRIDE}/pyproject.toml ]; then
10-
echo "⏭️ Use editable install of orchestrator-core with dev and test dependencies"
11-
pip install -e $CORE_OVERRIDE[dev,test]
12+
echo "⏭️ Use editable install of orchestrator-core"
13+
14+
extras=""
15+
[ "${AGENT_ENABLED,,}" = "true" ] && extras+="agent,"
16+
[ "${SEARCH_ENABLED,,}" = "true" ] && extras+="search,"
17+
18+
install_spec="$CORE_OVERRIDE"
19+
if [ -n "$extras" ]; then
20+
# Example: '/path/to/core[agent,search]'
21+
install_spec="$CORE_OVERRIDE"'['"${extras%,}"']'
22+
fi
23+
24+
echo "Installing with spec: '$install_spec'"
25+
uv pip install -e "$install_spec"
1226

1327
# Run any missing migrations on the database
1428
python main.py db upgrade heads
1529

16-
uvicorn --host 0.0.0.0 --port 8080 $UVICORN_ARGS main:app --reload --proxy-headers --reload-dir $CORE_OVERRIDE
30+
uvicorn --host 0.0.0.0 --port 8080 $UVICORN_ARGS main:app --reload --proxy-headers \
31+
--reload-dir $CORE_OVERRIDE \
32+
--reload-dir products \
33+
--reload-dir services \
34+
--reload-dir translations \
35+
--reload-dir utils \
36+
--reload-dir workflows
1737
else
1838
# Run any missing migrations on the database
1939
python main.py db upgrade heads
2040

21-
echo "⏭️ Use pip installed orchestrator-core $(pip freeze | grep orchestrator-core)"
41+
echo "⏭️ Use orchestrator-core as specified in pyproject.toml $(uv pip freeze | grep orchestrator-core)"
2242
uvicorn --host 0.0.0.0 --port 8080 $UVICORN_ARGS main:app --reload --proxy-headers
23-
fi
43+
fi

0 commit comments

Comments
 (0)