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
This helped me a TON! Thank you for posting. My only addendum would be a #5 that appears on the line just beneath the code you referenced in number 4. I changed the code to messages.append(response.choices[0].message) and the entire thing works perfectly now. Again, HUGE thanks for doing this!!
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!
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")
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]
Let us know what you want us to build next! 👩💻
Ok, the text variable also has to be valid only for the first step, otherwise it gets into a loop.
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.
1:47 I took that personally 😢😢
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
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
This helped me a TON! Thank you for posting. My only addendum would be a #5 that appears on the line just beneath the code you referenced in number 4. I changed the code to messages.append(response.choices[0].message) and the entire thing works perfectly now. Again, HUGE thanks for doing this!!
thx, just what kind of shell terminal is you using - like it?
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!
Interesting choice of using typer instead of langchain, any particular reason?
can you make update with new verson ? :)
I want voice input, output, session recording, and a tie-in to an AI organizer such as Langchain.
We just did a video about that!
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")
amazing woman!!!!!!!!
cool video)
you guys should tweet this out too
Good suggestion! twitter.com/warpdotdev/status/1715404831643533776
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]
This is installed on Win11 or Linux?
What is the name of the vs code theme?
Can it then be used offline?
This video is assa
Every time a dev uses a Mac a baby panda dies.
👎Thumbs down. Not good. I wanted to like this but there are far too many errors, unexplained/uncovered jumps, etc.