Getting Started
- Create an account on MindsDB cloud (if you don’t have one yet).
- Create a Slack Account and follow this instruction to connect Slack to MindsDB.
- Go to your MindsDB SQL Editor
Usage
This query will create a database calledmindsdb_slack
that comes with the channels
table.
1. Crafting the GPT-4 Model:
Generating a Machine Learning model with MindsDB feels like taking a thrilling elevator ride in Burj Khalifa (You don’t realize, that you made it)! Heregpt_model
represents our GPT-4 Model.
Before creating an OpenAI model, please create an engine, providing your OpenAI API key:
prompt_template
where we tell the GPT model how to respond to the questions asked by the user.
Let’s see how it works:
2. Feeding Personality into Our Model
Alright, so the old model’s replies were good. But hey, we can use some prompt template tricks to make it respond the way we want. Let’s do some Prompt Engineering. Now, let’s make a model calledwhizfizz_model
with a prompt template that gives GPT a wild personality that eludes a playful and magical aura. Imagine scientific knowledge with whimsical storytelling to create a unique and enchanting experience. We’ll call him WhizFizz:
3. Let’s Connect our GPT Model to Slack!
Thechannels
table can be used to search for channels
, messages
, and timestamps
, as well as to post messages into slack channels. These functionalities can also be done by using Slack API or Webhooks.
Let’s query the user’s question and see how our GPT model responds to it, by joining the model with the channels
table:
4. Posting Messages using SQL
We want to respond to the user’s questions by posting the output of our newly created WhizFizz Model. Let’s post the message by querying and joining the user’s questions to our model:5. Let’s automate this
We willCREATE JOB
to schedule periodical execution of SQL statements. Thw job will execute evry hour and do the following:
- Check for new messages using the
LAST
keyword. - Generate an appropriate response with the
whizfizz_model
model. - Insert the response into the channel.
LAST
keyword is used to ensure the query fetches only the newly added messages. Learn more here.
That sums up the tutorial! Here it will continually check for new messages posted in the channel and will respond to all newly added messages providing responses generated by OpenAI’s GPT model in the style of WhizFizz.
To check the jobs
and jobs_history
, we can use the following:
What’s next?Check out How to Generate Images using OpenAI with MindsDB to see another interesting use case of OpenAI integration.