repo
stringlengths
7
90
file_url
stringlengths
81
315
file_path
stringlengths
4
228
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 14:38:15
2026-01-05 02:33:18
truncated
bool
2 classes
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/themes/app.py
gradio/themes/app.py
import time import gradio as gr from gradio.themes.utils.theme_dropdown import create_theme_dropdown dropdown, js = create_theme_dropdown() with gr.Blocks() as demo: with gr.Row(equal_height=True): with gr.Column(scale=10): gr.Markdown( """ # Theme preview: `{T...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/themes/origin.py
gradio/themes/origin.py
from __future__ import annotations from collections.abc import Iterable from gradio.themes.base import Base from gradio.themes.utils import colors, fonts, sizes class Origin(Base): def __init__( self, *, primary_hue: colors.Color | str = colors.orange, secondary_hue: colors.Color...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/themes/utils/semver_match.py
gradio/themes/utils/semver_match.py
from __future__ import annotations from dataclasses import dataclass, field import huggingface_hub import semantic_version import semantic_version as semver @dataclass class ThemeAsset: filename: str version: semver.Version = field(init=False) def __post_init__(self): self.version = semver.Vers...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/themes/utils/__init__.py
gradio/themes/utils/__init__.py
from .semver_match import ( ThemeAsset, get_matching_version, get_theme_assets, ) __all__ = [ "ThemeAsset", "get_theme_assets", "get_matching_version", ]
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/themes/utils/readme_content.py
gradio/themes/utils/readme_content.py
README_CONTENT = """ --- tags: [gradio-theme] title: {theme_name} colorFrom: red colorTo: purple sdk: gradio sdk_version: {gradio_version} app_file: app.py pinned: false license: apache-2.0 --- # {theme_name} ## Description {description} ## Contributions Thanks to [@{author}](https://huggingface.co/{author}) for adding...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/themes/utils/fonts.py
gradio/themes/utils/fonts.py
from __future__ import annotations import json import textwrap from collections.abc import Iterable class FontEncoder(json.JSONEncoder): def default(self, obj): if isinstance(obj, Font): return { "__gradio_font__": True, "name": obj.name, "class...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/themes/utils/theme_dropdown.py
gradio/themes/utils/theme_dropdown.py
import os import pathlib from gradio.themes.utils import ThemeAsset def create_theme_dropdown(): import gradio as gr asset_path = pathlib.Path() / "themes" themes = [] for theme_asset in os.listdir(str(asset_path)): themes.append( (ThemeAsset(theme_asset), gr.Theme.load(str(asset...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/themes/utils/sizes.py
gradio/themes/utils/sizes.py
from __future__ import annotations class Size: all = [] def __init__( self, xxs: str, xs: str, sm: str, md: str, lg: str, xl: str, xxl: str, name=None ): self.xxs = xxs self.xs = xs self.sm = sm self.md = md self.lg = lg self.xl = xl self.xx...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/themes/utils/colors.py
gradio/themes/utils/colors.py
from __future__ import annotations class Color: all = [] def __init__( self, c50: str, c100: str, c200: str, c300: str, c400: str, c500: str, c600: str, c700: str, c800: str, c900: str, c950: str, name: st...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/test_data/blocks_configs.py
gradio/test_data/blocks_configs.py
XRAY_CONFIG = { "version": "3.40.1", "mode": "blocks", "dev_mode": True, "analytics_enabled": False, "components": [ { "id": 31, "type": "markdown", "props": { "value": "<h1>Detect Disease From Scan</h1>\n<p>With this model you can lorem ip...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
true
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/test_data/__init__.py
gradio/test_data/__init__.py
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/cli/cli.py
gradio/cli/cli.py
import sys import typer from rich.console import Console from gradio import analytics from .commands import ( custom_component, deploy, hf_login, load_app, print_environment_info, reload, sketch, upload_mcp, ) app = typer.Typer() app.add_typer(load_app, name="load") app.command("envi...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/cli/__init__.py
gradio/cli/__init__.py
from .cli import cli, deploy from .commands import custom_component, sketch __all__ = ["cli", "deploy", "custom_component", "sketch"]
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/cli/commands/cli_env_info.py
gradio/cli/commands/cli_env_info.py
"""This file is the part of 'gradio/cli.py' for printing the environment info for the cli command 'gradio environment' """ from __future__ import annotations import platform from importlib import metadata from packaging.requirements import Requirement from rich import print def print_environment_info(): """Pri...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/cli/commands/load.py
gradio/cli/commands/load.py
from __future__ import annotations import typer from .load_chat import main as chat load_app = typer.Typer(help="Load various types of interfaces and models") load_app.command("chat", help="Launch a chat interface using OpenAI-compatible API")( chat )
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/cli/commands/reload.py
gradio/cli/commands/reload.py
""" Contains the functions that run when `gradio` is called from the command line. Specifically, allows $ gradio app.py, to run app.py in reload mode where any changes in the app.py file or Gradio library reloads the demo. $ gradio app.py my_demo, to use variable names other than "demo" """ from __future__ import an...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/cli/commands/deploy_space.py
gradio/cli/commands/deploy_space.py
from __future__ import annotations import os import re import shutil import subprocess from typing import Annotated import huggingface_hub from rich import print from typer import Option import gradio as gr repo_directory = os.getcwd() readme_file = os.path.join(repo_directory, "README.md") github_action_template =...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/cli/commands/hf_login.py
gradio/cli/commands/hf_login.py
import os from huggingface_hub import interpreter_login, whoami def save_login(): try: while True: response = input("Stay logged in to Hugging Face? (Y/n): ").strip().lower() if response in ["y", "yes", ""]: # Empty string for just pressing Enter os.environ["GRADI...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/cli/commands/load_chat.py
gradio/cli/commands/load_chat.py
from __future__ import annotations import os import typer from gradio.external import load_chat as load_chat_external def main( base_url: str = typer.Argument( ..., help="OpenAI-compatible base URL, e.g. http://localhost:11434/v1/" ), model: str = typer.Argument(..., help="Model name, e.g. llam...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/cli/commands/upload_mcp.py
gradio/cli/commands/upload_mcp.py
def main(url_or_space_id: str, source_directory: str): import httpx from gradio_client.utils import is_http_url_like from huggingface_hub import space_info from mcp.server.fastmcp import FastMCP # type: ignore from gradio.utils import abspath, is_in_or_equal source_path = abspath(source_direc...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/cli/commands/sketch.py
gradio/cli/commands/sketch.py
from __future__ import annotations def launch( app_file: str = "app.py", # noqa: ARG001 ): raise DeprecationWarning( "The 'gradio sketch' command has been deprecated and removed in Gradio 6. " "Consider using 'gradio --vibe' instead. " )
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/cli/commands/utils.py
gradio/cli/commands/utils.py
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/cli/commands/display.py
gradio/cli/commands/display.py
from __future__ import annotations import time from types import TracebackType from rich.live import Live from rich.panel import Panel class LivePanelDisplay: def __init__(self, msg: str | None = None) -> None: self.lines = [msg] if msg else [] self._panel = Live(Panel("\n".join(self.lines)), re...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/cli/commands/__init__.py
gradio/cli/commands/__init__.py
from .cli_env_info import print_environment_info from .components import app as custom_component from .deploy_space import deploy from .hf_login import hf_login from .load import load_app from .reload import main as reload from .sketch import launch as sketch from .upload_mcp import main as upload_mcp __all__ = [ ...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/cli/commands/components/show.py
gradio/cli/commands/components/show.py
from __future__ import annotations import inspect from rich.console import Console from rich.table import Table import gradio._simple_templates import gradio.components import gradio.layouts from gradio.analytics import custom_component_analytics from gradio.blocks import BlockContext from gradio.components import C...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/cli/commands/components/create.py
gradio/cli/commands/components/create.py
from __future__ import annotations import inspect import shutil from pathlib import Path from typing import Annotated import typer from rich import print from rich.panel import Panel from rich.prompt import Confirm, Prompt from tomlkit import dump, parse import gradio from gradio.analytics import custom_component_an...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/cli/commands/components/dev.py
gradio/cli/commands/components/dev.py
from __future__ import annotations import shutil import subprocess from pathlib import Path from typing import Annotated import typer from rich import print import gradio from gradio.analytics import custom_component_analytics from gradio.cli.commands.components.install_component import _get_executable_path gradio_...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/cli/commands/components/_create_utils.py
gradio/cli/commands/components/_create_utils.py
from __future__ import annotations import dataclasses import inspect import json import re import shutil import textwrap from pathlib import Path from typing import Literal from huggingface_hub import snapshot_download import gradio def _in_test_dir(): """Check if the current working directory ends with gradio...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/cli/commands/components/build.py
gradio/cli/commands/components/build.py
from __future__ import annotations import importlib import shutil import subprocess from pathlib import Path from typing import Annotated import semantic_version import typer from tomlkit import dump, parse import gradio from gradio.analytics import custom_component_analytics from gradio.cli.commands.components._doc...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/cli/commands/components/_docs_assets.py
gradio/cli/commands/components/_docs_assets.py
css = """html { font-family: Inter; font-size: 16px; font-weight: 400; line-height: 1.5; -webkit-text-size-adjust: 100%; background: #fff; color: #323232; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; } :root { --space: 1; --vspace: calc(var(--...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/cli/commands/components/publish.py
gradio/cli/commands/components/publish.py
from __future__ import annotations import re import shutil import tempfile from pathlib import Path from typing import Annotated import semantic_version from huggingface_hub import HfApi from packaging.version import Version as PEP440Version from rich import print from rich.console import Console from rich.panel impo...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/cli/commands/components/__init__.py
gradio/cli/commands/components/__init__.py
from .app import app __all__ = ["app"]
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/cli/commands/components/docs.py
gradio/cli/commands/components/docs.py
from __future__ import annotations import importlib import re from pathlib import Path from typing import Annotated, Any import httpx import tomlkit as toml from typer import Argument, Option from gradio.analytics import custom_component_analytics from gradio.cli.commands.display import LivePanelDisplay from ._docs...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/cli/commands/components/install_component.py
gradio/cli/commands/components/install_component.py
from __future__ import annotations import shutil import subprocess from pathlib import Path from typing import Annotated from rich.markup import escape from typer import Argument, Option from gradio.cli.commands.display import LivePanelDisplay from gradio.utils import set_directory def _get_npm(npm_install: str): ...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/cli/commands/components/_docs_utils.py
gradio/cli/commands/components/_docs_utils.py
from __future__ import annotations import inspect import re import shutil import types import typing from subprocess import PIPE, Popen RUFF_INSTALLED = bool(shutil.which("ruff")) def find_first_non_return_key(some_dict): """Finds the first key in a dictionary that is not "return".""" for key, value in some...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/cli/commands/components/app.py
gradio/cli/commands/components/app.py
from typer import Typer from .build import _build from .create import _create from .dev import _dev from .docs import _docs from .install_component import _install from .publish import _publish from .show import _show app = Typer(help="Create and publish a new Gradio component") app.command("create", help="Create a ...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/_simple_templates/simpledropdown.py
gradio/_simple_templates/simpledropdown.py
from __future__ import annotations import warnings from collections.abc import Callable, Sequence from typing import TYPE_CHECKING, Any, Literal from gradio.components.base import Component, FormComponent from gradio.events import Events from gradio.i18n import I18nData if TYPE_CHECKING: from gradio.components i...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/_simple_templates/simpleimage.py
gradio/_simple_templates/simpleimage.py
"""gr.SimpleImage() component.""" from __future__ import annotations from collections.abc import Sequence from pathlib import Path from typing import TYPE_CHECKING, Any, Literal from gradio_client import handle_file from gradio_client.documentation import document from gradio.components.base import Component from g...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/_simple_templates/simpletextbox.py
gradio/_simple_templates/simpletextbox.py
from __future__ import annotations from collections.abc import Callable, Sequence from typing import TYPE_CHECKING, Any, Literal from gradio.components.base import Component, FormComponent from gradio.events import Events from gradio.i18n import I18nData if TYPE_CHECKING: from gradio.components import Timer cl...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/gradio/_simple_templates/__init__.py
gradio/_simple_templates/__init__.py
from .simpledropdown import SimpleDropdown from .simpleimage import SimpleImage from .simpletextbox import SimpleTextbox __all__ = ["SimpleDropdown", "SimpleTextbox", "SimpleImage"]
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/js/preview/src/examine.py
js/preview/src/examine.py
import argparse import importlib import inspect import os from pathlib import Path import sys from tomlkit import dumps, parse from gradio.blocks import BlockContext from gradio.components import Component if __name__ == "__main__": parser = argparse.ArgumentParser(description="Description of your program") ...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/js/preview/test/test/backend/gradio_test/__init__.py
js/preview/test/test/backend/gradio_test/__init__.py
from .test import Test __all__ = ['Test']
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/js/preview/test/test/backend/gradio_test/test.py
js/preview/test/test/backend/gradio_test/test.py
from gradio.components.base import Component class Test(Component): def preprocess(self, x): return x def postprocess(self, x): return x def example_inputs(self): return {"foo": "bar"} def api_info(self): return {"type": {}, "description": "any valid json"}
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/js/preview/test/test/demo/__init__.py
js/preview/test/test/demo/__init__.py
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/js/preview/test/test/demo/app.py
js/preview/test/test/demo/app.py
from gradio_test import Test import gradio as gr example = Test().example_inputs() with gr.Blocks() as demo: Test(value=example, interactive=True) Test(value=example, interactive=False) demo.launch()
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/js/_website/generate_jsons/check_lite_demos.py
js/_website/generate_jsons/check_lite_demos.py
import os def main(): demo_to_reqs = {} for demo in os.listdir("demo"): requirements = "" # only check demos with requirements, because we don't need to check the others if os.path.exists(os.path.join("demo", demo, "requirements.txt")): with open(os.path.join("demo", demo, "...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/js/_website/generate_jsons/chunking.py
js/_website/generate_jsons/chunking.py
import re from dataclasses import dataclass from typing import List, Tuple from transformers import AutoTokenizer @dataclass class BlogChunks: title: str content: List[str] type: str url: str class TextChunker: def __init__(self, model_name: str = "voyageai/voyage-3-large"): """Initialize...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/js/_website/generate_jsons/embed.py
js/_website/generate_jsons/embed.py
import libsql_client as libsql import os from openai import OpenAI import numpy as np from chunking import TextChunker from tqdm import tqdm import requests import voyageai # vo = voyageai.Client(api_key=os.getenv("VOYAGE_API_KEY"),) url = os.getenv("TURSO_DATABASE_URL") auth_token = os.getenv("TURSO_AUTH_TOKEN") db_...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/js/_website/generate_jsons/generate.py
js/_website/generate_jsons/generate.py
import json import os import re from subprocess import run import boto3 from botocore import UNSIGNED from botocore.client import Config from src import changelog, demos, docs, guides WEBSITE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) GRADIO_DIR = os.path.abspath(os.path.join(WEBSITE_DIR, "....
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/js/_website/generate_jsons/src/demos/__init__.py
js/_website/generate_jsons/src/demos/__init__.py
import json from pathlib import Path HERE = Path(__file__).parent WEBSITE_DIR = HERE.joinpath("../../..").resolve() PROJECT_ROOT = WEBSITE_DIR.joinpath("../..").resolve() GRADIO_DEMO_DIR = PROJECT_ROOT / "demo" def get_code_description_and_reqs(demo_dir): with demo_dir.joinpath("run.py").open() as f: co...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/js/_website/generate_jsons/src/docs/__init__.py
js/_website/generate_jsons/src/docs/__init__.py
import html import json import os import re import requests import base64 import urllib.parse from gradio_client.documentation import document_cls, generate_documentation import gradio from ..guides import guides, guide_names DIR = os.path.dirname(__file__) DEMOS_DIR = os.path.abspath(os.path.join(DIR, "../../../.....
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/js/_website/generate_jsons/src/guides/__init__.py
js/_website/generate_jsons/src/guides/__init__.py
import json import os import re import markdown DIR = os.path.dirname(__file__) GUIDES_DIR = os.path.abspath(os.path.join(DIR, "../../../../../guides")) GUIDE_ASSETS_DIR = os.path.join(GUIDES_DIR, "assets") DEMOS_DIR = os.path.abspath(os.path.join(DIR, "../../../../../demo")) CN_GUIDES_DIR = os.path.abspath(os.path.jo...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/js/_website/generate_jsons/src/changelog/__init__.py
js/_website/generate_jsons/src/changelog/__init__.py
import json import os import re DIR = os.path.dirname(__file__) CHANGELOG_FILE = os.path.abspath(os.path.join(DIR, "../../../../../CHANGELOG.md")) def clean(): with open(CHANGELOG_FILE) as change_file: content = change_file.read() # remove empty/unused sections content = re.sub(r"## [\w^:\n ...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/client/python/test/test_utils.py
client/python/test/test_utils.py
import importlib.resources import json import tempfile from copy import deepcopy from enum import Enum from pathlib import Path from typing import Any, Literal, Optional, Union from unittest.mock import MagicMock, patch import httpx import pytest from huggingface_hub import get_token from gradio_client import utils ...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/client/python/test/media_data.py
client/python/test/media_data.py
from typing import cast try: from gradio.media import get_audio, get_video except Exception: def get_video(filename: str | None): return cast(str, filename) def get_audio(filename: str | None): return cast(str, filename) BASE64_IMAGE = ( # test/test_files/bus.png "data:image/png;ba...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
true
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/client/python/test/conftest.py
client/python/test/conftest.py
import inspect import random import time import gradio as gr import pytest from pydub import AudioSegment def pytest_configure(config): config.addinivalue_line( "markers", "flaky: mark test as flaky. Failure will not cause te" ) @pytest.fixture def calculator_demo(): def calculator(num1, operat...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/client/python/test/test_client.py
client/python/test/test_client.py
from __future__ import annotations import pathlib import tempfile import threading import time import uuid from concurrent.futures import CancelledError, TimeoutError, wait from contextlib import contextmanager from datetime import datetime, timedelta from pathlib import Path from unittest.mock import MagicMock, patch...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
true
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/client/python/test/test_documentation.py
client/python/test/test_documentation.py
from gradio_client import documentation class TestDocumentation: def test_website_documentation(self): docs = documentation.generate_documentation() assert len(docs) > 0
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/client/python/gradio_client/client.py
client/python/gradio_client/client.py
"""The main Client class for the Python client.""" from __future__ import annotations import asyncio import concurrent.futures import hashlib import json import math import os import re import secrets import shutil import tempfile import threading import time import urllib.parse import uuid import warnings from colle...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
true
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/client/python/gradio_client/exceptions.py
client/python/gradio_client/exceptions.py
class SerializationSetupError(ValueError): """Raised when a serializers cannot be set up correctly.""" pass class AuthenticationError(ValueError): """Raised when the client is unable to authenticate itself to a Gradio app due to invalid or missing credentials.""" pass class ValidationError(ValueEr...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/client/python/gradio_client/data_classes.py
client/python/gradio_client/data_classes.py
from __future__ import annotations from typing import Any, TypedDict from typing_extensions import NotRequired class FileData(TypedDict): name: str | None # filename data: str | None # base64 encoded data size: NotRequired[int | None] # size in bytes is_file: NotRequired[ bool ] # wh...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/client/python/gradio_client/utils.py
client/python/gradio_client/utils.py
from __future__ import annotations import asyncio import base64 import concurrent.futures import copy import inspect import json import mimetypes import os import pkgutil import secrets import shutil import tempfile import time import warnings from collections.abc import Callable, Coroutine from dataclasses import dat...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
true
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/client/python/gradio_client/documentation.py
client/python/gradio_client/documentation.py
"""Contains methods that generate documentation for Gradio functions and classes.""" from __future__ import annotations import dataclasses import inspect import warnings from collections import defaultdict from collections.abc import Callable from functools import lru_cache classes_to_document = defaultdict(list) cl...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/client/python/gradio_client/__init__.py
client/python/gradio_client/__init__.py
from gradio_client.client import Client from gradio_client.data_classes import FileData from gradio_client.utils import __version__, file, handle_file __all__ = [ "Client", "file", "handle_file", "FileData", "__version__", ]
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/client/python/gradio_client/templates/discord_chat.py
client/python/gradio_client/templates/discord_chat.py
import asyncio import os import threading from threading import Event import discord import gradio as gr from discord import Permissions from discord.ext import commands from discord.utils import oauth_url import gradio_client as grc from gradio_client.utils import QueueError event = Event() DISCORD_TOKEN = os.gete...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/__init__.py
demo/__init__.py
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/random_demos.py
demo/random_demos.py
"""Opens X demos randomly for quick inspection Usage: python random_demos.py <num_demos> Example: python random_demos.py 8 """ from __future__ import annotations import argparse import importlib import pathlib import os import random import gradio as gr parser = argparse.ArgumentParser() parser.add_argument("num_d...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/video_identity/run.py
demo/video_identity/run.py
import gradio as gr from gradio.media import get_video def video_identity(video): return video # get_video() returns file paths to sample media included with Gradio demo = gr.Interface(video_identity, gr.Video(), "playable_video", examples=[ ...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/todo_list_js/run.py
demo/todo_list_js/run.py
""" This is a simple todo list app that allows you to edit tasks and mark tasks as complete. All actions are performed on the client side. """ import gradio as gr tasks = ["Get a job", "Marry rich", "", "", "", ""] textboxes = [] buttons = [] with gr.Blocks() as demo: with gr.Row(): with gr.Column(scale=3)...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/dataset_component/run.py
demo/dataset_component/run.py
import gradio as gr with gr.Blocks() as demo: gr.Dataset(components=[gr.Textbox(visible=False)], label="Text Dataset", samples=[ ["The quick brown fox jumps over the lazy dog"], ["Build & share delightful machine learning apps"], ["She sells seashells by the seas...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/image_selections/run.py
demo/image_selections/run.py
import gradio as gr import numpy as np with gr.Blocks() as demo: tolerance = gr.Slider(label="Tolerance", info="How different colors can be in a segment.", minimum=0, maximum=256*3, value=50) with gr.Row(): input_img = gr.Image(label="Input") output_img = gr.Image(label="Selected Segment") ...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/fake_gan/run.py
demo/fake_gan/run.py
# This demo needs to be run from the repo folder. # python demo/fake_gan/run.py import random import time import gradio as gr def fake_gan(): time.sleep(1) images = [ (random.choice( [ "http://www.marketingtool.online/en/face-generator/img/faces/avatar-1151ce9f4b2043de0d2e3b...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/image_classification/run.py
demo/image_classification/run.py
import gradio as gr import torch import requests from torchvision import transforms # type: ignore model = torch.hub.load('pytorch/vision:v0.6.0', 'resnet18', pretrained=True).eval() response = requests.get("https://git.io/JJkYN") labels = response.text.split("\n") def predict(inp): inp = transforms.ToTensor()(inp...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/blocks_webcam/run.py
demo/blocks_webcam/run.py
import numpy as np import gradio as gr def snap(image): return np.flipud(image) demo = gr.Interface(snap, gr.Image(sources=["webcam"]), "image") if __name__ == "__main__": demo.launch()
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/dataframe_colorful/run.py
demo/dataframe_colorful/run.py
import pandas as pd import gradio as gr df = pd.DataFrame( { "A": [14, 4, 5, 4, 1], "B": [5, 2, 54, 3, 2], "C": [20, 20, 7, 3, 8], "D": [14, 3, 6, 2, 6], "E": [23, 45, 64, 32, 23], } ) t = df.style.highlight_max(color="lightgreen", axis=0) with gr.Blocks() as demo: ...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/stream_frames/run.py
demo/stream_frames/run.py
import gradio as gr import numpy as np def flip(im): return np.flipud(im) demo = gr.Interface( flip, gr.Image(sources=["webcam"], streaming=True), "image", live=True, api_name="predict", ) if __name__ == "__main__": demo.launch()
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/blocks_static/run.py
demo/blocks_static/run.py
import gradio as gr demo = gr.Blocks() with demo: gr.Image( "https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=387&q=80" ) gr.Textbox("hi") gr.Number(3) if __name__ == "__main__": demo.launc...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/multimodaltextbox_component/run.py
demo/multimodaltextbox_component/run.py
import gradio as gr with gr.Blocks() as demo: gr.MultimodalTextbox(interactive=True) demo.launch()
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/interface_random_slider/run.py
demo/interface_random_slider/run.py
import gradio as gr def func(slider_1, slider_2, *args): return slider_1 + slider_2 * 5 demo = gr.Interface( func, [ gr.Slider(minimum=1.5, maximum=250000.89, randomize=True, label="Random Big Range"), gr.Slider(minimum=-1, maximum=1, randomize=True, step=0.05, label="Random only multiple ...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/all_demos/run.py
demo/all_demos/run.py
import importlib import gradio as gr import os import sys import copy import pathlib from gradio.media import MEDIA_ROOT os.environ["GRADIO_ANALYTICS_ENABLED"] = "False" demo_dir = pathlib.Path(__file__).parent / "demos" names = sorted(os.listdir("./demos")) all_demos = [] demo_module = None for p in sorted(os.list...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/theme_builder/run.py
demo/theme_builder/run.py
import gradio as gr from gradio.themes.builder_app import demo if __name__ == "__main__": demo.launch(css_paths=["demo/custom_css/custom_css.css"], theme=gr.themes.Base(), head="<style id='theme_css'></style>")
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/slider_component/run.py
demo/slider_component/run.py
import gradio as gr with gr.Blocks() as demo: gr.Slider() demo.launch()
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/mini_leaderboard/run.py
demo/mini_leaderboard/run.py
# type: ignore import gradio as gr import pandas as pd from pathlib import Path abs_path = Path(__file__).parent.absolute() df = pd.read_json(str(abs_path / "assets/leaderboard_data.json")) invisible_df = df.copy() COLS = [ "T", "Model", "Average ⬆️", "ARC", "HellaSwag", "MMLU", "Truthful...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/mini_leaderboard/assets/__init__.py
demo/mini_leaderboard/assets/__init__.py
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/kitchen_sink/run.py
demo/kitchen_sink/run.py
import os import json import numpy as np import gradio as gr from gradio.media import get_image, get_video, get_audio, get_file CHOICES = ["foo", "bar", "baz"] JSONOBJ = """{"items":{"item":[{"id": "0001","type": null,"is_good": false,"ppu": 0.55,"batters":{"batter":[{ "id": "1001", "type": "Regular" },{ "id": "1002...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/theme_extended_step_2/run.py
demo/theme_extended_step_2/run.py
import gradio as gr import time with gr.Blocks() as demo: textbox = gr.Textbox(label="Name") slider = gr.Slider(label="Count", minimum=0, maximum=100, step=1) with gr.Row(): button = gr.Button("Submit", variant="primary") clear = gr.Button("Clear") output = gr.Textbox(label="Output") ...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/blocks_simple_squares/run.py
demo/blocks_simple_squares/run.py
import gradio as gr demo = gr.Blocks() with demo: default_json = {"a": "a"} num = gr.State(value=0) squared = gr.Number(value=0) btn = gr.Button("Next Square", elem_id="btn", elem_classes=["abc", "def"]) stats = gr.State(value=default_json) table = gr.JSON() def increase(var, stats_hist...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/file_component_events/run.py
demo/file_component_events/run.py
import gradio as gr def delete_file(n: int, file: gr.DeletedFileData): return [file.file.path, n + 1] with gr.Blocks() as demo: with gr.Row(): with gr.Column(): file_component = gr.File(label="Upload Single File", file_count="single") with gr.Column(): output_file_1 ...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/mcp_resources_and_prompts/run.py
demo/mcp_resources_and_prompts/run.py
""" Adapts the FastMCP quickstart example to work with Gradio's MCP integration. """ import gradio as gr @gr.mcp.tool() # Not needed as functions are registered as tools by default def add(a: int, b: int) -> int: """Add two numbers""" return a + b @gr.mcp.resource("greeting://{name}") def get_greeting(name...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/mcp_resources_and_prompts/fastmcp.py
demo/mcp_resources_and_prompts/fastmcp.py
""" This is the equivalent of `run.py` but implemented with FastMCP v1. It is taken directly from the quickstart example from the MCP Python SDK: https://github.com/modelcontextprotocol/python-sdk """ from mcp.server.fastmcp import FastMCP # Create an MCP server mcp = FastMCP("Demo") # Add an addition tool @mcp.to...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/reload_mode/run.py
demo/reload_mode/run.py
import gradio as gr from functions import get_status # type: ignore if gr.NO_RELOAD: def eat(food): # type: ignore if food > 0: return {food_box: food - 1, status_box: "full"} else: return {status_box: "hungry"} else: def eat(food): return {status_box: get_statu...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/reload_mode/functions.py
demo/reload_mode/functions.py
import gradio as gr if gr.NO_RELOAD: def get_status(): # type: ignore return "full" else: def get_status(): return "reloaded"
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/textbox_component/run.py
demo/textbox_component/run.py
import gradio as gr with gr.Blocks() as demo: gr.Textbox() demo.launch()
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/fraud_detector/run.py
demo/fraud_detector/run.py
import random import os import gradio as gr def fraud_detector(card_activity, categories, sensitivity): activity_range = random.randint(0, 100) drop_columns = [ column for column in ["retail", "food", "other"] if column not in categories ] if len(drop_columns): card_activity.drop(column...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/fake_gan_no_input/run.py
demo/fake_gan_no_input/run.py
import time import gradio as gr def fake_gan(): time.sleep(1) images = [ "https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=387&q=80", "https://images.unsplash.com/photo-1554151228-14d9de...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/image-simple/run.py
demo/image-simple/run.py
import gradio as gr def image(im): return im with gr.Blocks() as demo: im = gr.Image() im2 = gr.Image() btn = gr.Button() btn.click(lambda x: x, outputs=im2, inputs=im) if __name__ == "__main__": demo.launch()
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/load_openapi_spec/run.py
demo/load_openapi_spec/run.py
import gradio as gr demo = gr.load_openapi( openapi_spec="https://petstore3.swagger.io/api/v3/openapi.json", base_url="https://petstore3.swagger.io/api/v3", paths=["/pet.*"], methods=["get", "post"], ) if __name__ == "__main__": demo.launch(mcp_server=True)
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/plot_guide_line/run.py
demo/plot_guide_line/run.py
import gradio as gr import pandas as pd import numpy as np import random df = pd.DataFrame({ 'height': np.random.randint(50, 70, 25), 'weight': np.random.randint(120, 320, 25), 'age': np.random.randint(18, 65, 25), 'ethnicity': [random.choice(["white", "black", "asian"]) for _ in range(25)] }) with gr...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/blocks_kinematics/run.py
demo/blocks_kinematics/run.py
import pandas as pd import numpy as np import gradio as gr def plot(v, a): g = 9.81 theta = a / 180 * 3.14 tmax = ((2 * v) * np.sin(theta)) / g timemat = tmax * np.linspace(0, 1, 40) x = (v * timemat) * np.cos(theta) y = ((v * timemat) * np.sin(theta)) - ((0.5 * g) * (timemat**2)) df = pd...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/colorpicker_component/run.py
demo/colorpicker_component/run.py
import gradio as gr with gr.Blocks() as demo: gr.ColorPicker() demo.launch()
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false