# Email: bt25.bcrs@gmail.com Password: Bantuda25New
# Verification Mobile: 9847578833
# https://copyassignment.com/create-your-own-chatgpt-with-python/
import openai
from tkinter import *
win = Tk()
win.geometry("750x450")
win['background'] = '#11A37B'
win.title("Using ChatGPT with Python GUI")
openai.api_key = "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"
model_engine = "text-davinci-003"
def reply(e):
completion = openai.Completion.create(n=1, stop=None,
engine="text-davinci-003", prompt=S1.get(),
max_tokens=1024, temperature=0.5)
response = completion.choices[0].text.strip()
txt.delete("0.0", END)
txt.insert("1.0", response)
S1, S2 = StringVar(), StringVar()
S1.set("")
font1 = ("Verdana", 14, "bold")
font2 = ("Verdana", 24, "bold")
lblHeader = Label(win, text="Hosted by BCRS", font=font2, bg='#11A37B', fg='#FFFFFF')
lblHeader.place(x=280, y=25)
pic = PhotoImage(file="ChatGPT.png")
lblImg = Label(win, image=pic)
lblImg.place(x=40, y=5)
lbl = Label(win, text='Enter prompt', font=font1, bg='#11A37B', fg='#FFFFFF')
lbl.place(x=10, y=130)
ent = Entry(win, textvariable=S1, font=font1, width=40, bg='#11A37B', fg='#FFFFFF')
ent.place(x=180, y=130)
ent.bind('<Return>', reply)
ent.focus()
txt = Text(win, font=font1, width=50, height=10, wrap=WORD, bg='#11A37B', fg='#FFFFFF')
txt.place(x=25, y=180)
win.mainloop()
No comments:
Post a Comment