Spaces:
Runtime error
Runtime error
File size: 1,143 Bytes
2ed21d9 ae23c5d 2ed21d9 a521a96 02ab7a5 2ed21d9 02ab7a5 2ed21d9 0d97cfd 49b6696 | 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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | import openai
import gradio as gr
messages = []
messages.append({"role": "system", "content": "You are a chatbot designed to help customers choose their Effort's Eco-Essentials clothing and provide support."})
theme = gr.themes.Monochrome(
primary_hue="green",
spacing_size="sm",
radius_size="sm"
)
def response(userInput, history):
messages.append({"role": "user", "content": userInput})
response = openai.chat.completions.create (
model="gpt-3.5-turbo-0125",
messages = messages
)
reply = response.choices[0].message.content
messages.append({"role": "assistant", "content": reply})
history.append((userInput, reply))
return "", history
css = """
.block {
margin: 0px !important;
}
.share-button.svelte-1ylopk1 {
display: none !important;
}
textarea.svelte-1f354aw {
resize: none !important;
}
"""
with gr.Blocks(theme = theme, css=css) as demo:
chatbot = gr.Chatbot(show_label = False)
msg = gr.Textbox(show_label = False)
msg.submit(response, [msg, chatbot], [msg, chatbot])
demo.launch(share=False) |