aliabd HF staff commited on
Commit
ccc7a73
1 Parent(s): f1cc7be

Upload folder using huggingface_hub

Browse files
Files changed (5) hide show
  1. README.md +1 -1
  2. avatar.png +0 -0
  3. requirements.txt +1 -1
  4. run.ipynb +1 -1
  5. run.py +15 -9
README.md CHANGED
@@ -5,7 +5,7 @@ emoji: 🔥
5
  colorFrom: indigo
6
  colorTo: indigo
7
  sdk: gradio
8
- sdk_version: 3.40.1
9
  app_file: run.py
10
  pinned: false
11
  hf_oauth: true
 
5
  colorFrom: indigo
6
  colorTo: indigo
7
  sdk: gradio
8
+ sdk_version: 3.41.2
9
  app_file: run.py
10
  pinned: false
11
  hf_oauth: true
avatar.png ADDED
requirements.txt CHANGED
@@ -1 +1 @@
1
- https://gradio-main-build.s3.amazonaws.com/2e720c0c47ea94923ab689f928308157f2c30b2d/gradio-3.40.1-py3-none-any.whl
 
1
+ https://gradio-main-build.s3.amazonaws.com/d76d50112328711b1a692b80c1e88a085b15b301/gradio-3.41.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", "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\", 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", " 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}
 
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": ["# Downloading files from the demo repo\n", "import os\n", "!wget -q https://github.com/gradio-app/gradio/raw/main/demo/chatbot_multimodal/avatar.png"]}, {"cell_type": "code", "execution_count": null, "id": 44380577570523278879349135829904343037, "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import os\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", "\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(\n", " [],\n", " elem_id=\"chatbot\",\n", " bubble_full_width=False,\n", " avatar_images=(None, (os.path.join(os.path.abspath(''), \"avatar.png\"))),\n", " )\n", "\n", " with gr.Row():\n", " txt = gr.Textbox(\n", " scale=4,\n", " show_label=False,\n", " placeholder=\"Enter text and press enter, or upload an image\",\n", " container=False,\n", " )\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,9 +1,10 @@
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)]
9
  return history, gr.update(value="", interactive=False)
@@ -24,16 +25,21 @@ def bot(history):
24
 
25
 
26
  with gr.Blocks() as demo:
27
- chatbot = gr.Chatbot([], elem_id="chatbot", height=750)
 
 
 
 
 
28
 
29
  with gr.Row():
30
- with gr.Column(scale=0.85):
31
- txt = gr.Textbox(
32
- show_label=False,
33
- placeholder="Enter text and press enter, or upload an image",
34
- container=False)
35
- with gr.Column(scale=0.15, min_width=0):
36
- btn = gr.UploadButton("📁", file_types=["image", "video", "audio"])
37
 
38
  txt_msg = txt.submit(add_text, [chatbot, txt], [chatbot, txt], queue=False).then(
39
  bot, chatbot, chatbot
 
1
  import gradio as gr
2
+ import os
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
+
8
  def add_text(history, text):
9
  history = history + [(text, None)]
10
  return history, gr.update(value="", interactive=False)
 
25
 
26
 
27
  with gr.Blocks() as demo:
28
+ chatbot = gr.Chatbot(
29
+ [],
30
+ elem_id="chatbot",
31
+ bubble_full_width=False,
32
+ avatar_images=(None, (os.path.join(os.path.dirname(__file__), "avatar.png"))),
33
+ )
34
 
35
  with gr.Row():
36
+ txt = gr.Textbox(
37
+ scale=4,
38
+ show_label=False,
39
+ placeholder="Enter text and press enter, or upload an image",
40
+ container=False,
41
+ )
42
+ btn = gr.UploadButton("📁", file_types=["image", "video", "audio"])
43
 
44
  txt_msg = txt.submit(add_text, [chatbot, txt], [chatbot, txt], queue=False).then(
45
  bot, chatbot, chatbot