Hello guys, we know that OpenAI's o1 model appears to think before giving answers to users. I don't know how it works under the hood, but I've created something fun that mimics this "thinking…" behavior using the Gemini API. Let me clarify - this isn't a serious project! It's purely for entertainment, and the logic behind it is a bit silly.
The chatbot I created takes time to respond based on the difficulty of the question.
For example,
if the question is "Write a program to add two numbers" will take about 1 second, check the below image
However, if the question is like "Write a program to create an HTTP server in x86 assembly" it will take longer to respond compared to the simpler question.
To be honest, this chatbot doesn't actually "think" before responding. It just generates multiple answers under the hood and analyzes them, but we can pretend it's thinking by showing it in the UI! 😂
Also, just to be clear, this is purely for fun and not how OpenAI's o1 model works.
How it works:
Let me explain the logic under the hood
First I send a utility text of "I need you to rate the question from the programmer's point of view from 1 to 5 hardness from low to high", this will be added to Gemini along with the user prompt. Gemini responds with a difficulty rating. Based on this rating, for example, if the rating is 4, I generate four different answers to the same question and store them in an array.
Finally, I added another utility text of "This is the array of answers and I need you to analyze them and generate a final correct output".
This process generates a final answer, which is returned to the user. I also calculate how much time it takes for the system to generate and analyze the answers.
You can check out the code repo here: so-called-think
Clone the repo, create a .env
file, add your Gemini API key, and run it.
If you notice any mistakes, feel free to leave a comment.
Thanks, everyone!
Top comments (2)
Yesterday, I wondered if an app like this existed, and now here we are! Well done.
Thank you! Please share this with your friends if possible 😀