Skip to content

Commit 0476431

Browse files
committed
Regenerate RAG Template
Signed-off-by: Maysun J Faisal <[email protected]>
1 parent 2054a38 commit 0476431

20 files changed

+87
-18
lines changed

scripts/envs/audio-to-text

+3
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ export SUPPORT_DETR=false
1717

1818
# for gitlab case, since gitlab does not have pipeline webhook pre-set to trigger the initial build
1919
export APP_INTERFACE_CONTAINER="quay.io/redhat-ai-dev/audio-to-text:latest"
20+
21+
# Database configurations
22+
export SUPPORT_DB=false

scripts/envs/chatbot

+3
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ export VLLM_MAX_MODEL_LEN=4096
2121

2222
# for gitlab case, since gitlab does not have pipeline webhook pre-set to trigger the initial build
2323
export APP_INTERFACE_CONTAINER="quay.io/redhat-ai-dev/chatbot:latest"
24+
25+
# Database configurations
26+
export SUPPORT_DB=false

scripts/envs/codegen

+3
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ export VLLM_MAX_MODEL_LEN=6144
2222

2323
# for gitlab case, since gitlab does not have pipeline webhook pre-set to trigger the initial build
2424
export APP_INTERFACE_CONTAINER="quay.io/redhat-ai-dev/codegen:latest"
25+
26+
# Database configurations
27+
export SUPPORT_DB=false

scripts/envs/object-detection

+3
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ export SUPPORT_DETR=true
1717

1818
# for gitlab case, since gitlab does not have pipeline webhook pre-set to trigger the initial build
1919
export APP_INTERFACE_CONTAINER="quay.io/redhat-ai-dev/object_detection:latest"
20+
21+
# Database configurations
22+
export SUPPORT_DB=false

scripts/envs/rag

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export APP_TAGS='["ai", "llamacpp", "vllm", "python", "rag", "database"]'
55
export APP_RUN_COMMAND="streamlit run rag_app.py"
66
export INIT_CONTAINER="quay.io/redhat-ai-dev/granite-7b-lab:latest"
77
export INIT_CONTAINER_COMMAND="['/usr/bin/install', '/model/model.file', '/shared/']"
8+
export MODEL_PATH="/model/model.file"
89
export APP_PORT=8501
910
export MODEL_SERVICE_CONTAINER="quay.io/ai-lab/llamacpp_python:latest"
1011
export MODEL_SERVICE_PORT=8001
@@ -21,7 +22,7 @@ export VLLM_MAX_MODEL_LEN=4096
2122
# for gitlab case, since gitlab does not have pipeline webhook pre-set to trigger the initial build
2223
export APP_INTERFACE_CONTAINER="quay.io/redhat-ai-dev/rag:latest"
2324

24-
# Database Required
25+
# Database configurations
2526
export SUPPORT_DB=true
2627
export DB_CONTAINER="quay.io/redhat-ai-dev/chroma:latest"
2728
export DB_PORT=8000

scripts/import-ai-lab-samples

+3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ for f in */; do
6262
if [ $SUPPORT_DETR == false ]; then
6363
sed -i '/# SED_DETR_MODEL_SERVER_START/,/# SED_DETR_MODEL_SERVER_END/d' $DEST/template.yaml
6464
fi
65+
if [ $SUPPORT_DB == false ]; then
66+
sed -i '/# SED_DB_START/,/# SED_DB_END/d' $DEST/template.yaml
67+
fi
6568

6669
source $ROOT_DIR/properties
6770
cat $DEST/template.yaml | envsubst > $DEST/new-template.yaml

skeleton/gitops-template/components/http/base/deployment-database.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ metadata:
44
labels:
55
app.kubernetes.io/instance: ${{ values.name }}-database
66
app.kubernetes.io/managed-by: kustomize
7-
app.kubernetes.io/name: ${{ values.name }}-database
7+
app.kubernetes.io/name: ${{ values.name }}-database
88
app.kubernetes.io/part-of: ${{ values.name }}
99
name: ${{ values.name }}-database
1010
spec:
1111
replicas: 1
1212
selector:
1313
matchLabels:
14-
app.kubernetes.io/instance: ${{ values.name }}-database
14+
app.kubernetes.io/instance: ${{ values.name }}-database
1515
template:
1616
metadata:
1717
labels:
18-
app.kubernetes.io/instance: ${{ values.name }}-database
18+
app.kubernetes.io/instance: ${{ values.name }}-database
1919
spec:
2020
containers:
2121
- image: ${{ values.dbContainer }}

