reisarod commited on
Commit
5fae594
·
verified ·
1 Parent(s): 70edc2e

Upload folder using huggingface_hub

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +24 -0
  2. .gradio/flagged/dataset3.csv +2 -0
  3. .gradio/flagged/dataset4.csv +2 -0
  4. .gradio/flagged/dataset5.csv +30 -0
  5. .gradio/flagged/input_img/a98cdcb20c751cdea650/a new day - fondo completa.jpg +0 -0
  6. .gradio/flagged/output/814cb1f4f4281fc56236/image.webp +0 -0
  7. __pycache__/gradio_tool.cpython-311.pyc +0 -0
  8. app.py +25 -14
  9. app2.py +19 -0
  10. app3.py +14 -0
  11. app33.py +36 -0
  12. app5.py +37 -0
  13. diffusers-upscaler.py +38 -0
  14. diffusers_flux.py +6 -0
  15. example.py +20 -0
  16. gradio/.changeset/README.md +8 -0
  17. gradio/.changeset/changeset.cjs +332 -0
  18. gradio/.changeset/config.json +11 -0
  19. gradio/.changeset/fix_changelogs.cjs +149 -0
  20. gradio/.changeset/full-pigs-post.md +6 -0
  21. gradio/.config/.prettierignore +35 -0
  22. gradio/.config/.prettierrc.json +8 -0
  23. gradio/.config/basevite.config.ts +95 -0
  24. gradio/.config/copy_frontend.py +63 -0
  25. gradio/.config/demos.json +34 -0
  26. gradio/.config/eslint.config.js +164 -0
  27. gradio/.config/lite-builder/pyproject.toml +33 -0
  28. gradio/.config/lite-builder/src/lite_builder/__init__.py +0 -0
  29. gradio/.config/lite-builder/src/lite_builder/builder.py +5 -0
  30. gradio/.config/lite-builder/src/lite_builder/hooks.py +6 -0
  31. gradio/.config/playwright-ct.config.ts +41 -0
  32. gradio/.config/playwright-setup.js +179 -0
  33. gradio/.config/playwright.config.js +73 -0
  34. gradio/.config/playwright/index.html +12 -0
  35. gradio/.config/playwright/index.ts +2 -0
  36. gradio/.config/postcss.config.cjs +8 -0
  37. gradio/.config/setup_vite_tests.ts +8 -0
  38. gradio/.config/svelte.config.js +5 -0
  39. gradio/.config/tailwind.config.cjs +12 -0
  40. gradio/.config/vitest.config.ts +3 -0
  41. gradio/.devcontainer/devcontainer.json +41 -0
  42. gradio/.dockerignore +41 -0
  43. gradio/.editorconfig +8 -0
  44. gradio/.git-blame-ignore-revs +14 -0
  45. gradio/.github/ISSUE_TEMPLATE/bug_report_template.yml +69 -0
  46. gradio/.github/ISSUE_TEMPLATE/config.yml +5 -0
  47. gradio/.github/ISSUE_TEMPLATE/feature_request.md +19 -0
  48. gradio/.github/PULL_REQUEST_TEMPLATE.md +18 -0
  49. gradio/.github/actions/changes/action.yml +78 -0
  50. gradio/.github/actions/install-all-deps/action.yml +96 -0
.gitattributes CHANGED
@@ -33,3 +33,27 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ gradio/demo/blocks_flipper/screenshot.gif filter=lfs diff=lfs merge=lfs -text
37
+ gradio/demo/blocks_neural_instrument_coding/sax.wav filter=lfs diff=lfs merge=lfs -text
38
+ gradio/demo/calculator/screenshot.gif filter=lfs diff=lfs merge=lfs -text
39
+ gradio/demo/chatbot_core_components/files/world.mp4 filter=lfs diff=lfs merge=lfs -text
40
+ gradio/demo/chatbot_core_components_simple/files/world.mp4 filter=lfs diff=lfs merge=lfs -text
41
+ gradio/demo/dataset/files/world.mp4 filter=lfs diff=lfs merge=lfs -text
42
+ gradio/demo/gallery_component/files/world.mp4 filter=lfs diff=lfs merge=lfs -text
43
+ gradio/demo/hello_world_2/screenshot.gif filter=lfs diff=lfs merge=lfs -text
44
+ gradio/demo/image_mod/screenshot.png filter=lfs diff=lfs merge=lfs -text
45
+ gradio/demo/kitchen_sink/files/world.mp4 filter=lfs diff=lfs merge=lfs -text
46
+ gradio/demo/rt-detr-object-detection/3285790-hd_1920_1080_30fps.mp4 filter=lfs diff=lfs merge=lfs -text
47
+ gradio/demo/sales_projections/screenshot.gif filter=lfs diff=lfs merge=lfs -text
48
+ gradio/demo/sepia_filter/screenshot.gif filter=lfs diff=lfs merge=lfs -text
49
+ gradio/demo/unispeech-speaker-verification/samples/kirsten_dunst.wav filter=lfs diff=lfs merge=lfs -text
50
+ gradio/demo/video_component/files/world.mp4 filter=lfs diff=lfs merge=lfs -text
51
+ gradio/guides/assets/hf_demo.mp4 filter=lfs diff=lfs merge=lfs -text
52
+ gradio/guides/cn/assets/hf_demo.mp4 filter=lfs diff=lfs merge=lfs -text
53
+ gradio/js/component-test/src/lib/images/world.mp4 filter=lfs diff=lfs merge=lfs -text
54
+ gradio/js/spa/test/files/file_test.ogg filter=lfs diff=lfs merge=lfs -text
55
+ gradio/js/spa/test/files/world.mp4 filter=lfs diff=lfs merge=lfs -text
56
+ gradio/test/test_files/rotated_image.jpeg filter=lfs diff=lfs merge=lfs -text
57
+ node_modules/clarinet/samples/npm.json filter=lfs diff=lfs merge=lfs -text
58
+ node_modules/clarinet/samples/twitter.json filter=lfs diff=lfs merge=lfs -text
59
+ node_modules/clarinet/test/twitter.js filter=lfs diff=lfs merge=lfs -text
.gradio/flagged/dataset3.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ name,is_morning,temperature,output 0,output 1,timestamp
2
+ Rei,false,20,Good evening Rei. It is 20 degrees today,'-6.67,2024-11-17 04:50:44.018497
.gradio/flagged/dataset4.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ input_img,output,timestamp
2
+ .gradio/flagged/input_img/a98cdcb20c751cdea650/a new day - fondo completa.jpg,.gradio/flagged/output/814cb1f4f4281fc56236/image.webp,2024-11-17 04:53:32.100201
.gradio/flagged/dataset5.csv ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ text,output,timestamp
2
+ "'hazme la letra de una canción en castellano, que tenga la misma estructura a esta: {[Pre-Hook]
3
+ Ka-hóhh, ka-ha-ka,
4
+ (Ka-hohh, ya, ya-hóhh)
5
+
6
+ [Hook]
7
+ Pilaŋ áŋpetu, ka-ha-ka,
8
+ (Grateful day, Ka-hohh, ya, ya-hóhh)
9
+
10
+ Wíŋyaŋ, wíŋyaŋ, hééé,
11
+ (Sun, sun, shine, lé-ló)
12
+
13
+ Čhaŋnúŋpa owaŋyaŋke, ka-hóhh,
14
+ (Sacred pipe, ka-hóhh)
15
+
16
+ [Pre-Hook]
17
+ Ka-hóhh, ka-ha-ka,
18
+ (Ka-hohh, ya, ya-hóhh)
19
+
20
+ [Hook]
21
+ Pilaŋ áŋpetu, ka-ha-ka,
22
+ (Grateful day, Ka-hohh, ya, ya-hóhh)
23
+
24
+ Háu waŋblí, oškáte,
25
+ (Hawk speaks, in joy)
26
+
27
+ [Outro]
28
+ Pilaŋ áŋpetu, ka-ha-ka,
29
+ (Grateful day, Ka-hohh, ya, ya-hóhh)}","[{""token"": ""hazme la letra de una canci\u00f3n en castellano, que tenga la misma estructura a esta: {[Pre-Hook]\nKa-h\u00f3hh, ka-ha-ka,\n(Ka-hohh, ya, ya-h\u00f3hh)\n\n[Hook]\nPila\u014b \u00e1\u014bpetu, ka-ha-ka,\n(Grateful day, Ka-hohh, ya, ya-h\u00f3hh)\n\nW\u00ed\u014bya\u014b, w\u00ed\u014bya\u014b, h\u00e9\u00e9\u00e9,\n(Sun, sun, shine, l\u00e9-l\u00f3)\n\n\u010cha\u014bn\u00fa\u014bpa owa\u014bya\u014bke, ka-h\u00f3hh,\n(Sacred pipe, ka-h\u00f3hh)\n\n[Pre-Hook]\nKa-h\u00f3hh, ka-ha-ka,\n(Ka-hohh, ya, ya-h\u00f3hh)\n\n[Hook]\nPila\u014b \u00e1\u014bpetu, ka-ha-ka,\n(Grateful day, Ka-hohh, ya, ya-h\u00f3hh)\n\nH\u00e1u wa\u014bbl\u00ed, o\u0161k\u00e1te,\n(Hawk speaks, in joy)\n\n[Outro]\nPila\u014b \u00e1\u014bpetu, ka-ha-ka,\n(Grateful day, Ka-hohh, ya, ya-h\u00f3hh)}"", ""class_or_confidence"": null}]",2024-12-07 00:13:40.443441
30
+ Does Chicago have any stores and does Joe live here?,"[{""token"": ""Does Chicago have any stores and does Joe live here?"", ""class_or_confidence"": null}]",2024-12-14 10:11:53.275861
.gradio/flagged/input_img/a98cdcb20c751cdea650/a new day - fondo completa.jpg ADDED
.gradio/flagged/output/814cb1f4f4281fc56236/image.webp ADDED
__pycache__/gradio_tool.cpython-311.pyc ADDED
Binary file (1.18 kB). View file
 
app.py CHANGED
@@ -1,19 +1,30 @@
1
- import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!"
5
 
