Spaces:
Sleeping
Sleeping
Download app.py from zelk12/Chat_interface_test: direct link, hf CLI and curl.
- Browser
- Download file 2.55 kB
-
https://huggingface.co/spaces/zelk12/Chat_interface_test/resolve/main/app.py
- Command line
-
hf download hf://spaces/zelk12/Chat_interface_test/app.py
-
curl -L -o app.py https://huggingface.co/spaces/zelk12/Chat_interface_test/resolve/main/app.py
2.55 kB
| #========= | |
| #========= | |
| # Library Import | |
| import random | |
| import gradio as gr | |
| from huggingface_hub import InferenceClient | |
| #========= | |
| #========= | |
| # Backend Logic | |
| def random_response(message, history): | |
| return random.choice(["Yes", "No"]) | |
| # ========= | |
| # ========= | |
| # User Interface (UI) Definition | |
| with gr.Blocks(theme=gr.themes.Soft(primary_hue="teal", secondary_hue="slate", neutral_hue="neutral")) as demo: # Using Soft theme with adjusted hues for a refined look | |
| gr.HTML("""<a href="https://visitorbadge.io/status?path=https%3A%2F%2Fhuggingface.co%2Fspaces%2Fzelk12%2FChat_interface_test"> | |
| <img src="https://api.visitorbadge.io/api/combined?path=https%3A%2F%2Fhuggingface.co%2Fspaces%2Fzelk12%2FChat_interface_test&countColor=%23263759" /> | |
| </a>""") | |
| with gr.Accordion( | |
| "API", | |
| open=False, | |
| ): | |
| with gr.Row(): | |
| gr.Textbox( | |
| label="API key", | |
| scale=4, | |
| ) | |
| with gr.Column(): | |
| gr.Button( | |
| value="Apply", | |
| scale=1, | |
| ) | |
| gr.Button( | |
| value="Reset", | |
| scale=1, | |
| ) | |
| gr.Markdown("API key State: False") | |
| gr.Dropdown(label="Choose provider") | |
| gr.Markdown("Provider State: False") | |
| gr.ChatInterface(random_response, | |
| multimodal=True, | |
| chatbot=gr.Chatbot( | |
| label="output", | |
| ), | |
| type="messages", | |
| textbox=gr.MultimodalTextbox( | |
| label="input", | |
| ), | |
| editable=True, | |
| title="Chat interface test", | |
| save_history=True, | |
| ) | |
| gr.Markdown("Token in output: False") | |
| gr.Markdown("Token in input: False") | |
| with gr.Accordion( | |
| "Settings", | |
| open=False, | |
| ): | |
| gr.Dropdown(label="Choose model") | |
| gr.Textbox(label="System instructions",) | |
| gr.Slider(label="temperature", | |
| interactive=True, | |
| minimum=0, | |
| maximum=2, | |
| value=0.95) | |
| gr.Slider(label="topP", | |
| interactive=True, | |
| minimum=0, | |
| maximum=1, | |
| value=0.5) | |
| gr.Slider(label="topK", | |
| interactive=True, | |
| value=100) | |
| gr.Checkbox( | |
| label="Enable output stream" | |
| ) | |
| gr.Checkbox( | |
| label="Grounding with Google Search" | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() |