The ChatGPT API Beginners Guide

  Рет қаралды 18,470

warpdotdev

warpdotdev

Күн бұрын

Learn how to build your own ChatGPT chatbot with the ChatGPT API, Python, and OpenAI in this tutorial. We'll cover setting up a Python environment, getting an OpenAI API key, and coding a basic chatbot that can have conversations and remember context with the ChatGPT API. 🚀🐍
The code utilizes packages like OpenAI, Typer, OS and DotEnv to call the ChatGPT API from Python. We implement features like max tokens, temperature, and model selection to customize the chatbot responses. The chatbot handles user input and displays ChatGPT's responses in the terminal.
This is a beginner friendly project that shows how easy it is to integrate ChatGPT into your own Python applications using the ChatGPT API. While basic, it lays the foundation to build more advanced chatbots with the OpenAI API and Python all in your terminal.
TIMESTAMPS
0:00 Intro
0:27 Setup Environment (Mac + Python)
1:18 Project Intilialize
1:49 First lines of code
2:05 All the dependencies explained
2:28 Securing your API Key
3:35 Attaching ChatGPT to Python Typer
4:29 If you are getting an error...
4:41 The ChatGPT API Response Explained
5:12 Fixing ChatGPT's short term memory
6:09 Optimizing the code further with Python's Typer
7:13 Start ChatGPT with a question
8:00 How to build further!
8:07 AI In your terminal! (Warp)
8:44 Thanks for Watching!
🔗RESOURCES:
Source Code: github.com/theRubberDuckiee/c...
ChatGPT API Documentation: openai.com/api-docs
Python Download: www.python.org/downloads/
Requests Library: requests.readthedocs.io/en/ma...
pyenv: github.com/pyenv/pyenv
pyenv for Windows: github.com/pyenv-win/pyenv-win
Blog with full instructions 👉 dev.to/therubberduckiee/begin...
Try Warp now for FREE 👉 bit.ly/warpdotdev
Twitter 🐦
/ warpdotdev
TikTok 📱
/ warp.dev

