-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds a
run_examples_on_click
parameter to gr.ChatInterface
mirror…
…ing the the `run_on_click` parameter in `gr.Examples` (#10109) * add param * add changeset * add changeset * more changes * add changeset * slight refactor * add changeset * fix * fixes * tweak * clean * clean * lint * upload * notebook * more testing * changes * notebook * add changeset * notebooks * format * format * fix undo * changes * changes * fix * changes * fix assert --------- Co-authored-by: gradio-pr-bot <[email protected]>
- Loading branch information
1 parent
6645518
commit 48e4aa9
Showing
13 changed files
with
222 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"gradio": minor | ||
"website": minor | ||
--- | ||
|
||
feat:adds a `run_examples_on_click` parameter to `gr.ChatInterface` mirroring the the `run_on_click` parameter in `gr.Examples` |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
demo/test_chatinterface_multimodal_examples/cached_testcase.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from pathlib import Path | ||
import gradio as gr | ||
|
||
image = str(Path(__file__).parent / "files" / "avatar.png") | ||
audio = str(Path(__file__).parent / "files" / "cantina.wav") | ||
|
||
def echo(message, history): | ||
return f"You wrote: {message['text']} and uploaded {len(message['files'])} files." | ||
|
||
demo = gr.ChatInterface( | ||
fn=echo, | ||
type="messages", | ||
examples=[{"text": "hello"}, {"text": "hola", "files": [image]}, {"text": "merhaba", "files": [image, audio]}], | ||
title="Echo Bot", | ||
multimodal=True, | ||
) | ||
|
||
if __name__ == "__main__": | ||
demo.launch() |
File renamed without changes
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from pathlib import Path | ||
import gradio as gr | ||
|
||
image = str(Path(__file__).parent / "files" / "avatar.png") | ||
audio = str(Path(__file__).parent / "files" / "cantina.wav") | ||
|
||
def echo(message, history): | ||
return f"You wrote: {message['text']} and uploaded {len(message['files'])} files." | ||
|
||
demo = gr.ChatInterface( | ||
fn=echo, | ||
type="messages", | ||
examples=[{"text": "hello"}, {"text": "hola", "files": [image]}, {"text": "merhaba", "files": [image, audio]}], | ||
title="Echo Bot", | ||
multimodal=True, | ||
) | ||
|
||
if __name__ == "__main__": | ||
demo.launch() |
Oops, something went wrong.