5.2. Chatting with the model
Once you serve your model, you can now chat with the model.
The model you are chatting with must match the model you are serving. With the default config.yaml file, the granite-7b-redhat-lab model is the default for serving and chatting.
Prerequisites
- You installed RHEL AI with the bootable container image.
- You initialized InstructLab.
- You downloaded your preferred Granite LLMs.
- You are serving a model.
- You have root user access on your machine.
Procedure
- Since you are serving the model in one terminal window, you must open another terminal to chat with the model.
To chat with the default model, run the following command:
$ ilab model chatTo chat with a specific model run the following command:
$ ilab model chat --model <model-path>Example command
$ ilab model chat --model ~/.cache/instructlab/models/granite-8b-code-instruct
Example output of the chatbot
$ ilab model chat
╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────── system ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Welcome to InstructLab Chat w/ GRANITE-8B-CODE-INSTRUCT (type /h for help) │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
>>> [S][default]
+ Type exit to leave the chatbot.
By default, the ilab CLI does not use authentication. If you want to expose your server to the internet, you can create a API key that connects to your server with the following procedures.
Prerequisites
- You installed the Red Hat Enterprise Linux AI image on bare metal.
- You initialized InstructLab
- You downloaded your preferred Granite LLMs.
- You have root user access on your machine.
Procedure
Create a API key that is held in
$VLLM_API_KEYparameter by running the following command:$ export VLLM_API_KEY=$(python -c 'import secrets; print(secrets.token_urlsafe())')You can view the API key by running the following command:
$ echo $VLLM_API_KEYUpdate the
config.yamlby running the following command:$ ilab config editAdd the following parameters to the
vllm_argssection of yourconfig.yamlfile.serve: vllm: vllm_args: - --api-key - <api-key-string>where
- <api-key-string>
- Specify your API key string.
You can verify that the server is using API key authentication by running the following command:
$ ilab model chatThen, seeing the following error that shows an unauthorized user.
openai.AuthenticationError: Error code: 401 - {'error': 'Unauthorized'}Verify that your API key is working by running the following command:
$ ilab model chat -m granite-7b-redhat-lab --endpoint-url https://inference.rhelai.com/v1 --api-key $VLLM_API_KEYExample output
$ ilab model chat ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────── system ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ Welcome to InstructLab Chat w/ GRANITE-7B-LAB (type /h for help) │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ >>> [S][default]