6
- demo = gr.Interface(fn=greet, inputs="textbox", outputs="textbox")
7
-
8
- demo.launch(share=True) # Share your demo with just 1 extra parameter 🚀
 
 
 
 
 
 
 
 
 
9
 
 
 
10
 
11
- from gradio_client import Client
 
12
 
13
- client = Client("http://127.0.0.1:7860/")
14
- result = client.predict(
15
- name="Hello!!",
16
- intensity=0,
17
- api_name="/predict"
18
- )
19
- print(result)
 
1
+ from gradio_tool import GradioTool
2
+ import os
3
 
4
+ class StableDiffusionTool(GradioTool):
5
+ """Tool for calling stable diffusion from llm"""
6
 
7
+ def __init__(
8
+ self,
9
+ name="StableDiffusion",
10
+ description=(
11
+ "An image generator. Use this to generate images based on "
12
+ "text input. Input should be a description of what the image should "
13
+ "look like. The output will be a path to an image file."
14
+ ),
15
+ src="gradio-client-demos/stable-diffusion",
16
+ hf_token=None,
17
+ ) -> None:
18
+ super().__init__(name, description, src, hf_token)
19
 
20
+ def create_job(self, query: str) -> Job:
21
+ return self.client.submit(query, "", 9, fn_index=1)
22
 
23
+ def postprocess(self, output: str) -> str:
24
+ return [os.path.join(output, i) for i in os.listdir(output) if not i.endswith("json")][0]
25
 
