Skip to content

Commit

Permalink
Separate RAG content and embeddings images, use CPU version of torch …
Browse files Browse the repository at this point in the history
…library
  • Loading branch information
TamiTakamiya committed Jan 22, 2025
1 parent b3357b1 commit d99e179
Show file tree
Hide file tree
Showing 7 changed files with 1,060 additions and 917 deletions.
2 changes: 1 addition & 1 deletion .tekton/ansible-chatbot-service-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ spec:
- name: COMMIT_SHA
value: $(tasks.clone-repository.results.commit)
- name: BUILD_ARGS
value: ["IMAGE_TAGS=pr-{{pull_request_number}} pr-{{pull_request_number}}.$(tasks.git-metadata.results.commit-timestamp)", "GIT_COMMIT=$(tasks.clone-repository.results.commit)", "RAG_CONTENTS_SUB_FOLDER=vector_db/aap_product_docs", "LIGHTSPEED_RAG_CONTENT_IMAGE=quay.io/ansible/aap-rag-content:latest"]
value: ["IMAGE_TAGS=pr-{{pull_request_number}} pr-{{pull_request_number}}.$(tasks.git-metadata.results.commit-timestamp)", "GIT_COMMIT=$(tasks.clone-repository.results.commit)", "RAG_CONTENTS_SUB_FOLDER=vector_db/aap_product_docs", "LIGHTSPEED_RAG_CONTENT_IMAGE=quay.io/ansible/aap-rag-content:latest", "LIGHTSPEED_RAG_EMBEDDINGS_IMAGE=quay.io/ansible/aap-rag-embeddings-image:latest"]
- name: BUILD_ARGS_FILE
value: $(params.build-args-file)
runAfter:
Expand Down
2 changes: 1 addition & 1 deletion .tekton/ansible-chatbot-service-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ spec:
- name: TARGET_STAGE
value: production
- name: BUILD_ARGS
value: [ "IMAGE_TAGS=latest 1.0.$(tasks.git-metadata.results.commit-timestamp)", "GIT_COMMIT=$(tasks.clone-repository.results.commit)", "RAG_CONTENTS_SUB_FOLDER=vector_db/aap_product_docs", "LIGHTSPEED_RAG_CONTENT_IMAGE=quay.io/ansible/aap-rag-content:latest"]
value: [ "IMAGE_TAGS=latest 1.0.$(tasks.git-metadata.results.commit-timestamp)", "GIT_COMMIT=$(tasks.clone-repository.results.commit)", "RAG_CONTENTS_SUB_FOLDER=vector_db/aap_product_docs", "LIGHTSPEED_RAG_CONTENT_IMAGE=quay.io/ansible/aap-rag-content:latest", "LIGHTSPEED_RAG_EMBEDDINGS_IMAGE=quay.io/ansible/aap-rag-embeddings-image:latest"]
runAfter:
- prefetch-dependencies
taskRef:
Expand Down
3 changes: 2 additions & 1 deletion Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
WORKDIR /app-root

COPY --from=lightspeed-rag-content /rag/${RAG_CONTENTS_SUB_FOLDER} ${APP_ROOT}/${RAG_CONTENTS_SUB_FOLDER}
COPY --from=lightspeed-rag-content /rag/embeddings_model ./embeddings_model
COPY --from=lightspeed-rag-embeddings /rag/embeddings_model ./embeddings_model

# Add explicit files and directories
# (avoid accidental inclusion of local directories or env files or credentials)
COPY runner.py requirements.txt ./

RUN pip3.11 install --upgrade pip
RUN pip3.11 install --no-cache-dir -r requirements.txt

COPY ols ./ols
Expand Down
411 changes: 124 additions & 287 deletions pdm.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ description = "Road-core service is an AI powered assistant that runs on OpenShi
authors = []
dependencies = [
"pdm==2.21.0",
"torch==2.5.1",
'torch@http://download.pytorch.org/whl/cpu/torch-2.5.1%2Bcpu-cp311-cp311-linux_x86_64.whl ; platform_system != "Darwin"',
'torch-macos@http://download.pytorch.org/whl/cpu/torch-2.5.1-cp311-none-macosx_11_0_arm64.whl ; platform_system == "Darwin"',
"pandas==2.1.4",
"httpx==0.27.2",
"fastapi==0.115.6",
Expand Down
1,552 changes: 927 additions & 625 deletions requirements.txt

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion scripts/build-container-aap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# Build an ansible-chatbot-service image locally

AAP_VERSION=v2.5
LIGHTSPEED_RAG_CONTENT_IMAGE=quay.io/ttakamiy/aap-rag-content:latest
LIGHTSPEED_RAG_CONTENT_IMAGE=quay.io/ansible/aap-rag-content:latest
LIGHTSPEED_RAG_EMBEDDINGS_IMAGE=quay.io/ansible/aap-rag-embeddings-image:latest
RAG_CONTENTS_SUB_FOLDER=vector_db/aap_product_docs

CACHE_OPTS=""
Expand All @@ -16,6 +17,7 @@ podman build \
${CACHE_OPTS} \
--build-arg=VERSION="${AAP_VERSION}" \
--build-arg=LIGHTSPEED_RAG_CONTENT_IMAGE="${LIGHTSPEED_RAG_CONTENT_IMAGE}" \
--build-arg=LIGHTSPEED_RAG_EMBEDDINGS_IMAGE="${LIGHTSPEED_RAG_EMBEDDINGS_IMAGE}" \
--build-arg=RAG_CONTENTS_SUB_FOLDER="${RAG_CONTENTS_SUB_FOLDER}" \
-t "${AAP_API_IMAGE:-quay.io/ansible/ansible-chatbot-service:latest}" \
-f Containerfile
Expand Down

0 comments on commit d99e179

Please sign in to comment.