Skip to content

Commit fac3844

Browse files
Upgrade ty to 0.0.2 (#12582)
* changes * changes * add changeset * changes * changes * changes * changes * changes * add changeset --------- Co-authored-by: gradio-pr-bot <[email protected]>
1 parent 5cf1ae5 commit fac3844

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+280
-260
lines changed

.changeset/fast-ads-retire.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"gradio": patch
3+
---
4+
5+
feat:Upgrade `ty` to `0.0.2`
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pytest-asyncio
22
pytest==7.1.2
33
pytest-xdist
4-
ty==0.0.1a18
4+
ty==0.0.2
55
pydub==0.25.1

demo/audio_subtitle/run.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: audio_subtitle"]}, {"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", "from gradio.media import get_audio, get_file, MEDIA_PATHS\n", "\n", "\n", "a = get_audio(\"cate_blanch.mp3\")\n", "b = get_audio(\"cate_blanch_2.mp3\")\n", "s1 = get_file(\"s1.srt\")\n", "s2 = get_file(\"s2.vtt\")\n", "\n", "\n", "def add_subtitles_to_audio(audio, subtitles=None):\n", " if subtitles is None:\n", " return audio\n", " if subtitles is not None:\n", " return gr.Audio(label=\"Out\", value=audio, subtitles=subtitles.name)\n", "\n", "\n", "demo = gr.Interface(\n", " fn=add_subtitles_to_audio,\n", " inputs=[\n", " gr.Audio(label=\"In\", interactive=True),\n", " gr.File(label=\"Subtitle\", file_types=[\".srt\", \".vtt\"]),\n", " ],\n", " outputs=gr.Audio(label=\"Out\"),\n", " examples=[\n", " [a, s1],\n", " [b, s2],\n", " ],\n", " api_name=\"predict\",\n", ")\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch(allowed_paths=[MEDIA_PATHS])\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
1+
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: audio_subtitle"]}, {"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", "from gradio.media import get_audio, get_file, MEDIA_PATHS\n", "\n", "\n", "a = get_audio(\"cate_blanch.mp3\")\n", "b = get_audio(\"cate_blanch_2.mp3\")\n", "s1 = get_file(\"s1.srt\")\n", "s2 = get_file(\"s2.vtt\")\n", "\n", "\n", "def add_subtitles_to_audio(audio, subtitles=None):\n", " if subtitles is None:\n", " return audio\n", " if subtitles is not None:\n", " return gr.Audio(label=\"Out\", value=audio, subtitles=subtitles.name)\n", "\n", "\n", "demo = gr.Interface(\n", " fn=add_subtitles_to_audio,\n", " inputs=[\n", " gr.Audio(label=\"In\", interactive=True),\n", " gr.File(label=\"Subtitle\", file_types=[\".srt\", \".vtt\"]),\n", " ],\n", " outputs=gr.Audio(label=\"Out\"),\n", " examples=[\n", " [a, s1],\n", " [b, s2],\n", " ],\n", " api_name=\"predict\",\n", ")\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch(allowed_paths=[MEDIA_PATHS]) # type: ignore\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}

demo/audio_subtitle/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ def add_subtitles_to_audio(audio, subtitles=None):
3030
)
3131

3232
if __name__ == "__main__":
33-
demo.launch(allowed_paths=[MEDIA_PATHS])
33+
demo.launch(allowed_paths=[MEDIA_PATHS]) # type: ignore

demo/blocks_outputs/run.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: blocks_outputs"]}, {"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", "def make_markdown():\n", " return [\n", " [\n", " \"# hello again\",\n", " \"Hello my name is frank, I am liking the small turtle you have there. It would be a shame if it went missing.\",\n", " '<img src=\"https://images.unsplash.com/photo-1574613362884-f79513a5128c?fit=crop&w=500&q=80\"/>',\n", " ],\n", " [\n", " \"## hello again again\",\n", " \"Hello my name is frank, I am liking the small turtle you have there. It would be a shame if it went missing.\",\n", " '<img src=\"https://images.unsplash.com/photo-1574613362884-f79513a5128c?fit=crop&w=500&q=80\"/>',\n", " ],\n", " [\n", " \"### hello thrice\",\n", " \"Hello my name is frank, I am liking the small turtle you have there. It would be a shame if it went missing.\",\n", " '<img src=\"https://images.unsplash.com/photo-1574613362884-f79513a5128c?fit=crop&w=500&q=80\"/>',\n", " ],\n", " ]\n", "\n", "with gr.Blocks() as demo:\n", " with gr.Column():\n", " txt = gr.Textbox(label=\"Small Textbox\", lines=1, show_label=False)\n", " txt = gr.Textbox(label=\"Large Textbox\", lines=5, show_label=False)\n", " num = gr.Number(label=\"Number\", show_label=False)\n", " check = gr.Checkbox(label=\"Checkbox\", show_label=False)\n", " check_g = gr.CheckboxGroup(\n", " label=\"Checkbox Group\", choices=[\"One\", \"Two\", \"Three\"], show_label=False\n", " )\n", " radio = gr.Radio(\n", " label=\"Radio\", choices=[\"One\", \"Two\", \"Three\"], show_label=False\n", " )\n", " drop = gr.Dropdown(\n", " label=\"Dropdown\", choices=[\"One\", \"Two\", \"Three\"], show_label=False\n", " )\n", " slider = gr.Slider(label=\"Slider\", show_label=False)\n", " audio = gr.Audio(show_label=False)\n", " file = gr.File(show_label=False)\n", " video = gr.Video(show_label=False)\n", " image = gr.Image(show_label=False)\n", " df = gr.Dataframe(show_label=False)\n", " html = gr.HTML(show_label=False)\n", " json = gr.JSON(show_label=False)\n", " md = gr.Markdown(show_label=False)\n", " label = gr.Label(show_label=False)\n", " highlight = gr.HighlightedText(show_label=False)\n", " gr.Dataframe(interactive=True, column_count=3, column_limits=(3, 3), label=\"Dataframe\")\n", " gr.Dataframe(interactive=True, column_count=4, label=\"Dataframe\")\n", " gr.Dataframe(\n", " interactive=True, headers=[\"One\", \"Two\", \"Three\", \"Four\"], label=\"Dataframe\"\n", " )\n", " gr.Dataframe(\n", " interactive=True,\n", " headers=[\"One\", \"Two\", \"Three\", \"Four\"],\n", " column_count=4,\n", " column_limits=(4, 4),\n", " row_count=7,\n", " row_limits=(7, 7),\n", " value=[[0, 0, 0, 0]],\n", " label=\"Dataframe\",\n", " )\n", " gr.Dataframe(\n", " interactive=True, headers=[\"One\", \"Two\", \"Three\", \"Four\"], column_count=4\n", " )\n", " df = gr.DataFrame(\n", " [\n", " [\n", " \"# hello\",\n", " \"Hello my name is frank, I am liking the small turtle you have there. It would be a shame if it went missing.\",\n", " '<img src=\"https://images.unsplash.com/photo-1574613362884-f79513a5128c?fit=crop&w=500&q=80\"/>',\n", " ],\n", " [\n", " \"## hello\",\n", " \"Hello my name is frank, I am liking the small turtle you have there. It would be a shame if it went missing.\",\n", " '<img src=\"https://images.unsplash.com/photo-1574613362884-f79513a5128c?fit=crop&w=500&q=80\"/>',\n", " ],\n", " [\n", " \"### hello\",\n", " \"Hello my name is frank, I am liking the small turtle you have there. It would be a shame if it went missing.\",\n", " '<img src=\"https://images.unsplash.com/photo-1574613362884-f79513a5128c?fit=crop&w=500&q=80\"/>',\n", " ],\n", " ],\n", " headers=[\"One\", \"Two\", \"Three\"],\n", " wrap=True,\n", " datatype=[\"markdown\", \"markdown\", \"html\"],\n", " interactive=True,\n", " )\n", " btn = gr.Button(\"Run\")\n", " btn.click(fn=make_markdown, inputs=None, outputs=df)\n", "\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: blocks_outputs"]}, {"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", "def make_markdown():\n", " return [\n", " [\n", " \"# hello again\",\n", " \"Hello my name is frank, I am liking the small turtle you have there. It would be a shame if it went missing.\",\n", " '<img src=\"https://images.unsplash.com/photo-1574613362884-f79513a5128c?fit=crop&w=500&q=80\"/>',\n", " ],\n", " [\n", " \"## hello again again\",\n", " \"Hello my name is frank, I am liking the small turtle you have there. It would be a shame if it went missing.\",\n", " '<img src=\"https://images.unsplash.com/photo-1574613362884-f79513a5128c?fit=crop&w=500&q=80\"/>',\n", " ],\n", " [\n", " \"### hello thrice\",\n", " \"Hello my name is frank, I am liking the small turtle you have there. It would be a shame if it went missing.\",\n", " '<img src=\"https://images.unsplash.com/photo-1574613362884-f79513a5128c?fit=crop&w=500&q=80\"/>',\n", " ],\n", " ]\n", "\n", "with gr.Blocks() as demo:\n", " with gr.Column():\n", " txt = gr.Textbox(label=\"Small Textbox\", lines=1, show_label=False)\n", " txt = gr.Textbox(label=\"Large Textbox\", lines=5, show_label=False)\n", " num = gr.Number(label=\"Number\", show_label=False)\n", " check = gr.Checkbox(label=\"Checkbox\", show_label=False)\n", " check_g = gr.CheckboxGroup(\n", " label=\"Checkbox Group\", choices=[\"One\", \"Two\", \"Three\"], show_label=False\n", " )\n", " radio = gr.Radio(\n", " label=\"Radio\", choices=[\"One\", \"Two\", \"Three\"], show_label=False\n", " )\n", " drop = gr.Dropdown(\n", " label=\"Dropdown\", choices=[\"One\", \"Two\", \"Three\"], show_label=False\n", " )\n", " slider = gr.Slider(label=\"Slider\", show_label=False)\n", " audio = gr.Audio(show_label=False)\n", " file = gr.File(show_label=False)\n", " video = gr.Video(show_label=False)\n", " image = gr.Image(show_label=False)\n", " df = gr.Dataframe(show_label=False)\n", " html = gr.HTML(show_label=False)\n", " json = gr.JSON(show_label=False)\n", " md = gr.Markdown(show_label=False)\n", " label = gr.Label(show_label=False)\n", " highlight = gr.HighlightedText(show_label=False)\n", " gr.Dataframe(interactive=True, column_count=3, column_limits=(3, 3), label=\"Dataframe\")\n", " gr.Dataframe(interactive=True, column_count=4, label=\"Dataframe\")\n", " gr.Dataframe(\n", " interactive=True, headers=[\"One\", \"Two\", \"Three\", \"Four\"], label=\"Dataframe\"\n", " )\n", " gr.Dataframe(\n", " interactive=True,\n", " headers=[\"One\", \"Two\", \"Three\", \"Four\"],\n", " column_count=4,\n", " column_limits=(4, 4),\n", " row_count=7,\n", " row_limits=(7, 7),\n", " value=[[0, 0, 0, 0]],\n", " label=\"Dataframe\",\n", " )\n", " gr.Dataframe(\n", " interactive=True, headers=[\"One\", \"Two\", \"Three\", \"Four\"], column_count=4\n", " )\n", " df = gr.DataFrame(\n", " [\n", " [\n", " \"# hello\",\n", " \"Hello my name is frank, I am liking the small turtle you have there. It would be a shame if it went missing.\",\n", " '<img src=\"https://images.unsplash.com/photo-1574613362884-f79513a5128c?fit=crop&w=500&q=80\"/>',\n", " ],\n", " [\n", " \"## hello\",\n", " \"Hello my name is frank, I am liking the small turtle you have there. It would be a shame if it went missing.\",\n", " '<img src=\"https://images.unsplash.com/photo-1574613362884-f79513a5128c?fit=crop&w=500&q=80\"/>',\n", " ],\n", " [\n", " \"### hello\",\n", " \"Hello my name is frank, I am liking the small turtle you have there. It would be a shame if it went missing.\",\n", " '<img src=\"https://images.unsplash.com/photo-1574613362884-f79513a5128c?fit=crop&w=500&q=80\"/>',\n", " ],\n", " ],\n", " headers=[\"One\", \"Two\", \"Three\"],\n", " wrap=True,\n", " datatype=[\"markdown\", \"markdown\", \"html\"], # type: ignore\n", " interactive=True,\n", " )\n", " btn = gr.Button(\"Run\")\n", " btn.click(fn=make_markdown, inputs=None, outputs=df)\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}

demo/blocks_outputs/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def make_markdown():
8383
],
8484
headers=["One", "Two", "Three"],
8585
wrap=True,
86-
datatype=["markdown", "markdown", "html"],
86+
datatype=["markdown", "markdown", "html"], # type: ignore
8787
interactive=True,
8888
)
8989
btn = gr.Button("Run")

demo/chatbot_component/run.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: chatbot_component"]}, {"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", "with gr.Blocks() as demo:\n", " gr.Chatbot(value=[\n", " {\"role\": \"user\", \"content\": \"Hello World\"},\n", " {\"role\": \"assistant\", \"content\": \"Hey Gradio!\"},\n", " {\"role\": \"user\", \"content\": \"\u2764\ufe0f\"},\n", " {\"role\": \"assistant\", \"content\": \"\ud83d\ude0d\"},\n", " {\"role\": \"user\", \"content\": \"\ud83d\udd25\"},\n", " {\"role\": \"assistant\", \"content\": \"\ud83e\udd17\"}\n", " ])\n", "\n", "demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
1+
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: chatbot_component"]}, {"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", "with gr.Blocks() as demo:\n", " gr.Chatbot(value=[ # type: ignore\n", " {\"role\": \"user\", \"content\": \"Hello World\"},\n", " {\"role\": \"assistant\", \"content\": \"Hey Gradio!\"},\n", " {\"role\": \"user\", \"content\": \"\u2764\ufe0f\"},\n", " {\"role\": \"assistant\", \"content\": \"\ud83d\ude0d\"},\n", " {\"role\": \"user\", \"content\": \"\ud83d\udd25\"},\n", " {\"role\": \"assistant\", \"content\": \"\ud83e\udd17\"}\n", " ])\n", "\n", "demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}

demo/chatbot_component/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import gradio as gr
22

33
with gr.Blocks() as demo:
4-
gr.Chatbot(value=[
4+
gr.Chatbot(value=[ # type: ignore
55
{"role": "user", "content": "Hello World"},
66
{"role": "assistant", "content": "Hey Gradio!"},
77
{"role": "user", "content": "❤️"},

0 commit comments

Comments
 (0)