mikaelbhai's picture
Update app.py
9d7fffe
raw history blame
No virus
783 Bytes
import openai
import gradio as gr
openai.api_key = "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"
messages.append({"role": "user", "content": user_input})
def openai_chat(prompt):
messages.append({"role": "user", "content": user_input})
completions = openai.Completion.create(
engine="text-davinci-003",
prompt=prompt,
max_tokens=1024,
n=1,
temperature=0.5,
)
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,
title = "bhAI",
inputs = ["text",'state'],
outputs = ["chatbot",'state']).launch(debug = True)