PrototipoTUR / app.py
dtrejopizzo's picture
Update app.py
cdcdde4
raw
history blame
822 Bytes
import openai
import gradio as gr
openai.api_key ='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'
def openai_chat(prompt):
completions = openai.Completion.create(
engine="text-davinci-003",
prompt=prompt+"The following is the prompt from teacher working in canvas infrastructure",
max_tokens=1024,
n=1,
temperature=0.5,
frequency_penalty=0,
presence_penalty=0.6,
stop=[" Human:", " AI:"]
)
message = completions.choices[0].text
return message.strip()
def chatbot(input, history=[]):
output = openai_chat(input)
history.append((input, output))
return history, history
gr.Interface(fn = chatbot,
inputs = ["text",'state'],
outputs = ["chatbot",'state'],
allow_flagging="manual").launch()