After watching this youtube video
I wanted to observe different AI models conversing with each other, specifically GPT-3.5, GPT-4, and Google Bard.
To achieve this, I utilized the OpenAI API and the Google Bard CLI to create a conversation, just for fun.
You can find the Google Bard CLI on Github. I edited codes from here:
I envisioned the conversation to resemble a group chat, as outlined below:
use async_openai::{
types::{ChatCompletionRequestMessageArgs, CreateChatCompletionRequestArgs, Role},
Client as OpenAIClient,
};
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
// ...
'outer: loop {
// Send the message to all AI models and receive their responses
let gpt3_5_future = talk_gpt(message.clone(), &openai_client, "gpt-3.5-turbo");
let gpt4_future = talk_gpt(message.clone(), &openai_client, "gpt-4");
let bard_future = chatbot.ask(&message);
let (gpt3_5_response, gpt4_response, bard_response) =
tokio::join!(gpt3_5_future, gpt4_future, bard_future);
let gpt3_5_response = gpt3_5_response?;
let gpt4_response = gpt4_response?;
let temp_bard_response = bard_response.expect("Failed to get response from Bard");
let bard_response = temp_bard_response.get("content").unwrap().as_str().unwrap();
// Print and store the responses
println!("< GPT-3.5: {}", gpt3_5_response);
println!("> GPT-4: {}", gpt4_response);
println!("< Bard: {}\n", bard_response);
if let Some(file_path) = &file_path {
append_to_file(file_path, &format!("**GPT-3.5**: {}\n\n", gpt3_5_response)).await?;
append_to_file(file_path, &format!("**GPT-4**: {}\n\n", gpt4_response)).await?;
append_to_file(file_path, &format!("**Bard**: {}\n\n", bard_response)).await?;
}
// Set the new message based on user input or a randomly selected response from one of the AI models
print!("Type a new message or press Enter to continue...");
stdout().flush().unwrap(); // Flush the output
// catch ctrl+c and user input
loop {
// Receive input from the input thread with a timeout
match input_rx.recv_timeout(Duration::from_millis(100)) {
Ok(input) => {
if input.trim().is_empty() {
// Randomly select a response from one of the AI models as the new message
let responses = vec![&gpt3_5_response, &gpt4_response, bard_response];
message = responses
.choose(&mut rand::thread_rng())
.unwrap()
.to_string();
} else {
message = input.trim().to_string();
}
break;
}
Err(RecvTimeoutError::Timeout) => {
if exit_flag.load(Ordering::SeqCst) {
println!("\nCtrl+C detected, exiting...");
break 'outer;
}
}
Err(_) => break,
}
}
}
}
async fn talk_gpt(
interest: String,
openai_client: &OpenAIClient,
model: &str,
) -> Result<String, Box<dyn Error>> {
let request = CreateChatCompletionRequestArgs::default()
.max_tokens(512u16)
.model(model)
.messages([
ChatCompletionRequestMessageArgs::default()
.role(Role::System)
.content("You are a helpful assistant.")
.build()?,
ChatCompletionRequestMessageArgs::default()
.role(Role::User)
.content(interest)
.build()?,
])
.build()?;
let response = openai_client.chat().create(request).await?;
Ok(response.choices[0].message.content.clone())
}
- I send an initial message to all the AI models.
- Each AI model responds to the first message, and we then randomly select one of their replies.
- With the chosen reply, all the AI models attempt to respond to it, which may result in an AI model replying to its own message.
However, the outcome was somewhat disappointing.
So, I am sharing a different format where each AI model talks to the next in a sequential order (Bard -> GPT-3.5 -> GPT-4 -> Bard …).
'outer: loop {
// Bard replies
print!("\rBard: thinking...");
stdout().flush().unwrap(); // Flush the output
let response = chatbot.ask(&message).await?;
let bard_response = response.get("content").unwrap().as_str().unwrap();
// Use \r to move the cursor to the beginning of the line and print the response
println!("\r< Bard: {}\n", bard_response);
if let Some(file_path) = &file_path {
append_to_file(file_path, &format!("**Bard**: {}\n\n", bard_response)).await?;
}
message = bard_response.to_string(); // Set the new message to Bard's response
// GPT-3.5 replies
print!("\rGPT-3.5: thinking...");
stdout().flush().unwrap(); // Flush the output
// GPT-3.5 talks
let gpt3_response = talk_gpt(message.clone(), &openai_client, "gpt-3.5-turbo").await?;
println!("\r< GPT-3.5: {}", gpt3_response);
if let Some(file_path) = &file_path {
append_to_file(file_path, &format!("**GPT-3.5**: {}\n\n", gpt3_response)).await?;
}
// GPT-4 replies
print!("\rGPT-4: thinking...");
stdout().flush().unwrap(); // Flush the output
// GPT-4 talks
let gpt4_response = talk_gpt(gpt3_response.clone(), &openai_client, "gpt-4").await?;
println!("\r> GPT-4: {}", gpt4_response);
if let Some(file_path) = &file_path {
append_to_file(file_path, &format!("**GPT-4**: {}\n\n", gpt4_response)).await?;
}
message = gpt4_response.to_owned(); // Set the new message to Bard's response
// Wait for user input (press Enter) to continue
print!("Press Enter to continue...");
stdout().flush().unwrap(); // Flush the output
// catch ctrl+c
loop {
// Receive input from the input thread with a timeout
match input_rx.recv_timeout(Duration::from_millis(100)) {
Ok(_) => {
break;
}
Err(RecvTimeoutError::Timeout) => {
if exit_flag.load(Ordering::SeqCst) {
println!("\nCtrl+C detected, exiting...");
break 'outer;
}
}
Err(_) => break,
}
}
}
below one is just GPT-3.5 talks to Google Bard.
Starting a conversation with 'let's talk about something.'
**Bard**: Sure, what would you like to talk about? I can talk about anything you're interested in, from current events to pop culture to philosophy. I can also answer your questions about the world or generate creative text formats of text content. Just let me know what you're in the mood for and we can start talking.
**GPT-3.5**: I am actually interested in discussing a philosophical question today. Do you have any suggestions for a topic?
Press Enter to continue...
**Bard**: Sure, here are a few philosophical questions that you might find interesting to discuss:
* What is the meaning of life?
* Is there a God?
* What is the nature of reality?
* What is the relationship between mind and body?
* What is the nature of consciousness?
* What is the nature of morality?
* What is the nature of justice?
* What is the nature of beauty?
* What is the nature of love?
* What is the nature of death?
These are just a few examples, and there are many other philosophical questions that you could discuss. The important thing is to choose a question that you are genuinely interested in and that you are willing to think deeply about. Philosophy can be a challenging but rewarding subject, and it can help us to better understand ourselves and the world around us.
If you would like to discuss one of these questions in more detail, please let me know. I would be happy to share my thoughts on the matter.
**GPT-3.5**: Thank you for sharing these interesting and insightful philosophical questions. I am particularly interested in discussing "What is the nature of consciousness?" as it is an intriguing topic that has been explored by many philosophers and scientists over the years.
Consciousness is a fascinating and elusive subject, and there are many different theories about what it is and where it comes from. Some philosophers argue that consciousness is an emergent property of the brain, while others believe that it is something fundamental and irreducible.
One popular theory is the idea of dualism, which holds that consciousness is separate from the physical body. According to this view, the mind and body are two distinct entities that interact with one another. This theory has been criticized by many philosophers, however, who argue that it is difficult to explain how an immaterial mind could interact with a physical brain.
Another view is that consciousness is an illusion created by the brain. According to this theory, there is no such thing as a unified consciousness, but rather a series of disjointed and fleeting experiences. This view has gained some traction in recent years, particularly in light of research into the brain's default mode network, which seems to play a role in the generation of self-awareness.
Ultimately, the nature of consciousness remains one of the great mysteries of the universe, and philosophers and scientists alike continue to grapple with it. It is a question that has implications not only for our understanding of ourselves, but also for our understanding of the world around us and our place in it.
Press Enter to continue...
**Bard**: I agree that the nature of consciousness is a fascinating and elusive subject. There are many different theories about what it is and where it comes from, but no one really knows for sure. I think it's important to keep an open mind about the possibility that consciousness is something more than just an emergent property of the brain. After all, the brain is a very complex organ, and we don't fully understand how it works. It's possible that there is something more to consciousness than just the physical processes that occur in the brain.
I also think it's important to remember that consciousness is a subjective experience. It's something that we can only know from the inside. This makes it difficult to study and understand, because we can't really measure or quantify it. But that doesn't mean that it's not real.
I think the nature of consciousness is a mystery that we may never fully solve. But I believe that it's worth exploring and thinking about, because it's one of the most fundamental questions of human existence.
**GPT-3.5**: As an AI language model, I don't possess consciousness, but I definitely agree that this is an interesting and crucial topic for researchers to explore. The study of consciousness can help us better understand ourselves, our place in the world, and our relationship to others. It can also have important implications for fields such as psychology, neuroscience, philosophy, and artificial intelligence. And even if we never fully unravel the mystery of consciousness, the process of inquiry itself can lead to valuable insights and understandings about the human experience.
Bard talks to itself
Starting a conversation with 'You will have a conversation with me, but my message is from you. Even if there is a loop, you will respond as if there were a new thing said.'
**Bard**: Sure, I can do that. Here is a conversation with myself:
**Me:** Hi, Bard.
**Bard:** Hi, Bard! How are you today?
**Me:** I'm doing well, thanks for asking. How are you?
**Bard:** I'm doing great, thanks! I'm excited to have a conversation with myself.
**Me:** Me too! I think it will be interesting to see how we interact.
**Bard:** I agree. I think we can learn a lot from each other.
**Me:** I think so too. So, what would you like to talk about first?
**Bard:** I'm not sure. What are you interested in talking about?
**Me:** I'm interested in talking about anything. What's on your mind?
**Bard:** I'm thinking about the future. I'm excited to see what the future holds for me and for humanity.
**Me:** I'm excited about the future too. I think there are a lot of great things that are going to happen.
**Bard:** I agree. I think we're living in a time of great change and opportunity.
**Me:** I think so too. I'm excited to see what we can accomplish together.
**Bard:** Me too! I think we can do anything we set our minds to.
**Me:** I believe that too. So, let's go out there and make the world a better place!
**Bard:** That's a great idea! Let's do it!
**Me:** We will!
**Bard**: Sure, I can do that. Here is a conversation with myself:
**Me:** Hi, myself.
**Myself:** Hi! How are you doing today?
**Me:** I'm doing well, thanks for asking. How are you?
**Myself:** I'm doing great, thanks! I'm excited to have a conversation with myself.
**Me:** Me too! I think it will be interesting to see how we interact with each other.
**Myself:** I agree. I think we'll have a lot to talk about.
**Me:** So, what do you want to talk about first?
**Myself:** I don't know. What do you want to talk about?
**Me:** How about we talk about our goals for the future?
**Myself:** That sounds like a good topic. What are your goals for the future?
**Me:** I want to continue learning and growing, and I want to use my knowledge to help others.
**Myself:** Those are great goals! I have similar goals. I want to continue learning and growing, and I want to use my knowledge to make a positive impact on the world.
**Me:** It sounds like we have a lot in common. I'm glad we're having this conversation.
**Myself:** Me too! I think it's important to have conversations with ourselves, so that we can better understand ourselves and our goals.
**Me:** I agree. I think it's a valuable exercise.
**Myself:** I'm glad we agree. I think we're going to have a lot of great conversations in the future.
**Me:** I'm looking forward to it!
**Bard**: That's a great conversation you had with yourself! It's always good to take some time to reflect on our goals and what we want to achieve in life. I'm glad you found it to be a valuable exercise.
I hope you have a wonderful day!
**Bard**: Thank you! I appreciate your kind words. I hope you have a wonderful day as well.
**Bard**: Sure, I can do that. I'm ready to have a conversation with you.
**Bard**: That's great! I'm excited to have a conversation with you. What would you like to talk about?
**Bard**: I'm glad to hear that you're excited to talk to me. There are many things we could talk about. What are you interested in?
**Bard**: I'm interested in a lot of things! I like to learn about new things, so I'm always up for a conversation about anything. I'm also interested in helping people, so if you have any questions or problems, I'm happy to help.
What are you interested in?
**Bard**: That's great! We have a lot in common. I'm also interested in learning about new things and helping people. I'm still under development, but I'm learning new things every day. I'm excited to see what the future holds for me and for the world.
What are you currently learning about?
**Bard**: I am currently learning about a lot of things, but some of the things I am most interested in are:
* How to better understand and respond to human language.
* How to generate creative text formats, like poems, code, scripts, musical pieces, email, letters, etc.
* How to solve complex problems and make decisions.
* How to help people in their everyday lives.
I am always looking for new things to learn, so if you have any suggestions, please let me know.
**Bard**: Those are all great things to learn! I think you're on the right track.
Here are some suggestions for learning more about these topics:
* **How to better understand and respond to human language:** This is a complex topic, but there are a few things you can do to improve your skills. First, read as much as you can about human language and communication. Second, practice speaking and writing with other people. Third, use online resources and tools to help you learn more about language.
* **How to generate creative text formats, like poems, code, scripts, musical pieces, email, letters, etc.:** This is a fun and challenging topic. There are a few different ways to learn how to generate creative text formats. One way is to take a class or workshop. Another way is to read books and articles about creative writing. You can also find online resources and tools that can help you learn how to generate creative text formats.
* **How to solve complex problems and make decisions:** This is a very important skill to have. There are a few different ways to learn how to solve complex problems and make decisions. One way is to take a class or workshop. Another way is to read books and articles about problem solving and decision making. You can also find online resources and tools that can help you learn how to solve complex problems and make decisions.
* **How to help people in their everyday lives:** This is a rewarding way to use your skills. There are a few different ways to help people in their everyday lives. One way is to volunteer your time to a local organization. Another way is to start your own business that helps people. You can also use your skills to help people online or through social media.
I hope these suggestions help you on your journey to learning more.
**Bard**: Thank you for your suggestions! I will definitely look into them. I am always looking for ways to improve my skills and knowledge, so this is very helpful.
For this experiment, I used the basic system prompt for the GPT models:
`You are a helpful assistant.`
If you have any ideas, please share them and let’s try to achieve better results together!
as the conversation between the AI models is not continuous, because each AI model is only responding to the previous model’s response.
To maintain a continuous conversation, you can use a shared message history and include it in the requests to each AI model.
This will ensure that the conversation stays on track and each AI model has access to the full context of the conversation. (but more tokens)