Skip to content

Commit 5d3c90f

Browse files
authored
chore (AI-Assistant): add embeddings to docker-compose.dev.yml; improve installation docs (baserow#4563)
* chore (AI-Assistant): add embeddings to docker-compose.dev.yml; improve installation docs * Fix flaky test * Address feedback * Fix just dev down to stop all services
1 parent 62ebe6c commit 5d3c90f

File tree

7 files changed

+146
-41
lines changed

7 files changed

+146
-41
lines changed

backend/Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
182182
apt-get update && \
183183
apt-get upgrade -y && \
184184
apt-get install -y --no-install-recommends \
185+
gettext \
185186
xmlsec1
186187

187188
ENV DOCKER_USER=baserow_docker_user \
@@ -236,6 +237,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
236237
python3.11-dev \
237238
ca-certificates \
238239
postgresql-client-15 \
240+
gettext \
239241
xmlsec1 \
240242
curl \
241243
graphviz \
@@ -275,13 +277,14 @@ USER $UID:$GID
275277
WORKDIR /baserow/backend
276278

277279
# Install all dependencies
280+
COPY --chown=$UID:$GID LICENSE /baserow/LICENSE
281+
COPY --chown=$UID:$GID premium/LICENSE /baserow/premium/LICENSE
282+
COPY --chown=$UID:$GID enterprise/LICENSE /baserow/enterprise/LICENSE
283+
278284
RUN --mount=type=cache,target=$UV_CACHE_DIR,sharing=locked,uid=$UID,gid=$GID \
279-
--mount=type=bind,source=LICENSE,target=/baserow/LICENSE \
280285
--mount=type=bind,source=backend/uv.lock,target=/baserow/backend/uv.lock \
281286
--mount=type=bind,source=backend/pyproject.toml,target=/baserow/backend/pyproject.toml \
282-
--mount=type=bind,source=premium/LICENSE,target=/baserow/premium/LICENSE \
283287
--mount=type=bind,source=premium/backend/pyproject.toml,target=/baserow/premium/backend/pyproject.toml \
284-
--mount=type=bind,source=enterprise/LICENSE,target=/baserow/enterprise/LICENSE \
285288
--mount=type=bind,source=enterprise/backend/pyproject.toml,target=/baserow/enterprise/backend/pyproject.toml \
286289
uv sync --frozen --no-install-workspace --no-install-project
287290

backend/tests/baserow/contrib/database/rows/test_row_history.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,7 @@ def test_create_rows_action_row_history_with_undo_redo(
998998

999999
assert RowHistory.objects.count() == 1
10001000

1001-
history_entries = RowHistory.objects.order_by("row_id").values(
1001+
history_entries = RowHistory.objects.order_by("row_id", "action_timestamp").values(
10021002
"user_id",
10031003
"user_name",
10041004
"table_id",
@@ -1040,7 +1040,7 @@ def test_create_rows_action_row_history_with_undo_redo(
10401040
)
10411041
assert undone
10421042

1043-
history_entries = RowHistory.objects.order_by("row_id").values(
1043+
history_entries = RowHistory.objects.order_by("row_id", "action_timestamp").values(
10441044
"user_id",
10451045
"user_name",
10461046
"table_id",
@@ -1094,7 +1094,7 @@ def test_create_rows_action_row_history_with_undo_redo(
10941094
)
10951095
assert redone
10961096

1097-
history_entries = RowHistory.objects.order_by("row_id").values(
1097+
history_entries = RowHistory.objects.order_by("row_id", "action_timestamp").values(
10981098
"user_id",
10991099
"user_name",
11001100
"table_id",

docker-compose.dev.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ services:
4242
- "${HOST_PUBLISH_IP:-127.0.0.1}:8000:8000"
4343
- "${HOST_PUBLISH_IP:-127.0.0.1}:${BASEROW_BACKEND_DEBUGGER_PORT:-5678}:${BASEROW_BACKEND_DEBUGGER_PORT:-5678}"
4444
volumes:
45+
- ./docs:/baserow/docs
4546
- ./backend:/baserow/backend
4647
- ./premium/backend/:/baserow/premium/backend
4748
- ./enterprise/backend/:/baserow/enterprise/backend
@@ -92,6 +93,7 @@ services:
9293
- OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318
9394
- BASEROW_DANGEROUS_SILKY_ANALYZE_QUERIES
9495
volumes:
96+
- ./docs:/baserow/docs
9597
- ./backend:/baserow/backend
9698
- ./premium/backend/:/baserow/premium/backend
9799
- ./enterprise/backend/:/baserow/enterprise/backend
@@ -110,6 +112,7 @@ services:
110112
- OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318
111113
- BASEROW_DANGEROUS_SILKY_ANALYZE_QUERIES
112114
volumes:
115+
- ./docs:/baserow/docs
113116
- ./backend:/baserow/backend
114117
- ./premium/backend/:/baserow/premium/backend
115118
- ./enterprise/backend/:/baserow/enterprise/backend
@@ -218,6 +221,28 @@ services:
218221
local:
219222
ports:
220223
- "4318:4318"
224+
225+
embeddings:
226+
profiles: ["ai"]
227+
build:
228+
context: ./embeddings
229+
dockerfile: Dockerfile
230+
ports:
231+
- "${HOST_PUBLISH_IP:-127.0.0.1}:7999:80"
232+
networks:
233+
local:
234+
restart: unless-stopped
235+
healthcheck:
236+
test:
237+
[
238+
"CMD",
239+
"python",
240+
"-c",
241+
"import requests; requests.get('http://localhost/health').raise_for_status()",
242+
]
243+
interval: 1m30s
244+
timeout: 10s
245+
retries: 3
221246

222247
volumes:
223248
pgdatadev:

docker-compose.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ services:
320320
BASEROW_AUTOMATION_WORKFLOW_RATE_LIMIT_CACHE_EXPIRY_SECONDS:
321321
BASEROW_AUTOMATION_WORKFLOW_MAX_CONSECUTIVE_ERRORS:
322322
BASEROW_INTEGRATIONS_PERIODIC_MINUTE_MIN:
323+
BASEROW_ENTERPRISE_ASSISTANT_LLM_MODEL:
323324
depends_on:
324325
- backend
325326
networks:
@@ -340,7 +341,8 @@ services:
340341
"/baserow/backend/docker/docker-entrypoint.sh celery-worker-healthcheck",
341342
]
342343
depends_on:
343-
- backend
344+
- db
345+
- redis
344346
volumes:
345347
- media:/baserow/media
346348
networks:
@@ -361,7 +363,8 @@ services:
361363
"/baserow/backend/docker/docker-entrypoint.sh celery-exportworker-healthcheck",
362364
]
363365
depends_on:
364-
- backend
366+
- db
367+
- redis
365368
volumes:
366369
- media:/baserow/media
367370
networks:
@@ -385,7 +388,8 @@ services:
385388
# See https://github.com/sibson/redbeat/issues/129#issuecomment-1057478237
386389
stop_signal: SIGQUIT
387390
depends_on:
388-
- backend
391+
- db
392+
- redis
389393
volumes:
390394
- media:/baserow/media
391395
networks:
Lines changed: 74 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,78 @@
11
# Setup embeddings server in dev environment
22

33
If you would like to use the AI-assistant in combination with the search documentation
4-
tool, then you must add the embeddings server. This
5-
6-
## Docker compose
7-
8-
Add the following to your `docker-compose.dev.yml` and then (re)start your dev server.
9-
The `BASEROW_EMBEDDINGS_API_URL=http://embeddings:80` variable is already configured by
10-
default for the backend container, so it should then work out of the box.
11-
12-
```yaml
13-
embeddings:
14-
build:
15-
context: ./embeddings
16-
dockerfile: Dockerfile
17-
ports:
18-
- "${HOST_PUBLISH_IP:-127.0.0.1}:7999:80"
19-
networks:
20-
local:
21-
restart: unless-stopped
22-
healthcheck:
23-
test:
24-
[
25-
"CMD",
26-
"python",
27-
"-c",
28-
"import requests; requests.get('http://localhost/health').raise_for_status()",
29-
]
30-
interval: 1m30s
31-
timeout: 10s
32-
retries: 3
4+
tool, then you must start the embeddings server.
5+
6+
## Getting Started
7+
8+
You can build and start the embedding service by adding `ai` to the `COMPOSE_PROFILES` environment variable:
9+
10+
```bash
11+
COMPOSE_PROFILES=ai
3312
```
13+
14+
If you need both `ai` and `optional` profiles, combine them with a comma:
15+
16+
```bash
17+
COMPOSE_PROFILES=ai,optional
18+
```
19+
20+
After starting the services, make sure the correct environment variables are set. In particular, `BASEROW_EMBEDDINGS_API_URL` must be set correctly for the embedding server to work. See [ai-assistant.md](../installation/ai-assistant.md) for the full list of required variables.
21+
22+
Then, run the management command to schedule the initial import:
23+
24+
From the host:
25+
26+
```bash
27+
just dcd run --rm backend manage sync_knowledge_base
28+
```
29+
30+
From inside the container:
31+
```bash
32+
./baserow sync_knowledge_base
33+
```
34+
35+
This will schedule a task to import `website_export.csv` containing all the docs and generate the embeddings using the local service. Once completed, asking the assistant to search for docs should show "Exploring the knowledge base..." in the UI when the assistant uses the `search_docs` tool, and the answers should show sources from the docs.
36+
37+
38+
## Troubleshooting
39+
40+
### Kuma is not available in the sidebar
41+
42+
Make sure `BASEROW_ENTERPRISE_ASSISTANT_LLM_MODEL` is set correctly both in the backend and in the frontend. See [ai-assistant.md](../installation/ai-assistant.md) for more information.
43+
44+
### Kuma is visible but it doesn't search the docs
45+
46+
Run the management command to synchronize the docs in the knowledge base:
47+
48+
From the host:
49+
```bash
50+
just dcd run --rm backend manage sync_knowledge_base
51+
```
52+
53+
From inside the container:
54+
```bash
55+
./baserow sync_knowledge_base
56+
```
57+
58+
59+
### The embedding service is not reachable
60+
61+
Verify the server is up and running by executing one of the following commands:
62+
63+
From the host:
64+
```bash
65+
curl -X POST "http://localhost:7999/embed" \
66+
-H "Content-Type: application/json" \
67+
-d '{"texts": "test"}'
68+
```
69+
70+
From inside the container:
71+
72+
```bash
73+
curl -X POST "$BASEROW_EMBEDDINGS_API_URL/embed" \
74+
-H "Content-Type: application/json" \
75+
-d '{"texts": "test"}'
76+
```
77+
78+
This command should return a vector of more than 500 numbers. If it doesn't, check that the embeddings container is running and healthy.

docs/installation/ai-assistant.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ server.
1717

1818
Set the model you want, restart Baserow, and let migrations run.
1919

20+
**Important:** When running Baserow with Docker Compose or multiple services, `BASEROW_ENTERPRISE_ASSISTANT_LLM_MODEL` must be set in **all services** (both backend and frontend) for the assistant to work properly.
21+
2022
```dotenv
2123
# Required
2224
BASEROW_ENTERPRISE_ASSISTANT_LLM_MODEL=openai/gpt-4o
@@ -77,9 +79,11 @@ OpenAI-compatible client accordingly.
7779

7880
## 4) Knowledge-base lookup
7981

80-
If your deployment method doesnt auto-provision embeddings, run the Baserow embeddings
82+
If your deployment method doesn't auto-provision embeddings, run the Baserow embeddings
8183
service and point Baserow at it.
8284

85+
**For developers using Docker Compose:** See [embeddings-server.md](../development/embeddings-server.md) for setup instructions.
86+
8387
### Run the embeddings container
8488

8589
```bash
@@ -95,3 +99,27 @@ BASEROW_EMBEDDINGS_API_URL=http://your-embedder-service
9599
```
96100

97101
After restart and migrations, knowledge-base lookup will be available.
102+
103+
## 5) Troubleshooting
104+
105+
### The assistant doesn't appear or doesn't work
106+
107+
If the assistant is not visible in the sidebar or doesn't work, verify that:
108+
109+
1. `BASEROW_ENTERPRISE_ASSISTANT_LLM_MODEL` is set correctly in **both** the backend and frontend services
110+
2. The required API key for your chosen provider is set (e.g., `OPENAI_API_KEY`, `GROQ_API_KEY`, etc.)
111+
112+
### Verifying environment variables in development
113+
114+
To check if the variables are set correctly in development, from the host run:
115+
116+
```bash
117+
# Check backend
118+
just dcd run --rm backend bash -c env | grep LLM_MODEL
119+
just dcd run --rm backend bash -c env | grep API_KEY
120+
121+
# Check frontend
122+
just dcd run --rm web-frontend bash -c env | grep LLM_MODEL
123+
```
124+
125+
Both commands must return the same value for `BASEROW_ENTERPRISE_ASSISTANT_LLM_MODEL`. If either is missing or they differ, update your environment configuration and restart the services.

justfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ _dev-start:
242242

243243
# Start docker services (redis, db, mailhog, otel-collector)
244244
echo "==> Starting Docker services (redis, db, mailhog, otel-collector)..."
245-
just dc-dev up -d redis db mailhog otel-collector caddy
245+
just dc-dev up -d --scale backend=0 --scale web-frontend=0 --scale celery=0 --scale celery-beat-worker=0 --scale celery-export-worker=0
246246

247247
# Wait for services to be ready
248248
echo "==> Waiting for PostgreSQL to be ready..."
@@ -369,7 +369,7 @@ _dev-stop:
369369

370370
# Stop docker services
371371
echo "Stopping Docker services..."
372-
just dc-dev stop redis db mailhog otel-collector
372+
just dc-dev down
373373

374374
echo ""
375375
echo "Development environment stopped."

0 commit comments

Comments
 (0)