Spaces:
Paused
Paused
Download work-app.py from alliwene/chat-bot-test: direct link, hf CLI and curl.
- Browser
- Download file 1.08 kB
-
https://huggingface.co/spaces/alliwene/chat-bot-test/resolve/main/work-app.py
- Command line
-
hf download hf://spaces/alliwene/chat-bot-test/work-app.py
-
curl -L -o work-app.py https://huggingface.co/spaces/alliwene/chat-bot-test/resolve/main/work-app.py
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() | |