freddyaboulton HF Staff commited on
Commit
06ef074
·
verified ·
1 Parent(s): 085ac50

Upload folder using huggingface_hub

Browse files
Files changed (7) hide show
  1. README.md +7 -7
  2. cached_testcase.py +19 -0
  3. files/avatar.png +0 -0
  4. files/cantina.wav +0 -0
  5. requirements.txt +2 -0
  6. run.ipynb +1 -0
  7. run.py +19 -0
README.md CHANGED
@@ -1,12 +1,12 @@
 
1
  ---
2
- title: Test Chatinterface Multimodal Examples Main
3
- emoji: 👁
4
- colorFrom: blue
5
- colorTo: red
6
  sdk: gradio
7
  sdk_version: 5.8.0
8
- app_file: app.py
9
  pinned: false
 
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+
2
  ---
3
+ title: test_chatinterface_multimodal_examples_main
4
+ emoji: 🔥
5
+ colorFrom: indigo
6
+ colorTo: indigo
7
  sdk: gradio
8
  sdk_version: 5.8.0
9
+ app_file: run.py
10
  pinned: false
11
+ hf_oauth: true
12
  ---
 
 
cached_testcase.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pathlib import Path
2
+ import gradio as gr
3
+
4
+ image = str(Path(__file__).parent / "files" / "avatar.png")
5
+ audio = str(Path(__file__).parent / "files" / "cantina.wav")
6
+
7
+ def echo(message, history):
8
+ return f"You wrote: {message['text']} and uploaded {len(message['files'])} files."
9
+
10
+ demo = gr.ChatInterface(
11
+ fn=echo,
12
+ type="messages",
13
+ examples=[{"text": "hello"}, {"text": "hola", "files": [image]}, {"text": "merhaba", "files": [image, audio]}],
14
+ title="Echo Bot",
15
+ multimodal=True,
16
+ )
17
+
18
+ if __name__ == "__main__":
19
+ demo.launch()
files/avatar.png ADDED
files/cantina.wav ADDED
Binary file (132 kB). View file
 
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio-client @ git+https://github.com/gradio-app/gradio@48e4aa9d627b6958a0b215d6312de508845f669c#subdirectory=client/python
2
+ https://gradio-pypi-previews.s3.amazonaws.com/48e4aa9d627b6958a0b215d6312de508845f669c/gradio-5.8.0-py3-none-any.whl
run.ipynb ADDED
@@ -0,0 +1 @@
 
 
1
+ {"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: test_chatinterface_multimodal_examples"]}, {"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/test_chatinterface_multimodal_examples/cached_testcase.py\n", "os.mkdir('files')\n", "!wget -q -O files/avatar.png https://github.com/gradio-app/gradio/raw/main/demo/test_chatinterface_multimodal_examples/files/avatar.png\n", "!wget -q -O files/cantina.wav https://github.com/gradio-app/gradio/raw/main/demo/test_chatinterface_multimodal_examples/files/cantina.wav"]}, {"cell_type": "code", "execution_count": null, "id": "44380577570523278879349135829904343037", "metadata": {}, "outputs": [], "source": ["from pathlib import Path\n", "import gradio as gr\n", "\n", "image = str(Path(__file__).parent / \"files\" / \"avatar.png\")\n", "audio = str(Path(__file__).parent / \"files\" / \"cantina.wav\")\n", "\n", "def echo(message, history):\n", " return f\"You wrote: {message['text']} and uploaded {len(message['files'])} files.\"\n", "\n", "demo = gr.ChatInterface(\n", " fn=echo,\n", " type=\"messages\",\n", " examples=[{\"text\": \"hello\"}, {\"text\": \"hola\", \"files\": [image]}, {\"text\": \"merhaba\", \"files\": [image, audio]}],\n", " title=\"Echo Bot\",\n", " multimodal=True,\n", ")\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
run.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pathlib import Path
2
+ import gradio as gr
3
+
4
+ image = str(Path(__file__).parent / "files" / "avatar.png")
5
+ audio = str(Path(__file__).parent / "files" / "cantina.wav")
6
+
7
+ def echo(message, history):
8
+ return f"You wrote: {message['text']} and uploaded {len(message['files'])} files."
9
+
10
+ demo = gr.ChatInterface(
11
+ fn=echo,
12
+ type="messages",
13
+ examples=[{"text": "hello"}, {"text": "hola", "files": [image]}, {"text": "merhaba", "files": [image, audio]}],
14
+ title="Echo Bot",
15
+ multimodal=True,
16
+ )
17
+
18
+ if __name__ == "__main__":
19
+ demo.launch()