How to Create your own ChatGPT in 2 lines?

Rajya Vardhan Mishra
1 min readAug 11, 2023

If you are wondering: How to Create your own ChatGPT? Your own chatbot that comes with customizations:
1. Temperature — lets you control the creativity of answer.
2. Use a model of your choice like GPT-3.5 Turbo or even latest GPT-4

Then I can explain it in just 2 lines. Ready?

# 𝙻𝚒𝚗𝚎 𝟷
𝚌𝚑𝚊𝚝 = 𝙲𝚑𝚊𝚝𝙾𝚙𝚎𝚗𝙰𝙸(𝚝𝚎𝚖𝚙𝚎𝚛𝚊𝚝𝚞𝚛𝚎=𝟶.𝟽, 𝚖𝚘𝚍𝚎𝚕='𝚐𝚙𝚝-𝟹.𝟻-𝚝𝚞𝚛𝚋𝚘')
# 𝙻𝚒𝚗𝚎 𝟸
𝚌𝚘𝚗𝚟𝚎𝚛𝚜𝚊𝚝𝚒𝚘𝚗 = 𝚌𝚑𝚊𝚝(
[
𝚂𝚢𝚜𝚝𝚎𝚖𝙼𝚎𝚜𝚜𝚊𝚐𝚎(𝚌𝚘𝚗𝚝𝚎𝚗𝚝="𝚈𝚘𝚞 𝚊𝚛𝚎 𝚊 𝚜𝚊𝚛𝚌𝚊𝚜𝚝𝚒𝚌 𝙰𝙸 𝚊𝚜𝚜𝚒𝚜𝚝𝚊𝚗𝚝"),
𝙷𝚞𝚖𝚊𝚗𝙼𝚎𝚜𝚜𝚊𝚐𝚎(𝚌𝚘𝚗𝚝𝚎𝚗𝚝="𝙿𝚕𝚎𝚊𝚜𝚎 𝚊𝚗𝚜𝚠𝚎𝚛 𝚒𝚗 𝟹 𝚠𝚘𝚛𝚍𝚜: 𝙷𝚘𝚠 𝚌𝚊𝚗 𝙸 𝚕𝚎𝚊𝚛𝚗 𝚍𝚛𝚒𝚟𝚒𝚗𝚐 𝚊 𝚌𝚊𝚛")
]
)
𝚙𝚛𝚒𝚗𝚝(𝚌𝚘𝚗𝚟𝚎𝚛𝚜𝚊𝚝𝚒𝚘𝚗)

GPT returns answer -> “By practicing consistently.”

See how simple it is!!

For full code and a bit more complex example, see the comments.

In the previous post, we learned how to create AI-powered Q&A bot in just 2 lines.
Congratulations! You just created a ChatGPT in 2 lines of code.

Follow me on this adventure of #AI, #Langchain, and #LLM.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Rajya Vardhan Mishra
Rajya Vardhan Mishra

Written by Rajya Vardhan Mishra

Passionate Engineering Leader @Google. On a mission to make this world a better place. Driven by Optimism, Gratitude, Curiosity, & Determination.

No responses yet

Write a response