PC & IT SUPPORT MADE EASY FORUM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

OpenAI GUI Python3 Script

Go down

OpenAI GUI Python3 Script Empty OpenAI GUI Python3 Script

Post by jamied_uk 28th February 2023, 14:40

Code:
#!/usr/bin/python3
# sudo apt install -y python3-tk
# pip3 install openai
from tkinter import *
import openai
from tkinter import messagebox

root=Tk()
root.geometry("350x500")
root.config(bg="white")
openai.api_key="KEY-HERE"
model_engine="text-davinci-003"

def response():
    msg=messagebox.get()
    lstbx.insert(0, "You: " + msg)
    answer=openai.Completion.create(
        engine=model_engine,
        prompt=msg,
    )
    message=answer.choices[0].text
    print(message)
    lstbx.insert(0, "Bot: " + message)

message=StringVar()
messagebox=Entry(root, textvariable=message, font=('calibre',10,'normal'), border=2, width=32)
messagebox.place(x=10, y=444)

sendmessageimg=PhotoImage(file='send.png')
sendmessagebutton=Button(root, image=sendmessageimg, command=response, borderwidth=0)
sendmessagebutton.place(x=260, y=440)

lstbx=Listbox(root, height=20, width=43)
lstbx.place(x=15, y=80)

user_name=Label(root, text="Number", width=10)
root.mainloop()
jamied_uk
jamied_uk
Admin

Posts : 2953
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum