Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- requirements.txt +1 -1
- run.ipynb +1 -1
- run.py +9 -2
requirements.txt
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
|
2 |
-
https://gradio-main-build.s3.amazonaws.com/
|
|
|
1 |
|
2 |
+
https://gradio-main-build.s3.amazonaws.com/21c0198da1b075526732ebca38ef0c883a96dc4b/gradio-3.35.2-py3-none-any.whl
|
run.ipynb
CHANGED
@@ -1 +1 @@
|
|
1 |
-
{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: chatbot_multimodal"]}, {"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 gradio as gr\n", "\n", "\n", "def add_text(history, text):\n", " history = history + [(text, None)]\n", " return history, gr.update(value=\"\", interactive=False)\n", "\n", "\n", "def add_file(history, file):\n", " history = history + [((file.name,), None)]\n", " return history\n", "\n", "\n", "def bot(history):\n", " response = \"**That's cool!**\"\n", " history[-1][1] =
|
|
|
1 |
+
{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: chatbot_multimodal"]}, {"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 gradio as gr\n", "import random\n", "import time\n", "\n", "# Chatbot demo with multimodal input (text, markdown, LaTeX, code blocks, image, audio, & video). Plus shows support for streaming text.\n", "\n", "def add_text(history, text):\n", " history = history + [(text, None)]\n", " return history, gr.update(value=\"\", interactive=False)\n", "\n", "\n", "def add_file(history, file):\n", " history = history + [((file.name,), None)]\n", " return history\n", "\n", "\n", "def bot(history):\n", " response = \"**That's cool!**\"\n", " history[-1][1] = \"\"\n", " for character in response:\n", " history[-1][1] += character\n", " time.sleep(0.05)\n", " yield history\n", "\n", "\n", "with gr.Blocks() as demo:\n", " chatbot = gr.Chatbot([], elem_id=\"chatbot\").style(height=750)\n", "\n", " with gr.Row():\n", " with gr.Column(scale=0.85):\n", " txt = gr.Textbox(\n", " show_label=False,\n", " placeholder=\"Enter text and press enter, or upload an image\",\n", " ).style(container=False)\n", " with gr.Column(scale=0.15, min_width=0):\n", " btn = gr.UploadButton(\"\ud83d\udcc1\", file_types=[\"image\", \"video\", \"audio\"])\n", "\n", " txt_msg = txt.submit(add_text, [chatbot, txt], [chatbot, txt], queue=False).then(\n", " bot, chatbot, chatbot\n", " )\n", " txt_msg.then(lambda: gr.update(interactive=True), None, [txt], queue=False)\n", " file_msg = btn.upload(add_file, [chatbot, btn], [chatbot], queue=False).then(\n", " bot, chatbot, chatbot\n", " )\n", "\n", "demo.queue()\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
|
run.py
CHANGED
@@ -1,5 +1,8 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
|
|
3 |
|
4 |
def add_text(history, text):
|
5 |
history = history + [(text, None)]
|
@@ -13,8 +16,11 @@ def add_file(history, file):
|
|
13 |
|
14 |
def bot(history):
|
15 |
response = "**That's cool!**"
|
16 |
-
history[-1][1] =
|
17 |
-
|
|
|
|
|
|
|
18 |
|
19 |
|
20 |
with gr.Blocks() as demo:
|
@@ -37,5 +43,6 @@ with gr.Blocks() as demo:
|
|
37 |
bot, chatbot, chatbot
|
38 |
)
|
39 |
|
|
|
40 |
if __name__ == "__main__":
|
41 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import random
|
3 |
+
import time
|
4 |
|
5 |
+
# Chatbot demo with multimodal input (text, markdown, LaTeX, code blocks, image, audio, & video). Plus shows support for streaming text.
|
6 |
|
7 |
def add_text(history, text):
|
8 |
history = history + [(text, None)]
|
|
|
16 |
|
17 |
def bot(history):
|
18 |
response = "**That's cool!**"
|
19 |
+
history[-1][1] = ""
|
20 |
+
for character in response:
|
21 |
+
history[-1][1] += character
|
22 |
+
time.sleep(0.05)
|
23 |
+
yield history
|
24 |
|
25 |
|
26 |
with gr.Blocks() as demo:
|
|
|
43 |
bot, chatbot, chatbot
|
44 |
)
|
45 |
|
46 |
+
demo.queue()
|
47 |
if __name__ == "__main__":
|
48 |
demo.launch()
|