skeleton/template.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -312,10 +312,12 @@ spec:
312312
modelEndpoint: ${{ parameters.modelEndpoint }}
313313
# for RHOAI
314314
rhoaiSelected: ${{ parameters.rhoaiSelected }}
315+
# SED_DB_START
315316
# Database is required for the RAG templates
316317
dbRequired: ${SUPPORT_DB}
317318
dbContainer: ${DB_CONTAINER}
318319
dbPort: ${DB_PORT}
320+
# SED_DB_END
319321
- action: fs:rename
320322
id: renameComponentDir
321323
name: Rename Component Directory

templates/rag/content/Containerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM registry.access.redhat.com/ubi9/python-311:1-66.1720018730
1+
FROM registry.access.redhat.com/ubi9/python-311:1-72.1722518949
22
### Update sqlite for chroma
33
USER root
44
RUN dnf remove sqlite3 -y
@@ -21,4 +21,4 @@ EXPOSE 8501
2121
ENV HF_HUB_CACHE=/rag/models/
2222
RUN mkdir -p /rag/models/
2323
RUN chgrp -R 0 /rag/models/ && chmod -R g=u /rag/models/
24-
ENTRYPOINT [ "streamlit", "run" ,"rag_app.py" ]
24+
ENTRYPOINT [ "streamlit", "run" ,"rag_app.py" ]
Loading
Loading
Loading
Loading
Loading

templates/rag/content/docs/rhoai.md

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Running Samples in OpenShift AI
2+
3+
This document will outline how you can run build and run your sample applications within an OpenShift AI workbench.
4+
5+
## Prerequisites
6+
7+
- Red Hat OpenShift AI installed, and `Create workbench for OpenShift AI` selected during component creation.
8+
- `oc` cli installed
9+
- `oc` can be downloaded from https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/
10+
- Permissions to run `oc port-forward` on the cluster, specifically an account with the following roles:
11+
- `get`, `create`, and `list` for the `pods/portforward` subresource
12+
13+
## Running the Sample
14+
15+
1) While on Console, navigate to the `OpenShift AI` by clicking the square "apps" icon on the top-right corner (next to the notifications icon). `Openshift AI` will be listed in the dropdown list
16+
17+
![image](./.assets/access-openshift-ai.png)
18+
19+
2) Go to the `Data Science Projects` section and access your application's project named `{{ values.namespace }}`
20+
21+
![image](./.assets/data-science-projects.png)
22+
23+
3) Access the `workbench` named `{{ values.name }}-notebook`
24+
25+
![image](./.assets/access-workbench.png)
26+
27+
4) Go to `File->Open` and select `Terminal`
28+
29+
![image](./.assets/open-terminal.png)
30+
31+
5) In the terminal, run `cd ${{ values.name }}` to navigate to your sample app's directory
32+
33+
6) Run `pip install --upgrade -r requirements.txt` to install the dependencies for your application
34+
35+
7) Run `${{ values.appRunCommand }}` to run the sample in the workbench.
36+
37+
## Accessing the Sample
38+
39+
With the sample app now running, the following steps will allow you to access the sample app in your browser:
40+
41+
1) Navigate back to the OpenShift AI dashboard, and find the name of your workbench.
42+
![image](./.assets/workbench-name.png)
43+
44+
2) In a terminal window on your machine, run `oc get pods -l app=<workbench-name>`. This will retrieve the name of the pod where the workbench is running.
45+
46+
3) Run `oc port-forward <pod-name> ${{ values.appPort }}` to port forward the sample application's port to your local machine.
47+
48+
4) Finally, visit `http://localhost:${{ values.appPort }}` in your browser to access the application.

templates/rag/content/manage_vectordb.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,4 @@ def clear_db(self):
7878
self.client.drop_collection(self.collection_name)
7979
print("Cleared DB")
8080
except:
81-
print("Couldn't clear the collection possibly because it doesn't exist")
81+
print("Couldn't clear the collection possibly because it doesn't exist")

templates/rag/content/mkdocs.yml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ nav:
55
- Source Component: source-component.md
66
- Pipelines: pipelines.md
77
- GitOps Application: gitops-application.md
8+
- OpenShift AI: rhoai.md
89

910
plugins:
1011
- techdocs-core
+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
langchain-openai==0.1.7
22
langchain==0.1.20
3-
chromadb==0.5.4
3+
chromadb==0.5.5
44
sentence-transformers==2.7.0
55
streamlit==1.34.0
66
pypdf==4.2.0
77
pymilvus==2.4.1
8+

templates/rag/db/Containerfile

-2
This file was deleted.

templates/rag/template.yaml

