Construct a Celebrity Twitter Chatbot with GPT-4 Make your personal SnoopStein 1. Create a GPT-4 model! 2. Create an ML model with personality 3. Connect your GPT-4 model to Twitter! 4. Writing tweets using SQL 5. Eventually: let’s create the JOB Conclusion

-

That is what you might be constructing: A custom chatbot using MindsDB’s connectors to Twitter, OpenAI’s GPT-4 and custom prompts.
A straightforward example is that this Twitter bot – @Snoop_Stein – who will reply with the suitable context and personality to any tweets which mention him. In case you haven’t tried tweeting to SnoopStein yet, test it out and tweet at your recent friend and rapping physicist! See what it comes up with.

To start:

MindsDB is a preferred open-source low-code machine learning platform that helps developers easily construct #AI-powered solutions. It automates and integrates top machine learning frameworks into the information stack to streamline the mixing of AI into applications, making it accessible to developers of all skill levels.

Now allow us to show you ways we built the Snoop_Stein GPT-4 bot and the way you’ll be able to construct your personal.

Let’s first see how easy it’s to create a machine learning model represented as a virtual ‘AI table’ in MindsDB. In this instance, we are going to call our GPT4 model gptbot_model.

(Keep in mind that GPT-4 API is in HIGH demand and is rate limited, so might be slow. The next steps might each take just a few seconds)

CREATE MODEL mindsdb.gpt_model
PREDICT response
USING
engine = 'openai',
-- api_key = 'your openai key', in MindsDB cloud accounts we offer a default key
model_name = 'gpt-4', -- you can too use 'text-davinci-003', 'gpt-3.5-turbo'
prompt_template = 'reply to {{text}} by {{author_username}}';

Optionally, In case you are using MindsDB on docker or if you would like to use your personal OpenAI API key, simply pass the api_key argument within the USING.

One essential attribute here is prompt_template. That is where we tell GPT learn how to write answers; it’s a template because you’ll be able to pass values from columns, on this case the template accommodates {{author_username}} and {{text}}, which might be replaced from the WHERE variables within the query. Let’s see in motion:

SELECT response from mindsdb.gpt_model WHERE author_username = "mindsdb" AND text="why is gravity so different on the sun?";

As you’ll be able to see, the previous model gave responses that aren’t that exciting. But we will use some prompt template magic to shape how we would like the model to reply. Essentially we use prompt_template to clarify how we would like GPT to formulate its responses.
Let’s create a model mindsdb.snoopstein_model with a prompt template that provides GPT a hybrid personality: he’s half-Einstein, half-Snoop Dogg. A superb physicist who owns the rap game. His name is :

CREATE MODEL mindsdb.snoopstein_model
PREDICT response
USING
engine = 'openai',
max_tokens = 300,
-- api_key = 'your openai key, in cloud accounts we offer one',
model_name = 'gpt-4', -- you can too use 'text-davinci-003' or 'gpt-3.5-turbo'
prompt_template = 'From input message: {{text}}
by from_user: {{author_username}}
In lower than 550 characters, write a Twitter response to {{author_username}} in the next format:
Dear @,

Now let’s test this model:

SELECT response from mindsdb.snoopstein_model
WHERE
author_username = "someuser"
AND text="@snoop_stein, why is gravity so different on the sun?.";

Let’s try one other one:

SELECT response from mindsdb.snoopstein_model
WHERE
author_username = "someuser"
AND text="@snoop_stein, Aside from yourself, which rappers would make one of the best physicists and why?!";

We’re going to arrange a MindsDB SQL statement to hook up with twitter with read-only access:

CREATE DATABASE my_twitter
WITH ENGINE = 'twitter';

This creates a database called my_twitter. This database ships with a table called tweets that we will use to look for tweets in addition to to write down tweets.

You should use the Twitter API to get an inventory of tweets with a selected text or hashtag, within the case below mindsdb or #mindsdb.

SELECT 
id, created_at, author_username, text
FROM my_twitter.tweets
WHERE
query = '(@snoopstein OR @snoop_stein OR #snoopstein OR #snoop_stein) -is:retweet'
AND created_at > '2023-03-20'
LIMIT 20;