26
+ def _block_input(self, gr) -> "gr.components.Component":
27
+ return gr.Textbox()
28
+
29
+ def _block_output(self, gr) -> "gr.components.Component":
30
+ return gr.Image()
 
 
app2.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def greet(name):
4
+ return "Hello " + name + "!"
5
+
6
+ demo = gr.Interface(fn=greet, inputs="textbox", outputs="textbox")
7
+
8
+ demo.launch(share=True) # Share your demo with just 1 extra parameter 🚀
9
+
10
+
11
+ from gradio_client import Client
12
+
13
+ client = Client("http://127.0.0.1:7860/")
14
+ result = client.predict(
15
+ name="Hello!!",
16
+ intensity=0,
17
+ api_name="/predict"
18
+ )
19
+ print(result)
app3.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def greet(name, is_morning, temperature):
4
+ salutation = "Good morning" if is_morning else "Good evening"
5
+ greeting = f"{salutation} {name}. It is {temperature} degrees today"
6
+ celsius = (temperature - 32) * 5 / 9
7
+ return greeting, round(celsius, 2)
8
+
9
+ demo = gr.Interface(
10
+ fn=greet,
11
+ inputs=["text", "checkbox", gr.Slider(0, 100)],
12
+ outputs=["text", "number"],
13
+ )
14
+ demo.launch()
app33.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def calculator(num1, operation, num2):
4
+ if operation == "add":
5
+ return num1 + num2
6
+ elif operation == "subtract":
7
+ return num1 - num2
8
+ elif operation == "multiply":
9
+ return num1 * num2
10
+ elif operation == "divide":
11
+ if num2 == 0:
12
+ raise gr.Error("Cannot divide by zero!")
13
+ return num1 / num2
14
+
15
+ demo = gr.Interface(
16
+ calculator,
17
+ [
18
+ "number",
19
+ gr.Radio(["add", "subtract", "multiply", "divide"]),
20
+ "number"
21
+ ],
22
+ "number",
23
+ examples=[
24
+ [45, "add", 3],
25
+ [3.14, "divide", 2],
26
+ [144, "multiply", 2.5],
27
+ [0, "subtract", 1.2],
28
+ ],
29
+ title="Toy Calculator",
30
+ description="Here's a sample toy calculator.",
31
+ )
32
+
33
+ demo.launch()
34
+
35
+
36
+
app5.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from diffusers.utils import load_image
3
+ from diffusers import FluxControlNetModel
4
+ from diffusers.pipelines import FluxControlNetPipeline
5
+
6
+ # Load pipeline
7
+ controlnet = FluxControlNetModel.from_pretrained(
8
+ "jasperai/Flux.1-dev-Controlnet-Upscaler",
9
+ torch_dtype=torch.bfloat16
10
+ )
11
+ pipe = FluxControlNetPipeline.from_pretrained(
12
+ "black-forest-labs/FLUX.1-dev",
13
+ controlnet=controlnet,
14
+ torch_dtype=torch.bfloat16
15
+ )
16
+ pipe.to("cuda")
17
+
18
+ # Load a control image
19
+ control_image = load_image(
20
+ "https://huggingface.co/jasperai/Flux.1-dev-Controlnet-Upscaler/resolve/main/examples/input.jpg"
21
+ )
22
+
23
+ w, h = control_image.size
24
+
25
+ # Upscale x4
26
+ control_image = control_image.resize((w * 4, h * 4))
27
+
28
+ image = pipe(
29
+ prompt="",
30
+ control_image=control_image,
31
+ controlnet_conditioning_scale=0.6,
32
+ num_inference_steps=40,
33
+ guidance_scale=3.5,
34
+ height=control_image.size[1],
35
+ width=control_image.size[0]
36
+ ).images[0]
37
+ image
diffusers-upscaler.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from diffusers.utils import load_image
3
+ from diffusers import FluxControlNetModel
4
+ from diffusers.pipelines import FluxControlNetPipeline
5
+
6
+ # Load pipeline
7
+ controlnet = FluxControlNetModel.from_pretrained(
8
+ "jasperai/Flux.1-dev-Controlnet-Upscaler",
9
+ torch_dtype=torch.bfloat16
10
+ )
11
+ pipe = FluxControlNetPipeline.from_pretrained(
12
+ "black-forest-labs/FLUX.1-dev",
13
+ controlnet=controlnet,
14
+ torch_dtype=torch.bfloat16
15
+ )
16
+ pipe.to("cpu")
17
+
18
+ # Load a control image
19
+ control_image = load_image(
20
+ "https://huggingface.co/jasperai/Flux.1-dev-Controlnet-Upscaler/resolve/main/examples/input.jpg"
21
+ )
22
+
23
+ w, h = control_image.size
24
+
25
+ # Upscale x4
26
+ control_image = control_image.resize((w * 4, h * 4))
27
+
28
+ image = pipe(
29
+ prompt="",
30
+ control_image=control_image,
31
+ controlnet_conditioning_scale=0.6,
32
+ num_inference_steps=28,
33
+ guidance_scale=3.5,
34
+ height=control_image.size[1],
35
+ width=control_image.size[0]
36
+ ).images[0]
37
+ image
38
+
diffusers_flux.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ from diffusers import DiffusionPipeline
2
+
3
+ pipe = DiffusionPipeline.from_pretrained("jasperai/Flux.1-dev-Controlnet-Upscaler")
4
+
5
+ prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"
6
+ image = pipe(prompt).images[0]
example.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+
3
+ import gradio as gr
4
+
5
+ ner_pipeline = pipeline("ner")
6
+
7
+ examples = [
8
+ "Does Chicago have any stores and does Joe live here?",
9
+ ]
10
+
11
+ def ner(text):
12
+ output = ner_pipeline(text)
13
+ return {"text": text, "entities": output}
14
+
15
+ demo = gr.Interface(ner,
16
+ gr.Textbox(placeholder="Enter sentence here..."),
17
+ gr.HighlightedText(),
18
+ examples=examples)
19
+
20
+ demo.launch()
gradio/.changeset/README.md ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ # Changesets
2
+
3
+ Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4
+ with multi-package repos, or single-package repos to help you version and publish your code. You can
5
+ find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6
+
7
+ We have a quick list of common questions to get you started engaging with this project in
8
+ [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
gradio/.changeset/changeset.cjs ADDED
@@ -0,0 +1,332 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const { getPackagesSync } = require("@manypkg/get-packages");
2
+ const dependents_graph = require("@changesets/get-dependents-graph");
3
+
4
+ const gh = require("@changesets/get-github-info");
5
+ const { existsSync, readFileSync, writeFileSync } = require("fs");
6
+ const { join } = require("path");
7
+
8
+ const { getInfo, getInfoFromPullRequest } = gh;
9
+ const pkg_data = getPackagesSync(process.cwd());
10
+ const { packages, rootDir } = pkg_data;
11
+ const dependents = dependents_graph.getDependentsGraph({
12
+ packages,
13
+ root: pkg_data.rootPackage
14
+ });
15
+
16
+ /**
17
+ * @typedef {{packageJson: {name: string, python?: boolean}, dir: string}} Package
18
+ */
19
+
20
+ /**
21
+ * @typedef {{summary: string, id: string, commit: string, releases: {name: string}}} Changeset
22
+ */
23
+
24
+ /**
25
+ *
26
+ * @param {string} package_name The name of the package to find the directories for
27
+ * @returns {string[]} The directories for the package
28
+ */
29
+ function find_packages_dirs(package_name) {
30
+ /** @type {string[]} */
31
+ let package_dirs = [];
32
+
33
+ /** @type {Package | undefined} */
34
+ const _package = packages.find((p) => p.packageJson.name === package_name);
35
+ if (!_package) throw new Error(`Package ${package_name} not found`);
36
+
37
+ package_dirs.push(_package.dir);
38
+ if (_package.packageJson.python) {
39
+ package_dirs.push(join(_package.dir, ".."));
40
+ }
41
+ return package_dirs;
42
+ }
43
+
44
+ let lines = {
45
+ _handled: []
46
+ };
47
+
48
+ const changelogFunctions = {
49
+ /**
50
+ *
51
+ * @param {Changeset[]} changesets The changesets that have been created
52
+ * @param {any} dependenciesUpdated The dependencies that have been updated
53
+ * @param {any} options The options passed to the changelog generator
54
+ * @returns {Promise<string>} The release line for the dependencies
55
+ */
56
+ getDependencyReleaseLine: async (
57
+ changesets,
58
+ dependenciesUpdated,
59
+ options
60
+ ) => {
61
+ if (!options.repo) {
62
+ throw new Error(
63
+ 'Please provide a repo to this changelog generator like this:\n"changelog": ["@changesets/changelog-github", { "repo": "org/repo" }]'
64
+ );
65
+ }
66
+ if (dependenciesUpdated.length === 0) return "";
67
+
68
+ const changesetLink = `- Updated dependencies [${(
69
+ await Promise.all(
70
+ changesets.map(async (cs) => {
71
+ if (cs.commit) {
72
+ let { links } = await getInfo({
73
+ repo: options.repo,
74
+ commit: cs.commit
75
+ });
76
+ return links.commit;
77
+ }
78
+ })
79
+ )
80
+ )
81
+ .filter((_) => _)
82
+ .join(", ")}]:`;
83
+
84
+ const updatedDepenenciesList = dependenciesUpdated.map(
85
+ /**
86
+ *
87
+ * @param {any} dependency The dependency that has been updated
88
+ * @returns {string} The formatted dependency
89
+ */
90
+ (dependency) => {
91
+ const updates = dependents.get(dependency.name);
92
+
93
+ if (updates && updates.length > 0) {
94
+ updates.forEach((update) => {
95
+ if (!lines[update]) {
96
+ lines[update] = {
97
+ dirs: find_packages_dirs(update),
98
+ current_changelog: "",
99
+ feat: [],
100
+ fix: [],
101
+ highlight: [],
102
+ previous_version: packages.find(
103
+ (p) => p.packageJson.name === update
104
+ ).packageJson.version,
105
+ dependencies: []
106
+ };
107
+
108
+ const changelog_path = join(
109
+ //@ts-ignore
110
+ lines[update].dirs[1] || lines[update].dirs[0],
111
+ "CHANGELOG.md"
112
+ );
113
+
114
+ if (existsSync(changelog_path)) {
115
+ //@ts-ignore
116
+ lines[update].current_changelog = readFileSync(
117
+ changelog_path,
118
+ "utf-8"
119
+ )
120
+ .replace(`# ${update}`, "")
121
+ .trim();
122
+ }
123
+ }
124
+ lines[update].dependencies.push(
125
+ ` - ${dependency.name}@${dependency.newVersion}`
126
+ );
127
+ });
128
+ }
129
+
130
+ return ` - ${dependency.name}@${dependency.newVersion}`;
131
+ }
132
+ );
133
+
134
+ writeFileSync(
135
+ join(rootDir, ".changeset", "_changelog.json"),
136
+ JSON.stringify(lines, null, 2)
137
+ );
138
+
139
+ return [changesetLink, ...updatedDepenenciesList].join("\n");
140
+ },
141
+ /**
142
+ *
143
+ * @param {{summary: string, id: string, commit: string, releases: {name: string}[]}} changeset The changeset that has been created
144
+ * @param {any} type The type of changeset
145
+ * @param {any} options The options passed to the changelog generator
146
+ * @returns {Promise<string>} The release line for the changeset
147
+ */
148
+ getReleaseLine: async (changeset, type, options) => {
149
+ if (!options || !options.repo) {
150
+ throw new Error(
151
+ 'Please provide a repo to this changelog generator like this:\n"changelog": ["@changesets/changelog-github", { "repo": "org/repo" }]'
152
+ );
153
+ }
154
+
155
+ let prFromSummary;
156
+ let commitFromSummary;
157
+ /**
158
+ * @type {string[]}
159
+ */
160
+ let usersFromSummary = [];
161
+
162
+ const replacedChangelog = changeset.summary
163
+ .replace(/^\s*(?:pr|pull|pull\s+request):\s*#?(\d+)/im, (_, pr) => {
164
+ let num = Number(pr);
165
+ if (!isNaN(num)) prFromSummary = num;
166
+ return "";
167
+ })
168
+ .replace(/^\s*commit:\s*([^\s]+)/im, (_, commit) => {
169
+ commitFromSummary = commit;
170
+ return "";
171
+ })
172
+ .replace(/^\s*(?:author|user):\s*@?([^\s]+)/gim, (_, user) => {
173
+ usersFromSummary.push(user);
174
+ return "";
175
+ })
176
+ .trim();
177
+
178
+ const [firstLine, ...futureLines] = replacedChangelog
179
+ .split("\n")
180
+ .map((l) => l.trimRight());
181
+
182
+ const links = await (async () => {
183
+ if (prFromSummary !== undefined) {
184
+ let { links } = await getInfoFromPullRequest({
185
+ repo: options.repo,
186
+ pull: prFromSummary
187
+ });
188
+ if (commitFromSummary) {
189
+ links = {
190
+ ...links,
191
+ commit: `[\`${commitFromSummary}\`](https://github.com/${options.repo}/commit/${commitFromSummary})`
192
+ };
193
+ }
194
+ return links;
195
+ }
196
+ const commitToFetchFrom = commitFromSummary || changeset.commit;
197
+ if (commitToFetchFrom) {
198
+ let { links } = await getInfo({
199
+ repo: options.repo,
200
+ commit: commitToFetchFrom
201
+ });
202
+ return links;
203
+ }
204
+ return {
205
+ commit: null,
206
+ pull: null,
207
+ user: null
208
+ };
209
+ })();
210
+
211
+ const user_link = /\[(@[^]+)\]/.exec(links.user);
212
+ const users =
213
+ usersFromSummary && usersFromSummary.length
214
+ ? usersFromSummary
215
+ .map((userFromSummary) => `@${userFromSummary}`)
216
+ .join(", ")
217
+ : user_link
218
+ ? user_link[1]
219
+ : links.user;
220
+
221
+ const prefix = [
222
+ links.pull === null ? "" : `${links.pull}`,
223
+ links.commit === null ? "" : `${links.commit}`
224
+ ]
225
+ .join(" ")
226
+ .trim();
227
+
228
+ const suffix = users === null ? "" : ` Thanks ${users}!`;
229
+
230
+ /**
231
+ * @typedef {{[key: string]: string[] | {dirs: string[], current_changelog: string, feat: {summary: string}[], fix: {summary: string}[], highlight: {summary: string}[]}}} ChangesetMeta
232
+ */
233
+
234
+ /**
235
+ * @type { ChangesetMeta & { _handled: string[] } }}
236
+ */
237
+
238
+ if (lines._handled.includes(changeset.id)) {
239
+ return "done";
240
+ }
241
+ lines._handled.push(changeset.id);
242
+
243
+ changeset.releases.forEach((release) => {
244
+ if (!lines[release.name]) {
245
+ lines[release.name] = {
246
+ dirs: find_packages_dirs(release.name),
247
+ current_changelog: "",
248
+ feat: [],
249
+ fix: [],
250
+ highlight: [],
251
+ previous_version: packages.find(
252
+ (p) => p.packageJson.name === release.name
253
+ ).packageJson.version,
254
+ dependencies: []
255
+ };
256
+ }
257
+
258
+ const changelog_path = join(
259
+ //@ts-ignore
260
+ lines[release.name].dirs[1] || lines[release.name].dirs[0],
261
+ "CHANGELOG.md"
262
+ );
263
+
264
+ if (existsSync(changelog_path)) {
265
+ //@ts-ignore
266
+ lines[release.name].current_changelog = readFileSync(
267
+ changelog_path,
268
+ "utf-8"
269
+ )
270
+ .replace(`# ${release.name}`, "")
271
+ .trim();
272
+ }
273
+
274
+ const [, _type, summary] = changeset.summary
275
+ .trim()
276
+ .match(/^(feat|fix|highlight)\s*:\s*([^]*)/im) || [
277
+ ,
278
+ "feat",
279
+ changeset.summary
280
+ ];
281
+
282
+ let formatted_summary = "";
283
+
284
+ if (_type === "highlight") {
285
+ const [heading, ...rest] = summary.trim().split("\n");
286
+ const _heading = `${heading} ${prefix ? `(${prefix})` : ""}`;
287
+ const _rest = rest.concat(["", suffix]);
288
+
289
+ formatted_summary = `${_heading}\n${_rest.join("\n")}`;
290
+ } else {
291
+ formatted_summary = handle_line(summary, prefix, suffix);
292
+ }
293
+
294
+ //@ts-ignore
295
+ lines[release.name][_type].push({
296
+ summary: formatted_summary
297
+ });
298
+ });
299
+
300
+ writeFileSync(
301
+ join(rootDir, ".changeset", "_changelog.json"),
302
+ JSON.stringify(lines, null, 2)
303
+ );
304
+
305
+ return `\n\n-${prefix ? `${prefix} -` : ""} ${firstLine}\n${futureLines
306
+ .map((l) => ` ${l}`)
307
+ .join("\n")}`;
308
+ }
309
+ };
310
+
311
+ /**
312
+ * @param {string} str The changelog entry
313
+ * @param {string} prefix The prefix to add to the first line
314
+ * @param {string} suffix The suffix to add to the last line
315
+ * @returns {string} The formatted changelog entry
316
+ */
317
+ function handle_line(str, prefix, suffix) {
318
+ const [_s, ...lines] = str.split("\n").filter(Boolean);
319
+
320
+ const desc = `${prefix ? `${prefix} -` : ""} ${_s.replace(
321
+ /[\s\.]$/,
322
+ ""
323
+ )}. ${suffix}`;
324
+
325
+ if (_s.length === 1) {
326
+ return desc;
327
+ }
328
+
329
+ return [desc, ...lines.map((l) => ` ${l}`)].join("/n");
330
+ }
331
+
332
+ module.exports = changelogFunctions;
gradio/.changeset/config.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json",
3
+ "changelog": ["./changeset.cjs", { "repo": "gradio-app/gradio" }],
4
+ "commit": false,
5
+ "fixed": [],
6
+ "linked": [],
7
+ "access": "public",
8
+ "baseBranch": "main",
9
+ "updateInternalDependencies": "patch",
10
+ "ignore": ["@self/spaces-test", "@self/cdn-test"]
11
+ }
gradio/.changeset/fix_changelogs.cjs ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const { join } = require("path");
2
+ const { readFileSync, existsSync, writeFileSync, unlinkSync } = require("fs");
3
+ const { getPackagesSync } = require("@manypkg/get-packages");
4
+
5
+ const RE_PKG_NAME = /^[\w-]+\b/;
6
+ const pkg_meta = getPackagesSync(process.cwd());
7
+
8
+ /**
9
+ * @typedef {{dirs: string[], highlight: {summary: string}[], feat: {summary: string}[], fix: {summary: string}[], current_changelog: string}} ChangesetMeta
10
+ */
11
+
12
+ /**
13
+ * @typedef {{[key: string]: ChangesetMeta}} ChangesetMetaCollection
14
+ */
15
+
16
+ function run() {
17
+ if (!existsSync(join(pkg_meta.rootDir, ".changeset", "_changelog.json"))) {
18
+ console.warn("No changesets to process");
19
+ return;
20
+ }
21
+
22
+ /**
23
+ * @type { ChangesetMetaCollection & { _handled: string[] } }}
24
+ */
25
+ const { _handled, ...packages } = JSON.parse(
26
+ readFileSync(
27
+ join(pkg_meta.rootDir, ".changeset", "_changelog.json"),
28
+ "utf-8"
29
+ )
30
+ );
31
+
32
+ /**
33
+ * @typedef { {packageJson: {name: string, version: string, python: boolean}, dir: string} } PackageMeta
34
+ */
35
+
36
+ /**
37
+ * @type { {[key:string]: PackageMeta} }
38
+ */
39
+ const all_packages = pkg_meta.packages.reduce((acc, pkg) => {
40
+ acc[pkg.packageJson.name] = /**@type {PackageMeta} */ (
41
+ /** @type {unknown} */ (pkg)
42
+ );
43
+ return acc;
44
+ }, /** @type {{[key:string] : PackageMeta}} */ ({}));
45
+
46
+ for (const pkg_name in packages) {
47
+ const { dirs, highlight, feat, fix, current_changelog, dependencies } =
48
+ /**@type {ChangesetMeta} */ (packages[pkg_name]);
49
+
50
+ if (pkg_name === "@gradio/lite") {
51
+ const target = all_packages.gradio.packageJson.version.split(".");
52
+
53
+ const current_version = packages[pkg_name].previous_version.split(".");
54
+
55
+ if (!packages.gradio) {
56
+ const patch = parseInt(current_version[2]) + 1;
57
+ const new_version = [target[0], target[1], patch];
58
+ all_packages[pkg_name].packageJson.version = new_version.join(".");
59
+ } else {
60
+ if (parseInt(target[1]) > parseInt(current_version[1])) {
61
+ all_packages[pkg_name].packageJson.version = target.join(".");
62
+ } else if (parseInt(target[1]) === parseInt(current_version[1])) {
63
+ const patch = parseInt(current_version[2]) + 1;
64
+ const new_version = [target[0], target[1], patch];
65
+ all_packages[pkg_name].packageJson.version = new_version.join(".");
66
+ }
67
+ }
68
+
69
+ writeFileSync(
70
+ join(all_packages[pkg_name].dir, "package.json"),
71
+ JSON.stringify(all_packages[pkg_name].packageJson, null, "\t") + "\n"
72
+ );
73
+ }
74
+
75
+ const { version, python } = all_packages[pkg_name].packageJson;
76
+
77
+ const highlights = highlight?.map((h) => `${h.summary}`) || [];
78
+ const features = feat?.map((f) => `- ${f.summary}`) || [];
79
+ const fixes = fix?.map((f) => `- ${f.summary}`) || [];
80
+ const deps = Array.from(new Set(dependencies?.map((d) => d.trim()))) || [];
81
+
82
+ const release_notes = /** @type {[string[], string][]} */ ([
83
+ [highlights, "### Highlights"],
84
+ [features, "### Features"],
85
+ [fixes, "### Fixes"],
86
+ [deps, "### Dependency updates"]
87
+ ])
88
+ .filter(([s], i) => s.length > 0)
89
+ .map(([lines, title]) => {
90
+ if (title === "### Highlights") {
91
+ return `${title}\n\n${lines.join("\n\n")}`;
92
+ }
93
+
94
+ return `${title}\n\n${lines.join("\n")}`;
95
+ })
96
+ .join("\n\n");
97
+
98
+ const new_changelog = `# ${pkg_name}
99
+
100
+ ## ${version}
101
+
102
+ ${release_notes}
103
+
104
+ ${current_changelog.replace(`# ${pkg_name}`, "").trim()}
105
+ `.trim();
106
+
107
+ dirs.forEach((dir) => {
108
+ writeFileSync(join(dir, "CHANGELOG.md"), new_changelog);
109
+ });
110
+
111
+ if (python) {
112
+ bump_local_dependents(pkg_name, version);
113
+ }
114
+ }
115
+
116
+ unlinkSync(join(pkg_meta.rootDir, ".changeset", "_changelog.json"));
117
+
118
+ /**
119
+ * @param {string} pkg_to_bump The name of the package to bump
120
+ * @param {string} version The version to bump to
121
+ * @returns {void}
122
+ * */
123
+ function bump_local_dependents(pkg_to_bump, version) {
124
+ for (const pkg_name in all_packages) {
125
+ const {
126
+ dir,
127
+ packageJson: { python }
128
+ } = all_packages[pkg_name];
129
+
130
+ if (!python) continue;
131
+
132
+ const requirements_path = join(dir, "..", "requirements.txt");
133
+ const requirements = readFileSync(requirements_path, "utf-8").split("\n");
134
+
135
+ const pkg_index = requirements.findIndex((line) => {
136
+ const m = line.trim().match(RE_PKG_NAME);
137
+ if (!m) return false;
138
+ return m[0] === pkg_to_bump;
139
+ });
140
+
141
+ if (pkg_index !== -1) {
142
+ requirements[pkg_index] = `${pkg_to_bump}==${version}`;
143
+ writeFileSync(requirements_path, requirements.join("\n"));
144
+ }
145
+ }
146
+ }
147
+ }
148
+
149
+ run();
gradio/.changeset/full-pigs-post.md ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ ---
2
+ "@gradio/core": patch
3
+ "gradio": patch
4
+ ---
5
+
6
+ fix:Fix css preload when serving from proxied subpaths
gradio/.config/.prettierignore ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ **/*.md
2
+ **/js/app/public/**
3
+ **/pnpm-workspace.yaml
4
+ **/js/app/dist/**
5
+ **/js/wasm/dist/**
6
+ **/js/preview/dist/**
7
+ **/client/js/dist/**
8
+ **/js/*/dist/**
9
+ **/pnpm-lock.yaml
10
+ **/js/plot/src/Plot.svelte
11
+ **/.svelte-kit/**
12
+ **/demo/**
13
+ **/gradio/**
14
+ **/.pnpm-store/**
15
+ **/.venv/**
16
+
17
+ /guides/**
18
+ **/.mypy_cache/**
19
+ !test-strategy.md
20
+ **/js/_space-test/**
21
+ ../js/lite/src/theme.css
22
+ ../js/storybook/theme.css
23
+ **/gradio_cached_examples/**
24
+ **/storybook-static/**
25
+ **/.vscode/**
26
+ sweep.yaml
27
+ **/.vercel/**
28
+ **/build/**
29
+ **/src/lib/json/**/*
30
+ **/playwright/.cache/**/*
31
+ **/theme/src/pollen.css
32
+ **/venv/**
33
+ ../js/app/src/api_docs/CodeSnippet.svelte
34
+ ../js/app/src/api_docs/RecordingSnippet.svelte
35
+ ../.changeset/pre.json
gradio/.config/.prettierrc.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "useTabs": true,
3
+ "singleQuote": false,
4
+ "trailingComma": "none",
5
+ "printWidth": 80,
6
+ "plugins": ["prettier-plugin-svelte"],
7
+ "overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
8
+ }
gradio/.config/basevite.config.ts ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { defineConfig } from "vite";
2
+ import { svelte } from "@sveltejs/vite-plugin-svelte";
3
+ import sveltePreprocess from "svelte-preprocess";
4
+ // @ts-ignore
5
+ import custom_media from "postcss-custom-media";
6
+ import global_data from "@csstools/postcss-global-data";
7
+ // @ts-ignore
8
+ import prefixer from "postcss-prefix-selector";
9
+ import { readFileSync } from "fs";
10
+ import { join } from "path";
11
+ import { fileURLToPath } from "url";
12
+
13
+ const __dirname = fileURLToPath(new URL(".", import.meta.url));
14
+ const version_path = join(__dirname, "..", "gradio", "package.json");
15
+ const theme_token_path = join(
16
+ __dirname,
17
+ "..",
18
+ "js",
19
+ "theme",
20
+ "src",
21
+ "tokens.css"
22
+ );
23
+
24
+ const version = JSON.parse(readFileSync(version_path, { encoding: "utf-8" }))
25
+ .version.trim()
26
+ .replace(/\./g, "-");
27
+
28
+ //@ts-ignore
29
+ export default defineConfig(({ mode }) => {
30
+ const production = mode === "production";
31
+
32
+ return {
33
+ server: {
34
+ port: 9876
35
+ },
36
+ resolve: {
37
+ conditions: ["gradio"]
38
+ },
39
+ build: {
40
+ sourcemap: false,
41
+ target: "esnext",
42
+ minify: production,
43
+ rollupOptions: {
44
+ external: ["virtual:component-loader"]
45
+ }
46
+ },
47
+ define: {
48
+ BUILD_MODE: production ? JSON.stringify("prod") : JSON.stringify("dev"),
49
+ BACKEND_URL: production
50
+ ? JSON.stringify("")
51
+ : JSON.stringify("http://localhost:7860/"),
52
+ GRADIO_VERSION: JSON.stringify(version)
53
+ },
54
+ css: {
55
+ postcss: {
56
+ plugins: [
57
+ prefixer({
58
+ prefix: `.gradio-container-${version}`,
59
+ // @ts-ignore
60
+ transform(prefix, selector, prefixedSelector, fileName) {
61
+ if (selector.indexOf("gradio-container") > -1) {
62
+ return prefix;
63
+ } else if (
64
+ selector.indexOf(":root") > -1 ||
65
+ selector.indexOf("dark") > -1 ||
66
+ fileName.indexOf(".svelte") > -1
67
+ ) {
68
+ return selector;
69
+ }
70
+ return prefixedSelector;
71
+ }
72
+ }),
73
+ custom_media()
74
+ ]
75
+ }
76
+ },
77
+ plugins: [
78
+ svelte({
79
+ inspector: false,
80
+ compilerOptions: {
81
+ dev: !production
82
+ },
83
+ hot: !process.env.VITEST && !production,
84
+ preprocess: sveltePreprocess({
85
+ postcss: {
86
+ plugins: [
87
+ global_data({ files: [theme_token_path] }),
88
+ custom_media()
89
+ ]
90
+ }
91
+ })
92
+ })
93
+ ]
94
+ };
95
+ });
gradio/.config/copy_frontend.py ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import shutil
4
+ import pathlib
5
+ from typing import Any
6
+
7
+ from hatchling.builders.hooks.plugin.interface import BuildHookInterface
8
+
9
+
10
+ def copy_js_code(root: str | pathlib.Path):
11
+ NOT_COMPONENT = [
12
+ "app",
13
+ "node_modules",
14
+ "storybook",
15
+ "playwright-report",
16
+ "workbench",
17
+ "tooltils",
18
+ "component-test",
19
+ "core",
20
+ "spa",
21
+ ]
22
+ for entry in (pathlib.Path(root) / "js").iterdir():
23
+ if (
24
+ entry.is_dir()
25
+ and not str(entry.name).startswith("_")
26
+ and not str(entry.name) in NOT_COMPONENT
27
+ ):
28
+
29
+ def ignore(s, names):
30
+ ignored = []
31
+ for n in names:
32
+ if (
33
+ n.startswith("CHANGELOG")
34
+ or n.startswith("README.md")
35
+ or n.startswith("node_modules")
36
+ or ".test." in n
37
+ or ".stories." in n
38
+ or ".spec." in n
39
+ ):
40
+ ignored.append(n)
41
+ return ignored
42
+
43
+ shutil.copytree(
44
+ str(entry),
45
+ str(pathlib.Path("gradio") / "_frontend_code" / entry.name),
46
+ ignore=ignore,
47
+ dirs_exist_ok=True,
48
+ )
49
+ shutil.copytree(
50
+ str(pathlib.Path(root) / "client" / "js"),
51
+ str(pathlib.Path("gradio") / "_frontend_code" / "client"),
52
+ ignore=lambda d, names: ["node_modules", "test"],
53
+ dirs_exist_ok=True,
54
+ )
55
+
56
+
57
+ class BuildHook(BuildHookInterface):
58
+ def initialize(self, version: str, build_data: dict[str, Any]) -> None:
59
+ copy_js_code(self.root)
60
+
61
+
62
+ if __name__ == "__main__":
63
+ copy_js_code(pathlib.Path("..").resolve())
gradio/.config/demos.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ "audio_debugger",
3
+ "blocks_essay",
4
+ "blocks_group",
5
+ "blocks_js_methods",
6
+ "blocks_layout",
7
+ "blocks_multiple_event_triggers",
8
+ "blocks_update",
9
+ "calculator",
10
+ "cancel_events",
11
+ "chatbot_multimodal",
12
+ "chatinterface_streaming_echo",
13
+ "clear_components",
14
+ "code",
15
+ "fake_gan",
16
+ "fake_diffusion_with_gif",
17
+ "file_explorer_component_events",
18
+ "image_mod_default_image",
19
+ "image_editor_events",
20
+ "image_segmentation",
21
+ "interface_random_slider",
22
+ "kitchen_sink",
23
+ "kitchen_sink_random",
24
+ "matrix_transpose",
25
+ "mini_leaderboard",
26
+ "model3D",
27
+ "native_plots",
28
+ "reverse_audio",
29
+ "stt_or_tts",
30
+ "stream_audio",
31
+ "stream_frames",
32
+ "video_component",
33
+ "zip_files"
34
+ ]
gradio/.config/eslint.config.js ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import globals from "globals";
2
+ import ts_plugin from "@typescript-eslint/eslint-plugin";
3
+ import js_plugin from "@eslint/js";
4
+ import jsdoc from "eslint-plugin-jsdoc";
5
+
6
+ import typescriptParser from "@typescript-eslint/parser";
7
+ import sveltePlugin from "eslint-plugin-svelte";
8
+ import svelteParser from "svelte-eslint-parser";
9
+
10
+ const ts_rules_disabled = Object.fromEntries(
11
+ Object.keys(ts_plugin.rules).map((rule) => [
12
+ `@typescript-eslint/${rule}`,
13
+ "off"
14
+ ])
15
+ );
16
+ const js_rules_disabled = Object.fromEntries(
17
+ Object.keys(js_plugin.configs.all.rules).map((rule) => [rule, "off"])
18
+ );
19
+
20
+ const jsdoc_rules_disabled = Object.fromEntries(
21
+ Object.keys(jsdoc.configs.recommended.rules).map((rule) => [
22
+ `jsdoc/${rule}`,
23
+ "off"
24
+ ])
25
+ );
26
+
27
+ const js_rules = {
28
+ ...js_rules_disabled,
29
+ "no-console": ["error", { allow: ["warn", "error", "debug", "info"] }],
30
+ "no-constant-condition": "error",
31
+ "no-dupe-args": "error",
32
+ "no-extra-boolean-cast": "error",
33
+ "no-unexpected-multiline": "error",
34
+ "no-unreachable": "error",
35
+ "array-callback-return": "error",
36
+ complexity: "error",
37
+ "no-else-return": "error",
38
+ "no-useless-return": "error",
39
+ "no-undef": "error"
40
+ };
41
+
42
+ const ts_rules = {
43
+ ...ts_rules_disabled,
44
+ "@typescript-eslint/adjacent-overload-signatures": "error",
45
+ "@typescript-eslint/explicit-function-return-type": [
46
+ "error",
47
+ { allowExpressions: true }
48
+ ],
49
+ "@typescript-eslint/consistent-type-exports": "error",
50
+ "@typescript-eslint/ban-types": "error",
51
+ "@typescript-eslint/array-type": "error",
52
+ "@typescript-eslint/no-inferrable-types": "error"
53
+ };
54
+
55
+ const jsdoc_rules = {
56
+ ...jsdoc_rules_disabled,
57
+ "jsdoc/require-param-description": "error",
58
+ "jsdoc/require-returns-description": "error"
59
+ };
60
+
61
+ const { browser, es2021, node } = globals;
62
+
63
+ export default [
64
+ {
65
+ ignores: [
66
+ "**/.svelte-kit/**/*",
67
+ "**/node_modules/**",
68
+ "**/dist/**",
69
+ "**/.config/*",
70
+ "**/*.spec.ts",
71
+ "**/*.test.ts",
72
+ "**/*.node-test.ts",
73
+ "js/spa/test/**/*",
74
+ "**/*vite.config.ts",
75
+ "**/_website/**/*",
76
+ "**/app/**/*",
77
+ "**/_spaces-test/**/*",
78
+ "**/preview/test/**/*",
79
+ "**/component-test/**/*",
80
+ "**/js/wasm/src/webworker/**/*"
81
+ ]
82
+ },
83
+ {
84
+ files: ["**/*.js", "**/*.cjs"],
85
+ languageOptions: {
86
+ globals: {
87
+ ...browser,
88
+ ...es2021,
89
+ ...node
90
+ }
91
+ },
92
+
93
+ plugins: {
94
+ "eslint:recommended": js_plugin,
95
+ jsdoc
96
+ },
97
+ rules: { ...js_rules, ...jsdoc_rules }
98
+ },
99
+
100
+ {
101
+ files: ["**/*.ts"],
102
+ languageOptions: {
103
+ parser: typescriptParser,
104
+ parserOptions: {
105
+ project: "./tsconfig.json",
106
+ extraFileExtensions: [".svelte"]
107
+ },
108
+ globals: {
109
+ ...browser,
110
+ ...es2021,
111
+ ...node
112
+ }
113
+ },
114
+
115
+ plugins: {
116
+ "@typescript-eslint": ts_plugin,
117
+ "eslint:recommended": js_plugin,
118
+ jsdoc
119
+ },
120
+ rules: {
121
+ ...ts_rules,
122
+ ...js_rules,
123
+ ...jsdoc_rules,
124
+ "no-undef": "off"
125
+ }
126
+ },
127
+ {
128
+ files: ["**/client/js/**"],
129
+ languageOptions: {
130
+ parserOptions: {
131
+ project: "./client/js/tsconfig.json"
132
+ }
133
+ }
134
+ },
135
+ {
136
+ files: ["**/*.svelte"],
137
+ languageOptions: {
138
+ parser: svelteParser,
139
+ parserOptions: {
140
+ parser: typescriptParser,
141
+ project: "./tsconfig.json",
142
+ extraFileExtensions: [".svelte"]
143
+ },
144
+ globals: {
145
+ ...browser,
146
+ ...es2021
147
+ }
148
+ },
149
+ plugins: {
150
+ svelte: sveltePlugin,
151
+ "@typescript-eslint": ts_plugin,
152
+ "eslint:recommended": js_plugin,
153
+ jsdoc
154
+ },
155
+ rules: {
156
+ ...ts_rules,
157
+ ...js_rules,
158
+ ...jsdoc_rules,
159
+ ...sveltePlugin.configs.recommended.rules,
160
+ "svelte/no-at-html-tags": "off",
161
+ "no-undef": "off"
162
+ }
163
+ }
164
+ ];
gradio/.config/lite-builder/pyproject.toml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [build-system]
2
+ requires = ["hatchling",]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "lite-builder"
7
+ description = "Python library for easily interacting with trained machine learning models"
8
+ license = "Apache-2.0"
9
+ version = "0.0.2"
10
+ requires-python = ">=3.8"
11
+ authors = [
12
+ { name = "Abubakar Abid", email = "gradio-team@huggingface.co" },
13
+ { name = "Ali Abid", email = "gradio-team@huggingface.co" },
14
+ { name = "Ali Abdalla", email = "gradio-team@huggingface.co" },
15
+ { name = "Dawood Khan", email = "gradio-team@huggingface.co" },
16
+ { name = "Ahsen Khaliq", email = "gradio-team@huggingface.co" },
17
+ { name = "Pete Allen", email = "gradio-team@huggingface.co" },
18
+ { name = "Ömer Faruk Özdemir", email = "gradio-team@huggingface.co" },
19
+ { name = "Freddy A Boulton", email = "gradio-team@huggingface.co" },
20
+ { name = "Hannah Blair", email = "gradio-team@huggingface.co" },
21
+ ]
22
+ keywords = ["machine learning", "reproducibility", "visualization"]
23
+
24
+ classifiers = [
25
+ 'Development Status :: 5 - Production/Stable',
26
+ ]
27
+
28
+ [tool.hatch.build]
29
+ sources = ["src"]
30
+ only-packages = true
31
+
32
+ [project.entry-points.hatch]
33
+ lite_builder = "lite_builder.hooks"
gradio/.config/lite-builder/src/lite_builder/__init__.py ADDED
File without changes
gradio/.config/lite-builder/src/lite_builder/builder.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ from hatchling.builders.wheel import WheelBuilder
2
+
3
+
4
+ class LiteBuilder(WheelBuilder):
5
+ PLUGIN_NAME = 'lite'
gradio/.config/lite-builder/src/lite_builder/hooks.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ from hatchling.plugin import hookimpl
2
+ from .builder import LiteBuilder
3
+
4
+ @hookimpl
5
+ def hatch_register_builder():
6
+ return LiteBuilder
gradio/.config/playwright-ct.config.ts ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { defineConfig, devices } from "@playwright/experimental-ct-svelte";
2
+ import config from "./basevite.config";
3
+
4
+ /**
5
+ * See https://playwright.dev/docs/test-configuration.
6
+ */
7
+ export default defineConfig({
8
+ testDir: "../",
9
+ /* The base directory, relative to the config file, for snapshot files created with toMatchSnapshot and toHaveScreenshot. */
10
+ snapshotDir: "./__snapshots__",
11
+ /* Maximum time one test can run for. */
12
+ timeout: 10 * 1000,
13
+ /* Run tests in files in parallel */
14
+ fullyParallel: true,
15
+ /* Fail the build on CI if you accidentally left test.only in the source code. */
16
+ forbidOnly: !!process.env.CI,
17
+ /* Retry on CI only */
18
+ retries: process.env.CI ? 2 : 0,
19
+ /* Opt out of parallel tests on CI. */
20
+ workers: process.env.CI ? 1 : undefined,
21
+ /* Reporter to use. See https://playwright.dev/docs/test-reporters */
22
+ reporter: "html",
23
+ /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
24
+ use: {
25
+ /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
26
+ trace: "on-first-retry",
27
+
28
+ /* Port to use for Playwright component endpoint. */
29
+ ctPort: 3100,
30
+ ctViteConfig: config({ mode: "development", command: "build" })
31
+ },
32
+ testMatch: "*.component.spec.ts",
33
+
34
+ /* Configure projects for major browsers */
35
+ projects: [
36
+ {
37
+ name: "chromium",
38
+ use: { ...devices["Desktop Chrome"] }
39
+ }
40
+ ]
41
+ });
gradio/.config/playwright-setup.js ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { spawn } from "node:child_process";
2
+ import { join, basename } from "path";
3
+ import { fileURLToPath } from "url";
4
+ import { readdirSync, writeFileSync } from "fs";
5
+ import net from "net";
6
+
7
+ import kl from "kleur";
8
+
9
+ const __dirname = fileURLToPath(new URL(".", import.meta.url));
10
+ const TEST_APP_PATH = join(__dirname, "./test.py");
11
+ const TEST_FILES_PATH = join(__dirname, "..", "js", "spa", "test");
12
+ const ROOT = join(__dirname, "..");
13
+
14
+ const test_files = readdirSync(TEST_FILES_PATH)
15
+ .filter(
16
+ (f) =>
17
+ f.endsWith("spec.ts") &&
18
+ !f.endsWith(".skip.spec.ts") &&
19
+ !f.endsWith(".component.spec.ts") &&
20
+ !f.endsWith(".reload.spec.ts")
21
+ )
22
+ .map((f) => ({
23
+ module_name: `${basename(f, ".spec.ts")}.run`,
24
+ dir_name: basename(f, ".spec.ts")
25
+ }));
26
+
27
+ export default async function global_setup() {
28
+ const verbose = process.env.GRADIO_TEST_VERBOSE;
29
+
30
+ const port = await find_free_port(7860, 8860);
31
+ process.env.GRADIO_E2E_TEST_PORT = port;
32
+
33
+ process.stdout.write(kl.yellow("\nCreating test gradio app.\n\n"));
34
+
35
+ const test_cases = [];
36
+ // check if there is a testcase file in the same directory as the test file
37
+ // if there is, append that to the file
38
+ test_files.forEach((value) => {
39
+ const test_case_dir = join(ROOT, "demo", value.dir_name);
40
+
41
+ readdirSync(test_case_dir)
42
+ .filter((f) => f.endsWith("_testcase.py"))
43
+ .forEach((f) => {
44
+ test_cases.push({
45
+ module_name: `${value.dir_name}.${basename(f, ".py")}`,
46
+ dir_name: `${value.dir_name}_${basename(f, ".py")}`
47
+ });
48
+ });
49
+ });
50
+
51
+ const all_test_files = test_files.concat(test_cases);
52
+ const test_app = make_app(all_test_files, port);
53
+ process.stdout.write(kl.yellow("App created. Starting test server.\n\n"));
54
+
55
+ process.stdout.write(kl.bgBlue(" =========================== \n"));
56
+ process.stdout.write(kl.bgBlue(" === PYTHON STARTUP LOGS === \n"));
57
+ process.stdout.write(kl.bgBlue(" =========================== \n\n"));
58
+
59
+ writeFileSync(TEST_APP_PATH, test_app);
60
+
61
+ const app = await spawn_gradio_app(TEST_APP_PATH, port, verbose);
62
+
63
+ process.stdout.write(
64
+ kl.green(`\n\nServer started. Running tests on port ${port}.\n`)
65
+ );
66
+
67
+ return () => {
68
+ process.stdout.write(kl.green(`\nTests complete, cleaning up!\n`));
69
+
70
+ kill_process(app);
71
+ };
72
+ }
73
+ const INFO_RE = /^INFO:/;
74
+
75
+ function spawn_gradio_app(app, port, verbose) {
76
+ const PORT_RE = new RegExp(`:${port}`);
77
+
78
+ return new Promise((res, rej) => {
79
+ const _process = spawn(`python`, [app], {
80
+ shell: true,
81
+ stdio: "pipe",
82
+ cwd: ROOT,
83
+ env: {
84
+ ...process.env,
85
+ PYTHONUNBUFFERED: "true",
86
+ GRADIO_ANALYTICS_ENABLED: "False",
87
+ GRADIO_IS_E2E_TEST: "1"
88
+ }
89
+ });
90
+ _process.stdout.setEncoding("utf8");
91
+
92
+ function std_out(data) {
93
+ const _data = data.toString();
94
+ const is_info = INFO_RE.test(_data);
95
+
96
+ if (is_info) {
97
+ process.stdout.write(kl.yellow(_data));
98
+ }
99
+
100
+ if (!is_info) {
101
+ process.stdout.write(`${_data}\n`);
102
+ }
103
+
104
+ if (PORT_RE.test(_data)) {
105
+ process.stdout.write(kl.bgBlue("\n =========== END =========== "));
106
+
107
+ res(_process);
108
+
109
+ if (!verbose) {
110
+ _process.stdout.off("data", std_out);
111
+ _process.stderr.off("data", std_out);
112
+ }
113
+ }
114
+ }
115
+
116
+ _process.stdout.on("data", std_out);
117
+ _process.stderr.on("data", std_out);
118
+ _process.on("exit", () => kill_process(_process));
119
+ _process.on("close", () => kill_process(_process));
120
+ _process.on("disconnect", () => kill_process(_process));
121
+ });
122
+ }
123
+
124
+ function kill_process(process) {
125
+ process.kill("SIGKILL");
126
+ }
127
+
128
+ function make_app(demos, port) {
129
+ return `
130
+ import uvicorn
131
+ from fastapi import FastAPI
132
+ import gradio as gr
133
+
134
+ ${demos.map((obj) => `from demo.${obj.module_name} import demo as ${obj.dir_name}`).join("\n")}
135
+
136
+ app = FastAPI()
137
+ ${demos
138
+ .map(
139
+ (obj) =>
140
+ `app = gr.mount_gradio_app(app, ${obj.dir_name}, path="/${obj.dir_name}", max_file_size=${
141
+ obj.dir_name == "upload_file_limit_test" ? "'15kb'" : "None"
142
+ })`
143
+ )
144
+ .join("\n")}
145
+
146
+ config = uvicorn.Config(app, port=${port}, log_level="info")
147
+ server = uvicorn.Server(config=config)
148
+ server.run()`;
149
+ }
150
+
151
+ export async function find_free_port(start_port, end_port) {
152
+ for (let port = start_port; port < end_port; port++) {
153
+ if (await is_free_port(port)) {
154
+ return port;
155
+ }
156
+ }
157
+
158
+ throw new Error(
159
+ `Could not find free ports: there were not enough ports available.`
160
+ );
161
+ }
162
+
163
+ export function is_free_port(port) {
164
+ return new Promise((accept, reject) => {
165
+ const sock = net.createConnection(port, "127.0.0.1");
166
+ sock.once("connect", () => {
167
+ sock.end();
168
+ accept(false);
169
+ });
170
+ sock.once("error", (e) => {
171
+ sock.destroy();
172
+ if (e.code === "ECONNREFUSED") {
173
+ accept(true);
174
+ } else {
175
+ reject(e);
176
+ }
177
+ });
178
+ });
179
+ }
gradio/.config/playwright.config.js ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { defineConfig, devices } from "@playwright/test";
2
+
3
+ const base = defineConfig({
4
+ use: {
5
+ screenshot: "only-on-failure",
6
+ trace: "retain-on-failure",
7
+ bypassCSP: true,
8
+ launchOptions: {
9
+ args: [
10
+ "--disable-web-security",
11
+ "--use-fake-device-for-media-stream",
12
+ "--use-fake-ui-for-media-stream",
13
+ "--use-file-for-fake-audio-capture=../gradio/test_data/test_audio.wav"
14
+ ]
15
+ }
16
+ },
17
+ expect: { timeout: 10000 },
18
+ timeout: 30000,
19
+ testMatch: /.*\.spec\.ts/,
20
+ testDir: "..",
21
+ workers: process.env.CI ? 1 : undefined,
22
+ retries: 3
23
+ });
24
+
25
+ const normal = defineConfig(base, {
26
+ globalSetup: process.env.CUSTOM_TEST ? undefined : "./playwright-setup.js",
27
+ projects: [
28
+ {
29
+ name: "firefox",
30
+ use: { ...devices["Desktop Firefox"] },
31
+ testMatch: /.stream_(audio|video)_out\.spec\.ts/
32
+ },
33
+ {
34
+ name: "chrome",
35
+ use: {
36
+ ...devices["Desktop Chrome"],
37
+ permissions: ["clipboard-read", "clipboard-write", "microphone"]
38
+ },
39
+ testIgnore: /.stream_(audio|video)_out\.spec\.ts/
40
+ }
41
+ ]
42
+ });
43
+
44
+ const lite = defineConfig(base, {
45
+ webServer: {
46
+ command: "python -m http.server 8000 --directory ../js/lite",
47
+ url: "http://localhost:8000/",
48
+ reuseExistingServer: !process.env.CI
49
+ },
50
+ testMatch: [
51
+ "**/file_component_events.spec.ts",
52
+ "**/kitchen_sink.spec.ts",
53
+ "**/gallery_component_events.spec.ts",
54
+ "**/image_remote_url.spec.ts", // To detect the bugs on Lite fixed in https://github.com/gradio-app/gradio/pull/8011 and https://github.com/gradio-app/gradio/pull/8026
55
+ "**/outbreak_forecast.spec.ts" // To test matplotlib on Lite
56
+ ],
57
+ workers: 1,
58
+ retries: 3,
59
+ timeout: 60000,
60
+ projects: [
61
+ {
62
+ name: "chromium",
63
+ use: { ...devices["Desktop Chrome"] }
64
+ },
65
+ {
66
+ name: "firefox",
67
+ use: { ...devices["Desktop Firefox"] },
68
+ testIgnore: "**/kitchen_sink.*" // This test requires the camera permission but it's not supported on FireFox: https://github.com/microsoft/playwright/issues/11714
69
+ }
70
+ ]
71
+ });
72
+
73
+ export default !!process.env.GRADIO_E2E_TEST_LITE ? lite : normal;
gradio/.config/playwright/index.html ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Testing Page</title>
7
+ </head>
8
+ <body>
9
+ <div id="root"></div>
10
+ <script type="module" src="./index.ts"></script>
11
+ </body>
12
+ </html>
gradio/.config/playwright/index.ts ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ // Import styles, initialize component theme here.
2
+ // import '../src/common.css';
gradio/.config/postcss.config.cjs ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ const tailwindcss = require("tailwindcss");
2
+ const autoprefixer = require("autoprefixer");
3
+ const nested = require("tailwindcss/nesting");
4
+ const tw_config = require("./tailwind.config.cjs");
5
+
6
+ module.exports = {
7
+ plugins: [nested, tailwindcss(tw_config), autoprefixer]
8
+ };
gradio/.config/setup_vite_tests.ts ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ import type { TestingLibraryMatchers } from "@testing-library/jest-dom/matchers";
2
+ import "@testing-library/jest-dom/vitest";
3
+
4
+ declare module "vitest" {
5
+ interface Assertion<T = any>
6
+ extends jest.Matchers<void, T>,
7
+ TestingLibraryMatchers<T, void> {}
8
+ }
gradio/.config/svelte.config.js ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
2
+
3
+ export default {
4
+ preprocess: vitePreprocess()
5
+ };
gradio/.config/tailwind.config.cjs ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ module.exports = {
2
+ content: [
3
+ "./src/**/*.{html,js,svelte,ts}",
4
+ "**/@gradio/**/*.{html,js,svelte,ts}"
5
+ ],
6
+
7
+ theme: {
8
+ extend: {}
9
+ },
10
+
11
+ plugins: [require("@tailwindcss/forms")]
12
+ };
gradio/.config/vitest.config.ts ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ import config from "../js/spa/vite.config";
2
+
3
+ export default config;
gradio/.devcontainer/devcontainer.json ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // See https://containers.dev
2
+ {
3
+ "name": "Python 3",
4
+ "image": "mcr.microsoft.com/devcontainers/python:1-3.9",
5
+
6
+ // See https://containers.dev/features
7
+ "features": {
8
+ "ghcr.io/devcontainers/features/git:1": {},
9
+ "ghcr.io/devcontainers/features/node:1": {},
10
+ "ghcr.io/devcontainers-contrib/features/ffmpeg-apt-get:1": {}
11
+ },
12
+
13
+ "hostRequirements": {
14
+ "cpus": 4,
15
+ "memory": "8gb",
16
+ "storage": "32gb"
17
+ },
18
+
19
+ "customizations": {
20
+ "vscode": {
21
+ "extensions": [
22
+ "ms-python.python",
23
+ "ms-python.vscode-pylance",
24
+ "ms-python.black-formatter",
25
+ "ms-toolsai.jupyter",
26
+ "esbenp.prettier-vscode",
27
+ "svelte.svelte-vscode",
28
+ "phoenisx.cssvar"
29
+ ],
30
+ "remote.autoForwardPorts": false
31
+ }
32
+ },
33
+
34
+ "forwardPorts": [7860, 9876],
35
+ "portsAttributes": {
36
+ "7860": { "label": "gradio port" },
37
+ "9876": { "label": "gradio dev port" }
38
+ },
39
+
40
+ "postCreateCommand": "export NODE_OPTIONS=\"--max-old-space-size=8192\" && chmod +x scripts/install_gradio.sh scripts/install_test_requirements.sh scripts/build_frontend.sh && ./scripts/install_gradio.sh && ./scripts/install_test_requirements.sh && ./scripts/build_frontend.sh"
41
+ }
gradio/.dockerignore ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Python build
2
+ .eggs/
3
+ gradio.egg-info/*
4
+ !gradio.egg-info/requires.txt
5
+ !gradio.egg-info/PKG-INFO
6
+ dist/
7
+ *.pyc
8
+ __pycache__/
9
+ *.py[cod]
10
+ *$py.class
11
+ build/
12
+
13
+ # JS build
14
+ gradio/templates/frontend/static
15
+ gradio/templates/frontend/cdn
16
+
17
+ # Secrets
18
+ .env
19
+
20
+ # Gradio run artifacts
21
+ *.db
22
+ *.sqlite3
23
+ gradio/launches.json
24
+ gradio/hash_seed.txt
25
+
26
+ # Tests
27
+ .coverage
28
+ coverage.xml
29
+ test.txt
30
+
31
+ # Demos
32
+ demo/tmp.zip
33
+ demo/flagged
34
+ demo/files/*.avi
35
+ demo/files/*.mp4
36
+
37
+ # Etc
38
+ .idea/*
39
+ .DS_Store
40
+ *.bak
41
+ workspace.code-workspace
gradio/.editorconfig ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+
2
+ root = true
3
+
4
+ [{js/**,client/js/**}]
5
+ end_of_line = lf
6
+ insert_final_newline = true
7
+ indent_style = tab
8
+ tab_width = 2
gradio/.git-blame-ignore-revs ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # https://github.com/gradio-app/gradio/pull/4487 - refactor components.py to separate files
2
+ 69f36f98535c904e7cac2b4942cecc747ed7443c
3
+ # Format the codebase
4
+ cc0cff893f9d7d472788adc2510c123967b384fe
5
+ # Switch from black to ruff
6
+ 8a70e83db9c7751b46058cdd2514e6bddeef6210
7
+ # format (#4810)
8
+ 7fa5e766ce0f89f1fb84c329e62c9df9c332120a
9
+ # lint website
10
+ 4bf301324b3b180fa32166ff1774312b01334c88
11
+ # format frontend with prettier
12
+ 980b9f60eb49ed81e4957debe7b23a559a4d4b51
13
+ # Refactor component directories (#5074)
14
+ 1419538ea795caa391e3de809379f10639e9e764
gradio/.github/ISSUE_TEMPLATE/bug_report_template.yml ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: "\U0001F41E Bug report"
2
+ description: Report a bug on Gradio
3
+ labels: ["bug"]
4
+ body:
5
+ - type: markdown
6
+ attributes:
7
+ value: |
8
+ Thanks for taking the time to fill out this bug report! Before you get started, please [search to see](https://github.com/gradio-app/gradio/issues) if an issue already exists for the bug you encountered
9
+ - type: textarea
10
+ id: bug-description
11
+ attributes:
12
+ label: Describe the bug
13
+ description: Please provide a concise description of what the bug is, in clear English. If you intend to submit a PR for this issue, tell us in the description.
14
+ placeholder: Bug description
15
+ validations:
16
+ required: true
17
+ - type: checkboxes
18
+ attributes:
19
+ label: Have you searched existing issues? 🔎
20
+ description: Please search to see if an issue already exists for the issue you encountered.
21
+ options:
22
+ - label: I have searched and found no existing issues
23
+ required: true
24
+ - type: textarea
25
+ id: reproduction
26
+ attributes:
27
+ label: Reproduction
28
+ description: Please provide a minimal example, with code, that can be run to reproduce the issue. Do NOT provide screenshots of code, or link to external repos or applications. Use ``` to format code blocks.
29
+ placeholder: Reproduction
30
+ value: |
31
+ ```python
32
+ import gradio as gr
33
+
34
+ ```
35
+ validations:
36
+ required: true
37
+ - type: textarea
38
+ id: screenshot
39
+ attributes:
40
+ label: Screenshot
41
+ description: If relevant, please include screenshot(s) of your Gradio app so that we can understand what the issue is.
42
+ - type: textarea
43
+ id: logs
44
+ attributes:
45
+ label: Logs
46
+ description: "Please include the full stacktrace of the errors you get from Python or Javascript. If you are running in a colab notebooks, you can get the logs with by setting `debug=True`, i.e: `gradio.Interface.launch(debug=True)`"
47
+ render: shell
48
+ - type: textarea
49
+ id: system-info
50
+ attributes:
51
+ label: System Info
52
+ description: Please ensure you are running the latest version of Gradio. You can get the Gradio version and all its dependencies by running `gradio environment`
53
+ render: shell
54
+ validations:
55
+ required: true
56
+ - type: dropdown
57
+ id: severity
58
+ attributes:
59
+ label: Severity
60
+ description: Select the severity of this issue
61
+ options:
62
+ - I can work around it
63
+ - Blocking usage of gradio
64
+ validations:
65
+ required: true
66
+ - type: markdown
67
+ attributes:
68
+ value: |
69
+ 📌 Please ensure that you have filled all of the required sections above, and that the reproduction you have provided is [minimal, complete, and reproducible](https://stackoverflow.com/help/minimal-reproducible-example). Incomplete issues will be closed.
gradio/.github/ISSUE_TEMPLATE/config.yml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ blank_issues_enabled: false
2
+ contact_links:
3
+ - name: 💡 General questions
4
+ url: https://discord.com/invite/feTf9x3ZSB
5
+ about: Have general questions about how to use Gradio? Please ask in our community Discord for quicker responses
gradio/.github/ISSUE_TEMPLATE/feature_request.md ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ name: ⚡ Feature request
3
+ about: Suggest an improvement or new feature or a new Guide for Gradio
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+ - [ ] I have searched to see if a similar issue already exists.
10
+
11
+
12
+ **Is your feature request related to a problem? Please describe.**
13
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
14
+
15
+ **Describe the solution you'd like**
16
+ A clear and concise description of what you want to happen.
17
+
18
+ **Additional context**
19
+ Add any other context or screenshots about the feature request here.
gradio/.github/PULL_REQUEST_TEMPLATE.md ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Description
2
+
3
+ Please include a concise summary, in clear English, of the changes in this pull request. If it closes an issue, please mention it here.
4
+
5
+ Closes: #(issue)
6
+
7
+ ## 🎯 PRs Should Target Issues
8
+
9
+ Before your create a PR, please check to see if there is [an existing issue](https://github.com/gradio-app/gradio/issues) for this change. If not, please create an issue before you create this PR, unless the fix is very small.
10
+
11
+ Not adhering to this guideline will result in the PR being closed.
12
+
13
+ ## Testing and Formatting Your Code
14
+
15
+ 1. PRs will only be merged if tests pass on CI. We recommend at least running the backend tests locally, please set up [your Gradio environment locally](https://github.com/gradio-app/gradio/blob/main/CONTRIBUTING.md) and run the backed tests: `bash scripts/run_backend_tests.sh`
16
+
17
+ 2. Please run these bash scripts to automatically format your code: `bash scripts/format_backend.sh`, and (if you made any changes to non-Python files) `bash scripts/format_frontend.sh`
18
+
gradio/.github/actions/changes/action.yml ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: "prepare"
2
+ description: "Prepare workflow"
3
+
4
+ inputs:
5
+ token:
6
+ description: "GitHub token"
7
+ filter:
8
+ description: "Which filter to use"
9
+
10
+ outputs:
11
+ should_run:
12
+ description: "Whether to run the workflow"
13
+ value: ${{ steps.pr.outputs.should_run }}
14
+ pr_number:
15
+ description: "PR number"
16
+ value: ${{ steps.pr.outputs.pr_number }}
17
+ sha:
18
+ description: "SHA of the HEAD commit of the PR"
19
+ value: ${{ steps.pr.outputs.sha }}
20
+ source_repo:
21
+ description: "Source repo"
22
+ value: ${{ steps.pr.outputs.source_repo }}
23
+ source_branch:
24
+ description: "Source branch"
25
+ value: ${{ steps.pr.outputs.source_branch }}
26
+ labels:
27
+ description: "Labels on the PR"
28
+ value: ${{ steps.pr.outputs.labels }}
29
+ run_id:
30
+ description: "Run ID"
31
+ value: ${{ steps.pr.outputs.run_id }}
32
+ gradio_version:
33
+ description: "Gradio version"
34
+ value: ${{ steps.pr.outputs.gradio_version }}
35
+
36
+ runs:
37
+ using: "composite"
38
+ steps:
39
+ - uses: actions/checkout@v4
40
+ - uses: gradio-app/github/actions/filter-paths@main
41
+ id: changes
42
+ with:
43
+ token: ${{ inputs.token }}
44
+ filter: ${{ inputs.filter }}
45
+ - name: get gradio version
46
+ id: gradio_version
47
+ shell: bash
48
+ run: |
49
+ GRADIO_VERSION=$(curl -s https://pypi.org/pypi/gradio/json | grep -o '"version":"[^"]*"' | cut -d'"' -f4 | head -n 1)
50
+ echo "gradio_version=$GRADIO_VERSION" >> $GITHUB_OUTPUT
51
+ - name: convert to JSON
52
+ uses: gradio-app/github/actions/input-to-json@main
53
+ with:
54
+ path: output.json
55
+ sha: ${{ github.event.pull_request.head.sha || github.sha }}
56
+ source_repo: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
57
+ source_branch: ${{ github.event.pull_request.head.ref || github.ref }}
58
+ pr_number: ${{ github.event.pull_request.number || 'false'}}
59
+ should_run: ${{ steps.changes.outputs.match }}
60
+ labels: "[${{ join(github.event.pull_request.labels.*.name, ', ') }}]"
61
+ run_id: ${{ github.run_id }}
62
+ gradio_version: ${{ steps.gradio_version.outputs.gradio_version }}
63
+ - name: cat json
64
+ run: cat output.json
65
+ shell: bash
66
+ - name: upload JSON
67
+ uses: actions/upload-artifact@v4
68
+ with:
69
+ name: changes
70
+ path: output.json
71
+ - name: set outputs
72
+ id: pr
73
+ uses: gradio-app/github/actions/json-to-output@main
74
+ with:
75
+ path: output.json
76
+ - name: echo outputs
77
+ run: echo "${{ toJson(steps.pr.outputs) }}"
78
+ shell: bash
gradio/.github/actions/install-all-deps/action.yml ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: "install all deps"
2
+ description: "Install all deps"
3
+
4
+ inputs:
5
+ skip_build:
6
+ description: "Skip build"
7
+ default: "false"
8
+ build_lite:
9
+ description: "Build lite"
10
+ default: "false"
11
+ test:
12
+ description: "Test"
13
+ default: "false"
14
+ python_version:
15
+ description: "Python version"
16
+ default: "3.10"
17
+ os:
18
+ description: "OS"
19
+ default: "ubuntu-latest"
20
+ outputs:
21
+ venv_activate:
22
+ description: "Venv activate"
23
+ value: ${{ steps.venv.outputs.venv_activate }}
24
+
25
+ runs:
26
+ using: "composite"
27
+ steps:
28
+ - name: Set venv binary path (linux)
29
+ if: ${{ inputs.os == 'ubuntu-latest' }}
30
+ shell: bash
31
+ run: |
32
+ echo "VENV_ACTIVATE=venv/bin/activate" >> $GITHUB_ENV
33
+ - name: Set venv binary path (windows)
34
+ if: ${{ inputs.os == 'windows-latest' }}
35
+ shell: bash
36
+ run: |
37
+ echo "VENV_ACTIVATE=venv\\\Scripts\\\activate" >> $GITHUB_ENV
38
+ - name: log venv binary path
39
+ id: venv
40
+ shell: bash
41
+ run: |
42
+ echo "venv_activate=$VENV_ACTIVATE" >> $GITHUB_OUTPUT
43
+ - name: Install Python
44
+ uses: actions/setup-python@v5
45
+ with:
46
+ python-version: ${{ inputs.python_version }}
47
+ cache: pip
48
+ cache-dependency-path: |
49
+ client/python/requirements.txt
50
+ requirements.txt
51
+ test/requirements.txt
52
+ - name: Create env
53
+ shell: bash
54
+ run: |
55
+ python -m pip install --upgrade virtualenv
56
+ python -m virtualenv venv
57
+ - name: Install uv
58
+ shell: bash
59
+ run: |
60
+ curl -LsSf https://astral.sh/uv/install.sh | sh
61
+ echo "$HOME/.cargo/bin" >> $GITHUB_PATH
62
+ - uses: actions/cache@v4
63
+ id: cache
64
+ with:
65
+ path: |
66
+ venv/**
67
+ client/python/venv
68
+ restore-keys: |
69
+ gradio-lib-${{inputs.python_version}}-${{inputs.os}}-latest-pip-
70
+ key: "gradio-lib-${{inputs.python_version}}-${{inputs.os}}-latest-pip-${{ hashFiles('client/python/requirements.txt') }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('test/requirements.txt') }}-${{ hashFiles('client/python/test/requirements.txt') }}${{ inputs.test == 'true' && '-test' || ''}}"
71
+ - name: Install ffmpeg
72
+ uses: FedericoCarboni/setup-ffmpeg@583042d32dd1cabb8bd09df03bde06080da5c87c # @v2
73
+ - name: Install test dependencies
74
+ if: inputs.test == 'true' && steps.cache.outputs.cache-hit != 'true'
75
+ shell: bash
76
+ run: |
77
+ . ${{ env.VENV_ACTIVATE }}
78
+ uv pip install -r test/requirements.txt
79
+ uv pip install -r client/python/test/requirements.txt
80
+ - name: Install Gradio and Client Libraries Locally (Linux)
81
+ shell: bash
82
+ run: |
83
+ . ${{ env.VENV_ACTIVATE }}
84
+ uv pip install -e client/python
85
+ uv pip install -e ".[oauth]"
86
+ - name: install-frontend
87
+ uses: "gradio-app/gradio/.github/actions/install-frontend-deps@main"
88
+ with:
89
+ skip_build: ${{ inputs.skip_build }}
90
+ build_lite: ${{ inputs.build_lite }}
91
+ - name: generate json
92
+ shell: bash
93
+ if: inputs.os == 'ubuntu-latest'
94
+ run: |
95
+ . ${{ env.VENV_ACTIVATE }}
96
+ uv pip install boto3 && python js/_website/generate_jsons/generate.py