Spaces:
Sleeping
Sleeping
File size: 783 Bytes
0b577d7 be54d16 0b577d7 9d7fffe 3bb7591 9d7fffe 3bb7591 9d7fffe 3bb7591 0b577d7 3bb7591 7317f35 3bb7591 0b577d7 c22b716 9129702 ad87696 9129702 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
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) |