chat-bot-test / work-app.py
alliwene's picture
Upload folder using huggingface_hub
7baaae1
Raw
History Blame Contribute Delete
1.08 kB
import gradio as gr
from backend import generate_response, add_text, calc_cost, transcribe
with gr.Blocks() as demo:
chatbot = gr.Chatbot()
with gr.Row():
with gr.Column(scale=0.9):
message = gr.Textbox(
label="\n",
placeholder="Please enter a message and press Enter",
)
with gr.Column(scale=0.05):
cost_view = gr.Number(label="Usage in $", value=0)
clear = gr.ClearButton([chatbot, message, cost_view])
models = gr.Radio(
value="gpt-3.5-turbo",
choices=["gpt-3.5-turbo", "gpt-3.5-turbo-0301", "gpt-3.5-turbo-16k"],
label="Models",
info="Which openai chat model to use",
)
response = (
message.submit(add_text, [message, chatbot], [message, chatbot], queue=False)
.then(generate_response, [chatbot, models], chatbot)
.then(calc_cost, outputs=cost_view)
)
response.then(lambda: gr.update(interactive=True), None, [message], queue=False)
demo.queue()
if __name__ == "__main__":
demo.launch()