From be2380b1bfd9058b7f782b5f4ce2ba1389822428 Mon Sep 17 00:00:00 2001 From: James Garside Date: Fri, 25 Oct 2024 10:20:54 +0100 Subject: [PATCH 1/3] Bumbed Python base image for Chatbot Demo --- example-apps/chatbot-rag-app/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example-apps/chatbot-rag-app/Dockerfile b/example-apps/chatbot-rag-app/Dockerfile index e937336c..f298d5d5 100644 --- a/example-apps/chatbot-rag-app/Dockerfile +++ b/example-apps/chatbot-rag-app/Dockerfile @@ -8,7 +8,7 @@ RUN rm -rf /app/frontend/node_modules RUN cd frontend && yarn install RUN cd frontend && REACT_APP_API_HOST=/api yarn build -FROM python:3.9-slim +FROM python:3.10-slim WORKDIR /app RUN mkdir -p ./frontend/build From 654f84222ef83a4a0496f7b73aa62f6c1ddc6845 Mon Sep 17 00:00:00 2001 From: James Garside Date: Wed, 30 Oct 2024 10:32:32 +0000 Subject: [PATCH 2/3] Moved to Rank window size --- example-apps/relevance-workbench/app-api/app.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/example-apps/relevance-workbench/app-api/app.py b/example-apps/relevance-workbench/app-api/app.py index 0ba4044c..31f64989 100644 --- a/example-apps/relevance-workbench/app-api/app.py +++ b/example-apps/relevance-workbench/app-api/app.py @@ -31,7 +31,8 @@ def route_api_search(index): """ [query, rrf, type, k, datasetId] = [ request.args.get("q"), - request.args.get("rrf", default=False, type=lambda v: v.lower() == "true"), + request.args.get("rrf", default=False, + type=lambda v: v.lower() == "true"), request.args.get("type", default="bm25"), request.args.get("k", default=0), request.args.get("dataset", default="movies"), @@ -41,7 +42,8 @@ def route_api_search(index): query, index, **{"rrf": rrf, "k": k, "dataset": datasetId} ) elif type == "bm25": - search_result = run_full_text_search(query, index, **{"dataset": datasetId}) + search_result = run_full_text_search( + query, index, **{"dataset": datasetId}) transformed_search_result = transform_search_response( search_result, datasets[datasetId]["mapping_fields"] ) @@ -165,7 +167,7 @@ def get_hybrid_search_rrf_request_body(query, size=10, **options): "_source": False, "fields": result_fields, "size": size, - "rank": {"rrf": {"window_size": 10, "rank_constant": 2}}, + "rank": {"rrf": {"rank_window_size": 10, "rank_constant": 2}}, "sub_searches": [ {"query": {"bool": {"should": text_expansions}}}, {"query": {"multi_match": {"query": query, "fields": search_fields}}}, @@ -198,7 +200,8 @@ def execute_search_request_using_raw_dsl(index, body): response = es.perform_request( "POST", f"/{index}/_search", - headers={"content-type": "application/json", "accept": "application/json"}, + headers={"content-type": "application/json", + "accept": "application/json"}, body=body, ) From bf558994bf6651e3c97d4757a56b9b2e29d6d3e5 Mon Sep 17 00:00:00 2001 From: James Garside Date: Wed, 30 Oct 2024 10:37:49 +0000 Subject: [PATCH 3/3] Now reads elser model and index from envar --- example-apps/relevance-workbench/app-api/app.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/example-apps/relevance-workbench/app-api/app.py b/example-apps/relevance-workbench/app-api/app.py index 31f64989..e03eb7e3 100644 --- a/example-apps/relevance-workbench/app-api/app.py +++ b/example-apps/relevance-workbench/app-api/app.py @@ -5,6 +5,8 @@ CLOUD_ID = os.environ["CLOUD_ID"] ES_USER = os.environ["ELASTICSEARCH_USERNAME"] ES_PASSWORD = os.environ["ELASTICSEARCH_PASSWORD"] +ELSER_MODEL = os.getenv("ELSER_MODEL", ".elser_model_2") +INDEX = os.getenv("ES_INDEX", "search-movies") datasets = { "movies": { @@ -84,7 +86,7 @@ def get_text_expansion_request_body(query, size=10, **options): te = {"text_expansion": {}} te["text_expansion"][field] = { "model_text": query, - "model_id": ".elser_model_1", + "model_id": ELSER_MODEL, "boost": boost, } text_expansions.append(te) @@ -114,7 +116,7 @@ def get_text_expansion_request_body(query, size=10, **options): te = {"text_expansion": {}} te["text_expansion"][field] = { "model_text": query, - "model_id": ".elser_model_1", + "model_id": ELSER_MODEL, "boost": boost, } text_expansions.append(te) @@ -159,7 +161,7 @@ def get_hybrid_search_rrf_request_body(query, size=10, **options): te = {"text_expansion": {}} te["text_expansion"][field] = { "model_text": query, - "model_id": ".elser_model_1", + "model_id": ELSER_MODEL, "boost": boost, } text_expansions.append(te)