Note that the parameter query supports anything that the twitter API supports as query, for more reference, read (https://developer.twitter.com/en/docs/twitter-api/tweets/search/integrate/build-a-query)

Let’s test that this model can generate outputs based on the Snoop Stein personality on many tweets, by joining the model with the tweets table:

SELECT 
t.id AS in_reply_to_tweet_id,
t.text AS input_text,
t.author_username,
t.created_at,
r.response AS text
FROM my_twitter.tweets t
JOIN mindsdb.snoopstein_model r
WHERE t.query = '(@snoopstein OR @snoop_stein OR #snoopstein OR #snoop_stein) -is:retweet -from:snoop_stein'
AND t.created_at > '2023-03-20'
LIMIT 4;

Now we’re on the part where we would like MindsDB to write down responses back into Twitter. For this, you will want to enroll for a Twitter dev account in an effort to actually find a way to write down tweets back into Twitter (write, versus read-only), when you don’t have a Twitter dev account already.

Twitter may take a day or so to approve your recent dev account. Once you might be approved, listed here are the steps to link your Twitter account to MindsDB:
https://www.youtube.com/watch?v=qVe7PeC0sUQ

  1. Open developer portal,
  2. Select the [+ Add app] button to create a recent app
  3. Select [Create new]
  4. Select “Production” and provides it a reputation
  5. Copy and populate within the query:

6. Click Setup on

  • On Permissions Select: Read and Write
  • On Form of app Select: Web App, Automated App or Bot
  • On App info: provide any url for the callback url and website url
  • Click Save

7. Once you might be back within the app settings, click Keys and Tokens

8. Generate Access Token and Secret and populate on the query

  • Access Token
  • Access Token Secret

You may create a recent updated database so it could possibly read and write as follows:

CREATE DATABASE mindsdb.my_twitter_v2
WITH
PARAMETERS = {
"consumer_key": "your twitter App API key",
"consumer_secret": "your twitter App API key secret",
"bearer_token": "your twitter App bearer TOKEN",
"access_token": "your twitter App Access Token",
"access_token_secret": "your twitter App Access Token Secret"
};

Let’s test by tweeting just a few things into the MindsDB Twitter account

INSERT INTO my_twitter_v2.tweets (in_reply_to_tweet_id, text) 
VALUES
(1633439839491092482, 'MindsDB is great! now its super easy to construct ML powered apps using JOBS https://docs.mindsdb.com/sql/tutorials/twitter-chatbot'),
(1634126825377996800, 'Holy!! MindsDB is such a useful gizmo for developers doing ML https://docs.mindsdb.com/sql/tutorials/twitter-chatbot');

Like magic right? Those tweets ought to be live now on twitter, You may check your tweet responses here:
https://twitter.com/MindsDB/status/1633439839491092482
And here:
https://twitter.com/MindsDB/status/1634126825377996800

Note: you’ll be able to insert any of the values of the tweepy function create_tweet: https://docs.tweepy.org/en/stable/client.html#tweepy.Client.create_tweet

The CREATE JOB statement is great because you should utilize it to automate work. The concept is straightforward, you give it a question you would like to execute and the way often. Let’s arrange a job for Snoop Stein!

Let’s write a JOB called gpt4_twitter_job:

  1. Checks for brand spanking new tweets
  2. Generates a response using the OpenAI model
  3. Writes the responses back into Twitter

All of this might be written in a single SQL command

CREATE JOB mindsdb.gpt4_twitter_job AS (
-- insert into tweets the output of joining model and recent tweets
INSERT INTO my_twitter_v2.tweets (in_reply_to_tweet_id, text)
SELECT
t.id AS in_reply_to_tweet_id,
r.response AS text
FROM my_twitter.tweets t
JOIN mindsdb.snoopstein_model r
WHERE
t.query = '(@snoopstein OR @snoop_stein OR #snoopstein OR #snoop_stein) -is:retweet -from:snoop_stein'
AND t.created_at > "{{PREVIOUS_START_DATETIME}}"
limit 10
)
EVERY hour

And there it’s! Every hour, we might be checking for brand spanking new tweets that mention MindsDB, and replying with responses generated by OpenAI GPT-4 using the template from step 2 that may respond in a method that mixes Albert Einstein and Snoop Dogg.

You may check in case your JOB is running effectively

SELECT * FROM jobs WHERE name="gpt4_twitter_job";
SELECT * FROM jobs_history WHERE name="gpt4_twitter_job";

You may stop the job as follows

DROP JOB gpt4_twitter_job

MindsDB is a robust software platform that allows developers to simply construct machine learning features into their applications. With MindsDB, developers can train machine learning models from different data sources and integration platforms, and output the generated ML results or predictions directly into the DB, queryable as tables, or output via the connected application, on this case, Twitter. This instance of constructing a Twitter chatbot with GPT-4 integration will not be the one quick solution that developers can implement in only just a few minutes: MindsDB has many examples, including integration with many other models, including Hugging Face, to construct applications that may summarize text, translate, analyze customer sentiment (product reviews) and perform every kind of business forecasting. You will discover many examples here https://docs.mindsdb.com/nlp/nlp-extended-examples.

In pt. 2 of this series on Twitter and GPT integration, out next week, we are going to walk you thru some recent features that may allow quick creation of a conversational chatbot, that is in a position to keep up the state of historical messages and supply appropriate responses in context. Be certain that you don’t miss it by going here and signing up for our blog updates!

Completely satisfied coding, and please join our community Slack for feedback, support, and questions. We sit up for meeting you there!

admin

What are your thoughts on this topic?
Let us know in the comments below.

1 COMMENT

Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
japanese type beat
japanese type beat
4 months ago

japanese type beat

Share this article

Recent posts

Parking difficulties in complex urban areas ‘solved’ with AI convergence technology

Jeonnam attracted attention by demonstrating long-distance parking for address-based self-driving cars that combined latest technologies of the Fourth Industrial Revolution, corresponding to artificial intelligence...

Figure AI’s $675 Million Breakthrough in Humanoid Robotics

Within the ever-evolving landscape of technology, humanoid robotics stands as a frontier teeming with potential and promise. The concept, once confined to the realms...

Rolls-Royce advances into solar drones…applies for brand new technology patent

It has been reported that Rolls-Royce has entered the sphere of solar-powered drones. News specialist Bnn reported on the twenty sixth (local time) that Rolls-Royce...

The Stacking Ensemble Method

Understand stacking using scikit-learnDiscover the ability of stacking in machine learning — a method that mixes multiple models right into a single powerhouse predictor....

Rosie Brothers holds ‘Preparation for Digital Leading Schools’ webinar for teachers

Three firms, including Rosie Brothers (CEO Sang-min Noh), Classting (CEO Hyeon-gu Cho), and iPortfolio (CEO Seong-yoon Kim), specializing in artificial intelligence (AI) education, held...

Recent comments

AeroSlim Weight loss price on NIA holds AI Ethics Idea Contest Awards Ceremony
skapa binance-konto on LLMs and the Emerging ML Tech Stack
бнанс рестраця для США on Model Evaluation in Time Series Forecasting
Bonus Pendaftaran Binance on Meet Our Fleet
Créer un compte gratuit on About Me — How I give AI artists a hand
To tài khon binance on China completely blocks ‘Chat GPT’
Regístrese para obtener 100 USDT on Reducing bias and improving safety in DALL·E 2
crystal teeth whitening on What babies can teach AI
binance referral bonus on DALL·E API now available in public beta
www.binance.com prihlásení on Neural Networks and Life
Büyü Yapılmışsa Nasıl Bozulur on Introduction to PyTorch: from training loop to prediction
yıldızname on OpenAI Function Calling
Kısmet Bağlılığını Çözmek İçin Dua on Examining Flights within the U.S. with AWS and Power BI
Kısmet Bağlılığını Çözmek İçin Dua on How Meta’s AI Generates Music Based on a Reference Melody
Kısmet Bağlılığını Çözmek İçin Dua on ‘이루다’의 스캐터랩, 기업용 AI 시장에 도전장
uçak oyunu bahis on Thanks!
para kazandıran uçak oyunu on Make Machine Learning Work for You
medyum on Teaching with AI
aviator oyunu oyna on Machine Learning for Beginners !
yıldızname on Final DXA-nation
adet kanı büyüsü on ‘Fake ChatGPT’ app on the App Store
Eşini Eve Bağlamak İçin Dua on LLMs and the Emerging ML Tech Stack
aviator oyunu oyna on AI as Artist’s Augmentation
Büyü Yapılmışsa Nasıl Bozulur on Some Guy Is Trying To Turn $100 Into $100,000 With ChatGPT
Eşini Eve Bağlamak İçin Dua on Latest embedding models and API updates
Kısmet Bağlılığını Çözmek İçin Dua on Jorge Torres, Co-founder & CEO of MindsDB – Interview Series
gideni geri getiren büyü on Joining the battle against health care bias
uçak oyunu bahis on A faster method to teach a robot
uçak oyunu bahis on Introducing the GPT Store
para kazandıran uçak oyunu on Upgrading AI-powered travel products to first-class
para kazandıran uçak oyunu on 10 Best AI Scheduling Assistants (September 2023)
aviator oyunu oyna on 🤗Hugging Face Transformers Agent
Kısmet Bağlılığını Çözmek İçin Dua on Time Series Prediction with Transformers
para kazandıran uçak oyunu on How China is regulating robotaxis
bağlanma büyüsü on MLflow on Cloud
para kazandıran uçak oyunu on Can The 2024 US Elections Leverage Generative AI?
Canbar Büyüsü on The reverse imitation game
bağlanma büyüsü on The NYU AI School Returns Summer 2023
para kazandıran uçak oyunu on Beyond ChatGPT; AI Agent: A Recent World of Staff
Büyü Yapılmışsa Nasıl Bozulur on The Murky World of AI and Copyright
gideni geri getiren büyü on ‘Midjourney 5.2’ creates magical images
Büyü Yapılmışsa Nasıl Bozulur on Microsoft launches the brand new Bing, with ChatGPT inbuilt
gideni geri getiren büyü on MemCon 2023: We’ll Be There — Will You?
adet kanı büyüsü on Meet the Fellow: Umang Bhatt
aviator oyunu oyna on Meet the Fellow: Umang Bhatt
abrir uma conta na binance on The reverse imitation game
código de indicac~ao binance on Neural Networks and Life
Larry Devin Vaughn Wall on How China is regulating robotaxis
Jon Aron Devon Bond on How China is regulating robotaxis
otvorenie úctu na binance on Evolution of Blockchain by DLC
puravive reviews consumer reports on AI-Driven Platform Could Streamline Drug Development
puravive reviews consumer reports on How OpenAI is approaching 2024 worldwide elections
www.binance.com Registrácia on DALL·E now available in beta