+11-8
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ apiVersion: scaffolder.backstage.io/v1beta3
22
# https://backstage.io/docs/features/software-catalog/descriptor-format#kind-template
33
kind: Template
44
metadata:
5-
name: rag2
6-
title: RAG2 Chatbot Application
7-
description: "RAG2 Chatbot Application example with an LLM and a Vector database enabled"
5+
name: rag
6+
title: RAG Chatbot Application
7+
description: RAG Chatbot Application example with an LLM and a Vector database enabled
88
tags: ["ai", "llamacpp", "vllm", "python", "rag", "database"]
99
spec:
1010
type: service
@@ -177,8 +177,9 @@ spec:
177177
namespace: ${{ parameters.namespace }}
178178
repoURL: https://${{ parameters.githubServer if parameters.hostType === 'GitHub' else parameters.gitlabServer }}/${{ parameters.repoOwner }}/${{ parameters.repoName }}-gitops
179179
srcRepoURL: https://${{ parameters.githubServer if parameters.hostType === 'GitHub' else parameters.gitlabServer }}/${{ parameters.repoOwner }}/${{ parameters.repoName }}
180-
appContainer: ${{ 'quay.io/redhat-ai-dev/ai-template-bootstrap-app:latest' if parameters.hostType === 'GitHub' else 'quay.io/redhat-ai-dev/chatbot:latest' }}
180+
appContainer: ${{ 'quay.io/redhat-ai-dev/ai-template-bootstrap-app:latest' if parameters.hostType === 'GitHub' else 'quay.io/redhat-ai-dev/rag:latest' }}
181181
appPort: 8501
182+
appRunCommand: "streamlit run rag_app.py"
182183
modelServiceContainer: quay.io/ai-lab/llamacpp_python:latest
183184
modelServicePort: 8001
184185
# Renders all the template variables into the files and directory names and content, and places the result in the workspace.
@@ -191,15 +192,15 @@ spec:
191192
values:
192193
name: ${{ parameters.name }}
193194
namespace: ${{ parameters.namespace }}
194-
description: Secure Supply Chain Example for RAG Application example with LLM enabled chat applications
195+
description: Secure Supply Chain Example for RAG Chatbot Application example with an LLM and a Vector database enabled
195196
dockerfile: Containerfile
196197
buildContext: .
197198
gitopsSecretName: ${{ 'gitops-auth-secret' if parameters.hostType === 'GitHub' else 'gitlab-auth-secret' }}
198199
image: '${{ parameters.imageRegistry }}/${{ parameters.imageOrg }}/${{ parameters.imageName }}'
199-
tags: '["ai", "llamacpp", "vllm", "python"]'
200+
tags: '["ai", "llamacpp", "vllm", "python", "rag", "database"]'
200201
owner: ${{ parameters.owner }}
201202
repoSlug: '${{ parameters.imageOrg }}/${{ parameters.imageName }}'
202-
defaultBranch: ${{ parameters.branch }}
203+
defaultBranch: ${{ parameters.branch }}
203204
- id: fetch-github-action
204205
name: Fetch GitHub Action
205206
action: fetch:plain
@@ -270,7 +271,7 @@ spec:
270271
initContainer: quay.io/redhat-ai-dev/granite-7b-lab:latest
271272
modelInitCommand: "['/usr/bin/install', '/model/model.file', '/shared/']"
272273
modelPath: "/model/model.file"
273-
appContainer: ${{ 'quay.io/redhat-ai-dev/ai-template-bootstrap-app:latest' if parameters.hostType === 'GitHub' else 'quay.io/redhat-ai-dev/chatbot:latest' }}
274+
appContainer: ${{ 'quay.io/redhat-ai-dev/ai-template-bootstrap-app:latest' if parameters.hostType === 'GitHub' else 'quay.io/redhat-ai-dev/rag:latest' }}
274275
appPort: 8501
275276
modelServiceContainer: quay.io/ai-lab/llamacpp_python:latest
276277
modelServicePort: 8001
@@ -285,10 +286,12 @@ spec:
285286
modelEndpoint: ${{ parameters.modelEndpoint }}
286287
# for RHOAI
287288
rhoaiSelected: ${{ parameters.rhoaiSelected }}
289+
# SED_DB_START
288290
# Database is required for the RAG templates
289291
dbRequired: true
290292
dbContainer: quay.io/redhat-ai-dev/chroma:latest
291293
dbPort: 8000
294+
# SED_DB_END
292295
- action: fs:rename
293296
id: renameComponentDir
294297
name: Rename Component Directory

0 commit comments

Comments
 (0)