From 46060609858043fde51d24a446752d3dfdbfe8e8 Mon Sep 17 00:00:00 2001 From: Miguel Grinberg Date: Tue, 10 Sep 2024 17:29:15 +0100 Subject: [PATCH] Update the chatbot example to use newer SparseVectorStrategy class --- example-apps/chatbot-rag-app/api/chat.py | 4 +- example-apps/chatbot-rag-app/requirements.txt | 295 +++++++++--------- 2 files changed, 144 insertions(+), 155 deletions(-) diff --git a/example-apps/chatbot-rag-app/api/chat.py b/example-apps/chatbot-rag-app/api/chat.py index bc96020d..54380010 100644 --- a/example-apps/chatbot-rag-app/api/chat.py +++ b/example-apps/chatbot-rag-app/api/chat.py @@ -1,4 +1,4 @@ -from langchain_elasticsearch import ElasticsearchStore +from langchain_elasticsearch import ElasticsearchStore, SparseVectorStrategy from llm_integrations import get_llm from elasticsearch_client import ( elasticsearch_client, @@ -20,7 +20,7 @@ store = ElasticsearchStore( es_connection=elasticsearch_client, index_name=INDEX, - strategy=ElasticsearchStore.SparseVectorRetrievalStrategy(model_id=ELSER_MODEL), + strategy=SparseVectorStrategy(model_id=ELSER_MODEL), ) diff --git a/example-apps/chatbot-rag-app/requirements.txt b/example-apps/chatbot-rag-app/requirements.txt index 494af517..47c55d69 100644 --- a/example-apps/chatbot-rag-app/requirements.txt +++ b/example-apps/chatbot-rag-app/requirements.txt @@ -2,277 +2,267 @@ # This file is autogenerated by pip-compile with Python 3.11 # by the following command: # -# pip-compile requirements.in +# pip-compile # -aiohttp==3.10.0 - # via - # cohere - # langchain - # langchain-community - # openai +aiohappyeyeballs==2.4.0 + # via aiohttp +aiohttp==3.10.5 + # via langchain aiosignal==1.3.1 # via aiohttp -annotated-types==0.5.0 +annotated-types==0.7.0 # via pydantic -anyio==3.7.1 +anyio==4.4.0 # via # httpx - # langchain-core -async-timeout==4.0.3 - # via aiohttp -attrs==23.1.0 + # openai +attrs==24.2.0 # via aiohttp -backoff==2.2.1 - # via cohere -blinker==1.6.2 +blinker==1.8.2 # via flask -boto3==1.28.61 - # via -r requirements.in -botocore==1.31.61 +boto3==1.35.15 + # via + # -r requirements.in + # cohere +botocore==1.35.15 # via # boto3 # s3transfer -build==1.0.3 +build==1.2.2 # via pip-tools -cachetools==5.3.1 +cachetools==5.5.0 # via google-auth -certifi==2023.7.22 +certifi==2024.8.30 # via # elastic-transport # httpcore # httpx # requests -charset-normalizer==3.2.0 - # via - # aiohttp - # requests +charset-normalizer==3.3.2 + # via requests click==8.1.7 # via # flask # pip-tools -cohere==4.52 +cohere==5.9.1 # via -r requirements.in -dataclasses-json==0.5.14 - # via - # langchain - # langchain-community -elastic-transport==8.4.0 +distro==1.9.0 + # via openai +docstring-parser==0.16 + # via google-cloud-aiplatform +elastic-transport==8.15.0 # via elasticsearch -elasticsearch==8.12.1 +elasticsearch[vectorstore-mmr]==8.15.1 # via # -r requirements.in # langchain-elasticsearch -exceptiongroup==1.2.0 +exceptiongroup==1.2.2 # via -r requirements.in -fastavro==1.9.4 +fastavro==1.9.7 # via cohere -filelock==3.13.1 +filelock==3.16.0 # via huggingface-hub -flask==2.3.3 +flask==3.0.3 # via # -r requirements.in # flask-cors -flask-cors==4.0.0 +flask-cors==5.0.0 # via -r requirements.in -frozenlist==1.4.0 +frozenlist==1.4.1 # via # aiohttp # aiosignal -fsspec==2024.2.0 +fsspec==2024.9.0 # via huggingface-hub -google-api-core[grpc]==2.14.0 +google-api-core[grpc]==2.19.2 # via # google-cloud-aiplatform # google-cloud-bigquery # google-cloud-core # google-cloud-resource-manager # google-cloud-storage -google-auth==2.23.2 +google-auth==2.34.0 # via # google-api-core + # google-cloud-aiplatform + # google-cloud-bigquery # google-cloud-core + # google-cloud-resource-manager # google-cloud-storage -google-cloud-aiplatform==1.35.0 +google-cloud-aiplatform==1.65.0 # via -r requirements.in -google-cloud-bigquery==3.13.0 +google-cloud-bigquery==3.25.0 # via google-cloud-aiplatform -google-cloud-core==2.3.3 +google-cloud-core==2.4.1 # via # google-cloud-bigquery # google-cloud-storage -google-cloud-resource-manager==1.10.4 +google-cloud-resource-manager==1.12.5 # via google-cloud-aiplatform -google-cloud-storage==2.11.0 +google-cloud-storage==2.18.2 # via google-cloud-aiplatform -google-crc32c==1.5.0 - # via google-resumable-media -google-resumable-media==2.6.0 +google-crc32c==1.6.0 + # via + # google-cloud-storage + # google-resumable-media +google-resumable-media==2.7.2 # via # google-cloud-bigquery # google-cloud-storage -googleapis-common-protos[grpc]==1.61.0 +googleapis-common-protos[grpc]==1.65.0 # via # google-api-core # grpc-google-iam-v1 # grpcio-status -grpc-google-iam-v1==0.12.7 +grpc-google-iam-v1==0.13.1 # via google-cloud-resource-manager -grpcio==1.59.3 +grpcio==1.66.1 # via # google-api-core - # google-cloud-bigquery # googleapis-common-protos # grpc-google-iam-v1 # grpcio-status -grpcio-status==1.59.3 +grpcio-status==1.66.1 # via # -r requirements.in # google-api-core h11==0.14.0 # via httpcore -httpcore==1.0.4 +httpcore==1.0.5 # via httpx -httpx==0.25.2 - # via mistralai -huggingface-hub==0.21.4 +httpx==0.27.2 + # via + # cohere + # langchain-mistralai + # langsmith + # openai +httpx-sse==0.4.0 + # via + # cohere + # langchain-mistralai +huggingface-hub==0.24.6 # via tokenizers -idna==3.4 +idna==3.8 # via # anyio # httpx # requests # yarl -importlib-metadata==6.8.0 - # via - # -r requirements.in - # cohere -itsdangerous==2.1.2 +importlib-metadata==8.4.0 + # via -r requirements.in +itsdangerous==2.2.0 # via flask -jinja2==3.1.2 +jinja2==3.1.4 # via flask +jiter==0.5.0 + # via openai jmespath==1.0.1 # via # boto3 # botocore jsonpatch==1.33 - # via - # langchain - # langchain-core -jsonpointer==2.4 + # via langchain-core +jsonpointer==3.0.0 # via jsonpatch -langchain==0.1.9 +langchain==0.2.16 # via -r requirements.in -langchain-community==0.0.27 - # via langchain -langchain-core==0.1.30 +langchain-core==0.2.38 # via # langchain - # langchain-community # langchain-elasticsearch # langchain-mistralai -langchain-elasticsearch==0.1.0 + # langchain-text-splitters +langchain-elasticsearch==0.2.2 # via -r requirements.in -langchain-mistralai==0.0.5 +langchain-mistralai==0.1.13 # via -r requirements.in -langsmith==0.1.10 +langchain-text-splitters==0.2.4 + # via langchain +langsmith==0.1.117 # via # langchain - # langchain-community # langchain-core -markupsafe==2.1.3 +markupsafe==2.1.5 # via # jinja2 # werkzeug -marshmallow==3.20.1 - # via dataclasses-json -mistralai==0.1.3 - # via langchain-mistralai -multidict==6.0.4 +multidict==6.1.0 # via # aiohttp # yarl -mypy-extensions==1.0.0 - # via typing-inspect -numexpr==2.8.5 +numexpr==2.10.1 # via -r requirements.in numpy==1.26.4 # via + # elasticsearch # langchain - # langchain-community - # langchain-elasticsearch # numexpr - # pandas - # pyarrow # shapely -openai==0.27.9 +openai==1.44.1 # via -r requirements.in -orjson==3.9.15 - # via - # langsmith - # mistralai -packaging==23.2 +orjson==3.10.7 + # via langsmith +packaging==24.1 # via # build # google-cloud-aiplatform # google-cloud-bigquery # huggingface-hub # langchain-core - # marshmallow -pandas==2.2.1 - # via mistralai -pip-tools==7.3.0 +parameterized==0.9.0 + # via cohere +pip-tools==7.4.1 # via -r requirements.in -proto-plus==1.22.3 +proto-plus==1.24.0 # via + # google-api-core # google-cloud-aiplatform - # google-cloud-bigquery # google-cloud-resource-manager -protobuf==4.25.1 +protobuf==5.28.0 # via # google-api-core # google-cloud-aiplatform - # google-cloud-bigquery # google-cloud-resource-manager # googleapis-common-protos # grpc-google-iam-v1 # grpcio-status # proto-plus -pyarrow==15.0.1 - # via mistralai -pyasn1==0.5.0 +pyasn1==0.6.0 # via # pyasn1-modules # rsa -pyasn1-modules==0.3.0 +pyasn1-modules==0.4.0 # via google-auth -pydantic==2.5.2 +pydantic==2.9.1 # via + # cohere + # google-cloud-aiplatform # langchain # langchain-core # langsmith - # mistralai -pydantic-core==2.14.5 - # via pydantic -pyproject-hooks==1.0.0 - # via build -python-dateutil==2.8.2 + # openai +pydantic-core==2.23.3 + # via + # cohere + # pydantic +pyproject-hooks==1.1.0 + # via + # build + # pip-tools +python-dateutil==2.9.0.post0 # via # botocore # google-cloud-bigquery - # pandas -python-dotenv==1.0.0 +python-dotenv==1.0.1 # via -r requirements.in -pytz==2024.1 - # via pandas -pyyaml==6.0.1 +pyyaml==6.0.2 # via # huggingface-hub # langchain - # langchain-community # langchain-core -regex==2023.10.3 +regex==2024.7.24 # via tiktoken -requests==2.31.0 +requests==2.32.3 # via # cohere # google-api-core @@ -280,64 +270,63 @@ requests==2.31.0 # google-cloud-storage # huggingface-hub # langchain - # langchain-community - # langchain-core # langsmith - # openai # tiktoken rsa==4.9 # via google-auth -s3transfer==0.7.0 +s3transfer==0.10.2 # via boto3 -shapely==2.0.2 +shapely==2.0.6 # via google-cloud-aiplatform +simsimd==5.1.2 + # via elasticsearch six==1.16.0 # via python-dateutil -sniffio==1.3.0 +sniffio==1.3.1 # via # anyio # httpx -sqlalchemy==2.0.20 - # via - # langchain - # langchain-community -tenacity==8.2.3 + # openai +sqlalchemy==2.0.34 + # via langchain +tenacity==8.5.0 # via # langchain - # langchain-community # langchain-core -tiktoken==0.5.1 +tiktoken==0.7.0 # via -r requirements.in -tokenizers==0.15.2 - # via langchain-mistralai -tqdm==4.66.1 +tokenizers==0.20.0 + # via + # cohere + # langchain-mistralai +tqdm==4.66.5 # via # huggingface-hub # openai -typing-extensions==4.7.1 +types-requests==2.32.0.20240907 + # via cohere +typing-extensions==4.12.2 # via + # cohere # huggingface-hub + # langchain-core + # openai # pydantic # pydantic-core # sqlalchemy - # typing-inspect -typing-inspect==0.9.0 - # via dataclasses-json -tzdata==2024.1 - # via pandas -urllib3==1.26.16 +urllib3==2.2.2 # via # botocore - # cohere # elastic-transport # requests -werkzeug==2.3.7 + # types-requests +werkzeug==3.0.4 # via flask -wheel==0.41.3 +wheel==0.44.0 # via pip-tools -yarl==1.9.2 +yarl==1.11.1 # via aiohttp -zipp==3.17.0 +zipp==3.20.1 # via importlib-metadata # The following packages are considered to be unsafe in a requirements file: