-
Notifications
You must be signed in to change notification settings - Fork 42
add simple chatbot definition #156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sallyom
wants to merge
1
commit into
opendatahub-io:main
Choose a base branch
from
sallyom:add-chatbot
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
## Simple chatbot | ||
|
||
This folder holds the resource definitions to launch a chatbot. | ||
Before deploying, update the values in [configmap.yaml](./configmap.yaml) and [secret-token.yaml](./secret-token.yaml) | ||
Specifically, `model_endpoint` value must be provided. | ||
Optionally, `model_name` and `api_key` can be provided. | ||
|
||
Update the deployment as necessary and | ||
run this from the root of the repository | ||
|
||
|
||
```bash | ||
oc apply --kustomize ./kubernetes_yaml/chatbot | ||
``` | ||
|
||
### Chatbot | ||
|
||
The chatbot image is built from | ||
[ai-lab-recipes repository chatbot](https://github.com/containers/ai-lab-recipes/blob/main/recipes/natural_language_processing/chatbot/app/Containerfile) | ||
with the below system prompt line from | ||
[chatbot_ui.py](https://github.com/containers/ai-lab-recipes/blob/main/recipes/natural_language_processing/chatbot/app/chatbot_ui.py) | ||
commented out, since it's not compatible with vLLM: | ||
|
||
```bash | ||
prompt = ChatPromptTemplate.from_messages([ | ||
#("system", "You are world class technical advisor."), | ||
MessagesPlaceholder(variable_name="history"), | ||
("user", "{input}") | ||
]) | ||
``` | ||
|
||
|
||
## Candidate model inference service | ||
|
||
This folder also contains an example InferenceService definition. Modify [candidate-server.yaml](./candidate-server.yaml) as needed to launch a model | ||
from `S3` with `vLLM`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
apiVersion: serving.kserve.io/v1beta1 | ||
kind: InferenceService | ||
metadata: | ||
annotations: | ||
openshift.io/display-name: candidate | ||
serving.knative.openshift.io/enablePassthrough: "true" | ||
sidecar.istio.io/inject: "true" | ||
sidecar.istio.io/rewriteAppHTTPProbers: "true" | ||
finalizers: | ||
- inferenceservice.finalizers | ||
labels: | ||
opendatahub.io/dashboard: "true" | ||
name: candidatemodel | ||
spec: | ||
predictor: | ||
maxReplicas: 1 | ||
minReplicas: 1 | ||
model: | ||
modelFormat: | ||
name: vLLM | ||
name: "" | ||
resources: | ||
limits: | ||
cpu: "2" | ||
memory: 8Gi | ||
nvidia.com/gpu: "1" | ||
requests: | ||
cpu: "1" | ||
memory: 4Gi | ||
nvidia.com/gpu: "1" | ||
runtime: candidatemodel | ||
storage: | ||
# Update to match project s3 storage | ||
key: storage-s3 | ||
# Update path to match candidate-server location | ||
path: xxxxxxxx/xxxxxxxxx/pvc-to-model-op/model/phase_2/model/hf_format/candidate_model/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you do helm chart instead of kustomize, you can easily template this from values/CLI params. Just a thought... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: chatbot-config | ||
data: | ||
model_name: UPDATE | ||
model_endpoint: UPDATE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: chatbot | ||
labels: | ||
app: chatbot | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: chatbot | ||
template: | ||
metadata: | ||
labels: | ||
app: chatbot | ||
spec: | ||
serviceAccountName: chatbot-sa | ||
containers: | ||
- name: chatbot-inference | ||
image: quay.io/sallyom/chatbot:vllm | ||
env: | ||
- name: MODEL_NAME | ||
valueFrom: | ||
configMapKeyRef: | ||
name: chatbot-config | ||
key: model_name | ||
- name: MODEL_ENDPOINT | ||
valueFrom: | ||
configMapKeyRef: | ||
name: chatbot-config | ||
key: model_endpoint | ||
- name: MODEL_ENDPOINT_BEARER | ||
valueFrom: | ||
secretKeyRef: | ||
name: model-token | ||
key: api_key | ||
ports: | ||
- containerPort: 8501 | ||
securityContext: | ||
runAsNonRoot: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
|
||
resources: | ||
- deployment.yaml | ||
- service.yaml | ||
- route.yaml | ||
- sa.yaml | ||
- configmap.yaml | ||
- secret-token.yaml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: route.openshift.io/v1 | ||
kind: Route | ||
metadata: | ||
name: chatbot | ||
labels: | ||
app: chatbot | ||
spec: | ||
to: | ||
kind: Service | ||
name: chatbot-service | ||
port: | ||
targetPort: 8501 | ||
tls: | ||
termination: edge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: chatbot-sa |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: model-token | ||
type: Opaque | ||
stringData: | ||
api_key: "xxx" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: chatbot-service | ||
labels: | ||
app: chatbot | ||
spec: | ||
selector: | ||
app: chatbot | ||
ports: | ||
- protocol: TCP | ||
port: 8501 | ||
targetPort: 8501 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.