Skip to content

Commit caa2cfe

Browse files
committed
add simple chatbot definition
Signed-off-by: sallyom <[email protected]>
1 parent b4cb233 commit caa2cfe

File tree

6 files changed

+102
-0
lines changed

6 files changed

+102
-0
lines changed

chatbot/README.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
## Simple chatbot
2+
3+
This folder holds the resource definitions to launch a chatbot given a `MODEL_ENDPOINT` and `MODEL_ENDPOINT_BEARER`.
4+
5+
Update the deployment as necessary and
6+
run this from the root of the repository
7+
8+
9+
```bash
10+
oc apply --kustomize ./chatbot
11+
```
12+
13+
TODO:
14+
- get `MODEL_ENDPOINT` from configmap or secret. Currently you need to update it in deployment.yaml
15+
16+
### Chatbot
17+
18+
The chatbot image is built from
19+
[ai-lab-recipes repository chatbot](https://github.com/containers/ai-lab-recipes/blob/main/recipes/natural_language_processing/chatbot/app/Containerfile)
20+
with the below system prompt line from
21+
[chatbot_ui.py](https://github.com/containers/ai-lab-recipes/blob/main/recipes/natural_language_processing/chatbot/app/chatbot_ui.py)
22+
commented out, since it's not compatible with vLLM:
23+
24+
```bash
25+
prompt = ChatPromptTemplate.from_messages([
26+
#("system", "You are world class technical advisor."),
27+
MessagesPlaceholder(variable_name="history"),
28+
("user", "{input}")
29+
])
30+
```

chatbot/deployment.yaml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: chatbot
5+
labels:
6+
app: chatbot
7+
spec:
8+
replicas: 1
9+
selector:
10+
matchLabels:
11+
app: chatbot
12+
template:
13+
metadata:
14+
labels:
15+
app: chatbot
16+
spec:
17+
serviceAccountName: chatbot-sa
18+
containers:
19+
- name: chatbot-inference
20+
image: quay.io/sallyom/chatbot:latest
21+
env:
22+
- name: MODEL_ENDPOINT
23+
# Update this value to the endpoint of a running model server
24+
value: https://candidatemodel-server-example/v1
25+
- name: MODEL_ENDPOINT_BEARER
26+
valueFrom:
27+
secretKeyRef:
28+
name: judge-server
29+
key: api_key
30+
ports:
31+
- containerPort: 8501
32+
securityContext:
33+
runAsNonRoot: true

chatbot/kustomization.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
4+
resources:
5+
- deployment.yaml
6+
- service.yaml
7+
- route.yaml
8+
- sa.yaml

chatbot/route.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: route.openshift.io/v1
2+
kind: Route
3+
metadata:
4+
name: chatbot
5+
labels:
6+
app: chatbot
7+
spec:
8+
to:
9+
kind: Service
10+
name: chatbot-service
11+
port:
12+
targetPort: 8501
13+
tls:
14+
termination: edge

chatbot/sa.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
name: chatbot-sa

chatbot/service.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: chatbot-service
5+
labels:
6+
app: chatbot
7+
spec:
8+
selector:
9+
app: chatbot
10+
ports:
11+
- protocol: TCP
12+
port: 8501
13+
targetPort: 8501

0 commit comments

Comments
 (0)