Chat GPT in 20 lines of code

Chat GPT in 20 lines of code

if you want to integrate chatgpt into your workflow here is all the code you need to get started you will need a API key from openai check out my github to get the code directly https://github.com/MAvoss/Falcon


import sys
# caution: path[0] is reserved for script path (or '' in REPL)
sys.path.insert(1, 'yourpathhere')
import keys?
!{sys.executable} -m pip install openai
import openai
openai.api_key = keys.get_openai_key()
# Note: you need to be using OpenAI Python v0.27.0 for the code below to work
import openai


question = input()


print(question)
output = openai.ChatCompletion.create(
? model="gpt-3.5-turbo",
? messages=[
? ? ? ? {"role": "user", "content":question},
? ? ]
)
print(output)        

要查看或添加评论,请登录

Joshua Voss的更多文章

社区洞察

其他会员也浏览了