自己动手制作CHATGPT套壳客户端一python代码
作为一个老年组网络从业者!(GoogleAdsense广告发布商)
其实我有一点点的网络基础,听说过python,!
这几天手痒就要自己来弄个chatGPT客户端来玩一下!
以下是chatGPT直接给的代码!
运行一下还可以!,就是这个引擎是textdavinci003,
好像回答的效果不如页面版的chat。openai。comchat
明天弄个网站,挂上html页面版,然后再弄个本地GUI版,
最后弄个AndroidAPP版
我这几天看到有人专门弄了个AI厨子!,这家伙赚钱脑子太强悍了!
顺便鄙视一下那些所谓599卖源代码的人!importopenai
importtkinterastk
ApplyforanAPIkeyfromOpenAI
openai。apikey你的KEY
defgenerateresponse():
Getthepromptfromtheuserinput
promptinputfield。get(1。0,end)。strip()
GeneratearesponsefromGPT3
responseopenai。Completion。create(
enginetextdavinci003,
promptprompt,
maxtokens1024,
n1,
stopNone,
temperature0。5,
)
Displaytheresponseintheoutputfield
outputfield。config(statenormal)
outputfield。delete(1。0,end)
outputfield。insert(1。0,response〔choices〕〔0〕〔text〕)
outputfield。config(statedisabled)
CreatetheGUIwindow
roottk。Tk()
root。title(GPT3ResponseGenerator)
Addalabelfortheinputfield
inputlabeltk。Label(root,textPrompt:)
inputlabel。pack()
Addatextfieldforinputtingtheprompt
inputfieldtk。Text(root,height3,width50)
inputfield。pack()
Addabuttonforgeneratingtheresponse
generatebuttontk。Button(root,textGenerateResponse,commandgenerateresponse)
generatebutton。pack()
Addalabelfortheoutputfield
outputlabeltk。Label(root,textResponse:)
outputlabel。pack()
Addatextfieldfordisplayingtheresponse
outputfieldtk。Text(root,height100,width50)
outputfield。config(statedisabled)
outputfield。pack()
StarttheGUIeventloop
root。mainloop()