jleezhang's picture
Update app.py
ae23c5d verified
raw
history blame
1.14 kB
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)