Upload folder using huggingface_hub
Browse files- requirements.txt +2 -2
- run.ipynb +1 -1
- run.py +14 -2
requirements.txt
CHANGED
|
@@ -1,2 +1,2 @@
|
|
| 1 |
-
gradio-client @ git+https://github.com/gradio-app/gradio@
|
| 2 |
-
https://gradio-pypi-previews.s3.amazonaws.com/
|
|
|
|
| 1 |
+
gradio-client @ git+https://github.com/gradio-app/gradio@69ecab35782a6704be6c1164eed41e8ade04e503#subdirectory=client/python
|
| 2 |
+
https://gradio-pypi-previews.s3.amazonaws.com/69ecab35782a6704be6c1164eed41e8ade04e503/gradio-5.38.2-py3-none-any.whl
|
run.ipynb
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: chatinterface_deep_link"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import time\n", "import gradio as gr\n", "\n", "def slow_echo(message, history):\n", " for i in range(len(message[\"text\"])):\n", " time.sleep(0.05)\n", " yield \"You typed: \" + message[\"text\"][: i + 1]\n", "\n", "chat = gr.ChatInterface(\n", " slow_echo,\n", " type=\"messages\",\n", " flagging_mode=\"manual\",\n", " flagging_options=[\"Like\", \"Spam\", \"Inappropriate\", \"Other\"],\n", " save_history=False,\n", " multimodal=True,\n", ")\n", "\n", "with gr.Blocks() as demo:\n", "
|
|
|
|
| 1 |
+
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: chatinterface_deep_link"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import time\n", "import gradio as gr\n", "\n", "def slow_echo(message, history):\n", " for i in range(len(message[\"text\"])):\n", " time.sleep(0.05)\n", " yield \"You typed: \" + message[\"text\"][: i + 1]\n", "\n", "chat = gr.ChatInterface(\n", " slow_echo,\n", " type=\"messages\",\n", " flagging_mode=\"manual\",\n", " flagging_options=[\"Like\", \"Spam\", \"Inappropriate\", \"Other\"],\n", " save_history=False,\n", " multimodal=True,\n", ")\n", "\n", "with gr.Blocks() as demo:\n", "\n", " chat.render()\n", " gr.DeepLinkButton()\n", "\n", "with demo.route(\"cached_examples\"):\n", " gr.Interface(lambda x, y: f\"{y}: {x}\",\n", " inputs=[gr.Textbox(label=\"name\"),\n", " gr.Radio(label=\"Salutation\", choices=[\"Hello\", \"Greetings\"])\n", " ],\n", " outputs=gr.Textbox(label=\"Output\"),\n", " examples=[[\"Freddy\", \"Hello\"]],\n", " cache_examples=True,\n", " deep_link=True)\n", "\n", "\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
|
run.py
CHANGED
|
@@ -16,8 +16,20 @@ chat = gr.ChatInterface(
|
|
| 16 |
)
|
| 17 |
|
| 18 |
with gr.Blocks() as demo:
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
|
| 23 |
if __name__ == "__main__":
|
|
|
|
| 16 |
)
|
| 17 |
|
| 18 |
with gr.Blocks() as demo:
|
| 19 |
+
|
| 20 |
+
chat.render()
|
| 21 |
+
gr.DeepLinkButton()
|
| 22 |
+
|
| 23 |
+
with demo.route("cached_examples"):
|
| 24 |
+
gr.Interface(lambda x, y: f"{y}: {x}",
|
| 25 |
+
inputs=[gr.Textbox(label="name"),
|
| 26 |
+
gr.Radio(label="Salutation", choices=["Hello", "Greetings"])
|
| 27 |
+
],
|
| 28 |
+
outputs=gr.Textbox(label="Output"),
|
| 29 |
+
examples=[["Freddy", "Hello"]],
|
| 30 |
+
cache_examples=True,
|
| 31 |
+
deep_link=True)
|
| 32 |
+
|
| 33 |
|
| 34 |
|
| 35 |
if __name__ == "__main__":
|