Skip to content

Commit d11312a

Browse files
chatbot-rag-app: updates to latest openai and uses uv to compile deps (#458)
Signed-off-by: Adrian Cole <[email protected]>
1 parent b250393 commit d11312a

File tree

6 files changed

+267
-125
lines changed

6 files changed

+267
-125
lines changed

docker/docker-compose-elastic.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ configs:
6262
6363
services:
6464
elasticsearch:
65-
image: docker.elastic.co/elasticsearch/elasticsearch:9.0.0
65+
image: docker.elastic.co/elasticsearch/elasticsearch:9.0.1
6666
container_name: elasticsearch
6767
ports:
6868
- 9200:9200
@@ -98,7 +98,7 @@ services:
9898
depends_on:
9999
elasticsearch:
100100
condition: service_healthy
101-
image: docker.elastic.co/elasticsearch/elasticsearch:9.0.0
101+
image: docker.elastic.co/elasticsearch/elasticsearch:9.0.1
102102
container_name: elasticsearch_settings
103103
restart: 'no'
104104
# gen-ai assistants in kibana save state in a way that requires system
@@ -113,7 +113,7 @@ services:
113113
'
114114
115115
kibana:
116-
image: docker.elastic.co/kibana/kibana:9.0.0
116+
image: docker.elastic.co/kibana/kibana:9.0.1
117117
container_name: kibana
118118
depends_on:
119119
elasticsearch_settings:
@@ -137,7 +137,7 @@ services:
137137
interval: 1s
138138

139139
otel-collector:
140-
image: docker.elastic.co/elastic-agent/elastic-otel-collector:9.0.0
140+
image: docker.elastic.co/elastic-agent/elastic-otel-collector:9.0.1
141141
container_name: otel-collector
142142
depends_on:
143143
elasticsearch:

example-apps/chatbot-rag-app/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
FROM node:22-alpine AS build-step
1+
FROM node:24-alpine AS build-step
22
WORKDIR /app
33
ENV PATH=/node_modules/.bin:$PATH
44
COPY frontend ./frontend
55
RUN cd frontend && yarn install
66
RUN cd frontend && REACT_APP_API_HOST=/api yarn build
77

88
# Use glibc-based image to get pre-compiled wheels for grpcio and tiktoken
9-
FROM python:3.12-slim
9+
FROM python:3.13-slim
1010

1111
WORKDIR /app
1212
RUN mkdir -p ./frontend/build

example-apps/chatbot-rag-app/README.md

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -159,21 +159,18 @@ nvm use --lts
159159
#### Configure your Python environment
160160

161161
Before we can run the app, we need a working Python environment with the
162-
correct packages installed:
162+
correct packages installed. This uses [uv][uv] for efficiency.
163163

164164
```bash
165-
python3 -m venv .venv
166-
source .venv/bin/activate
167-
# Install dotenv which is a portable way to load environment variables.
168-
pip install "python-dotenv[cli]"
169-
pip install -r requirements.txt
165+
uv venv --python 3.13
166+
uv pip install -r requirements.txt
170167
```
171168

172169
#### Create your Elasticsearch index
173170

174171
First, ingest the data into elasticsearch:
175172
```bash
176-
dotenv run -- flask create-index
173+
uv run -q --env-file .env flask create-index
177174
```
178175

179176
*Note*: This may take several minutes to complete
@@ -182,7 +179,7 @@ dotenv run -- flask create-index
182179

183180
Now, run the app, which listens on http://localhost:4000
184181
```bash
185-
dotenv run -- python api/app.py
182+
uv run -q --env-file .env python api/app.py
186183
```
187184

188185
## Advanced
@@ -196,7 +193,7 @@ This happens automatically, when using docker. If running with python directly,
196193
prefix `python` with `opentelemetry-instrument` to enable OpenTelemetry.
197194

198195
```bash
199-
dotenv run -- opentelemetry-instrument python api/app.py
196+
uv run -q --env-file .env opentelemetry-instrument python api/app.py
200197
```
201198

202199
[env.example](env.example) defaults to use an OpenTelemetry Collector,
@@ -219,20 +216,7 @@ To update package versions, recreate [requirements.txt](requirements.txt) and
219216
reinstall like this. Once checked in, any commands above will use updates.
220217

221218
```bash
222-
rm -rf .venv requirements.txt
223-
python3 -m venv .venv
224-
source .venv/bin/activate
225-
pip install --upgrade pip
226-
# Install dev requirements for pip-compile and edot-bootstrap
227-
pip install pip-tools elastic-opentelemetry
228-
# Recreate requirements.txt
229-
pip-compile
230-
# Install main dependencies
231-
pip install -r requirements.txt
232-
# Add opentelemetry instrumentation for these dependencies
233-
edot-bootstrap >> requirements.txt
234-
# Install opentelemetry dependencies
235-
pip install -r requirements.txt
219+
docker compose run --rm recreate-requirements
236220
```
237221

238222
### Elasticsearch index and chat_history index
@@ -265,3 +249,4 @@ docker compose up --build --force-recreate
265249
[docker-compose]: ../../docker/docker-compose-elastic.yml
266250
[edot-python]: https://github.com/elastic/elastic-otel-python
267251
[k8s-manifest-elastic]: ../../k8s/k8s-manifest-elastic.yml
252+
[uv]: https://docs.astral.sh/uv/getting-started/installation/

example-apps/chatbot-rag-app/docker-compose.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,26 @@ services:
3333
- "4000:4000"
3434
extra_hosts: # send localhost traffic to the docker host, e.g. your laptop
3535
- "localhost:host-gateway"
36+
37+
recreate-requirements:
38+
image: python:3.13-slim
39+
volumes:
40+
- .:/src
41+
working_dir: /build
42+
profiles:
43+
- util # don't start this as a service
44+
command: >
45+
bash -c "
46+
pip install uv &&
47+
uv venv &&
48+
cp /src/requirements.in . &&
49+
# First, install the application requirements into the venv
50+
uv pip compile requirements.in -o requirements.txt &&
51+
uv pip sync requirements.txt &&
52+
# Next, detect and add instrumentation requirements
53+
uv pip install elastic-opentelemetry &&
54+
uv run edot-bootstrap >> requirements.in &&
55+
# Finally, recreate a new pinned requirements.txt
56+
uv pip compile requirements.in -o requirements.txt
57+
cp requirements.txt /src/requirements.txt
58+
"

0 commit comments

Comments
 (0)