Пікірлер: 22
@warpdotdev
@warpdotdev 6 ай бұрын
Let us know what you want us to build next! 👩‍💻
@NCMB__
@NCMB__ 6 ай бұрын
Ok, the text variable also has to be valid only for the first step, otherwise it gets into a loop.
@NCMB__
@NCMB__ 6 ай бұрын
Ok, I added i=1 ahead of the while loop, then in it an if i==1 then prompt = text, else prompt = input() - the rest is the same.
@murtadha96
@murtadha96 6 ай бұрын
I actually REALLY love Warp AI! I can't recall how many times I've forgotten a Git command or a way to do something and Warp was the easiest way to go
@CodingWithLewis
@CodingWithLewis 6 ай бұрын
1:47 I took that personally 😢😢
@Screenamerockz
@Screenamerockz 5 ай бұрын
Interesting choice of using typer instead of langchain, any particular reason?
@leochen4393
@leochen4393 5 ай бұрын
This is installed on Win11 or Linux?
@DAM6014
@DAM6014 5 ай бұрын
What is the name of the vs code theme?
@soundsilove6123
@soundsilove6123 5 ай бұрын
can you make update with new verson ? :)
@Compguy321
@Compguy321 5 ай бұрын
4:51 is what I was looking for, how to print just the output. Thank you! This definitely was hard to figure out! However, I am getting errors when trying to run it: Traceback (most recent call last): File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in start(fakepyfile,mainpyfile) File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start exec(open(mainpyfile).read(), __main__.__dict__) File "", line 20, in TypeError: 'ChatCompletionMessage' object is not subscriptable [Program finished]
@user-gv9uw7cx6x
@user-gv9uw7cx6x 4 ай бұрын
cool video)
@WilliamDye-willdye
@WilliamDye-willdye 6 ай бұрын
I want voice input, output, session recording, and a tie-in to an AI organizer such as Langchain.
@warpdotdev
@warpdotdev 6 ай бұрын
We just did a video about that!
@maxcarlquist9637
@maxcarlquist9637 6 ай бұрын
I really enjoy your videos, but could your team consider slower and less "show casey" videos so one can follow? I really love the product you've created but always have a hard time following along. cheers!
@lbarcelocarrera
@lbarcelocarrera 4 ай бұрын
If you get this error: "AssertionError: Could not get a command for this Typer instance" Passing a name to typer might fix it, like so: app = typer.Typer(name="OpenAI Chatbot")
@user-zp2ze5ho3q
@user-zp2ze5ho3q 6 ай бұрын
you guys should tweet this out too
@warpdotdev
@warpdotdev 6 ай бұрын
Good suggestion! twitter.com/warpdotdev/status/1715404831643533776
@thatguy658
@thatguy658 2 ай бұрын
The latest OpenAI package has breaking changes: 1) import openai # Should be: from openai import OpenAI 2) openai.api_key = os.getenv("OPENAI_KEY") # Should be: client = OpenAI(api_key=os.getenv("OPENAI_KEY")) 3) response = openai.ChatCompletion.create() # Should be: response = client.chat.completions.create() 4) typer.echo(f'ChatGPT: {response["choices"][0]["message"]["content"]}') # Should be: typer.echo(response.choices[0].message.content) # I also had to add this import to fix a bug (for -t): from typing import Optional # And add this block so the -t text is used as first prompt: initial_prompt = text while True: if initial_prompt != None: prompt = initial_prompt initial_prompt = None else: prompt = input("You: ") P.S. I like your video editing style
@progamer-df3be
@progamer-df3be 3 ай бұрын
Can it then be used offline?
@pravachanpatra4012
@pravachanpatra4012 2 ай бұрын
This video is assa
@3ff3xgaming68
@3ff3xgaming68 3 ай бұрын
Every time a dev uses a Mac a baby panda dies.
@claudiusarnellius2465
@claudiusarnellius2465 2 ай бұрын
👎Thumbs down. Not good. I wanted to like this but there are far too many errors, unexplained/uncovered jumps, etc.
Why JavaScript Devs are Switching to Rust in 2024
10:35
warpdotdev
Рет қаралды 238 М.
Run your own AI (but private)
22:13
NetworkChuck
Рет қаралды 1 МЛН
原来小女孩在求救#海贼王  #路飞
00:32
路飞与唐舞桐
Рет қаралды 35 МЛН
Buy Feastables, Win Unlimited Money
00:51
MrBeast 2
Рет қаралды 62 МЛН
ШЕЛБИЛАР | bayGUYS
24:45
bayGUYS
Рет қаралды 382 М.
ChatGPT API - Introduction
1:03:37
Eli the Computer Guy
Рет қаралды 10 М.
Master the Perfect ChatGPT Prompt Formula (in just 8 minutes)!
8:30
ChatGPT Tutorial 2024: How to Use ChatGPT - Beginner to Pro!
56:00
Daragh Walsh
Рет қаралды 364 М.
Build Anything With ChatGPT, Here’s How
1:24:05
David Ondrej
Рет қаралды 918 М.
Prompt Engineering Tutorial - Master ChatGPT and LLM Responses
41:36
freeCodeCamp.org
Рет қаралды 1,2 МЛН
How I'd Learn AI in 2024 (if I could start over)
17:55
Dave Ebbelaar
Рет қаралды 711 М.
Build Anything With ChatGPT API, Here’s How
12:11
David Ondrej
Рет қаралды 24 М.
Apple, как вас уделал Тюменский бренд CaseGuru? Конец удивил #caseguru #кейсгуру #наушники
0:54
CaseGuru / Наушники / Пылесосы / Смарт-часы /
Рет қаралды 3 МЛН
M4 iPad Pro Impressions: Well This is Awkward
12:51
Marques Brownlee
Рет қаралды 4,6 МЛН