Skip to content

Commit ced23e5

Browse files
chatbot-rag-app: implements vertex tracing with langtrace (elastic#386)
Signed-off-by: Adrian Cole <adrian.cole@elastic.co>
1 parent e46b563 commit ced23e5

File tree

3 files changed

+51
-47
lines changed

3 files changed

+51
-47
lines changed

example-apps/chatbot-rag-app/api/llm_integrations.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ def init_openai_chat(temperature):
2020

2121

2222
def init_vertex_chat(temperature):
23+
# VertexAI is not yet in EDOT. Use the Langtrace Python SDK instead
24+
from langtrace_python_sdk.instrumentation import VertexAIInstrumentation
25+
26+
VertexAIInstrumentation().instrument()
2327
return ChatVertexAI(
2428
model_name=os.getenv("CHAT_MODEL"), streaming=True, temperature=temperature
2529
)

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ services:
1111
env_file:
1212
- .env
1313
command: flask create-index
14+
volumes:
15+
# VertexAI uses a file for GOOGLE_APPLICATION_CREDENTIALS, not an API key
16+
- ${HOME}/.config/gcloud:/root/.config/gcloud
1417
extra_hosts: # send localhost traffic to the docker host, e.g. your laptop
1518
- "localhost:host-gateway"
1619

@@ -23,6 +26,9 @@ services:
2326
context: .
2427
env_file:
2528
- .env
29+
volumes:
30+
# VertexAI uses a file for GOOGLE_APPLICATION_CREDENTIALS, not an API key
31+
- ${HOME}/.config/gcloud:/root/.config/gcloud
2632
ports:
2733
- "4000:4000"
2834
extra_hosts: # send localhost traffic to the docker host, e.g. your laptop

example-apps/chatbot-rag-app/requirements.txt

Lines changed: 41 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,19 @@ anyio==4.8.0
1818
# via
1919
# httpx
2020
# openai
21-
attrs==24.3.0
21+
attrs==25.1.0
2222
# via aiohttp
2323
blinker==1.9.0
2424
# via flask
25-
boto3==1.36.2
26-
# via langchain-aws
27-
botocore==1.36.2
25+
boto3==1.36.7
26+
# via
27+
# langchain-aws
28+
# langtrace-python-sdk
29+
botocore==1.36.7
2830
# via
2931
# boto3
3032
# s3transfer
31-
cachetools==5.5.0
33+
cachetools==5.5.1
3234
# via google-auth
3335
certifi==2024.12.14
3436
# via
@@ -41,13 +43,13 @@ charset-normalizer==3.4.1
4143
# via requests
4244
click==8.1.8
4345
# via flask
44-
cohere==5.13.8
46+
cohere==5.13.11
4547
# via langchain-cohere
4648
colorama==0.4.6
4749
# via langtrace-python-sdk
4850
dataclasses-json==0.6.7
4951
# via langchain-community
50-
deprecated==1.2.15
52+
deprecated==1.2.18
5153
# via
5254
# opentelemetry-api
5355
# opentelemetry-exporter-otlp-proto-grpc
@@ -61,13 +63,13 @@ elastic-opentelemetry==0.6.1
6163
# via -r requirements.in
6264
elastic-transport==8.17.0
6365
# via elasticsearch
64-
elasticsearch[vectorstore-mmr]==8.17.0
66+
elasticsearch[vectorstore-mmr]==8.17.1
6567
# via
6668
# -r requirements.in
6769
# langchain-elasticsearch
6870
fastavro==1.10.0
6971
# via cohere
70-
filelock==3.16.1
72+
filelock==3.17.0
7173
# via
7274
# huggingface-hub
7375
# transformers
@@ -85,24 +87,24 @@ fsspec==2024.12.0
8587
# via
8688
# huggingface-hub
8789
# langtrace-python-sdk
88-
google-api-core[grpc]==2.24.0
90+
google-api-core[grpc]==2.24.1
8991
# via
9092
# google-cloud-aiplatform
9193
# google-cloud-bigquery
9294
# google-cloud-core
9395
# google-cloud-resource-manager
9496
# google-cloud-storage
95-
google-auth==2.37.0
97+
google-auth==2.38.0
9698
# via
9799
# google-api-core
98100
# google-cloud-aiplatform
99101
# google-cloud-bigquery
100102
# google-cloud-core
101103
# google-cloud-resource-manager
102104
# google-cloud-storage
103-
google-cloud-aiplatform==1.77.0
105+
google-cloud-aiplatform==1.78.0
104106
# via langchain-google-vertexai
105-
google-cloud-bigquery==3.27.0
107+
google-cloud-bigquery==3.29.0
106108
# via google-cloud-aiplatform
107109
google-cloud-core==2.4.1
108110
# via
@@ -131,14 +133,14 @@ googleapis-common-protos[grpc]==1.66.0
131133
# opentelemetry-exporter-otlp-proto-http
132134
grpc-google-iam-v1==0.14.0
133135
# via google-cloud-resource-manager
134-
grpcio==1.69.0
136+
grpcio==1.70.0
135137
# via
136138
# google-api-core
137139
# googleapis-common-protos
138140
# grpc-google-iam-v1
139141
# grpcio-status
140142
# opentelemetry-exporter-otlp-proto-grpc
141-
grpcio-status==1.69.0
143+
grpcio-status==1.70.0
142144
# via google-api-core
143145
h11==0.14.0
144146
# via httpcore
@@ -183,52 +185,49 @@ jsonpatch==1.33
183185
# via langchain-core
184186
jsonpointer==3.0.0
185187
# via jsonpatch
186-
langchain==0.3.14
188+
langchain==0.3.15
187189
# via
188190
# -r requirements.in
189191
# langchain-community
190192
langchain-aws==0.2.11
191193
# via -r requirements.in
192-
langchain-cohere==0.3.4
194+
langchain-cohere==0.4.2
193195
# via -r requirements.in
194-
langchain-community==0.3.14
195-
# via langchain-experimental
196-
langchain-core==0.3.30
196+
langchain-community==0.3.15
197+
# via langchain-cohere
198+
langchain-core==0.3.31
197199
# via
198200
# langchain
199201
# langchain-aws
200202
# langchain-cohere
201203
# langchain-community
202204
# langchain-elasticsearch
203-
# langchain-experimental
204205
# langchain-google-vertexai
205206
# langchain-mistralai
206207
# langchain-openai
207208
# langchain-text-splitters
208209
langchain-elasticsearch==0.3.2
209210
# via -r requirements.in
210-
langchain-experimental==0.3.4
211-
# via langchain-cohere
212-
langchain-google-vertexai==2.0.11
211+
langchain-google-vertexai==2.0.12
213212
# via -r requirements.in
214213
langchain-mistralai==0.2.4
215214
# via -r requirements.in
216-
langchain-openai==0.3.1
215+
langchain-openai==0.3.2
217216
# via -r requirements.in
218217
langchain-text-splitters==0.3.5
219218
# via langchain
220-
langsmith==0.2.11
219+
langsmith==0.3.2
221220
# via
222221
# langchain
223222
# langchain-community
224223
# langchain-core
225-
langtrace-python-sdk==3.3.26
224+
langtrace-python-sdk==3.5.0
226225
# via -r requirements.in
227226
markupsafe==3.0.2
228227
# via
229228
# jinja2
230229
# werkzeug
231-
marshmallow==3.25.1
230+
marshmallow==3.26.0
232231
# via dataclasses-json
233232
multidict==6.1.0
234233
# via
@@ -242,10 +241,9 @@ numpy==2.2.2
242241
# langchain
243242
# langchain-aws
244243
# langchain-community
245-
# pandas
246244
# shapely
247245
# transformers
248-
openai==1.59.9
246+
openai==1.60.2
249247
# via langchain-openai
250248
opentelemetry-api==1.29.0
251249
# via
@@ -322,15 +320,11 @@ packaging==24.2
322320
# opentelemetry-instrumentation
323321
# opentelemetry-instrumentation-sqlalchemy
324322
# transformers
325-
pandas==2.2.3
326-
# via langchain-cohere
327-
parameterized==0.9.0
328-
# via cohere
329323
propcache==0.2.1
330324
# via
331325
# aiohttp
332326
# yarl
333-
proto-plus==1.25.0
327+
proto-plus==1.26.0
334328
# via
335329
# google-api-core
336330
# google-cloud-aiplatform
@@ -353,7 +347,7 @@ pyasn1==0.6.1
353347
# rsa
354348
pyasn1-modules==0.4.1
355349
# via google-auth
356-
pydantic==2.9.2
350+
pydantic==2.10.6
357351
# via
358352
# cohere
359353
# google-cloud-aiplatform
@@ -367,7 +361,7 @@ pydantic==2.9.2
367361
# openai
368362
# pydantic-settings
369363
# trace-attributes
370-
pydantic-core==2.23.4
364+
pydantic-core==2.27.2
371365
# via
372366
# cohere
373367
# pydantic
@@ -377,11 +371,8 @@ python-dateutil==2.9.0.post0
377371
# via
378372
# botocore
379373
# google-cloud-bigquery
380-
# pandas
381374
python-dotenv==1.0.1
382375
# via pydantic-settings
383-
pytz==2024.2
384-
# via pandas
385376
pyyaml==6.0.2
386377
# via
387378
# huggingface-hub
@@ -412,7 +403,7 @@ requests-toolbelt==1.0.0
412403
# via langsmith
413404
rsa==4.9
414405
# via google-auth
415-
s3transfer==0.11.1
406+
s3transfer==0.11.2
416407
# via boto3
417408
safetensors==0.5.2
418409
# via transformers
@@ -433,8 +424,6 @@ sqlalchemy==2.0.37
433424
# langchain
434425
# langchain-community
435426
# langtrace-python-sdk
436-
tabulate==0.9.0
437-
# via langchain-cohere
438427
tenacity==9.0.0
439428
# via
440429
# langchain
@@ -455,10 +444,12 @@ tqdm==4.67.1
455444
# huggingface-hub
456445
# openai
457446
# transformers
458-
trace-attributes==7.1.0
447+
trace-attributes==7.1.1
459448
# via langtrace-python-sdk
460-
transformers==4.48.0
449+
transformers==4.48.1
461450
# via langtrace-python-sdk
451+
types-pyyaml==6.0.12.20241230
452+
# via langchain-cohere
462453
types-requests==2.32.0.20241016
463454
# via cohere
464455
typing-extensions==4.12.2
@@ -477,8 +468,6 @@ typing-extensions==4.12.2
477468
# typing-inspect
478469
typing-inspect==0.9.0
479470
# via dataclasses-json
480-
tzdata==2024.2
481-
# via pandas
482471
ujson==5.10.0
483472
# via langtrace-python-sdk
484473
urllib3==2.3.0
@@ -499,6 +488,11 @@ yarl==1.18.3
499488
# via aiohttp
500489
zipp==3.21.0
501490
# via importlib-metadata
491+
zstandard==0.23.0
492+
# via langsmith
493+
494+
# The following packages are considered to be unsafe in a requirements file:
495+
# setuptools
502496
opentelemetry-instrumentation-asyncio==0.50b0
503497
opentelemetry-instrumentation-dbapi==0.50b0
504498
opentelemetry-instrumentation-logging==0.50b0

0 commit comments

Comments
 (0)