How to use ChatGPT in Python - Unofficial ChatGPT Python API Guide
Key Takeaways
The video demonstrates how to use ChatGPT in Python via the unofficial ChatGPT Python API Guide, utilizing tools like PieChatGPT and Google Colab to interact with ChatGPT and send prompts to receive responses.
Full Transcript
hey what's up coders welcome to one little coder if you have been Amazed by chat GPT today you have got an opportunity to use charge GPT with python that means you can generate a lot of text programmatically and also you could plug in it with services like whisper Dali stable division anything that has got an EPA so in this video I'm going to teach you how you can use chart GPT within your python environment and that is possible purely because thanks to this amazing repository called pie chart GPT from Terry so Terry thank you so much for making this library and then making it open source please go start the repository there is repository to show some love let's get started with our Google collab notebook this Google collab notebook will link will be linked in the YouTube description so you can right away click this and get started the first thing is open your Google collab notebook and then install pip install pie chat GPT so make sure that you install the right library because you don't want to install a malware from Pi Pi which is also a known issue with Pi Pi and if you install pie chart GPT then Google collab is going to ask you that you must restart the runtime in order to use the newly installed version then you have to click this button and then restart runtime after you click this button and click restart runtime you are going to start the coding first step is from PI chat GPT import charge GPT and the next step is you need to do authentication because charge GPT does not have an official API it this is a hack this is a worker on what you have to do is you need to extract the session token so how can you do that go to your chart GPT session where you have already logged into chatgpt right click from your browser and then click inspect or you can click F12 as well to open the developer tools after you click you can enter or click application and then you have to find cookies and inside cookies you will see something like chat Dot openai.com and then once you click that and enter you would see something called secure next auth session token and once you click that you have to just copy the value everything there and come back to your Google collab notebook and paste it here that session is that session token is valid for this session like the session that you are logged in here it is valid for that once you assign the value from the developer tools or for your Google Chrome or like in in my case I demonstrated it from Brave browser you can store it here and then you can use chat GPT to authenticate the session but let's say you don't want to authenticate with the session token but you want to authenticate with your email ID and the password that you have used for your chat GPT you can do it like this and you have got other ways like using a proxy or using a conversation ID which you can also check it out but basically the Second Step that you have to do is authenticate and the easiest way for you to authenticate is like I said go to the chat GPT web URL click right click inspect or go F12 developer tools click application click cookies enter the cookies and then copy the secure next or session tokens value not the name value and then come back to your Google collab notebook and paste it after you run this then you have successfully authenticated or connected this Google collab session with your chart GPT session the next thing is you need to send a message to chatgpt so that is basically your prompt in this case you can give a prom saying give me five ideas for a viral YouTube video on python once you send this message this is going to be a response now get a response message so the response when it gets returned it could contain a lot of items you just want the response message and then the message is the exact response from chat GPT so in my case it has given me five viral YouTube video ideas I do not know if I'm going to try it out but you have got five YouTube viral video ideas so after you get a message it is always good to refresh your authentic authorization token so that your token is valid but if you do not want to do it it is completely fine if you want to reset your conversation which means you do not want this particular session of chat GPT to remember what you have said for example in the browser world in the web world this is as equivalent as clicking the reset thread if you want to reset the thread then you can click here and the same thing you can do it with the reset conversation API dot reset conversation let me quickly summarize it first install pie chart GPT then after you install on Google collab especially it is going to ask you to restart the runtime if you are using it on your local computer you do not have to do it because it doesn't require you to do it but if you are doing it on Google collab this might be one-time requirement after that you can install or import from pie chart GPT import chat GPT then you have to get the session token which you have to get it from your web link where you have already logged in the chat jpt the next thing is API equals chat GPT of session token if you want different authentication method you can try it out here the next thing is you need to send a message to chatgpt and the message could be a prompt that you want to ask a question or anything that you want chat GPD to respond to then you have got the print message where you can get the response message component of the response and then you have the result so now I'm going to show you a different prompt let's go ahead and then say write an essay on generative Ai and then you can run this and the every time it takes different amount of time you would probably see this slightly longer than charge apt in itself because internally it uses headless methods to go run this message and then get a response to it and that's that's another thing that you would see different rather than using chat GPT in itself so let's wait for it to get the response back after 1 minute 30 seconds precisely 29 seconds charge GPS responses here which is an essay about generative AI generative AI is a type of artificial intelligence that's focused on generating new content and then it has got a lot of information for you to get and now this is exactly how you would use chat GPT with python for example you do not want to use it on Google collab if you want to use it on your local machine all you have to do is comment this line and then go to file and then download a DOT Pi file so if you want to use it on your local computer like a chrome job or anything like that you can do that and also if you want to make enhancements to it the things that you can do is instead of hard coding the value here it can be a component or it can be a value that you collect from the user in terms of voice like you can use um like Solutions like whisper to collect it and also you can take this message and feed into Solutions like stable diffusion to generate an image so this way you can take charge gpt's capability and then you can expand it into multi-modal learning like for example you have got text and you are combining it with the video audio image generation a lot more and that is why it is truly remarkable that you can use chat GPT with python today but also something that you need to keep in mind is chargpt today is not available itself releases their own API which means this solution will not work and also finally you need to remember that open AI can always change their solution in such a way that these kind of unofficial APA sources would do not work that is also a possible scenario in any case I would strongly recommend you to go raise an issue in Terrace repository which is called paija jbt and also if you have not start repository please show some love to the developer overall this notebook linked this Google collab notebook will be linked in the YouTube description and then you can directly jump start with your own chargpt with python I hope this video was helpful to you in learning how to use chatgpt with python if you have any questions let me know in the comment section otherwise Happy prompting
Original Description
This ChatGPT Tutorial teaches you how to use ChatGPT in Python on Free Google Colab using pyChatGPT
Links:
ChatGPT Unoffical Python API - https://github.com/terry3041/pyChatGPT
ChatGPT Google Colab Code Guide - https://colab.research.google.com/drive/1vl98oSAIK14wa5Fa0bFVc-o8zj2dJvUD?usp=sharing
❤️ If you want to support what we are doing ❤️
Support here:
Patreon - https://www.patreon.com/1littlecoder/
Ko-Fi - https://ko-fi.com/1littlecoder
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from 1littlecoder · 1littlecoder · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
How to create your Free Data Science Blog on Github with Fastpages from Fastai
1littlecoder
Making Interactive Matplotlib Plots for Data Science Visualizations on Jupyter (Python)
1littlecoder
Create your first Data Science Web App using R Shiny
1littlecoder
How to create a Reproducible Example in R using reprex
1littlecoder
No Code Visualization using esquisse with Tableau-like Drag and Drop GUI in R
1littlecoder
Scrape HTML Table using rvest and Process them for insights using tidyverse in R
1littlecoder
Google Teachable Machine Learning Build No Code AI solution
1littlecoder
Create meaningful fake tidy datasets in R using fakir [#rstats Package]
1littlecoder
How to enable using R Programming with Visual Studio VS Code
1littlecoder
Python, Community, Books - with Abhiram R - Bangpypers Co-organizers | 1littlecoder podcast
1littlecoder
Growing a Tech Community across India - Anubha Maneshwar, Founder Girlscript | 1littlecoder Podcast
1littlecoder
Intro to Google Colab - How to use Colab
1littlecoder
Intro to Plotly Express - Complex Interactive Charts with One-Line of Python Code
1littlecoder
Indic NLP Python Toolkit Open Source Development - iNLTK Creator Gaurav Arora | 1littlecoder Podcast
1littlecoder
Do you want a career in Data Science - Tamil Webinar
1littlecoder
Android Smartphone Analysis in R [Live Coding Screencast]
1littlecoder
Programmatically create Images, Memes, Watermarks using Python with imgmaker
1littlecoder
Kaggle Walkthrough to get you started with Data Science - Webinar
1littlecoder
Community, Corporate Job, Coding - Gnana Lakshmi T C aka Gyan, WomenWhoCode Leadership Fellow
1littlecoder
Easy ggplot2 Theme Customization with {ggeasy} | Data Visualization in R
1littlecoder
Excel to R - Pivot + Bar Chart in Excel & R using tidyverse [Live Coding]
1littlecoder
Excel to R #2 - VLOOKUP in Excel to LEFT_JOIN, MERGE in R
1littlecoder
5 websites to get Free Real-World Datasets for Data Science/ML Projects
1littlecoder
Excel to R #3 - APPROXIMATE VLOOKUP in Excel to FUZZY LEFT_JOIN in R
1littlecoder
Correlation-alternative PPS (Predictive Power Score) Python Package Demo
1littlecoder
Automated Website Screenshots in R using {webshot}
1littlecoder
Installing Custom RStudio Theme (Synthwave85)
1littlecoder
Analyse Google Trends Search Data in R using {gtrendsR}
1littlecoder
3 Tips to ask question on Stack Overflow the right way to get answers
1littlecoder
Learn Data Science with R - Mini Projects - Web Scraping Zomato
1littlecoder
Easily make Dumbbell Chart using {ggcharts} | Data Visualization in R
1littlecoder
GET Hackernews Front Page Results using REST API in R
1littlecoder
Quickly deploy ML WebApps from Google Colab using ngrok
1littlecoder
Use Jupyter Notebooks within VSCode (Visual Studio Code) in 2020
1littlecoder
Plotly Interactive Plots as Pandas Plotting Backend df.plot()
1littlecoder
Stack Overflow Developer Survey 2020 Highlights for New Programmers
1littlecoder
Matplotlib Animation Charts in Python using Celluloid
1littlecoder
Coding, Postwoman, Passion Project Book - Liyas Thomas Open Source Developer - 1littlecoder podcast
1littlecoder
Aspiring Data Scientist, Tips on How to learn Business Domain Knowledge
1littlecoder
Bokeh Interactive Charts as Pandas Plotting Backend df.plot_bokeh()
1littlecoder
Easy Fast Python Pandas Summary with Sidetable | Pandas Tips & Tricks
1littlecoder
Inception, Content Ideas, Consistency - Srivatsan Srinivasan AIEngineering YouTube Content Creator
1littlecoder
ggplot2 Text Customization with ggtext | Data Visualization in R
1littlecoder
Penguins Dataset Overview - iris alternative | EDA Data Visualization in R
1littlecoder
YouTube Growth Tips, Content Creation - Bhavesh Bhatt, YouTuber (Data Science & Machine Learning) #7
1littlecoder
Matplotlib Animated Bar Chart Race in Python | Data Visualization
1littlecoder
Simple Python GUI Development using {guietta}
1littlecoder
#8 Niche, Growth, Monetization - David Langer - YouTuber Dave on Data
1littlecoder
Simple Fast 3-step Python OCR using Deep Learning 40+ Languages
1littlecoder
Github New Feature Profile Summary/Mini-Resume - Profile Views
1littlecoder
Otto ML Assistant, GPT-3 on Philosophers, Nvidia-ARM - 3 ML Tech News
1littlecoder
What is OpenAI GPT-3 - Hype, Examples, Worries
1littlecoder
Julia 1.5, Datamuse API, Live HDR+ Pixel 4a - Machine Learning Tech News
1littlecoder
Self-driving Car Engineer sentenced, arXiv Dataset, AI/ML Startup Idea - Machine Learning Tech News
1littlecoder
GPT-3 Explorer, Ciphey (Automated Decryption), Py-Sudoku - ML Tech News
1littlecoder
How to use Advanced Google Search to extract Email Ids from Linkedin
1littlecoder
Cartoonizer Toon-IT (AI Web App), GPT-3 Advice, Android Earthquake Detection - ML Tech News
1littlecoder
Flow - R Package to visualize code logic, functions as a Flow Diagram
1littlecoder
Build GPT-3-like Language Model on Google Colab with minGPT [PyTorch]
1littlecoder
Create a Pencil Sketch Portrait with Python OpenCV
1littlecoder
More on: LLM Foundations
View skill →Related Reads
📰
📰
📰
📰
AI Background Music as a Product: Building and Selling Custom Sound Libraries for Creators and SaaS Teams
Dev.to AI
The ChatGPT Workflow That Saves Me 10 Hours Every Week
Medium · AI
Why Developers Don’t Search Google Like They Used To
Medium · AI
What looks like AI slop from the outside is my accessibility tool
Dev.to AI
🎓
Tutor Explanation
DeepCamp AI