Creating a Securechat App using OpenAI Embeddings and OpenAI Summarisation Models¶
This example will take you through the procedure of deploying a LLM chatbot that can answer questions based on specific dataset(s) provided by you.
Prerequisites¶
You need to create a folder in your workspace. This folder will contain all the documents you are going to use for data ingestion.
You can directly put your document-containing folder in the workspace from your local system by using the filebrowser application on the workspace tab in DKubeX UI, or you can create a folder from the CLI to download the files from their URL.
Export the following variables to your workspace by running the following commands. Replace $OpenAI API KEY$ in the command with your own OpenAI API key.
export PYTHONWARNINGS="ignore"
export OPENAI_API_KEY=$OpenAI API key$
Data ingestion and creating dataset¶
For OpenAI based data ingestion, use the following command. Replace the parts enclose with ‘$’ as shown in the example commands.
d3x fm docs add -d $dataset name$ -s $path to document containing folder$ -emb openai
d3x fm docs add -d contracts -s ./Contracts -emb openai
To check the datasets that has been created, stored and are ready to use, use the following command:
d3x fm docs show datasets
Note
For additional commands regarding datasets, documents, and backup, please visit Additional Commands Regarding Datasets, Documents & Backup.
Querying the dataset¶
You can test the datasets by querying them without creating the chatbots by using the following commands.
Note
A valid OpenAI API key has to be available in the LLM Keys tab in the Keys page in SecureLLM. For help regarding this, please visit Adding and Deleting OpenAI Keys.
Note
You need to create a SecureLLM API key before running these commands. For help regarding this, please visit Creating and Deleting Application Keys.
export OPENAI_API_KEY=$securellm API key$
d3x fm query -i openai -d $dataset name$ -emb openai --securellm
export OPENAI_API_KEY=sk-6wfu3yq-xtereni-xmg7wq6-rd2c3qp
d3x fm query -i openai -d contracts -emb openai --securellm
Creating and accessing the Securechat application¶
To create a Securechat application using OpenAI embeddings and OpenAI summarisation, use the following command. Make sure to replace the parts enclosed within $ with the appropriate details as shown in the example.
d3x apps create --name=$app name$ -e OPENAI_API_BASE=http://securellm-be.securellm:3005/v1 -e OPENAI_API_HOST=http://securellm-be.securellm:3005 -e OPENAI_API_KEY=$securellm API key$ -e DATASET=$dataset name$ -e embeddings=openai -e APP_TITLE="$app description$" -p 3000 --dockeruser=dkubex123 --dockerpsw=dckr_pat_LkREM9aGwlC_-o4bprMjrKf0uS0 -rt false -ip /$text to be added after DKubeX IP to open the chatbot$ --publish=true --memory=4 --cpu=1 dkubex123/llmapp:securechat
d3x apps create --name=nda -e OPENAI_API_BASE=http://securellm-be.securellm:3005/v1 -e OPENAI_API_HOST=http://securellm-be.securellm:3005 -e OPENAI_API_KEY=sk-tsvl4wy-d36e6uy-tkkrqta-rdsoqvy -e DATASET=contracts -e embeddings=openai -e APP_TITLE="NDA Contracts" -p 3000 --dockeruser=dkubex123 --dockerpsw=dckr_pat_LkREM9aGwlC_-o4bprMjrKf0uS0 -rt false -ip /nda --publish=true --memory=4 --cpu=1 dkubex123/llmapp:securechat
To check the status of the app deployment, use the following command:
d3x apps list
Once the app deployment status becomes running, you can access the application from the Apps page of DKubeX UI.