Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/audio/interactive/InteractiveAudio.svelte +332 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/audio/package.json +62 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/audio/recorder/AudioRecorder.svelte +287 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/audio/shared/VolumeLevels.svelte +12 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/audio/shared/WaveformRecordControls.svelte +279 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/audio/streaming/StreamAudio.svelte +205 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/button/package.json +35 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/chatbot/Index.svelte +178 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/chatbot/package.json +50 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/chatbot/shared/ChatBot.svelte +598 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/chatbot/shared/CopyAll.svelte +53 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/chatbot/shared/Download.svelte +16 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/chatbot/shared/MessageBox.svelte +61 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/chatbot/shared/Pending.svelte +60 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/chatbot/shared/ThumbDownActive.svelte +12 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/chatbot/shared/ThumbUpDefault.svelte +12 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/chatbot/shared/autorender.d.ts +1 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/chatbot/types.ts +49 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/column/package.json +32 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/fallback/Example.svelte +19 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/fileexplorer/Index.svelte +87 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/fileexplorer/shared/Checkbox.svelte +51 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/image/Index.svelte +235 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/image/package.json +57 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/image/shared/ClearImage.svelte +18 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/image/shared/ImagePreview.svelte +165 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/image/shared/ImageUploader.svelte +235 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/image/shared/index.ts +2 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/image/shared/utils.ts +29 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/plot/Index.svelte +73 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/plot/package.json +47 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/plot/shared/Plot.svelte +62 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/plot/shared/plot_types/AltairPlot.svelte +157 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/plot/shared/plot_types/MatplotlibPlot.svelte +28 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/plot/shared/plot_types/PlotlyPlot.svelte +50 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/preview/package.json +54 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/preview/rollup.config.js +54 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/preview/src/__pycache__/examine.cpython-310.pyc +0 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/preview/src/build.ts +108 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/preview/src/compiler.ts +2 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/preview/src/dev.ts +207 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/preview/src/index.ts +197 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/preview/src/plugins.ts +133 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/preview/src/register.mjs +3 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/preview/src/svelte-disclose.ts +2 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/preview/src/svelte-internal.ts +2 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/preview/src/svelte-submodules.ts +5 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/preview/src/svelte.ts +17 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/preview/test/test/.gitignore +9 -0
- evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/preview/test/test/backend/gradio_test/__init__.py +4 -0
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/audio/interactive/InteractiveAudio.svelte
ADDED
|
@@ -0,0 +1,332 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import { onDestroy, createEventDispatcher, tick } from "svelte";
|
| 3 |
+
import { Upload, ModifyUpload } from "@gradio/upload";
|
| 4 |
+
import { prepare_files, type FileData, type Client } from "@gradio/client";
|
| 5 |
+
import { BlockLabel } from "@gradio/atoms";
|
| 6 |
+
import { Music } from "@gradio/icons";
|
| 7 |
+
import { StreamingBar } from "@gradio/statustracker";
|
| 8 |
+
import AudioPlayer from "../player/AudioPlayer.svelte";
|
| 9 |
+
|
| 10 |
+
import type { IBlobEvent, IMediaRecorder } from "extendable-media-recorder";
|
| 11 |
+
import type { I18nFormatter } from "js/core/src/gradio_helper";
|
| 12 |
+
import AudioRecorder from "../recorder/AudioRecorder.svelte";
|
| 13 |
+
import StreamAudio from "../streaming/StreamAudio.svelte";
|
| 14 |
+
import { SelectSource } from "@gradio/atoms";
|
| 15 |
+
import type { WaveformOptions } from "../shared/types";
|
| 16 |
+
|
| 17 |
+
export let value: null | FileData = null;
|
| 18 |
+
export let label: string;
|
| 19 |
+
export let root: string;
|
| 20 |
+
export let loop: boolean;
|
| 21 |
+
export let show_label = true;
|
| 22 |
+
export let show_download_button = false;
|
| 23 |
+
export let sources:
|
| 24 |
+
| ["microphone"]
|
| 25 |
+
| ["upload"]
|
| 26 |
+
| ["microphone", "upload"]
|
| 27 |
+
| ["upload", "microphone"] = ["microphone", "upload"];
|
| 28 |
+
export let pending = false;
|
| 29 |
+
export let streaming = false;
|
| 30 |
+
export let i18n: I18nFormatter;
|
| 31 |
+
export let waveform_settings: Record<string, any>;
|
| 32 |
+
export let trim_region_settings = {};
|
| 33 |
+
export let waveform_options: WaveformOptions = {};
|
| 34 |
+
export let dragging: boolean;
|
| 35 |
+
export let active_source: "microphone" | "upload";
|
| 36 |
+
export let handle_reset_value: () => void = () => {};
|
| 37 |
+
export let editable = true;
|
| 38 |
+
export let max_file_size: number | null = null;
|
| 39 |
+
export let upload: Client["upload"];
|
| 40 |
+
export let stream_handler: Client["stream"];
|
| 41 |
+
export let stream_every: number;
|
| 42 |
+
export let uploading = false;
|
| 43 |
+
export let recording = false;
|
| 44 |
+
|
| 45 |
+
let time_limit: number | null = null;
|
| 46 |
+
let stream_state: "open" | "waiting" | "closed" = "closed";
|
| 47 |
+
|
| 48 |
+
export const modify_stream: (state: "open" | "closed" | "waiting") => void = (
|
| 49 |
+
state: "open" | "closed" | "waiting"
|
| 50 |
+
) => {
|
| 51 |
+
if (state === "closed") {
|
| 52 |
+
time_limit = null;
|
| 53 |
+
stream_state = "closed";
|
| 54 |
+
} else if (state === "waiting") {
|
| 55 |
+
stream_state = "waiting";
|
| 56 |
+
} else {
|
| 57 |
+
stream_state = "open";
|
| 58 |
+
}
|
| 59 |
+
};
|
| 60 |
+
|
| 61 |
+
export const set_time_limit = (time: number): void => {
|
| 62 |
+
if (recording) time_limit = time;
|
| 63 |
+
};
|
| 64 |
+
|
| 65 |
+
$: dispatch("drag", dragging);
|
| 66 |
+
|
| 67 |
+
// TODO: make use of this
|
| 68 |
+
// export let type: "normal" | "numpy" = "normal";
|
| 69 |
+
let recorder: IMediaRecorder;
|
| 70 |
+
let mode = "";
|
| 71 |
+
let header: Uint8Array | undefined = undefined;
|
| 72 |
+
let pending_stream: Uint8Array[] = [];
|
| 73 |
+
let submit_pending_stream_on_pending_end = false;
|
| 74 |
+
let inited = false;
|
| 75 |
+
|
| 76 |
+
const NUM_HEADER_BYTES = 44;
|
| 77 |
+
let audio_chunks: Blob[] = [];
|
| 78 |
+
let module_promises: [
|
| 79 |
+
Promise<typeof import("extendable-media-recorder")>,
|
| 80 |
+
Promise<typeof import("extendable-media-recorder-wav-encoder")>
|
| 81 |
+
];
|
| 82 |
+
|
| 83 |
+
function get_modules(): void {
|
| 84 |
+
module_promises = [
|
| 85 |
+
import("extendable-media-recorder"),
|
| 86 |
+
import("extendable-media-recorder-wav-encoder")
|
| 87 |
+
];
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
const is_browser = typeof window !== "undefined";
|
| 91 |
+
if (is_browser && streaming) {
|
| 92 |
+
get_modules();
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
const dispatch = createEventDispatcher<{
|
| 96 |
+
change: FileData | null;
|
| 97 |
+
stream: FileData;
|
| 98 |
+
edit: never;
|
| 99 |
+
play: never;
|
| 100 |
+
pause: never;
|
| 101 |
+
stop: never;
|
| 102 |
+
end: never;
|
| 103 |
+
drag: boolean;
|
| 104 |
+
error: string;
|
| 105 |
+
upload: FileData;
|
| 106 |
+
clear: undefined;
|
| 107 |
+
start_recording: undefined;
|
| 108 |
+
pause_recording: undefined;
|
| 109 |
+
stop_recording: undefined;
|
| 110 |
+
close_stream: undefined;
|
| 111 |
+
}>();
|
| 112 |
+
|
| 113 |
+
const dispatch_blob = async (
|
| 114 |
+
blobs: Uint8Array[] | Blob[],
|
| 115 |
+
event: "stream" | "change" | "stop_recording"
|
| 116 |
+
): Promise<void> => {
|
| 117 |
+
let _audio_blob = new File(blobs, "audio.wav");
|
| 118 |
+
const val = await prepare_files([_audio_blob], event === "stream");
|
| 119 |
+
value = (
|
| 120 |
+
(await upload(val, root, undefined, max_file_size || undefined))?.filter(
|
| 121 |
+
Boolean
|
| 122 |
+
) as FileData[]
|
| 123 |
+
)[0];
|
| 124 |
+
dispatch(event, value);
|
| 125 |
+
};
|
| 126 |
+
|
| 127 |
+
onDestroy(() => {
|
| 128 |
+
if (streaming && recorder && recorder.state !== "inactive") {
|
| 129 |
+
recorder.stop();
|
| 130 |
+
}
|
| 131 |
+
});
|
| 132 |
+
|
| 133 |
+
async function prepare_audio(): Promise<void> {
|
| 134 |
+
let stream: MediaStream | null;
|
| 135 |
+
|
| 136 |
+
try {
|
| 137 |
+
stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
| 138 |
+
} catch (err) {
|
| 139 |
+
if (!navigator.mediaDevices) {
|
| 140 |
+
dispatch("error", i18n("audio.no_device_support"));
|
| 141 |
+
return;
|
| 142 |
+
}
|
| 143 |
+
if (err instanceof DOMException && err.name == "NotAllowedError") {
|
| 144 |
+
dispatch("error", i18n("audio.allow_recording_access"));
|
| 145 |
+
return;
|
| 146 |
+
}
|
| 147 |
+
throw err;
|
| 148 |
+
}
|
| 149 |
+
if (stream == null) return;
|
| 150 |
+
|
| 151 |
+
if (streaming) {
|
| 152 |
+
const [{ MediaRecorder, register }, { connect }] =
|
| 153 |
+
await Promise.all(module_promises);
|
| 154 |
+
await register(await connect());
|
| 155 |
+
recorder = new MediaRecorder(stream, { mimeType: "audio/wav" });
|
| 156 |
+
recorder.addEventListener("dataavailable", handle_chunk);
|
| 157 |
+
} else {
|
| 158 |
+
recorder = new MediaRecorder(stream);
|
| 159 |
+
recorder.addEventListener("dataavailable", (event) => {
|
| 160 |
+
audio_chunks.push(event.data);
|
| 161 |
+
});
|
| 162 |
+
}
|
| 163 |
+
recorder.addEventListener("stop", async () => {
|
| 164 |
+
recording = false;
|
| 165 |
+
// recorder.stop();
|
| 166 |
+
await dispatch_blob(audio_chunks, "change");
|
| 167 |
+
await dispatch_blob(audio_chunks, "stop_recording");
|
| 168 |
+
audio_chunks = [];
|
| 169 |
+
});
|
| 170 |
+
inited = true;
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
async function handle_chunk(event: IBlobEvent): Promise<void> {
|
| 174 |
+
let buffer = await event.data.arrayBuffer();
|
| 175 |
+
let payload = new Uint8Array(buffer);
|
| 176 |
+
if (!header) {
|
| 177 |
+
header = new Uint8Array(buffer.slice(0, NUM_HEADER_BYTES));
|
| 178 |
+
payload = new Uint8Array(buffer.slice(NUM_HEADER_BYTES));
|
| 179 |
+
}
|
| 180 |
+
if (pending) {
|
| 181 |
+
pending_stream.push(payload);
|
| 182 |
+
} else {
|
| 183 |
+
let blobParts = [header].concat(pending_stream, [payload]);
|
| 184 |
+
if (!recording || stream_state === "waiting") return;
|
| 185 |
+
dispatch_blob(blobParts, "stream");
|
| 186 |
+
pending_stream = [];
|
| 187 |
+
}
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
$: if (submit_pending_stream_on_pending_end && pending === false) {
|
| 191 |
+
submit_pending_stream_on_pending_end = false;
|
| 192 |
+
if (header && pending_stream) {
|
| 193 |
+
let blobParts: Uint8Array[] = [header].concat(pending_stream);
|
| 194 |
+
pending_stream = [];
|
| 195 |
+
dispatch_blob(blobParts, "stream");
|
| 196 |
+
}
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
async function record(): Promise<void> {
|
| 200 |
+
recording = true;
|
| 201 |
+
dispatch("start_recording");
|
| 202 |
+
if (!inited) await prepare_audio();
|
| 203 |
+
header = undefined;
|
| 204 |
+
if (streaming) {
|
| 205 |
+
recorder.start(stream_every * 1000);
|
| 206 |
+
}
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
function clear(): void {
|
| 210 |
+
dispatch("change", null);
|
| 211 |
+
dispatch("clear");
|
| 212 |
+
mode = "";
|
| 213 |
+
value = null;
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
function handle_load({ detail }: { detail: FileData }): void {
|
| 217 |
+
value = detail;
|
| 218 |
+
dispatch("change", detail);
|
| 219 |
+
dispatch("upload", detail);
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
async function stop(): Promise<void> {
|
| 223 |
+
recording = false;
|
| 224 |
+
|
| 225 |
+
if (streaming) {
|
| 226 |
+
dispatch("close_stream");
|
| 227 |
+
dispatch("stop_recording");
|
| 228 |
+
recorder.stop();
|
| 229 |
+
|
| 230 |
+
if (pending) {
|
| 231 |
+
submit_pending_stream_on_pending_end = true;
|
| 232 |
+
}
|
| 233 |
+
dispatch_blob(audio_chunks, "stop_recording");
|
| 234 |
+
dispatch("clear");
|
| 235 |
+
mode = "";
|
| 236 |
+
}
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
$: if (!recording && recorder) stop();
|
| 240 |
+
$: if (recording && recorder) record();
|
| 241 |
+
</script>
|
| 242 |
+
|
| 243 |
+
<BlockLabel
|
| 244 |
+
{show_label}
|
| 245 |
+
Icon={Music}
|
| 246 |
+
float={active_source === "upload" && value === null}
|
| 247 |
+
label={label || i18n("audio.audio")}
|
| 248 |
+
/>
|
| 249 |
+
<div class="audio-container">
|
| 250 |
+
<StreamingBar {time_limit} />
|
| 251 |
+
{#if value === null || streaming}
|
| 252 |
+
{#if active_source === "microphone"}
|
| 253 |
+
<ModifyUpload {i18n} on:clear={clear} />
|
| 254 |
+
{#if streaming}
|
| 255 |
+
<StreamAudio
|
| 256 |
+
{record}
|
| 257 |
+
{recording}
|
| 258 |
+
{stop}
|
| 259 |
+
{i18n}
|
| 260 |
+
{waveform_settings}
|
| 261 |
+
{waveform_options}
|
| 262 |
+
waiting={stream_state === "waiting"}
|
| 263 |
+
/>
|
| 264 |
+
{:else}
|
| 265 |
+
<AudioRecorder
|
| 266 |
+
bind:mode
|
| 267 |
+
{i18n}
|
| 268 |
+
{editable}
|
| 269 |
+
{recording}
|
| 270 |
+
{dispatch_blob}
|
| 271 |
+
{waveform_settings}
|
| 272 |
+
{waveform_options}
|
| 273 |
+
{handle_reset_value}
|
| 274 |
+
on:start_recording
|
| 275 |
+
on:pause_recording
|
| 276 |
+
on:stop_recording
|
| 277 |
+
/>
|
| 278 |
+
{/if}
|
| 279 |
+
{:else if active_source === "upload"}
|
| 280 |
+
<!-- explicitly listed out audio mimetypes due to iOS bug not recognizing audio/* -->
|
| 281 |
+
<Upload
|
| 282 |
+
filetype="audio/aac,audio/midi,audio/mpeg,audio/ogg,audio/wav,audio/x-wav,audio/opus,audio/webm,audio/flac,audio/vnd.rn-realaudio,audio/x-ms-wma,audio/x-aiff,audio/amr,audio/*"
|
| 283 |
+
on:load={handle_load}
|
| 284 |
+
bind:dragging
|
| 285 |
+
bind:uploading
|
| 286 |
+
on:error={({ detail }) => dispatch("error", detail)}
|
| 287 |
+
{root}
|
| 288 |
+
{max_file_size}
|
| 289 |
+
{upload}
|
| 290 |
+
{stream_handler}
|
| 291 |
+
>
|
| 292 |
+
<slot />
|
| 293 |
+
</Upload>
|
| 294 |
+
{/if}
|
| 295 |
+
{:else}
|
| 296 |
+
<ModifyUpload
|
| 297 |
+
{i18n}
|
| 298 |
+
on:clear={clear}
|
| 299 |
+
on:edit={() => (mode = "edit")}
|
| 300 |
+
download={show_download_button ? value.url : null}
|
| 301 |
+
/>
|
| 302 |
+
|
| 303 |
+
<AudioPlayer
|
| 304 |
+
bind:mode
|
| 305 |
+
{value}
|
| 306 |
+
{label}
|
| 307 |
+
{i18n}
|
| 308 |
+
{dispatch_blob}
|
| 309 |
+
{waveform_settings}
|
| 310 |
+
{waveform_options}
|
| 311 |
+
{trim_region_settings}
|
| 312 |
+
{handle_reset_value}
|
| 313 |
+
{editable}
|
| 314 |
+
{loop}
|
| 315 |
+
interactive
|
| 316 |
+
on:stop
|
| 317 |
+
on:play
|
| 318 |
+
on:pause
|
| 319 |
+
on:edit
|
| 320 |
+
/>
|
| 321 |
+
{/if}
|
| 322 |
+
<SelectSource {sources} bind:active_source handle_clear={clear} />
|
| 323 |
+
</div>
|
| 324 |
+
|
| 325 |
+
<style>
|
| 326 |
+
.audio-container {
|
| 327 |
+
height: calc(var(--size-full) - var(--size-6));
|
| 328 |
+
display: flex;
|
| 329 |
+
flex-direction: column;
|
| 330 |
+
justify-content: space-between;
|
| 331 |
+
}
|
| 332 |
+
</style>
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/audio/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@gradio/audio",
|
| 3 |
+
"version": "0.14.2",
|
| 4 |
+
"description": "Gradio UI packages",
|
| 5 |
+
"type": "module",
|
| 6 |
+
"author": "",
|
| 7 |
+
"license": "ISC",
|
| 8 |
+
"private": false,
|
| 9 |
+
"dependencies": {
|
| 10 |
+
"@gradio/atoms": "workspace:^",
|
| 11 |
+
"@gradio/button": "workspace:^",
|
| 12 |
+
"@gradio/client": "workspace:^",
|
| 13 |
+
"@gradio/icons": "workspace:^",
|
| 14 |
+
"@gradio/statustracker": "workspace:^",
|
| 15 |
+
"@gradio/upload": "workspace:^",
|
| 16 |
+
"@gradio/utils": "workspace:^",
|
| 17 |
+
"@gradio/wasm": "workspace:^",
|
| 18 |
+
"@types/wavesurfer.js": "^6.0.10",
|
| 19 |
+
"extendable-media-recorder": "^9.0.0",
|
| 20 |
+
"extendable-media-recorder-wav-encoder": "^7.0.76",
|
| 21 |
+
"hls.js": "^1.5.13",
|
| 22 |
+
"resize-observer-polyfill": "^1.5.1",
|
| 23 |
+
"svelte-range-slider-pips": "^2.0.1",
|
| 24 |
+
"wavesurfer.js": "^7.4.2"
|
| 25 |
+
},
|
| 26 |
+
"devDependencies": {
|
| 27 |
+
"@gradio/preview": "workspace:^"
|
| 28 |
+
},
|
| 29 |
+
"main_changeset": true,
|
| 30 |
+
"main": "index.ts",
|
| 31 |
+
"exports": {
|
| 32 |
+
"./package.json": "./package.json",
|
| 33 |
+
".": {
|
| 34 |
+
"gradio": "./index.ts",
|
| 35 |
+
"svelte": "./dist/index.js",
|
| 36 |
+
"types": "./dist/index.d.ts"
|
| 37 |
+
},
|
| 38 |
+
"./example": {
|
| 39 |
+
"gradio": "./Example.svelte",
|
| 40 |
+
"svelte": "./dist/Example.svelte",
|
| 41 |
+
"types": "./dist/Example.svelte.d.ts"
|
| 42 |
+
},
|
| 43 |
+
"./shared": {
|
| 44 |
+
"gradio": "./shared/index.ts",
|
| 45 |
+
"svelte": "./dist/shared/index.js",
|
| 46 |
+
"types": "./dist/shared/index.d.ts"
|
| 47 |
+
},
|
| 48 |
+
"./base": {
|
| 49 |
+
"gradio": "./static/StaticAudio.svelte",
|
| 50 |
+
"svelte": "./dist/static/StaticAudio.svelte",
|
| 51 |
+
"types": "./dist/static/StaticAudio.svelte.d.ts"
|
| 52 |
+
}
|
| 53 |
+
},
|
| 54 |
+
"peerDependencies": {
|
| 55 |
+
"svelte": "^4.0.0"
|
| 56 |
+
},
|
| 57 |
+
"repository": {
|
| 58 |
+
"type": "git",
|
| 59 |
+
"url": "git+https://github.com/gradio-app/gradio.git",
|
| 60 |
+
"directory": "js/audio"
|
| 61 |
+
}
|
| 62 |
+
}
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/audio/recorder/AudioRecorder.svelte
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import { onMount } from "svelte";
|
| 3 |
+
import type { I18nFormatter } from "@gradio/utils";
|
| 4 |
+
import { createEventDispatcher } from "svelte";
|
| 5 |
+
import WaveSurfer from "wavesurfer.js";
|
| 6 |
+
import { skip_audio, process_audio } from "../shared/utils";
|
| 7 |
+
import WSRecord from "wavesurfer.js/dist/plugins/record.js";
|
| 8 |
+
import WaveformControls from "../shared/WaveformControls.svelte";
|
| 9 |
+
import WaveformRecordControls from "../shared/WaveformRecordControls.svelte";
|
| 10 |
+
import RecordPlugin from "wavesurfer.js/dist/plugins/record.js";
|
| 11 |
+
import type { WaveformOptions } from "../shared/types";
|
| 12 |
+
import { format_time } from "@gradio/utils";
|
| 13 |
+
|
| 14 |
+
export let mode: string;
|
| 15 |
+
export let i18n: I18nFormatter;
|
| 16 |
+
export let dispatch_blob: (
|
| 17 |
+
blobs: Uint8Array[] | Blob[],
|
| 18 |
+
event: "stream" | "change" | "stop_recording"
|
| 19 |
+
) => Promise<void> | undefined;
|
| 20 |
+
export let waveform_settings: Record<string, any>;
|
| 21 |
+
export let waveform_options: WaveformOptions = {
|
| 22 |
+
show_recording_waveform: true
|
| 23 |
+
};
|
| 24 |
+
export let handle_reset_value: () => void;
|
| 25 |
+
export let editable = true;
|
| 26 |
+
export let recording = false;
|
| 27 |
+
|
| 28 |
+
let micWaveform: WaveSurfer;
|
| 29 |
+
let recordingWaveform: WaveSurfer;
|
| 30 |
+
let playing = false;
|
| 31 |
+
|
| 32 |
+
let recordingContainer: HTMLDivElement;
|
| 33 |
+
let microphoneContainer: HTMLDivElement;
|
| 34 |
+
|
| 35 |
+
let record: WSRecord;
|
| 36 |
+
let recordedAudio: string | null = null;
|
| 37 |
+
|
| 38 |
+
// timestamps
|
| 39 |
+
let timeRef: HTMLTimeElement;
|
| 40 |
+
let durationRef: HTMLTimeElement;
|
| 41 |
+
let audio_duration: number;
|
| 42 |
+
let seconds = 0;
|
| 43 |
+
let interval: NodeJS.Timeout;
|
| 44 |
+
let timing = false;
|
| 45 |
+
// trimming
|
| 46 |
+
let trimDuration = 0;
|
| 47 |
+
|
| 48 |
+
const start_interval = (): void => {
|
| 49 |
+
clearInterval(interval);
|
| 50 |
+
interval = setInterval(() => {
|
| 51 |
+
seconds++;
|
| 52 |
+
}, 1000);
|
| 53 |
+
};
|
| 54 |
+
|
| 55 |
+
const dispatch = createEventDispatcher<{
|
| 56 |
+
start_recording: undefined;
|
| 57 |
+
pause_recording: undefined;
|
| 58 |
+
stop_recording: undefined;
|
| 59 |
+
stop: undefined;
|
| 60 |
+
play: undefined;
|
| 61 |
+
pause: undefined;
|
| 62 |
+
end: undefined;
|
| 63 |
+
edit: undefined;
|
| 64 |
+
}>();
|
| 65 |
+
|
| 66 |
+
function record_start_callback(): void {
|
| 67 |
+
start_interval();
|
| 68 |
+
timing = true;
|
| 69 |
+
dispatch("start_recording");
|
| 70 |
+
if (waveform_options.show_recording_waveform) {
|
| 71 |
+
let waveformCanvas = microphoneContainer;
|
| 72 |
+
if (waveformCanvas) waveformCanvas.style.display = "block";
|
| 73 |
+
}
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
async function record_end_callback(blob: Blob): Promise<void> {
|
| 77 |
+
seconds = 0;
|
| 78 |
+
timing = false;
|
| 79 |
+
clearInterval(interval);
|
| 80 |
+
try {
|
| 81 |
+
const array_buffer = await blob.arrayBuffer();
|
| 82 |
+
const context = new AudioContext({
|
| 83 |
+
sampleRate: waveform_settings.sampleRate
|
| 84 |
+
});
|
| 85 |
+
const audio_buffer = await context.decodeAudioData(array_buffer);
|
| 86 |
+
|
| 87 |
+
if (audio_buffer)
|
| 88 |
+
await process_audio(audio_buffer).then(async (audio: Uint8Array) => {
|
| 89 |
+
await dispatch_blob([audio], "change");
|
| 90 |
+
await dispatch_blob([audio], "stop_recording");
|
| 91 |
+
});
|
| 92 |
+
} catch (e) {
|
| 93 |
+
console.error(e);
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
$: record?.on("record-resume", () => {
|
| 98 |
+
start_interval();
|
| 99 |
+
});
|
| 100 |
+
|
| 101 |
+
$: recordingWaveform?.on("decode", (duration: any) => {
|
| 102 |
+
audio_duration = duration;
|
| 103 |
+
durationRef && (durationRef.textContent = format_time(duration));
|
| 104 |
+
});
|
| 105 |
+
|
| 106 |
+
$: recordingWaveform?.on(
|
| 107 |
+
"timeupdate",
|
| 108 |
+
(currentTime: any) =>
|
| 109 |
+
timeRef && (timeRef.textContent = format_time(currentTime))
|
| 110 |
+
);
|
| 111 |
+
|
| 112 |
+
$: recordingWaveform?.on("pause", () => {
|
| 113 |
+
dispatch("pause");
|
| 114 |
+
playing = false;
|
| 115 |
+
});
|
| 116 |
+
|
| 117 |
+
$: recordingWaveform?.on("play", () => {
|
| 118 |
+
dispatch("play");
|
| 119 |
+
playing = true;
|
| 120 |
+
});
|
| 121 |
+
|
| 122 |
+
$: recordingWaveform?.on("finish", () => {
|
| 123 |
+
dispatch("stop");
|
| 124 |
+
playing = false;
|
| 125 |
+
});
|
| 126 |
+
|
| 127 |
+
const create_mic_waveform = (): void => {
|
| 128 |
+
if (microphoneContainer) microphoneContainer.innerHTML = "";
|
| 129 |
+
if (micWaveform !== undefined) micWaveform.destroy();
|
| 130 |
+
if (!microphoneContainer) return;
|
| 131 |
+
micWaveform = WaveSurfer.create({
|
| 132 |
+
...waveform_settings,
|
| 133 |
+
normalize: false,
|
| 134 |
+
container: microphoneContainer
|
| 135 |
+
});
|
| 136 |
+
|
| 137 |
+
record = micWaveform.registerPlugin(RecordPlugin.create());
|
| 138 |
+
record.startMic();
|
| 139 |
+
record?.on("record-end", record_end_callback);
|
| 140 |
+
record?.on("record-start", record_start_callback);
|
| 141 |
+
record?.on("record-pause", () => {
|
| 142 |
+
dispatch("pause_recording");
|
| 143 |
+
clearInterval(interval);
|
| 144 |
+
});
|
| 145 |
+
|
| 146 |
+
record?.on("record-end", (blob) => {
|
| 147 |
+
recordedAudio = URL.createObjectURL(blob);
|
| 148 |
+
|
| 149 |
+
const microphone = microphoneContainer;
|
| 150 |
+
const recording = recordingContainer;
|
| 151 |
+
|
| 152 |
+
if (microphone) microphone.style.display = "none";
|
| 153 |
+
if (recording && recordedAudio) {
|
| 154 |
+
recording.innerHTML = "";
|
| 155 |
+
create_recording_waveform();
|
| 156 |
+
}
|
| 157 |
+
});
|
| 158 |
+
};
|
| 159 |
+
|
| 160 |
+
const create_recording_waveform = (): void => {
|
| 161 |
+
let recording = recordingContainer;
|
| 162 |
+
if (!recordedAudio || !recording) return;
|
| 163 |
+
recordingWaveform = WaveSurfer.create({
|
| 164 |
+
container: recording,
|
| 165 |
+
url: recordedAudio,
|
| 166 |
+
...waveform_settings
|
| 167 |
+
});
|
| 168 |
+
};
|
| 169 |
+
|
| 170 |
+
const handle_trim_audio = async (
|
| 171 |
+
start: number,
|
| 172 |
+
end: number
|
| 173 |
+
): Promise<void> => {
|
| 174 |
+
mode = "edit";
|
| 175 |
+
const decodedData = recordingWaveform.getDecodedData();
|
| 176 |
+
if (decodedData)
|
| 177 |
+
await process_audio(decodedData, start, end).then(
|
| 178 |
+
async (trimmedAudio: Uint8Array) => {
|
| 179 |
+
await dispatch_blob([trimmedAudio], "change");
|
| 180 |
+
await dispatch_blob([trimmedAudio], "stop_recording");
|
| 181 |
+
recordingWaveform.destroy();
|
| 182 |
+
create_recording_waveform();
|
| 183 |
+
}
|
| 184 |
+
);
|
| 185 |
+
dispatch("edit");
|
| 186 |
+
};
|
| 187 |
+
|
| 188 |
+
onMount(() => {
|
| 189 |
+
create_mic_waveform();
|
| 190 |
+
|
| 191 |
+
window.addEventListener("keydown", (e) => {
|
| 192 |
+
if (e.key === "ArrowRight") {
|
| 193 |
+
skip_audio(recordingWaveform, 0.1);
|
| 194 |
+
} else if (e.key === "ArrowLeft") {
|
| 195 |
+
skip_audio(recordingWaveform, -0.1);
|
| 196 |
+
}
|
| 197 |
+
});
|
| 198 |
+
});
|
| 199 |
+
</script>
|
| 200 |
+
|
| 201 |
+
<div class="component-wrapper">
|
| 202 |
+
<div
|
| 203 |
+
class="microphone"
|
| 204 |
+
bind:this={microphoneContainer}
|
| 205 |
+
data-testid="microphone-waveform"
|
| 206 |
+
/>
|
| 207 |
+
<div bind:this={recordingContainer} data-testid="recording-waveform" />
|
| 208 |
+
|
| 209 |
+
{#if (timing || recordedAudio) && waveform_options.show_recording_waveform}
|
| 210 |
+
<div class="timestamps">
|
| 211 |
+
<time bind:this={timeRef} class="time">0:00</time>
|
| 212 |
+
<div>
|
| 213 |
+
{#if mode === "edit" && trimDuration > 0}
|
| 214 |
+
<time class="trim-duration">{format_time(trimDuration)}</time>
|
| 215 |
+
{/if}
|
| 216 |
+
{#if timing}
|
| 217 |
+
<time class="duration">{format_time(seconds)}</time>
|
| 218 |
+
{:else}
|
| 219 |
+
<time bind:this={durationRef} class="duration">0:00</time>
|
| 220 |
+
{/if}
|
| 221 |
+
</div>
|
| 222 |
+
</div>
|
| 223 |
+
{/if}
|
| 224 |
+
|
| 225 |
+
{#if microphoneContainer && !recordedAudio}
|
| 226 |
+
<WaveformRecordControls
|
| 227 |
+
bind:record
|
| 228 |
+
{i18n}
|
| 229 |
+
{timing}
|
| 230 |
+
{recording}
|
| 231 |
+
show_recording_waveform={waveform_options.show_recording_waveform}
|
| 232 |
+
record_time={format_time(seconds)}
|
| 233 |
+
/>
|
| 234 |
+
{/if}
|
| 235 |
+
|
| 236 |
+
{#if recordingWaveform && recordedAudio}
|
| 237 |
+
<WaveformControls
|
| 238 |
+
bind:waveform={recordingWaveform}
|
| 239 |
+
container={recordingContainer}
|
| 240 |
+
{playing}
|
| 241 |
+
{audio_duration}
|
| 242 |
+
{i18n}
|
| 243 |
+
{editable}
|
| 244 |
+
interactive={true}
|
| 245 |
+
{handle_trim_audio}
|
| 246 |
+
bind:trimDuration
|
| 247 |
+
bind:mode
|
| 248 |
+
show_redo
|
| 249 |
+
{handle_reset_value}
|
| 250 |
+
{waveform_options}
|
| 251 |
+
/>
|
| 252 |
+
{/if}
|
| 253 |
+
</div>
|
| 254 |
+
|
| 255 |
+
<style>
|
| 256 |
+
.microphone {
|
| 257 |
+
width: 100%;
|
| 258 |
+
display: none;
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
.component-wrapper {
|
| 262 |
+
padding: var(--size-3);
|
| 263 |
+
width: 100%;
|
| 264 |
+
}
|
| 265 |
+
|
| 266 |
+
.timestamps {
|
| 267 |
+
display: flex;
|
| 268 |
+
justify-content: space-between;
|
| 269 |
+
align-items: center;
|
| 270 |
+
width: 100%;
|
| 271 |
+
padding: var(--size-1) 0;
|
| 272 |
+
margin: var(--spacing-md) 0;
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
.time {
|
| 276 |
+
color: var(--neutral-400);
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
.duration {
|
| 280 |
+
color: var(--neutral-400);
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
.trim-duration {
|
| 284 |
+
color: var(--color-accent);
|
| 285 |
+
margin-right: var(--spacing-sm);
|
| 286 |
+
}
|
| 287 |
+
</style>
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/audio/shared/VolumeLevels.svelte
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import { VolumeMuted, VolumeHigh, VolumeLow } from "@gradio/icons";
|
| 3 |
+
export let currentVolume: number;
|
| 4 |
+
</script>
|
| 5 |
+
|
| 6 |
+
{#if currentVolume == 0}
|
| 7 |
+
<VolumeMuted />
|
| 8 |
+
{:else if currentVolume < 0.5}
|
| 9 |
+
<VolumeLow />
|
| 10 |
+
{:else if currentVolume >= 0.5}
|
| 11 |
+
<VolumeHigh />
|
| 12 |
+
{/if}
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/audio/shared/WaveformRecordControls.svelte
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import { Pause } from "@gradio/icons";
|
| 3 |
+
import type { I18nFormatter } from "@gradio/utils";
|
| 4 |
+
import RecordPlugin from "wavesurfer.js/dist/plugins/record.js";
|
| 5 |
+
import DeviceSelect from "./DeviceSelect.svelte";
|
| 6 |
+
|
| 7 |
+
export let record: RecordPlugin;
|
| 8 |
+
export let i18n: I18nFormatter;
|
| 9 |
+
export let recording = false;
|
| 10 |
+
|
| 11 |
+
let micDevices: MediaDeviceInfo[] = [];
|
| 12 |
+
let recordButton: HTMLButtonElement;
|
| 13 |
+
let pauseButton: HTMLButtonElement;
|
| 14 |
+
let resumeButton: HTMLButtonElement;
|
| 15 |
+
let stopButton: HTMLButtonElement;
|
| 16 |
+
let stopButtonPaused: HTMLButtonElement;
|
| 17 |
+
let recording_ongoing = false;
|
| 18 |
+
|
| 19 |
+
export let record_time: string;
|
| 20 |
+
export let show_recording_waveform: boolean | undefined;
|
| 21 |
+
export let timing = false;
|
| 22 |
+
|
| 23 |
+
$: record.on("record-start", () => {
|
| 24 |
+
record.startMic();
|
| 25 |
+
|
| 26 |
+
recordButton.style.display = "none";
|
| 27 |
+
stopButton.style.display = "flex";
|
| 28 |
+
pauseButton.style.display = "block";
|
| 29 |
+
});
|
| 30 |
+
|
| 31 |
+
$: record.on("record-end", () => {
|
| 32 |
+
if (record.isPaused()) {
|
| 33 |
+
record.resumeRecording();
|
| 34 |
+
record.stopRecording();
|
| 35 |
+
}
|
| 36 |
+
record.stopMic();
|
| 37 |
+
|
| 38 |
+
recordButton.style.display = "flex";
|
| 39 |
+
stopButton.style.display = "none";
|
| 40 |
+
pauseButton.style.display = "none";
|
| 41 |
+
recordButton.disabled = false;
|
| 42 |
+
});
|
| 43 |
+
|
| 44 |
+
$: record.on("record-pause", () => {
|
| 45 |
+
pauseButton.style.display = "none";
|
| 46 |
+
resumeButton.style.display = "block";
|
| 47 |
+
stopButton.style.display = "none";
|
| 48 |
+
stopButtonPaused.style.display = "flex";
|
| 49 |
+
});
|
| 50 |
+
|
| 51 |
+
$: record.on("record-resume", () => {
|
| 52 |
+
pauseButton.style.display = "block";
|
| 53 |
+
resumeButton.style.display = "none";
|
| 54 |
+
recordButton.style.display = "none";
|
| 55 |
+
stopButton.style.display = "flex";
|
| 56 |
+
stopButtonPaused.style.display = "none";
|
| 57 |
+
});
|
| 58 |
+
|
| 59 |
+
$: if (recording && !recording_ongoing) {
|
| 60 |
+
record.startRecording();
|
| 61 |
+
recording_ongoing = true;
|
| 62 |
+
} else {
|
| 63 |
+
record.stopRecording();
|
| 64 |
+
recording_ongoing = false;
|
| 65 |
+
}
|
| 66 |
+
</script>
|
| 67 |
+
|
| 68 |
+
<div class="controls">
|
| 69 |
+
<div class="wrapper">
|
| 70 |
+
<button
|
| 71 |
+
bind:this={recordButton}
|
| 72 |
+
class="record record-button"
|
| 73 |
+
on:click={() => record.startRecording()}>{i18n("audio.record")}</button
|
| 74 |
+
>
|
| 75 |
+
|
| 76 |
+
<button
|
| 77 |
+
bind:this={stopButton}
|
| 78 |
+
class="stop-button {record.isPaused() ? 'stop-button-paused' : ''}"
|
| 79 |
+
on:click={() => {
|
| 80 |
+
if (record.isPaused()) {
|
| 81 |
+
record.resumeRecording();
|
| 82 |
+
record.stopRecording();
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
record.stopRecording();
|
| 86 |
+
}}>{i18n("audio.stop")}</button
|
| 87 |
+
>
|
| 88 |
+
|
| 89 |
+
<button
|
| 90 |
+
bind:this={stopButtonPaused}
|
| 91 |
+
id="stop-paused"
|
| 92 |
+
class="stop-button-paused"
|
| 93 |
+
on:click={() => {
|
| 94 |
+
if (record.isPaused()) {
|
| 95 |
+
record.resumeRecording();
|
| 96 |
+
record.stopRecording();
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
record.stopRecording();
|
| 100 |
+
}}>{i18n("audio.stop")}</button
|
| 101 |
+
>
|
| 102 |
+
|
| 103 |
+
<button
|
| 104 |
+
aria-label="pause"
|
| 105 |
+
bind:this={pauseButton}
|
| 106 |
+
class="pause-button"
|
| 107 |
+
on:click={() => record.pauseRecording()}><Pause /></button
|
| 108 |
+
>
|
| 109 |
+
<button
|
| 110 |
+
bind:this={resumeButton}
|
| 111 |
+
class="resume-button"
|
| 112 |
+
on:click={() => record.resumeRecording()}>{i18n("audio.resume")}</button
|
| 113 |
+
>
|
| 114 |
+
{#if timing && !show_recording_waveform}
|
| 115 |
+
<time class="duration-button duration">{record_time}</time>
|
| 116 |
+
{/if}
|
| 117 |
+
</div>
|
| 118 |
+
<DeviceSelect bind:micDevices {i18n} />
|
| 119 |
+
</div>
|
| 120 |
+
|
| 121 |
+
<style>
|
| 122 |
+
.controls {
|
| 123 |
+
display: flex;
|
| 124 |
+
align-items: center;
|
| 125 |
+
justify-content: space-between;
|
| 126 |
+
flex-wrap: wrap;
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
.wrapper {
|
| 130 |
+
display: flex;
|
| 131 |
+
align-items: center;
|
| 132 |
+
flex-wrap: wrap;
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
.record {
|
| 136 |
+
margin-right: var(--spacing-md);
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
.stop-button-paused {
|
| 140 |
+
display: none;
|
| 141 |
+
height: var(--size-8);
|
| 142 |
+
width: var(--size-20);
|
| 143 |
+
background-color: var(--block-background-fill);
|
| 144 |
+
border-radius: var(--button-large-radius);
|
| 145 |
+
align-items: center;
|
| 146 |
+
border: 1px solid var(--block-border-color);
|
| 147 |
+
margin: var(--size-1) var(--size-1) 0 0;
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
.stop-button-paused::before {
|
| 151 |
+
content: "";
|
| 152 |
+
height: var(--size-4);
|
| 153 |
+
width: var(--size-4);
|
| 154 |
+
border-radius: var(--radius-full);
|
| 155 |
+
background: var(--primary-600);
|
| 156 |
+
margin: 0 var(--spacing-xl);
|
| 157 |
+
}
|
| 158 |
+
.stop-button::before {
|
| 159 |
+
content: "";
|
| 160 |
+
height: var(--size-4);
|
| 161 |
+
width: var(--size-4);
|
| 162 |
+
border-radius: var(--radius-full);
|
| 163 |
+
background: var(--primary-600);
|
| 164 |
+
margin: 0 var(--spacing-xl);
|
| 165 |
+
animation: scaling 1800ms infinite;
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
.stop-button {
|
| 169 |
+
display: none;
|
| 170 |
+
height: var(--size-8);
|
| 171 |
+
width: var(--size-20);
|
| 172 |
+
background-color: var(--block-background-fill);
|
| 173 |
+
border-radius: var(--button-large-radius);
|
| 174 |
+
align-items: center;
|
| 175 |
+
border: 1px solid var(--primary-600);
|
| 176 |
+
margin: var(--size-1) var(--size-1) 0 0;
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
.record-button::before {
|
| 180 |
+
content: "";
|
| 181 |
+
height: var(--size-4);
|
| 182 |
+
width: var(--size-4);
|
| 183 |
+
border-radius: var(--radius-full);
|
| 184 |
+
background: var(--primary-600);
|
| 185 |
+
margin: 0 var(--spacing-xl);
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
.record-button {
|
| 189 |
+
height: var(--size-8);
|
| 190 |
+
width: var(--size-24);
|
| 191 |
+
background-color: var(--block-background-fill);
|
| 192 |
+
border-radius: var(--button-large-radius);
|
| 193 |
+
display: flex;
|
| 194 |
+
align-items: center;
|
| 195 |
+
border: 1px solid var(--block-border-color);
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
.stop-button:disabled {
|
| 199 |
+
cursor: not-allowed;
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
.record-button:disabled {
|
| 203 |
+
cursor: not-allowed;
|
| 204 |
+
opacity: 0.5;
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
@keyframes scaling {
|
| 208 |
+
0% {
|
| 209 |
+
background-color: var(--primary-600);
|
| 210 |
+
scale: 1;
|
| 211 |
+
}
|
| 212 |
+
50% {
|
| 213 |
+
background-color: var(--primary-600);
|
| 214 |
+
scale: 1.2;
|
| 215 |
+
}
|
| 216 |
+
100% {
|
| 217 |
+
background-color: var(--primary-600);
|
| 218 |
+
scale: 1;
|
| 219 |
+
}
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
.pause-button {
|
| 223 |
+
display: none;
|
| 224 |
+
height: var(--size-8);
|
| 225 |
+
width: var(--size-20);
|
| 226 |
+
border: 1px solid var(--block-border-color);
|
| 227 |
+
border-radius: var(--button-large-radius);
|
| 228 |
+
padding: var(--spacing-md);
|
| 229 |
+
margin: var(--size-1) var(--size-1) 0 0;
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
.resume-button {
|
| 233 |
+
display: none;
|
| 234 |
+
height: var(--size-8);
|
| 235 |
+
width: var(--size-20);
|
| 236 |
+
border: 1px solid var(--block-border-color);
|
| 237 |
+
border-radius: var(--button-large-radius);
|
| 238 |
+
padding: var(--spacing-xl);
|
| 239 |
+
line-height: 1px;
|
| 240 |
+
font-size: var(--text-md);
|
| 241 |
+
margin: var(--size-1) var(--size-1) 0 0;
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
.duration {
|
| 245 |
+
display: flex;
|
| 246 |
+
height: var(--size-8);
|
| 247 |
+
width: var(--size-20);
|
| 248 |
+
border: 1px solid var(--block-border-color);
|
| 249 |
+
padding: var(--spacing-md);
|
| 250 |
+
align-items: center;
|
| 251 |
+
justify-content: center;
|
| 252 |
+
margin: var(--size-1) var(--size-1) 0 0;
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
:global(::part(region)) {
|
| 256 |
+
border-radius: var(--radius-md);
|
| 257 |
+
height: 98% !important;
|
| 258 |
+
border: 1px solid var(--trim-region-color);
|
| 259 |
+
background-color: unset;
|
| 260 |
+
border-width: 1px 3px;
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
:global(::part(region))::after {
|
| 264 |
+
content: "";
|
| 265 |
+
position: absolute;
|
| 266 |
+
top: 0;
|
| 267 |
+
left: 0;
|
| 268 |
+
width: 100%;
|
| 269 |
+
height: 100%;
|
| 270 |
+
background: var(--trim-region-color);
|
| 271 |
+
opacity: 0.2;
|
| 272 |
+
border-radius: var(--radius-md);
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
:global(::part(region-handle)) {
|
| 276 |
+
width: 5px !important;
|
| 277 |
+
border: none;
|
| 278 |
+
}
|
| 279 |
+
</style>
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/audio/streaming/StreamAudio.svelte
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import { onMount } from "svelte";
|
| 3 |
+
import type { I18nFormatter } from "@gradio/utils";
|
| 4 |
+
import { Spinner } from "@gradio/icons";
|
| 5 |
+
import WaveSurfer from "wavesurfer.js";
|
| 6 |
+
import RecordPlugin from "wavesurfer.js/dist/plugins/record.js";
|
| 7 |
+
import type { WaveformOptions } from "../shared/types";
|
| 8 |
+
import DeviceSelect from "../shared/DeviceSelect.svelte";
|
| 9 |
+
|
| 10 |
+
export let recording = false;
|
| 11 |
+
export let paused_recording = false;
|
| 12 |
+
export let stop: () => void;
|
| 13 |
+
export let record: () => void;
|
| 14 |
+
export let i18n: I18nFormatter;
|
| 15 |
+
export let waveform_settings: Record<string, any>;
|
| 16 |
+
export let waveform_options: WaveformOptions = {
|
| 17 |
+
show_recording_waveform: true
|
| 18 |
+
};
|
| 19 |
+
export let waiting = false;
|
| 20 |
+
|
| 21 |
+
let micWaveform: WaveSurfer;
|
| 22 |
+
let waveformRecord: RecordPlugin;
|
| 23 |
+
|
| 24 |
+
let microphoneContainer: HTMLDivElement;
|
| 25 |
+
|
| 26 |
+
let micDevices: MediaDeviceInfo[] = [];
|
| 27 |
+
|
| 28 |
+
onMount(() => {
|
| 29 |
+
create_mic_waveform();
|
| 30 |
+
});
|
| 31 |
+
|
| 32 |
+
const create_mic_waveform = (): void => {
|
| 33 |
+
if (micWaveform !== undefined) micWaveform.destroy();
|
| 34 |
+
if (!microphoneContainer) return;
|
| 35 |
+
micWaveform = WaveSurfer.create({
|
| 36 |
+
...waveform_settings,
|
| 37 |
+
height: 100,
|
| 38 |
+
container: microphoneContainer
|
| 39 |
+
});
|
| 40 |
+
|
| 41 |
+
waveformRecord = micWaveform.registerPlugin(RecordPlugin.create());
|
| 42 |
+
};
|
| 43 |
+
</script>
|
| 44 |
+
|
| 45 |
+
<div class="mic-wrap">
|
| 46 |
+
{#if waveform_options.show_recording_waveform}
|
| 47 |
+
<div
|
| 48 |
+
bind:this={microphoneContainer}
|
| 49 |
+
style:display={recording ? "block" : "none"}
|
| 50 |
+
/>
|
| 51 |
+
{/if}
|
| 52 |
+
<div class="controls">
|
| 53 |
+
{#if recording && !waiting}
|
| 54 |
+
<button
|
| 55 |
+
class={paused_recording ? "stop-button-paused" : "stop-button"}
|
| 56 |
+
on:click={() => {
|
| 57 |
+
waveformRecord?.stopMic();
|
| 58 |
+
stop();
|
| 59 |
+
}}
|
| 60 |
+
>
|
| 61 |
+
<span class="record-icon">
|
| 62 |
+
<span class="pinger" />
|
| 63 |
+
<span class="dot" />
|
| 64 |
+
</span>
|
| 65 |
+
{paused_recording ? i18n("audio.pause") : i18n("audio.stop")}
|
| 66 |
+
</button>
|
| 67 |
+
{:else if recording && waiting}
|
| 68 |
+
<button
|
| 69 |
+
class="spinner-button"
|
| 70 |
+
on:click={() => {
|
| 71 |
+
stop();
|
| 72 |
+
}}
|
| 73 |
+
>
|
| 74 |
+
<div class="icon">
|
| 75 |
+
<Spinner />
|
| 76 |
+
</div>
|
| 77 |
+
{i18n("audio.waiting")}
|
| 78 |
+
</button>
|
| 79 |
+
{:else}
|
| 80 |
+
<button
|
| 81 |
+
class="record-button"
|
| 82 |
+
on:click={() => {
|
| 83 |
+
waveformRecord?.startMic();
|
| 84 |
+
record();
|
| 85 |
+
}}
|
| 86 |
+
>
|
| 87 |
+
<span class="record-icon">
|
| 88 |
+
<span class="dot" />
|
| 89 |
+
</span>
|
| 90 |
+
{i18n("audio.record")}
|
| 91 |
+
</button>
|
| 92 |
+
{/if}
|
| 93 |
+
|
| 94 |
+
<DeviceSelect bind:micDevices {i18n} />
|
| 95 |
+
</div>
|
| 96 |
+
</div>
|
| 97 |
+
|
| 98 |
+
<style>
|
| 99 |
+
.controls {
|
| 100 |
+
display: flex;
|
| 101 |
+
align-items: center;
|
| 102 |
+
justify-content: space-between;
|
| 103 |
+
flex-wrap: wrap;
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
.mic-wrap {
|
| 107 |
+
display: block;
|
| 108 |
+
align-items: center;
|
| 109 |
+
margin: var(--spacing-xl);
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
.icon {
|
| 113 |
+
width: var(--size-4);
|
| 114 |
+
height: var(--size-4);
|
| 115 |
+
fill: var(--primary-600);
|
| 116 |
+
stroke: var(--primary-600);
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
.stop-button-paused {
|
| 120 |
+
display: none;
|
| 121 |
+
height: var(--size-8);
|
| 122 |
+
width: var(--size-20);
|
| 123 |
+
background-color: var(--block-background-fill);
|
| 124 |
+
border-radius: var(--button-large-radius);
|
| 125 |
+
align-items: center;
|
| 126 |
+
border: 1px solid var(--block-border-color);
|
| 127 |
+
margin-right: 5px;
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
.stop-button-paused::before {
|
| 131 |
+
content: "";
|
| 132 |
+
height: var(--size-4);
|
| 133 |
+
width: var(--size-4);
|
| 134 |
+
border-radius: var(--radius-full);
|
| 135 |
+
background: var(--primary-600);
|
| 136 |
+
margin: 0 var(--spacing-xl);
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
.stop-button::before {
|
| 140 |
+
content: "";
|
| 141 |
+
height: var(--size-4);
|
| 142 |
+
width: var(--size-4);
|
| 143 |
+
border-radius: var(--radius-full);
|
| 144 |
+
background: var(--primary-600);
|
| 145 |
+
margin: 0 var(--spacing-xl);
|
| 146 |
+
animation: scaling 1800ms infinite;
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
.stop-button {
|
| 150 |
+
height: var(--size-8);
|
| 151 |
+
width: var(--size-20);
|
| 152 |
+
background-color: var(--block-background-fill);
|
| 153 |
+
border-radius: var(--button-large-radius);
|
| 154 |
+
align-items: center;
|
| 155 |
+
border: 1px solid var(--primary-600);
|
| 156 |
+
margin-right: 5px;
|
| 157 |
+
display: flex;
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
.spinner-button {
|
| 161 |
+
height: var(--size-8);
|
| 162 |
+
width: var(--size-24);
|
| 163 |
+
background-color: var(--block-background-fill);
|
| 164 |
+
border-radius: var(--radius-3xl);
|
| 165 |
+
align-items: center;
|
| 166 |
+
border: 1px solid var(--primary-600);
|
| 167 |
+
margin: 0 var(--spacing-xl);
|
| 168 |
+
display: flex;
|
| 169 |
+
justify-content: space-evenly;
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
.record-button::before {
|
| 173 |
+
content: "";
|
| 174 |
+
height: var(--size-4);
|
| 175 |
+
width: var(--size-4);
|
| 176 |
+
border-radius: var(--radius-full);
|
| 177 |
+
background: var(--primary-600);
|
| 178 |
+
margin: 0 var(--spacing-xl);
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
.record-button {
|
| 182 |
+
height: var(--size-8);
|
| 183 |
+
width: var(--size-24);
|
| 184 |
+
background-color: var(--block-background-fill);
|
| 185 |
+
border-radius: var(--button-large-radius);
|
| 186 |
+
display: flex;
|
| 187 |
+
align-items: center;
|
| 188 |
+
border: 1px solid var(--block-border-color);
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
@keyframes scaling {
|
| 192 |
+
0% {
|
| 193 |
+
background-color: var(--primary-600);
|
| 194 |
+
scale: 1;
|
| 195 |
+
}
|
| 196 |
+
50% {
|
| 197 |
+
background-color: var(--primary-600);
|
| 198 |
+
scale: 1.2;
|
| 199 |
+
}
|
| 200 |
+
100% {
|
| 201 |
+
background-color: var(--primary-600);
|
| 202 |
+
scale: 1;
|
| 203 |
+
}
|
| 204 |
+
}
|
| 205 |
+
</style>
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/button/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@gradio/button",
|
| 3 |
+
"version": "0.3.1",
|
| 4 |
+
"description": "Gradio UI packages",
|
| 5 |
+
"type": "module",
|
| 6 |
+
"author": "",
|
| 7 |
+
"license": "ISC",
|
| 8 |
+
"private": false,
|
| 9 |
+
"dependencies": {
|
| 10 |
+
"@gradio/client": "workspace:^",
|
| 11 |
+
"@gradio/upload": "workspace:^",
|
| 12 |
+
"@gradio/utils": "workspace:^"
|
| 13 |
+
},
|
| 14 |
+
"devDependencies": {
|
| 15 |
+
"@gradio/preview": "workspace:^"
|
| 16 |
+
},
|
| 17 |
+
"main": "./Index.svelte",
|
| 18 |
+
"main_changeset": true,
|
| 19 |
+
"exports": {
|
| 20 |
+
"./package.json": "./package.json",
|
| 21 |
+
".": {
|
| 22 |
+
"gradio": "./Index.svelte",
|
| 23 |
+
"svelte": "./dist/Index.svelte",
|
| 24 |
+
"types": "./dist/Index.svelte.d.ts"
|
| 25 |
+
}
|
| 26 |
+
},
|
| 27 |
+
"peerDependencies": {
|
| 28 |
+
"svelte": "^4.0.0"
|
| 29 |
+
},
|
| 30 |
+
"repository": {
|
| 31 |
+
"type": "git",
|
| 32 |
+
"url": "git+https://github.com/gradio-app/gradio.git",
|
| 33 |
+
"directory": "js/button"
|
| 34 |
+
}
|
| 35 |
+
}
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/chatbot/Index.svelte
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script context="module" lang="ts">
|
| 2 |
+
export { default as BaseChatBot } from "./shared/ChatBot.svelte";
|
| 3 |
+
</script>
|
| 4 |
+
|
| 5 |
+
<script lang="ts">
|
| 6 |
+
import type { Gradio, SelectData, LikeData } from "@gradio/utils";
|
| 7 |
+
|
| 8 |
+
import ChatBot from "./shared/ChatBot.svelte";
|
| 9 |
+
import type { UndoRetryData } from "./shared/utils";
|
| 10 |
+
import { Block, BlockLabel } from "@gradio/atoms";
|
| 11 |
+
import type { LoadingStatus } from "@gradio/statustracker";
|
| 12 |
+
import { Chat } from "@gradio/icons";
|
| 13 |
+
import type { FileData } from "@gradio/client";
|
| 14 |
+
import { StatusTracker } from "@gradio/statustracker";
|
| 15 |
+
import type {
|
| 16 |
+
Message,
|
| 17 |
+
ExampleMessage,
|
| 18 |
+
TupleFormat,
|
| 19 |
+
NormalisedMessage
|
| 20 |
+
} from "./types";
|
| 21 |
+
|
| 22 |
+
import { normalise_tuples, normalise_messages } from "./shared/utils";
|
| 23 |
+
|
| 24 |
+
export let elem_id = "";
|
| 25 |
+
export let elem_classes: string[] = [];
|
| 26 |
+
export let visible = true;
|
| 27 |
+
export let value: TupleFormat | Message[] = [];
|
| 28 |
+
export let scale: number | null = null;
|
| 29 |
+
export let min_width: number | undefined = undefined;
|
| 30 |
+
export let label: string;
|
| 31 |
+
export let show_label = true;
|
| 32 |
+
export let root: string;
|
| 33 |
+
export let _selectable = false;
|
| 34 |
+
export let likeable = false;
|
| 35 |
+
export let show_share_button = false;
|
| 36 |
+
export let rtl = false;
|
| 37 |
+
export let show_copy_button = true;
|
| 38 |
+
export let show_copy_all_button = false;
|
| 39 |
+
export let sanitize_html = true;
|
| 40 |
+
export let bubble_full_width = true;
|
| 41 |
+
export let layout: "bubble" | "panel" = "bubble";
|
| 42 |
+
export let type: "tuples" | "messages" = "tuples";
|
| 43 |
+
export let render_markdown = true;
|
| 44 |
+
export let line_breaks = true;
|
| 45 |
+
export let autoscroll = true;
|
| 46 |
+
export let _retryable = false;
|
| 47 |
+
export let _undoable = false;
|
| 48 |
+
export let latex_delimiters: {
|
| 49 |
+
left: string;
|
| 50 |
+
right: string;
|
| 51 |
+
display: boolean;
|
| 52 |
+
}[];
|
| 53 |
+
export let gradio: Gradio<{
|
| 54 |
+
change: typeof value;
|
| 55 |
+
select: SelectData;
|
| 56 |
+
share: ShareData;
|
| 57 |
+
error: string;
|
| 58 |
+
like: LikeData;
|
| 59 |
+
clear_status: LoadingStatus;
|
| 60 |
+
example_select: SelectData;
|
| 61 |
+
retry: UndoRetryData;
|
| 62 |
+
undo: UndoRetryData;
|
| 63 |
+
clear: null;
|
| 64 |
+
}>;
|
| 65 |
+
|
| 66 |
+
let _value: NormalisedMessage[] | null = [];
|
| 67 |
+
|
| 68 |
+
$: _value =
|
| 69 |
+
type === "tuples"
|
| 70 |
+
? normalise_tuples(value as TupleFormat, root)
|
| 71 |
+
: normalise_messages(value as Message[], root);
|
| 72 |
+
|
| 73 |
+
export let avatar_images: [FileData | null, FileData | null] = [null, null];
|
| 74 |
+
export let like_user_message = false;
|
| 75 |
+
export let loading_status: LoadingStatus | undefined = undefined;
|
| 76 |
+
export let height: number | string | undefined;
|
| 77 |
+
export let min_height: number | string | undefined;
|
| 78 |
+
export let max_height: number | string | undefined;
|
| 79 |
+
export let placeholder: string | null = null;
|
| 80 |
+
export let examples: ExampleMessage[] | null = null;
|
| 81 |
+
export let theme_mode: "system" | "light" | "dark";
|
| 82 |
+
</script>
|
| 83 |
+
|
| 84 |
+
<Block
|
| 85 |
+
{elem_id}
|
| 86 |
+
{elem_classes}
|
| 87 |
+
{visible}
|
| 88 |
+
padding={false}
|
| 89 |
+
{scale}
|
| 90 |
+
{min_width}
|
| 91 |
+
{height}
|
| 92 |
+
{min_height}
|
| 93 |
+
{max_height}
|
| 94 |
+
allow_overflow={true}
|
| 95 |
+
flex={true}
|
| 96 |
+
overflow_behavior="auto"
|
| 97 |
+
>
|
| 98 |
+
{#if loading_status}
|
| 99 |
+
<StatusTracker
|
| 100 |
+
autoscroll={gradio.autoscroll}
|
| 101 |
+
i18n={gradio.i18n}
|
| 102 |
+
{...loading_status}
|
| 103 |
+
show_progress={loading_status.show_progress === "hidden"
|
| 104 |
+
? "hidden"
|
| 105 |
+
: "minimal"}
|
| 106 |
+
on:clear_status={() => gradio.dispatch("clear_status", loading_status)}
|
| 107 |
+
/>
|
| 108 |
+
{/if}
|
| 109 |
+
<div class="wrapper">
|
| 110 |
+
{#if show_label}
|
| 111 |
+
<BlockLabel
|
| 112 |
+
{show_label}
|
| 113 |
+
Icon={Chat}
|
| 114 |
+
float={true}
|
| 115 |
+
label={label || "Chatbot"}
|
| 116 |
+
/>
|
| 117 |
+
{/if}
|
| 118 |
+
<ChatBot
|
| 119 |
+
i18n={gradio.i18n}
|
| 120 |
+
selectable={_selectable}
|
| 121 |
+
{likeable}
|
| 122 |
+
{show_share_button}
|
| 123 |
+
{show_copy_all_button}
|
| 124 |
+
value={_value}
|
| 125 |
+
{latex_delimiters}
|
| 126 |
+
{render_markdown}
|
| 127 |
+
{theme_mode}
|
| 128 |
+
pending_message={loading_status?.status === "pending"}
|
| 129 |
+
generating={loading_status?.status === "generating"}
|
| 130 |
+
{rtl}
|
| 131 |
+
{show_copy_button}
|
| 132 |
+
{like_user_message}
|
| 133 |
+
on:change={() => gradio.dispatch("change", value)}
|
| 134 |
+
on:select={(e) => gradio.dispatch("select", e.detail)}
|
| 135 |
+
on:like={(e) => gradio.dispatch("like", e.detail)}
|
| 136 |
+
on:share={(e) => gradio.dispatch("share", e.detail)}
|
| 137 |
+
on:error={(e) => gradio.dispatch("error", e.detail)}
|
| 138 |
+
on:example_select={(e) => gradio.dispatch("example_select", e.detail)}
|
| 139 |
+
on:retry={(e) => gradio.dispatch("retry", e.detail)}
|
| 140 |
+
on:undo={(e) => gradio.dispatch("undo", e.detail)}
|
| 141 |
+
on:clear={() => {
|
| 142 |
+
value = [];
|
| 143 |
+
gradio.dispatch("clear");
|
| 144 |
+
}}
|
| 145 |
+
{avatar_images}
|
| 146 |
+
{sanitize_html}
|
| 147 |
+
{bubble_full_width}
|
| 148 |
+
{line_breaks}
|
| 149 |
+
{autoscroll}
|
| 150 |
+
{layout}
|
| 151 |
+
{placeholder}
|
| 152 |
+
{examples}
|
| 153 |
+
{_retryable}
|
| 154 |
+
{_undoable}
|
| 155 |
+
upload={(...args) => gradio.client.upload(...args)}
|
| 156 |
+
_fetch={(...args) => gradio.client.fetch(...args)}
|
| 157 |
+
load_component={gradio.load_component}
|
| 158 |
+
msg_format={type}
|
| 159 |
+
root={gradio.root}
|
| 160 |
+
/>
|
| 161 |
+
</div>
|
| 162 |
+
</Block>
|
| 163 |
+
|
| 164 |
+
<style>
|
| 165 |
+
.wrapper {
|
| 166 |
+
display: flex;
|
| 167 |
+
position: relative;
|
| 168 |
+
flex-direction: column;
|
| 169 |
+
align-items: start;
|
| 170 |
+
width: 100%;
|
| 171 |
+
height: 100%;
|
| 172 |
+
flex-grow: 1;
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
:global(.progress-text) {
|
| 176 |
+
right: auto;
|
| 177 |
+
}
|
| 178 |
+
</style>
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/chatbot/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@gradio/chatbot",
|
| 3 |
+
"version": "0.15.0",
|
| 4 |
+
"description": "Gradio UI packages",
|
| 5 |
+
"type": "module",
|
| 6 |
+
"author": "",
|
| 7 |
+
"license": "ISC",
|
| 8 |
+
"private": false,
|
| 9 |
+
"dependencies": {
|
| 10 |
+
"@gradio/atoms": "workspace:^",
|
| 11 |
+
"@gradio/client": "workspace:^",
|
| 12 |
+
"@gradio/gallery": "workspace:^",
|
| 13 |
+
"@gradio/icons": "workspace:^",
|
| 14 |
+
"@gradio/markdown": "workspace:^",
|
| 15 |
+
"@gradio/plot": "workspace:^",
|
| 16 |
+
"@gradio/statustracker": "workspace:^",
|
| 17 |
+
"@gradio/theme": "workspace:^",
|
| 18 |
+
"@gradio/upload": "workspace:^",
|
| 19 |
+
"@gradio/utils": "workspace:^",
|
| 20 |
+
"@gradio/wasm": "workspace:^",
|
| 21 |
+
"@types/dompurify": "^3.0.2",
|
| 22 |
+
"@types/katex": "^0.16.0",
|
| 23 |
+
"@types/prismjs": "1.26.4",
|
| 24 |
+
"dequal": "^2.0.2"
|
| 25 |
+
},
|
| 26 |
+
"devDependencies": {
|
| 27 |
+
"@gradio/audio": "workspace:^",
|
| 28 |
+
"@gradio/image": "workspace:^",
|
| 29 |
+
"@gradio/preview": "workspace:^",
|
| 30 |
+
"@gradio/video": "workspace:^"
|
| 31 |
+
},
|
| 32 |
+
"main_changeset": true,
|
| 33 |
+
"main": "./Index.svelte",
|
| 34 |
+
"exports": {
|
| 35 |
+
"./package.json": "./package.json",
|
| 36 |
+
".": {
|
| 37 |
+
"gradio": "./Index.svelte",
|
| 38 |
+
"svelte": "./dist/Index.svelte",
|
| 39 |
+
"types": "./dist/Index.svelte.d.ts"
|
| 40 |
+
}
|
| 41 |
+
},
|
| 42 |
+
"peerDependencies": {
|
| 43 |
+
"svelte": "^4.0.0"
|
| 44 |
+
},
|
| 45 |
+
"repository": {
|
| 46 |
+
"type": "git",
|
| 47 |
+
"url": "git+https://github.com/gradio-app/gradio.git",
|
| 48 |
+
"directory": "js/chatbot"
|
| 49 |
+
}
|
| 50 |
+
}
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/chatbot/shared/ChatBot.svelte
ADDED
|
@@ -0,0 +1,598 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import {
|
| 3 |
+
format_chat_for_sharing,
|
| 4 |
+
type UndoRetryData,
|
| 5 |
+
is_last_bot_message,
|
| 6 |
+
group_messages,
|
| 7 |
+
load_components,
|
| 8 |
+
get_components_from_messages
|
| 9 |
+
} from "./utils";
|
| 10 |
+
import type { NormalisedMessage } from "../types";
|
| 11 |
+
import { copy } from "@gradio/utils";
|
| 12 |
+
import Message from "./Message.svelte";
|
| 13 |
+
|
| 14 |
+
import { dequal } from "dequal/lite";
|
| 15 |
+
import {
|
| 16 |
+
afterUpdate,
|
| 17 |
+
createEventDispatcher,
|
| 18 |
+
type SvelteComponent,
|
| 19 |
+
type ComponentType,
|
| 20 |
+
tick,
|
| 21 |
+
onMount
|
| 22 |
+
} from "svelte";
|
| 23 |
+
import { Image } from "@gradio/image/shared";
|
| 24 |
+
|
| 25 |
+
import { Clear, Trash, Community, ScrollDownArrow } from "@gradio/icons";
|
| 26 |
+
import { IconButtonWrapper, IconButton } from "@gradio/atoms";
|
| 27 |
+
import type { SelectData, LikeData } from "@gradio/utils";
|
| 28 |
+
import type { ExampleMessage } from "../types";
|
| 29 |
+
import { MarkdownCode as Markdown } from "@gradio/markdown";
|
| 30 |
+
import type { FileData, Client } from "@gradio/client";
|
| 31 |
+
import type { I18nFormatter } from "js/core/src/gradio_helper";
|
| 32 |
+
import Pending from "./Pending.svelte";
|
| 33 |
+
import { ShareError } from "@gradio/utils";
|
| 34 |
+
import { Gradio } from "@gradio/utils";
|
| 35 |
+
|
| 36 |
+
export let value: NormalisedMessage[] | null = [];
|
| 37 |
+
let old_value: NormalisedMessage[] | null = null;
|
| 38 |
+
|
| 39 |
+
import CopyAll from "./CopyAll.svelte";
|
| 40 |
+
|
| 41 |
+
export let _fetch: typeof fetch;
|
| 42 |
+
export let load_component: Gradio["load_component"];
|
| 43 |
+
|
| 44 |
+
let _components: Record<string, ComponentType<SvelteComponent>> = {};
|
| 45 |
+
|
| 46 |
+
async function update_components(): Promise<void> {
|
| 47 |
+
_components = await load_components(
|
| 48 |
+
get_components_from_messages(value),
|
| 49 |
+
_components,
|
| 50 |
+
load_component
|
| 51 |
+
);
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
$: value, update_components();
|
| 55 |
+
|
| 56 |
+
export let latex_delimiters: {
|
| 57 |
+
left: string;
|
| 58 |
+
right: string;
|
| 59 |
+
display: boolean;
|
| 60 |
+
}[];
|
| 61 |
+
export let pending_message = false;
|
| 62 |
+
export let generating = false;
|
| 63 |
+
export let selectable = false;
|
| 64 |
+
export let likeable = false;
|
| 65 |
+
export let show_share_button = false;
|
| 66 |
+
export let show_copy_all_button = false;
|
| 67 |
+
export let rtl = false;
|
| 68 |
+
export let show_copy_button = false;
|
| 69 |
+
export let avatar_images: [FileData | null, FileData | null] = [null, null];
|
| 70 |
+
export let sanitize_html = true;
|
| 71 |
+
export let bubble_full_width = true;
|
| 72 |
+
export let render_markdown = true;
|
| 73 |
+
export let line_breaks = true;
|
| 74 |
+
export let autoscroll = true;
|
| 75 |
+
export let theme_mode: "system" | "light" | "dark";
|
| 76 |
+
export let i18n: I18nFormatter;
|
| 77 |
+
export let layout: "bubble" | "panel" = "bubble";
|
| 78 |
+
export let placeholder: string | null = null;
|
| 79 |
+
export let upload: Client["upload"];
|
| 80 |
+
export let msg_format: "tuples" | "messages" = "tuples";
|
| 81 |
+
export let examples: ExampleMessage[] | null = null;
|
| 82 |
+
export let _retryable = false;
|
| 83 |
+
export let _undoable = false;
|
| 84 |
+
export let like_user_message = false;
|
| 85 |
+
export let root: string;
|
| 86 |
+
|
| 87 |
+
let target: HTMLElement | null = null;
|
| 88 |
+
|
| 89 |
+
onMount(() => {
|
| 90 |
+
target = document.querySelector("div.gradio-container");
|
| 91 |
+
});
|
| 92 |
+
|
| 93 |
+
let div: HTMLDivElement;
|
| 94 |
+
|
| 95 |
+
let show_scroll_button = false;
|
| 96 |
+
|
| 97 |
+
const dispatch = createEventDispatcher<{
|
| 98 |
+
change: undefined;
|
| 99 |
+
select: SelectData;
|
| 100 |
+
like: LikeData;
|
| 101 |
+
undo: UndoRetryData;
|
| 102 |
+
retry: UndoRetryData;
|
| 103 |
+
clear: undefined;
|
| 104 |
+
share: any;
|
| 105 |
+
error: string;
|
| 106 |
+
example_select: SelectData;
|
| 107 |
+
}>();
|
| 108 |
+
|
| 109 |
+
function is_at_bottom(): boolean {
|
| 110 |
+
return div && div.offsetHeight + div.scrollTop > div.scrollHeight - 100;
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
function scroll_to_bottom(): void {
|
| 114 |
+
if (!div) return;
|
| 115 |
+
div.scrollTo(0, div.scrollHeight);
|
| 116 |
+
show_scroll_button = false;
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
let scroll_after_component_load = false;
|
| 120 |
+
function on_child_component_load(): void {
|
| 121 |
+
if (scroll_after_component_load) {
|
| 122 |
+
scroll_to_bottom();
|
| 123 |
+
scroll_after_component_load = false;
|
| 124 |
+
}
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
async function scroll_on_value_update(): Promise<void> {
|
| 128 |
+
if (!autoscroll) return;
|
| 129 |
+
|
| 130 |
+
if (is_at_bottom()) {
|
| 131 |
+
// Child components may be loaded asynchronously,
|
| 132 |
+
// so trigger the scroll again after they load.
|
| 133 |
+
scroll_after_component_load = true;
|
| 134 |
+
|
| 135 |
+
await tick(); // Wait for the DOM to update so that the scrollHeight is correct
|
| 136 |
+
scroll_to_bottom();
|
| 137 |
+
} else {
|
| 138 |
+
show_scroll_button = true;
|
| 139 |
+
}
|
| 140 |
+
}
|
| 141 |
+
onMount(() => {
|
| 142 |
+
scroll_on_value_update();
|
| 143 |
+
});
|
| 144 |
+
$: if (value || pending_message || _components) {
|
| 145 |
+
scroll_on_value_update();
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
onMount(() => {
|
| 149 |
+
function handle_scroll(): void {
|
| 150 |
+
if (is_at_bottom()) {
|
| 151 |
+
show_scroll_button = false;
|
| 152 |
+
} else {
|
| 153 |
+
scroll_after_component_load = false;
|
| 154 |
+
}
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
div?.addEventListener("scroll", handle_scroll);
|
| 158 |
+
return () => {
|
| 159 |
+
div?.removeEventListener("scroll", handle_scroll);
|
| 160 |
+
};
|
| 161 |
+
});
|
| 162 |
+
|
| 163 |
+
let image_preview_source: string;
|
| 164 |
+
let image_preview_source_alt: string;
|
| 165 |
+
let is_image_preview_open = false;
|
| 166 |
+
|
| 167 |
+
afterUpdate(() => {
|
| 168 |
+
if (!div) return;
|
| 169 |
+
div.querySelectorAll("img").forEach((n) => {
|
| 170 |
+
n.addEventListener("click", (e) => {
|
| 171 |
+
const target = e.target as HTMLImageElement;
|
| 172 |
+
if (target) {
|
| 173 |
+
image_preview_source = target.src;
|
| 174 |
+
image_preview_source_alt = target.alt;
|
| 175 |
+
is_image_preview_open = true;
|
| 176 |
+
}
|
| 177 |
+
});
|
| 178 |
+
});
|
| 179 |
+
});
|
| 180 |
+
|
| 181 |
+
$: {
|
| 182 |
+
if (!dequal(value, old_value)) {
|
| 183 |
+
old_value = value;
|
| 184 |
+
dispatch("change");
|
| 185 |
+
}
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
$: groupedMessages = value && group_messages(value, msg_format);
|
| 189 |
+
|
| 190 |
+
function handle_example_select(i: number, example: ExampleMessage): void {
|
| 191 |
+
dispatch("example_select", {
|
| 192 |
+
index: i,
|
| 193 |
+
value: { text: example.text, files: example.files }
|
| 194 |
+
});
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
function handle_like(
|
| 198 |
+
i: number,
|
| 199 |
+
message: NormalisedMessage,
|
| 200 |
+
selected: string | null
|
| 201 |
+
): void {
|
| 202 |
+
if (selected === "undo" || selected === "retry") {
|
| 203 |
+
const val_ = value as NormalisedMessage[];
|
| 204 |
+
// iterate through messages until we find the last user message
|
| 205 |
+
// the index of this message is where the user needs to edit the chat history
|
| 206 |
+
let last_index = val_.length - 1;
|
| 207 |
+
while (val_[last_index].role === "assistant") {
|
| 208 |
+
last_index--;
|
| 209 |
+
}
|
| 210 |
+
dispatch(selected, {
|
| 211 |
+
index: val_[last_index].index,
|
| 212 |
+
value: val_[last_index].content
|
| 213 |
+
});
|
| 214 |
+
return;
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
if (msg_format === "tuples") {
|
| 218 |
+
dispatch("like", {
|
| 219 |
+
index: message.index,
|
| 220 |
+
value: message.content,
|
| 221 |
+
liked: selected === "like"
|
| 222 |
+
});
|
| 223 |
+
} else {
|
| 224 |
+
if (!groupedMessages) return;
|
| 225 |
+
|
| 226 |
+
const message_group = groupedMessages[i];
|
| 227 |
+
const [first, last] = [
|
| 228 |
+
message_group[0],
|
| 229 |
+
message_group[message_group.length - 1]
|
| 230 |
+
];
|
| 231 |
+
|
| 232 |
+
dispatch("like", {
|
| 233 |
+
index: [first.index, last.index] as [number, number],
|
| 234 |
+
value: message_group.map((m) => m.content),
|
| 235 |
+
liked: selected === "like"
|
| 236 |
+
});
|
| 237 |
+
}
|
| 238 |
+
}
|
| 239 |
+
</script>
|
| 240 |
+
|
| 241 |
+
{#if value !== null && value.length > 0}
|
| 242 |
+
<IconButtonWrapper>
|
| 243 |
+
{#if show_share_button}
|
| 244 |
+
<IconButton
|
| 245 |
+
Icon={Community}
|
| 246 |
+
on:click={async () => {
|
| 247 |
+
try {
|
| 248 |
+
// @ts-ignore
|
| 249 |
+
const formatted = await format_chat_for_sharing(value);
|
| 250 |
+
dispatch("share", {
|
| 251 |
+
description: formatted
|
| 252 |
+
});
|
| 253 |
+
} catch (e) {
|
| 254 |
+
console.error(e);
|
| 255 |
+
let message = e instanceof ShareError ? e.message : "Share failed.";
|
| 256 |
+
dispatch("error", message);
|
| 257 |
+
}
|
| 258 |
+
}}
|
| 259 |
+
>
|
| 260 |
+
<Community />
|
| 261 |
+
</IconButton>
|
| 262 |
+
{/if}
|
| 263 |
+
<IconButton Icon={Trash} on:click={() => dispatch("clear")} label={"Clear"}
|
| 264 |
+
></IconButton>
|
| 265 |
+
{#if show_copy_all_button}
|
| 266 |
+
<CopyAll {value} />
|
| 267 |
+
{/if}
|
| 268 |
+
</IconButtonWrapper>
|
| 269 |
+
{/if}
|
| 270 |
+
|
| 271 |
+
<div
|
| 272 |
+
class={layout === "bubble" ? "bubble-wrap" : "panel-wrap"}
|
| 273 |
+
bind:this={div}
|
| 274 |
+
role="log"
|
| 275 |
+
aria-label="chatbot conversation"
|
| 276 |
+
aria-live="polite"
|
| 277 |
+
>
|
| 278 |
+
{#if value !== null && value.length > 0 && groupedMessages !== null}
|
| 279 |
+
<div class="message-wrap" use:copy>
|
| 280 |
+
{#each groupedMessages as messages, i}
|
| 281 |
+
{@const role = messages[0].role === "user" ? "user" : "bot"}
|
| 282 |
+
{@const avatar_img = avatar_images[role === "user" ? 0 : 1]}
|
| 283 |
+
{@const opposite_avatar_img = avatar_images[role === "user" ? 0 : 1]}
|
| 284 |
+
{#if is_image_preview_open}
|
| 285 |
+
<div class="image-preview">
|
| 286 |
+
<img src={image_preview_source} alt={image_preview_source_alt} />
|
| 287 |
+
<button
|
| 288 |
+
class="image-preview-close-button"
|
| 289 |
+
on:click={() => {
|
| 290 |
+
is_image_preview_open = false;
|
| 291 |
+
}}><Clear /></button
|
| 292 |
+
>
|
| 293 |
+
</div>
|
| 294 |
+
{/if}
|
| 295 |
+
<Message
|
| 296 |
+
{messages}
|
| 297 |
+
{opposite_avatar_img}
|
| 298 |
+
{avatar_img}
|
| 299 |
+
{role}
|
| 300 |
+
{layout}
|
| 301 |
+
{dispatch}
|
| 302 |
+
{i18n}
|
| 303 |
+
{_fetch}
|
| 304 |
+
{line_breaks}
|
| 305 |
+
{theme_mode}
|
| 306 |
+
{target}
|
| 307 |
+
{root}
|
| 308 |
+
{upload}
|
| 309 |
+
{selectable}
|
| 310 |
+
{sanitize_html}
|
| 311 |
+
{bubble_full_width}
|
| 312 |
+
{render_markdown}
|
| 313 |
+
{rtl}
|
| 314 |
+
{i}
|
| 315 |
+
{value}
|
| 316 |
+
{latex_delimiters}
|
| 317 |
+
{_components}
|
| 318 |
+
{generating}
|
| 319 |
+
{msg_format}
|
| 320 |
+
show_like={role === "user" ? likeable && like_user_message : likeable}
|
| 321 |
+
show_retry={_retryable && is_last_bot_message(messages, value)}
|
| 322 |
+
show_undo={_undoable && is_last_bot_message(messages, value)}
|
| 323 |
+
{show_copy_button}
|
| 324 |
+
handle_action={(selected) => handle_like(i, messages[0], selected)}
|
| 325 |
+
{scroll}
|
| 326 |
+
/>
|
| 327 |
+
{/each}
|
| 328 |
+
{#if pending_message}
|
| 329 |
+
<Pending {layout} />
|
| 330 |
+
{/if}
|
| 331 |
+
</div>
|
| 332 |
+
{:else}
|
| 333 |
+
<div class="placeholder-content">
|
| 334 |
+
{#if placeholder !== null}
|
| 335 |
+
<div class="placeholder">
|
| 336 |
+
<Markdown message={placeholder} {latex_delimiters} {root} />
|
| 337 |
+
</div>
|
| 338 |
+
{/if}
|
| 339 |
+
{#if examples !== null}
|
| 340 |
+
<div class="examples">
|
| 341 |
+
{#each examples as example, i}
|
| 342 |
+
<button
|
| 343 |
+
class="example"
|
| 344 |
+
on:click={() => handle_example_select(i, example)}
|
| 345 |
+
>
|
| 346 |
+
{#if example.icon !== undefined}
|
| 347 |
+
<div class="example-icon-container">
|
| 348 |
+
<Image
|
| 349 |
+
class="example-icon"
|
| 350 |
+
src={example.icon.url}
|
| 351 |
+
alt="example-icon"
|
| 352 |
+
/>
|
| 353 |
+
</div>
|
| 354 |
+
{/if}
|
| 355 |
+
{#if example.display_text !== undefined}
|
| 356 |
+
<span class="example-display-text">{example.display_text}</span>
|
| 357 |
+
{:else}
|
| 358 |
+
<span class="example-text">{example.text}</span>
|
| 359 |
+
{/if}
|
| 360 |
+
{#if example.files !== undefined && example.files.length > 1}
|
| 361 |
+
<span class="example-file"
|
| 362 |
+
><em>{example.files.length} Files</em></span
|
| 363 |
+
>
|
| 364 |
+
{:else if example.files !== undefined && example.files[0] !== undefined && example.files[0].mime_type?.includes("image")}
|
| 365 |
+
<div class="example-image-container">
|
| 366 |
+
<Image
|
| 367 |
+
class="example-image"
|
| 368 |
+
src={example.files[0].url}
|
| 369 |
+
alt="example-image"
|
| 370 |
+
/>
|
| 371 |
+
</div>
|
| 372 |
+
{:else if example.files !== undefined && example.files[0] !== undefined}
|
| 373 |
+
<span class="example-file"
|
| 374 |
+
><em>{example.files[0].orig_name}</em></span
|
| 375 |
+
>
|
| 376 |
+
{/if}
|
| 377 |
+
</button>
|
| 378 |
+
{/each}
|
| 379 |
+
</div>
|
| 380 |
+
{/if}
|
| 381 |
+
</div>
|
| 382 |
+
{/if}
|
| 383 |
+
</div>
|
| 384 |
+
|
| 385 |
+
{#if show_scroll_button}
|
| 386 |
+
<div class="scroll-down-button-container">
|
| 387 |
+
<IconButton
|
| 388 |
+
Icon={ScrollDownArrow}
|
| 389 |
+
label="Scroll down"
|
| 390 |
+
size="large"
|
| 391 |
+
on:click={scroll_to_bottom}
|
| 392 |
+
/>
|
| 393 |
+
</div>
|
| 394 |
+
{/if}
|
| 395 |
+
|
| 396 |
+
<style>
|
| 397 |
+
.placeholder-content {
|
| 398 |
+
display: flex;
|
| 399 |
+
flex-direction: column;
|
| 400 |
+
height: 100%;
|
| 401 |
+
}
|
| 402 |
+
|
| 403 |
+
.placeholder {
|
| 404 |
+
align-items: center;
|
| 405 |
+
display: flex;
|
| 406 |
+
justify-content: center;
|
| 407 |
+
height: 100%;
|
| 408 |
+
flex-grow: 1;
|
| 409 |
+
}
|
| 410 |
+
|
| 411 |
+
.examples :global(img) {
|
| 412 |
+
pointer-events: none;
|
| 413 |
+
}
|
| 414 |
+
|
| 415 |
+
.examples {
|
| 416 |
+
margin: auto;
|
| 417 |
+
padding: var(--spacing-xxl);
|
| 418 |
+
display: grid;
|
| 419 |
+
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
| 420 |
+
gap: var(--spacing-xxl);
|
| 421 |
+
max-width: calc(min(4 * 200px + 5 * var(--spacing-xxl), 100%));
|
| 422 |
+
}
|
| 423 |
+
|
| 424 |
+
.example {
|
| 425 |
+
display: flex;
|
| 426 |
+
flex-direction: column;
|
| 427 |
+
align-items: center;
|
| 428 |
+
padding: var(--spacing-xl);
|
| 429 |
+
border: 0.05px solid var(--border-color-primary);
|
| 430 |
+
border-radius: var(--radius-xl);
|
| 431 |
+
background-color: var(--background-fill-secondary);
|
| 432 |
+
cursor: pointer;
|
| 433 |
+
transition: var(--button-transition);
|
| 434 |
+
max-width: var(--size-56);
|
| 435 |
+
width: 100%;
|
| 436 |
+
justify-content: center;
|
| 437 |
+
}
|
| 438 |
+
|
| 439 |
+
.example:hover {
|
| 440 |
+
background-color: var(--color-accent-soft);
|
| 441 |
+
border-color: var(--border-color-accent);
|
| 442 |
+
}
|
| 443 |
+
|
| 444 |
+
.example-icon-container {
|
| 445 |
+
display: flex;
|
| 446 |
+
align-self: flex-start;
|
| 447 |
+
margin-left: var(--spacing-md);
|
| 448 |
+
width: var(--size-6);
|
| 449 |
+
height: var(--size-6);
|
| 450 |
+
}
|
| 451 |
+
|
| 452 |
+
.example-display-text,
|
| 453 |
+
.example-text,
|
| 454 |
+
.example-file {
|
| 455 |
+
font-size: var(--text-md);
|
| 456 |
+
width: 100%;
|
| 457 |
+
text-align: center;
|
| 458 |
+
overflow: hidden;
|
| 459 |
+
text-overflow: ellipsis;
|
| 460 |
+
}
|
| 461 |
+
|
| 462 |
+
.example-display-text,
|
| 463 |
+
.example-file {
|
| 464 |
+
margin-top: var(--spacing-md);
|
| 465 |
+
}
|
| 466 |
+
|
| 467 |
+
.example-image-container {
|
| 468 |
+
flex-grow: 1;
|
| 469 |
+
display: flex;
|
| 470 |
+
justify-content: center;
|
| 471 |
+
align-items: center;
|
| 472 |
+
margin-top: var(--spacing-xl);
|
| 473 |
+
}
|
| 474 |
+
|
| 475 |
+
.example-image-container :global(img) {
|
| 476 |
+
max-height: 100%;
|
| 477 |
+
max-width: 100%;
|
| 478 |
+
height: var(--size-32);
|
| 479 |
+
width: 100%;
|
| 480 |
+
object-fit: cover;
|
| 481 |
+
border-radius: var(--radius-xl);
|
| 482 |
+
}
|
| 483 |
+
|
| 484 |
+
.panel-wrap {
|
| 485 |
+
width: 100%;
|
| 486 |
+
overflow-y: auto;
|
| 487 |
+
}
|
| 488 |
+
|
| 489 |
+
.bubble-wrap {
|
| 490 |
+
width: 100%;
|
| 491 |
+
overflow-y: auto;
|
| 492 |
+
height: 100%;
|
| 493 |
+
padding-top: var(--spacing-xxl);
|
| 494 |
+
}
|
| 495 |
+
|
| 496 |
+
@media (prefers-color-scheme: dark) {
|
| 497 |
+
.bubble-wrap {
|
| 498 |
+
background: var(--background-fill-secondary);
|
| 499 |
+
}
|
| 500 |
+
}
|
| 501 |
+
|
| 502 |
+
.message-wrap {
|
| 503 |
+
display: flex;
|
| 504 |
+
flex-direction: column;
|
| 505 |
+
justify-content: space-between;
|
| 506 |
+
margin-bottom: var(--spacing-xxl);
|
| 507 |
+
}
|
| 508 |
+
|
| 509 |
+
.message-wrap :global(.prose.chatbot.md) {
|
| 510 |
+
opacity: 0.8;
|
| 511 |
+
overflow-wrap: break-word;
|
| 512 |
+
}
|
| 513 |
+
|
| 514 |
+
.message-wrap :global(.message-row .md img) {
|
| 515 |
+
border-radius: var(--radius-xl);
|
| 516 |
+
margin: var(--size-2);
|
| 517 |
+
width: 400px;
|
| 518 |
+
max-width: 30vw;
|
| 519 |
+
max-height: 30vw;
|
| 520 |
+
}
|
| 521 |
+
|
| 522 |
+
/* link styles */
|
| 523 |
+
.message-wrap :global(.message a) {
|
| 524 |
+
color: var(--color-text-link);
|
| 525 |
+
text-decoration: underline;
|
| 526 |
+
}
|
| 527 |
+
|
| 528 |
+
/* table styles */
|
| 529 |
+
.message-wrap :global(.bot table),
|
| 530 |
+
.message-wrap :global(.bot tr),
|
| 531 |
+
.message-wrap :global(.bot td),
|
| 532 |
+
.message-wrap :global(.bot th) {
|
| 533 |
+
border: 1px solid var(--border-color-primary);
|
| 534 |
+
}
|
| 535 |
+
|
| 536 |
+
.message-wrap :global(.user table),
|
| 537 |
+
.message-wrap :global(.user tr),
|
| 538 |
+
.message-wrap :global(.user td),
|
| 539 |
+
.message-wrap :global(.user th) {
|
| 540 |
+
border: 1px solid var(--border-color-accent);
|
| 541 |
+
}
|
| 542 |
+
|
| 543 |
+
/* KaTeX */
|
| 544 |
+
.message-wrap :global(span.katex) {
|
| 545 |
+
font-size: var(--text-lg);
|
| 546 |
+
direction: ltr;
|
| 547 |
+
}
|
| 548 |
+
|
| 549 |
+
.message-wrap :global(span.katex-display) {
|
| 550 |
+
margin-top: 0;
|
| 551 |
+
}
|
| 552 |
+
|
| 553 |
+
.message-wrap :global(pre) {
|
| 554 |
+
position: relative;
|
| 555 |
+
}
|
| 556 |
+
|
| 557 |
+
.message-wrap :global(.grid-wrap) {
|
| 558 |
+
max-height: 80% !important;
|
| 559 |
+
max-width: 600px;
|
| 560 |
+
object-fit: contain;
|
| 561 |
+
}
|
| 562 |
+
|
| 563 |
+
.message-wrap > div :global(p:not(:first-child)) {
|
| 564 |
+
margin-top: var(--spacing-xxl);
|
| 565 |
+
}
|
| 566 |
+
|
| 567 |
+
.message-wrap {
|
| 568 |
+
display: flex;
|
| 569 |
+
flex-direction: column;
|
| 570 |
+
justify-content: space-between;
|
| 571 |
+
margin-bottom: var(--spacing-xxl);
|
| 572 |
+
}
|
| 573 |
+
|
| 574 |
+
.panel-wrap :global(.message-row:first-child) {
|
| 575 |
+
padding-top: calc(var(--spacing-xxl) * 2);
|
| 576 |
+
}
|
| 577 |
+
|
| 578 |
+
.scroll-down-button-container {
|
| 579 |
+
position: absolute;
|
| 580 |
+
bottom: 10px;
|
| 581 |
+
left: 50%;
|
| 582 |
+
transform: translateX(-50%);
|
| 583 |
+
z-index: var(--layer-top);
|
| 584 |
+
}
|
| 585 |
+
.scroll-down-button-container :global(button) {
|
| 586 |
+
border-radius: 50%;
|
| 587 |
+
box-shadow: var(--shadow-drop);
|
| 588 |
+
transition:
|
| 589 |
+
box-shadow 0.2s ease-in-out,
|
| 590 |
+
transform 0.2s ease-in-out;
|
| 591 |
+
}
|
| 592 |
+
.scroll-down-button-container :global(button:hover) {
|
| 593 |
+
box-shadow:
|
| 594 |
+
var(--shadow-drop),
|
| 595 |
+
0 2px 2px rgba(0, 0, 0, 0.05);
|
| 596 |
+
transform: translateY(-2px);
|
| 597 |
+
}
|
| 598 |
+
</style>
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/chatbot/shared/CopyAll.svelte
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import { onDestroy } from "svelte";
|
| 3 |
+
import { Copy, Check } from "@gradio/icons";
|
| 4 |
+
import type { NormalisedMessage } from "../types";
|
| 5 |
+
import { IconButton } from "@gradio/atoms";
|
| 6 |
+
|
| 7 |
+
let copied = false;
|
| 8 |
+
export let value: NormalisedMessage[] | null;
|
| 9 |
+
|
| 10 |
+
let timer: NodeJS.Timeout;
|
| 11 |
+
|
| 12 |
+
function copy_feedback(): void {
|
| 13 |
+
copied = true;
|
| 14 |
+
if (timer) clearTimeout(timer);
|
| 15 |
+
timer = setTimeout(() => {
|
| 16 |
+
copied = false;
|
| 17 |
+
}, 1000);
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
const copy_conversation = (): void => {
|
| 21 |
+
if (value) {
|
| 22 |
+
const conversation_value = value
|
| 23 |
+
.map((message) => {
|
| 24 |
+
if (message.type === "text") {
|
| 25 |
+
return `${message.role}: ${message.content}`;
|
| 26 |
+
}
|
| 27 |
+
return `${message.role}: ${message.content.value.url}`;
|
| 28 |
+
})
|
| 29 |
+
.join("\n\n");
|
| 30 |
+
|
| 31 |
+
navigator.clipboard.writeText(conversation_value).catch((err) => {
|
| 32 |
+
console.error("Failed to copy conversation: ", err);
|
| 33 |
+
});
|
| 34 |
+
}
|
| 35 |
+
};
|
| 36 |
+
|
| 37 |
+
async function handle_copy(): Promise<void> {
|
| 38 |
+
if ("clipboard" in navigator) {
|
| 39 |
+
copy_conversation();
|
| 40 |
+
copy_feedback();
|
| 41 |
+
}
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
onDestroy(() => {
|
| 45 |
+
if (timer) clearTimeout(timer);
|
| 46 |
+
});
|
| 47 |
+
</script>
|
| 48 |
+
|
| 49 |
+
<IconButton
|
| 50 |
+
Icon={copied ? Check : Copy}
|
| 51 |
+
on:click={handle_copy}
|
| 52 |
+
label={copied ? "Copied conversation" : "Copy conversation"}
|
| 53 |
+
></IconButton>
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/chatbot/shared/Download.svelte
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<svg
|
| 2 |
+
width="16"
|
| 3 |
+
height="16"
|
| 4 |
+
viewBox="0 0 12 12"
|
| 5 |
+
fill="none"
|
| 6 |
+
xmlns="http://www.w3.org/2000/svg"
|
| 7 |
+
>
|
| 8 |
+
<path
|
| 9 |
+
d="M6.27701 8.253C6.24187 8.29143 6.19912 8.32212 6.15147 8.34311C6.10383 8.36411 6.05233 8.37495 6.00026 8.37495C5.94819 8.37495 5.89669 8.36411 5.84905 8.34311C5.8014 8.32212 5.75865 8.29143 5.72351 8.253L3.72351 6.0655C3.65798 5.99185 3.62408 5.89536 3.62916 5.79691C3.63424 5.69846 3.67788 5.60596 3.75064 5.53945C3.8234 5.47293 3.91943 5.43774 4.01794 5.44149C4.11645 5.44525 4.20952 5.48764 4.27701 5.5595L5.62501 7.0345V1.5C5.62501 1.40054 5.66452 1.30516 5.73485 1.23483C5.80517 1.16451 5.90055 1.125 6.00001 1.125C6.09947 1.125 6.19485 1.16451 6.26517 1.23483C6.3355 1.30516 6.37501 1.40054 6.37501 1.5V7.034L7.72351 5.559C7.79068 5.4856 7.88425 5.44189 7.98364 5.43748C8.08304 5.43308 8.18011 5.46833 8.25351 5.5355C8.32691 5.60267 8.37062 5.69624 8.37503 5.79563C8.37943 5.89503 8.34418 5.9921 8.27701 6.0655L6.27701 8.253Z"
|
| 10 |
+
fill="currentColor"
|
| 11 |
+
/>
|
| 12 |
+
<path
|
| 13 |
+
d="M1.875 7.39258C1.875 7.29312 1.83549 7.19774 1.76517 7.12741C1.69484 7.05709 1.59946 7.01758 1.5 7.01758C1.40054 7.01758 1.30516 7.05709 1.23483 7.12741C1.16451 7.19774 1.125 7.29312 1.125 7.39258V7.42008C1.125 8.10358 1.125 8.65508 1.1835 9.08858C1.2435 9.53858 1.3735 9.91758 1.674 10.2186C1.975 10.5196 2.354 10.6486 2.804 10.7096C3.2375 10.7676 3.789 10.7676 4.4725 10.7676H7.5275C8.211 10.7676 8.7625 10.7676 9.196 10.7096C9.646 10.6486 10.025 10.5196 10.326 10.2186C10.627 9.91758 10.756 9.53858 10.817 9.08858C10.875 8.65508 10.875 8.10358 10.875 7.42008V7.39258C10.875 7.29312 10.8355 7.19774 10.7652 7.12741C10.6948 7.05709 10.5995 7.01758 10.5 7.01758C10.4005 7.01758 10.3052 7.05709 10.2348 7.12741C10.1645 7.19774 10.125 7.29312 10.125 7.39258C10.125 8.11008 10.124 8.61058 10.0735 8.98858C10.024 9.35558 9.9335 9.54958 9.7955 9.68808C9.657 9.82658 9.463 9.91658 9.0955 9.96608C8.718 10.0166 8.2175 10.0176 7.5 10.0176H4.5C3.7825 10.0176 3.2815 10.0166 2.904 9.96608C2.537 9.91658 2.343 9.82608 2.2045 9.68808C2.066 9.54958 1.976 9.35558 1.9265 8.98808C1.876 8.61058 1.875 8.11008 1.875 7.39258Z"
|
| 14 |
+
fill="currentColor"
|
| 15 |
+
/>
|
| 16 |
+
</svg>
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/chatbot/shared/MessageBox.svelte
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
export let expanded = false;
|
| 3 |
+
export let title: string;
|
| 4 |
+
|
| 5 |
+
function toggleExpanded(): void {
|
| 6 |
+
expanded = !expanded;
|
| 7 |
+
}
|
| 8 |
+
</script>
|
| 9 |
+
|
| 10 |
+
<button class="box" on:click={toggleExpanded}>
|
| 11 |
+
<div class="title">
|
| 12 |
+
<span class="title-text">{title}</span>
|
| 13 |
+
<span
|
| 14 |
+
style:transform={expanded ? "rotate(0)" : "rotate(90deg)"}
|
| 15 |
+
class="arrow"
|
| 16 |
+
>
|
| 17 |
+
▼
|
| 18 |
+
</span>
|
| 19 |
+
</div>
|
| 20 |
+
{#if expanded}
|
| 21 |
+
<div class="content">
|
| 22 |
+
<slot></slot>
|
| 23 |
+
</div>
|
| 24 |
+
{/if}
|
| 25 |
+
</button>
|
| 26 |
+
|
| 27 |
+
<style>
|
| 28 |
+
.box {
|
| 29 |
+
border-radius: 4px;
|
| 30 |
+
cursor: pointer;
|
| 31 |
+
max-width: max-content;
|
| 32 |
+
background: var(--color-accent-soft);
|
| 33 |
+
border: 1px solid var(--border-color-accent-subdued);
|
| 34 |
+
font-size: 0.8em;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
.title {
|
| 38 |
+
display: flex;
|
| 39 |
+
align-items: center;
|
| 40 |
+
padding: 3px 6px;
|
| 41 |
+
color: var(--body-text-color);
|
| 42 |
+
opacity: 0.8;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
.content {
|
| 46 |
+
padding: 4px 8px;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
.content :global(*) {
|
| 50 |
+
font-size: 0.8em;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
.title-text {
|
| 54 |
+
padding-right: var(--spacing-lg);
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
.arrow {
|
| 58 |
+
margin-left: auto;
|
| 59 |
+
opacity: 0.8;
|
| 60 |
+
}
|
| 61 |
+
</style>
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/chatbot/shared/Pending.svelte
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
export let layout = "bubble";
|
| 3 |
+
</script>
|
| 4 |
+
|
| 5 |
+
<div
|
| 6 |
+
class="message pending"
|
| 7 |
+
role="status"
|
| 8 |
+
aria-label="Loading response"
|
| 9 |
+
aria-live="polite"
|
| 10 |
+
style:border-radius={layout === "bubble" ? "var(--radius-xxl)" : "none"}
|
| 11 |
+
>
|
| 12 |
+
<span class="sr-only">Loading content</span>
|
| 13 |
+
<div class="dot-flashing" />
|
| 14 |
+
|
| 15 |
+
<div class="dot-flashing" />
|
| 16 |
+
|
| 17 |
+
<div class="dot-flashing" />
|
| 18 |
+
</div>
|
| 19 |
+
|
| 20 |
+
<style>
|
| 21 |
+
.pending {
|
| 22 |
+
background: var(--color-accent-soft);
|
| 23 |
+
display: flex;
|
| 24 |
+
flex-direction: row;
|
| 25 |
+
justify-content: center;
|
| 26 |
+
align-items: center;
|
| 27 |
+
align-self: center;
|
| 28 |
+
gap: 2px;
|
| 29 |
+
width: 100%;
|
| 30 |
+
height: var(--size-16);
|
| 31 |
+
}
|
| 32 |
+
.dot-flashing {
|
| 33 |
+
animation: flash 1s infinite ease-in-out;
|
| 34 |
+
border-radius: 5px;
|
| 35 |
+
background-color: var(--body-text-color);
|
| 36 |
+
width: 7px;
|
| 37 |
+
height: 7px;
|
| 38 |
+
color: var(--body-text-color);
|
| 39 |
+
}
|
| 40 |
+
@keyframes flash {
|
| 41 |
+
0%,
|
| 42 |
+
100% {
|
| 43 |
+
opacity: 0;
|
| 44 |
+
}
|
| 45 |
+
50% {
|
| 46 |
+
opacity: 1;
|
| 47 |
+
}
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
.dot-flashing:nth-child(1) {
|
| 51 |
+
animation-delay: 0s;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
.dot-flashing:nth-child(2) {
|
| 55 |
+
animation-delay: 0.33s;
|
| 56 |
+
}
|
| 57 |
+
.dot-flashing:nth-child(3) {
|
| 58 |
+
animation-delay: 0.66s;
|
| 59 |
+
}
|
| 60 |
+
</style>
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/chatbot/shared/ThumbDownActive.svelte
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<svg
|
| 2 |
+
width="100%"
|
| 3 |
+
height="100%"
|
| 4 |
+
viewBox="0 0 12 12"
|
| 5 |
+
fill="none"
|
| 6 |
+
xmlns="http://www.w3.org/2000/svg"
|
| 7 |
+
>
|
| 8 |
+
<path
|
| 9 |
+
d="M11.25 6.61523H9.375V1.36523H11.25V6.61523ZM3.375 1.36523H8.625V6.91636L7.48425 8.62748L7.16737 10.8464C7.14108 11.0248 7.05166 11.1879 6.91535 11.3061C6.77904 11.4242 6.60488 11.4896 6.4245 11.4902H6.375C6.07672 11.4899 5.79075 11.3713 5.57983 11.1604C5.36892 10.9495 5.2503 10.6635 5.25 10.3652V8.11523H2.25C1.85233 8.11474 1.47109 7.95654 1.18989 7.67535C0.908691 7.39415 0.750496 7.01291 0.75 6.61523V3.99023C0.750992 3.29435 1.02787 2.62724 1.51994 2.13517C2.01201 1.64311 2.67911 1.36623 3.375 1.36523Z"
|
| 10 |
+
fill="currentColor"
|
| 11 |
+
/>
|
| 12 |
+
</svg>
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/chatbot/shared/ThumbUpDefault.svelte
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<svg
|
| 2 |
+
width="100%"
|
| 3 |
+
height="100%"
|
| 4 |
+
viewBox="0 0 12 12"
|
| 5 |
+
fill="none"
|
| 6 |
+
xmlns="http://www.w3.org/2000/svg"
|
| 7 |
+
>
|
| 8 |
+
<path
|
| 9 |
+
d="M9.75 4.74023H7.5V2.49023C7.4997 2.19196 7.38108 1.90598 7.17017 1.69507C6.95925 1.48415 6.67328 1.36553 6.375 1.36523H5.57512C5.39481 1.366 5.22074 1.43138 5.08451 1.54952C4.94828 1.66766 4.85891 1.83072 4.83262 2.00911L4.51575 4.22798L3.17438 6.24023H0.75V11.4902H8.625C9.32089 11.4892 9.98799 11.2124 10.4801 10.7203C10.9721 10.2282 11.249 9.56112 11.25 8.86523V6.24023C11.2495 5.84256 11.0913 5.46132 10.8101 5.18012C10.5289 4.89893 10.1477 4.74073 9.75 4.74023ZM3 10.7402H1.5V6.99023H3V10.7402ZM10.5 8.86523C10.4994 9.36233 10.3017 9.8389 9.95017 10.1904C9.59867 10.5419 9.1221 10.7396 8.625 10.7402H3.75V6.72886L5.23425 4.50248L5.5755 2.11523H6.375C6.47446 2.11523 6.56984 2.15474 6.64017 2.22507C6.71049 2.2954 6.75 2.39078 6.75 2.49023V5.49023H9.75C9.94882 5.49053 10.1394 5.56965 10.28 5.71023C10.4206 5.85082 10.4997 6.04141 10.5 6.24023V8.86523Z"
|
| 10 |
+
fill="currentColor"
|
| 11 |
+
/>
|
| 12 |
+
</svg>
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/chatbot/shared/autorender.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
declare module "katex/dist/contrib/auto-render.js";
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/chatbot/types.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { FileData } from "@gradio/client";
|
| 2 |
+
|
| 3 |
+
export type MessageRole = "system" | "user" | "assistant";
|
| 4 |
+
|
| 5 |
+
export interface Metadata {
|
| 6 |
+
title: string | null;
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
export interface ComponentData {
|
| 10 |
+
component: string;
|
| 11 |
+
constructor_args: any;
|
| 12 |
+
props: any;
|
| 13 |
+
value: any;
|
| 14 |
+
alt_text: string | null;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
export interface Message {
|
| 18 |
+
role: MessageRole;
|
| 19 |
+
metadata: Metadata;
|
| 20 |
+
content: string | FileData | ComponentData;
|
| 21 |
+
index: number | [number, number];
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
export interface TextMessage extends Message {
|
| 25 |
+
type: "text";
|
| 26 |
+
content: string;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
export interface ComponentMessage extends Message {
|
| 30 |
+
type: "component";
|
| 31 |
+
content: ComponentData;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
export interface ExampleMessage {
|
| 35 |
+
icon?: FileData;
|
| 36 |
+
display_text?: string;
|
| 37 |
+
text: string;
|
| 38 |
+
files?: FileData[];
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
export type message_data =
|
| 42 |
+
| string
|
| 43 |
+
| { file: FileData | FileData[]; alt_text: string | null }
|
| 44 |
+
| { component: string; value: any; constructor_args: any; props: any }
|
| 45 |
+
| null;
|
| 46 |
+
|
| 47 |
+
export type TupleFormat = [message_data, message_data][] | null;
|
| 48 |
+
|
| 49 |
+
export type NormalisedMessage = TextMessage | ComponentMessage;
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/column/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@gradio/column",
|
| 3 |
+
"version": "0.2.0",
|
| 4 |
+
"description": "Gradio UI packages",
|
| 5 |
+
"type": "module",
|
| 6 |
+
"author": "",
|
| 7 |
+
"license": "ISC",
|
| 8 |
+
"main_changeset": true,
|
| 9 |
+
"private": false,
|
| 10 |
+
"main": "./Index.svelte",
|
| 11 |
+
"exports": {
|
| 12 |
+
".": {
|
| 13 |
+
"gradio": "./Index.svelte",
|
| 14 |
+
"svelte": "./dist/Index.svelte",
|
| 15 |
+
"types": "./dist/Index.svelte.d.ts"
|
| 16 |
+
},
|
| 17 |
+
"./package.json": "./package.json"
|
| 18 |
+
},
|
| 19 |
+
"devDependencies": {
|
| 20 |
+
"@gradio/preview": "workspace:^",
|
| 21 |
+
"@gradio/statustracker": "workspace:^",
|
| 22 |
+
"@gradio/utils": "workspace:^"
|
| 23 |
+
},
|
| 24 |
+
"peerDependencies": {
|
| 25 |
+
"svelte": "^4.0.0"
|
| 26 |
+
},
|
| 27 |
+
"repository": {
|
| 28 |
+
"type": "git",
|
| 29 |
+
"url": "git+https://github.com/gradio-app/gradio.git",
|
| 30 |
+
"directory": "js/column"
|
| 31 |
+
}
|
| 32 |
+
}
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/fallback/Example.svelte
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
export let value: string;
|
| 3 |
+
export let type: "gallery" | "table";
|
| 4 |
+
export let selected = false;
|
| 5 |
+
</script>
|
| 6 |
+
|
| 7 |
+
<div
|
| 8 |
+
class:table={type === "table"}
|
| 9 |
+
class:gallery={type === "gallery"}
|
| 10 |
+
class:selected
|
| 11 |
+
>
|
| 12 |
+
{value}
|
| 13 |
+
</div>
|
| 14 |
+
|
| 15 |
+
<style>
|
| 16 |
+
.gallery {
|
| 17 |
+
padding: var(--size-1) var(--size-2);
|
| 18 |
+
}
|
| 19 |
+
</style>
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/fileexplorer/Index.svelte
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<svelte:options accessors={true} />
|
| 2 |
+
|
| 3 |
+
<script lang="ts">
|
| 4 |
+
import type { Gradio, SelectData } from "@gradio/utils";
|
| 5 |
+
import { File } from "@gradio/icons";
|
| 6 |
+
import type { FileNode } from "./shared/types";
|
| 7 |
+
|
| 8 |
+
import { Block, BlockLabel } from "@gradio/atoms";
|
| 9 |
+
import DirectoryExplorer from "./shared/DirectoryExplorer.svelte";
|
| 10 |
+
|
| 11 |
+
import { StatusTracker } from "@gradio/statustracker";
|
| 12 |
+
import type { LoadingStatus } from "@gradio/statustracker";
|
| 13 |
+
|
| 14 |
+
import { _ } from "svelte-i18n";
|
| 15 |
+
|
| 16 |
+
export let elem_id = "";
|
| 17 |
+
export let elem_classes: string[] = [];
|
| 18 |
+
export let visible = true;
|
| 19 |
+
export let value: string[][];
|
| 20 |
+
let old_value: string[][];
|
| 21 |
+
export let label: string;
|
| 22 |
+
export let show_label: boolean;
|
| 23 |
+
export let height: number | string | undefined;
|
| 24 |
+
export let min_height: number | string | undefined;
|
| 25 |
+
export let max_height: number | string | undefined;
|
| 26 |
+
export let file_count: "single" | "multiple" = "multiple";
|
| 27 |
+
export let root_dir: string;
|
| 28 |
+
export let glob: string;
|
| 29 |
+
export let ignore_glob: string;
|
| 30 |
+
export let loading_status: LoadingStatus;
|
| 31 |
+
export let container = true;
|
| 32 |
+
export let scale: number | null = null;
|
| 33 |
+
export let min_width: number | undefined = undefined;
|
| 34 |
+
export let gradio: Gradio<{
|
| 35 |
+
change: never;
|
| 36 |
+
clear_status: LoadingStatus;
|
| 37 |
+
}>;
|
| 38 |
+
export let server: {
|
| 39 |
+
ls: (path: string[]) => Promise<FileNode[]>;
|
| 40 |
+
};
|
| 41 |
+
export let interactive: boolean;
|
| 42 |
+
|
| 43 |
+
$: rerender_key = [root_dir, glob, ignore_glob];
|
| 44 |
+
|
| 45 |
+
$: if (JSON.stringify(value) !== JSON.stringify(old_value)) {
|
| 46 |
+
old_value = value;
|
| 47 |
+
gradio.dispatch("change");
|
| 48 |
+
}
|
| 49 |
+
</script>
|
| 50 |
+
|
| 51 |
+
<Block
|
| 52 |
+
{visible}
|
| 53 |
+
variant={value === null ? "dashed" : "solid"}
|
| 54 |
+
border_mode={"base"}
|
| 55 |
+
padding={false}
|
| 56 |
+
{elem_id}
|
| 57 |
+
{elem_classes}
|
| 58 |
+
{container}
|
| 59 |
+
{scale}
|
| 60 |
+
{min_width}
|
| 61 |
+
allow_overflow={true}
|
| 62 |
+
overflow_behavior="auto"
|
| 63 |
+
{height}
|
| 64 |
+
{max_height}
|
| 65 |
+
{min_height}
|
| 66 |
+
>
|
| 67 |
+
<StatusTracker
|
| 68 |
+
{...loading_status}
|
| 69 |
+
autoscroll={gradio.autoscroll}
|
| 70 |
+
i18n={gradio.i18n}
|
| 71 |
+
on:clear_status={() => gradio.dispatch("clear_status", loading_status)}
|
| 72 |
+
/>
|
| 73 |
+
<BlockLabel
|
| 74 |
+
{show_label}
|
| 75 |
+
Icon={File}
|
| 76 |
+
label={label || "FileExplorer"}
|
| 77 |
+
float={false}
|
| 78 |
+
/>
|
| 79 |
+
{#key rerender_key}
|
| 80 |
+
<DirectoryExplorer
|
| 81 |
+
bind:value
|
| 82 |
+
{file_count}
|
| 83 |
+
{interactive}
|
| 84 |
+
ls_fn={server.ls}
|
| 85 |
+
/>
|
| 86 |
+
{/key}
|
| 87 |
+
</Block>
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/fileexplorer/shared/Checkbox.svelte
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import { createEventDispatcher } from "svelte";
|
| 3 |
+
export let value: boolean;
|
| 4 |
+
export let disabled: boolean;
|
| 5 |
+
const dispatch = createEventDispatcher<{ change: boolean }>();
|
| 6 |
+
</script>
|
| 7 |
+
|
| 8 |
+
<input
|
| 9 |
+
bind:checked={value}
|
| 10 |
+
on:input={() => dispatch("change", !value)}
|
| 11 |
+
type="checkbox"
|
| 12 |
+
{disabled}
|
| 13 |
+
class:disabled={disabled && !value}
|
| 14 |
+
/>
|
| 15 |
+
|
| 16 |
+
<style>
|
| 17 |
+
input {
|
| 18 |
+
--ring-color: transparent;
|
| 19 |
+
position: relative;
|
| 20 |
+
box-shadow: var(--input-shadow);
|
| 21 |
+
border: 1px solid var(--checkbox-border-color);
|
| 22 |
+
border-radius: var(--radius-xs);
|
| 23 |
+
background-color: var(--checkbox-background-color);
|
| 24 |
+
line-height: var(--line-sm);
|
| 25 |
+
width: 18px !important;
|
| 26 |
+
height: 18px !important;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
input:checked,
|
| 30 |
+
input:checked:hover,
|
| 31 |
+
input:checked:focus {
|
| 32 |
+
border-color: var(--checkbox-border-color-selected);
|
| 33 |
+
background-image: var(--checkbox-check);
|
| 34 |
+
background-color: var(--checkbox-background-color-selected);
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
input:hover {
|
| 38 |
+
border-color: var(--checkbox-border-color-hover);
|
| 39 |
+
background-color: var(--checkbox-background-color-hover);
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
input:focus {
|
| 43 |
+
border-color: var(--checkbox-border-color-focus);
|
| 44 |
+
background-color: var(--checkbox-background-color-focus);
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
.disabled {
|
| 48 |
+
opacity: 0.8 !important;
|
| 49 |
+
cursor: not-allowed;
|
| 50 |
+
}
|
| 51 |
+
</style>
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/image/Index.svelte
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<svelte:options accessors={true} />
|
| 2 |
+
|
| 3 |
+
<script context="module" lang="ts">
|
| 4 |
+
export { default as Webcam } from "./shared/Webcam.svelte";
|
| 5 |
+
export { default as BaseImageUploader } from "./shared/ImageUploader.svelte";
|
| 6 |
+
export { default as BaseStaticImage } from "./shared/ImagePreview.svelte";
|
| 7 |
+
export { default as BaseExample } from "./Example.svelte";
|
| 8 |
+
export { default as BaseImage } from "./shared/Image.svelte";
|
| 9 |
+
</script>
|
| 10 |
+
|
| 11 |
+
<script lang="ts">
|
| 12 |
+
import type { Gradio, SelectData, ValueData } from "@gradio/utils";
|
| 13 |
+
import StaticImage from "./shared/ImagePreview.svelte";
|
| 14 |
+
import ImageUploader from "./shared/ImageUploader.svelte";
|
| 15 |
+
import { afterUpdate } from "svelte";
|
| 16 |
+
|
| 17 |
+
import { Block, Empty, UploadText } from "@gradio/atoms";
|
| 18 |
+
import { Image } from "@gradio/icons";
|
| 19 |
+
import { StatusTracker } from "@gradio/statustracker";
|
| 20 |
+
import { upload, type FileData } from "@gradio/client";
|
| 21 |
+
import type { LoadingStatus } from "@gradio/statustracker";
|
| 22 |
+
|
| 23 |
+
type sources = "upload" | "webcam" | "clipboard" | null;
|
| 24 |
+
|
| 25 |
+
let stream_state = "closed";
|
| 26 |
+
let _modify_stream: (state: "open" | "closed" | "waiting") => void = () => {};
|
| 27 |
+
export function modify_stream_state(
|
| 28 |
+
state: "open" | "closed" | "waiting"
|
| 29 |
+
): void {
|
| 30 |
+
stream_state = state;
|
| 31 |
+
_modify_stream(state);
|
| 32 |
+
}
|
| 33 |
+
export const get_stream_state: () => void = () => stream_state;
|
| 34 |
+
export let set_time_limit: (arg0: number) => void;
|
| 35 |
+
export let value_is_output = false;
|
| 36 |
+
export let elem_id = "";
|
| 37 |
+
export let elem_classes: string[] = [];
|
| 38 |
+
export let visible = true;
|
| 39 |
+
export let value: null | FileData = null;
|
| 40 |
+
let old_value: null | FileData = null;
|
| 41 |
+
export let label: string;
|
| 42 |
+
export let show_label: boolean;
|
| 43 |
+
export let show_download_button: boolean;
|
| 44 |
+
export let root: string;
|
| 45 |
+
|
| 46 |
+
export let height: number | undefined;
|
| 47 |
+
export let width: number | undefined;
|
| 48 |
+
export let stream_every: number;
|
| 49 |
+
|
| 50 |
+
export let _selectable = false;
|
| 51 |
+
export let container = true;
|
| 52 |
+
export let scale: number | null = null;
|
| 53 |
+
export let min_width: number | undefined = undefined;
|
| 54 |
+
export let loading_status: LoadingStatus;
|
| 55 |
+
export let show_share_button = false;
|
| 56 |
+
export let sources: ("clipboard" | "webcam" | "upload")[] = [
|
| 57 |
+
"upload",
|
| 58 |
+
"clipboard",
|
| 59 |
+
"webcam"
|
| 60 |
+
];
|
| 61 |
+
export let interactive: boolean;
|
| 62 |
+
export let streaming: boolean;
|
| 63 |
+
export let pending: boolean;
|
| 64 |
+
export let mirror_webcam: boolean;
|
| 65 |
+
export let placeholder: string | undefined = undefined;
|
| 66 |
+
export let show_fullscreen_button: boolean;
|
| 67 |
+
export let input_ready: boolean;
|
| 68 |
+
let uploading = false;
|
| 69 |
+
$: input_ready = !uploading;
|
| 70 |
+
export let gradio: Gradio<{
|
| 71 |
+
input: never;
|
| 72 |
+
change: never;
|
| 73 |
+
error: string;
|
| 74 |
+
edit: never;
|
| 75 |
+
stream: ValueData;
|
| 76 |
+
drag: never;
|
| 77 |
+
upload: never;
|
| 78 |
+
clear: never;
|
| 79 |
+
select: SelectData;
|
| 80 |
+
share: ShareData;
|
| 81 |
+
clear_status: LoadingStatus;
|
| 82 |
+
close_stream: string;
|
| 83 |
+
}>;
|
| 84 |
+
|
| 85 |
+
$: {
|
| 86 |
+
if (JSON.stringify(value) !== JSON.stringify(old_value)) {
|
| 87 |
+
old_value = value;
|
| 88 |
+
gradio.dispatch("change");
|
| 89 |
+
if (!value_is_output) {
|
| 90 |
+
gradio.dispatch("input");
|
| 91 |
+
}
|
| 92 |
+
}
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
afterUpdate(() => {
|
| 96 |
+
value_is_output = false;
|
| 97 |
+
});
|
| 98 |
+
|
| 99 |
+
let dragging: boolean;
|
| 100 |
+
let active_source: sources = null;
|
| 101 |
+
let upload_component: ImageUploader;
|
| 102 |
+
const handle_drag_event = (event: Event): void => {
|
| 103 |
+
const drag_event = event as DragEvent;
|
| 104 |
+
drag_event.preventDefault();
|
| 105 |
+
drag_event.stopPropagation();
|
| 106 |
+
if (drag_event.type === "dragenter" || drag_event.type === "dragover") {
|
| 107 |
+
dragging = true;
|
| 108 |
+
} else if (drag_event.type === "dragleave") {
|
| 109 |
+
dragging = false;
|
| 110 |
+
}
|
| 111 |
+
};
|
| 112 |
+
|
| 113 |
+
const handle_drop = (event: Event): void => {
|
| 114 |
+
if (interactive) {
|
| 115 |
+
const drop_event = event as DragEvent;
|
| 116 |
+
drop_event.preventDefault();
|
| 117 |
+
drop_event.stopPropagation();
|
| 118 |
+
dragging = false;
|
| 119 |
+
|
| 120 |
+
if (upload_component) {
|
| 121 |
+
upload_component.loadFilesFromDrop(drop_event);
|
| 122 |
+
}
|
| 123 |
+
}
|
| 124 |
+
};
|
| 125 |
+
</script>
|
| 126 |
+
|
| 127 |
+
{#if !interactive}
|
| 128 |
+
<Block
|
| 129 |
+
{visible}
|
| 130 |
+
variant={"solid"}
|
| 131 |
+
border_mode={dragging ? "focus" : "base"}
|
| 132 |
+
padding={false}
|
| 133 |
+
{elem_id}
|
| 134 |
+
{elem_classes}
|
| 135 |
+
height={height || undefined}
|
| 136 |
+
{width}
|
| 137 |
+
allow_overflow={false}
|
| 138 |
+
{container}
|
| 139 |
+
{scale}
|
| 140 |
+
{min_width}
|
| 141 |
+
>
|
| 142 |
+
<StatusTracker
|
| 143 |
+
autoscroll={gradio.autoscroll}
|
| 144 |
+
i18n={gradio.i18n}
|
| 145 |
+
{...loading_status}
|
| 146 |
+
/>
|
| 147 |
+
<StaticImage
|
| 148 |
+
on:select={({ detail }) => gradio.dispatch("select", detail)}
|
| 149 |
+
on:share={({ detail }) => gradio.dispatch("share", detail)}
|
| 150 |
+
on:error={({ detail }) => gradio.dispatch("error", detail)}
|
| 151 |
+
{value}
|
| 152 |
+
{label}
|
| 153 |
+
{show_label}
|
| 154 |
+
{show_download_button}
|
| 155 |
+
selectable={_selectable}
|
| 156 |
+
{show_share_button}
|
| 157 |
+
i18n={gradio.i18n}
|
| 158 |
+
{show_fullscreen_button}
|
| 159 |
+
/>
|
| 160 |
+
</Block>
|
| 161 |
+
{:else}
|
| 162 |
+
<Block
|
| 163 |
+
{visible}
|
| 164 |
+
variant={value === null ? "dashed" : "solid"}
|
| 165 |
+
border_mode={dragging ? "focus" : "base"}
|
| 166 |
+
padding={false}
|
| 167 |
+
{elem_id}
|
| 168 |
+
{elem_classes}
|
| 169 |
+
height={height || undefined}
|
| 170 |
+
{width}
|
| 171 |
+
allow_overflow={false}
|
| 172 |
+
{container}
|
| 173 |
+
{scale}
|
| 174 |
+
{min_width}
|
| 175 |
+
on:dragenter={handle_drag_event}
|
| 176 |
+
on:dragleave={handle_drag_event}
|
| 177 |
+
on:dragover={handle_drag_event}
|
| 178 |
+
on:drop={handle_drop}
|
| 179 |
+
>
|
| 180 |
+
<StatusTracker
|
| 181 |
+
autoscroll={gradio.autoscroll}
|
| 182 |
+
i18n={gradio.i18n}
|
| 183 |
+
{...loading_status}
|
| 184 |
+
on:clear_status={() => gradio.dispatch("clear_status", loading_status)}
|
| 185 |
+
/>
|
| 186 |
+
|
| 187 |
+
<ImageUploader
|
| 188 |
+
bind:this={upload_component}
|
| 189 |
+
bind:uploading
|
| 190 |
+
bind:active_source
|
| 191 |
+
bind:value
|
| 192 |
+
bind:dragging
|
| 193 |
+
selectable={_selectable}
|
| 194 |
+
{root}
|
| 195 |
+
{sources}
|
| 196 |
+
on:edit={() => gradio.dispatch("edit")}
|
| 197 |
+
on:clear={() => {
|
| 198 |
+
gradio.dispatch("clear");
|
| 199 |
+
}}
|
| 200 |
+
on:stream={({ detail }) => gradio.dispatch("stream", detail)}
|
| 201 |
+
on:drag={({ detail }) => (dragging = detail)}
|
| 202 |
+
on:upload={() => gradio.dispatch("upload")}
|
| 203 |
+
on:select={({ detail }) => gradio.dispatch("select", detail)}
|
| 204 |
+
on:share={({ detail }) => gradio.dispatch("share", detail)}
|
| 205 |
+
on:error={({ detail }) => {
|
| 206 |
+
loading_status = loading_status || {};
|
| 207 |
+
loading_status.status = "error";
|
| 208 |
+
gradio.dispatch("error", detail);
|
| 209 |
+
}}
|
| 210 |
+
on:close_stream={() => {
|
| 211 |
+
gradio.dispatch("close_stream", "stream");
|
| 212 |
+
}}
|
| 213 |
+
{label}
|
| 214 |
+
{show_label}
|
| 215 |
+
{pending}
|
| 216 |
+
{streaming}
|
| 217 |
+
{mirror_webcam}
|
| 218 |
+
{stream_every}
|
| 219 |
+
bind:modify_stream={_modify_stream}
|
| 220 |
+
bind:set_time_limit
|
| 221 |
+
max_file_size={gradio.max_file_size}
|
| 222 |
+
i18n={gradio.i18n}
|
| 223 |
+
upload={(...args) => gradio.client.upload(...args)}
|
| 224 |
+
stream_handler={gradio.client?.stream}
|
| 225 |
+
>
|
| 226 |
+
{#if active_source === "upload" || !active_source}
|
| 227 |
+
<UploadText i18n={gradio.i18n} type="image" {placeholder} />
|
| 228 |
+
{:else if active_source === "clipboard"}
|
| 229 |
+
<UploadText i18n={gradio.i18n} type="clipboard" mode="short" />
|
| 230 |
+
{:else}
|
| 231 |
+
<Empty unpadded_box={true} size="large"><Image /></Empty>
|
| 232 |
+
{/if}
|
| 233 |
+
</ImageUploader>
|
| 234 |
+
</Block>
|
| 235 |
+
{/if}
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/image/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@gradio/image",
|
| 3 |
+
"version": "0.16.2",
|
| 4 |
+
"description": "Gradio UI packages",
|
| 5 |
+
"type": "module",
|
| 6 |
+
"author": "",
|
| 7 |
+
"license": "ISC",
|
| 8 |
+
"private": false,
|
| 9 |
+
"dependencies": {
|
| 10 |
+
"@gradio/atoms": "workspace:^",
|
| 11 |
+
"@gradio/client": "workspace:^",
|
| 12 |
+
"@gradio/icons": "workspace:^",
|
| 13 |
+
"@gradio/statustracker": "workspace:^",
|
| 14 |
+
"@gradio/upload": "workspace:^",
|
| 15 |
+
"@gradio/utils": "workspace:^",
|
| 16 |
+
"@gradio/wasm": "workspace:^",
|
| 17 |
+
"cropperjs": "^1.5.12",
|
| 18 |
+
"lazy-brush": "^1.0.1",
|
| 19 |
+
"resize-observer-polyfill": "^1.5.1"
|
| 20 |
+
},
|
| 21 |
+
"devDependencies": {
|
| 22 |
+
"@gradio/preview": "workspace:^"
|
| 23 |
+
},
|
| 24 |
+
"main_changeset": true,
|
| 25 |
+
"main": "./Index.svelte",
|
| 26 |
+
"exports": {
|
| 27 |
+
"./package.json": "./package.json",
|
| 28 |
+
".": {
|
| 29 |
+
"gradio": "./Index.svelte",
|
| 30 |
+
"svelte": "./dist/Index.svelte",
|
| 31 |
+
"types": "./dist/Index.svelte.d.ts"
|
| 32 |
+
},
|
| 33 |
+
"./example": {
|
| 34 |
+
"gradio": "./Example.svelte",
|
| 35 |
+
"svelte": "./dist/Example.svelte",
|
| 36 |
+
"types": "./dist/Example.svelte.d.ts"
|
| 37 |
+
},
|
| 38 |
+
"./base": {
|
| 39 |
+
"gradio": "./shared/ImagePreview.svelte",
|
| 40 |
+
"svelte": "./dist/shared/ImagePreview.svelte",
|
| 41 |
+
"types": "./dist/shared/ImagePreview.svelte.d.ts"
|
| 42 |
+
},
|
| 43 |
+
"./shared": {
|
| 44 |
+
"gradio": "./shared/index.ts",
|
| 45 |
+
"svelte": "./dist/shared/index.js",
|
| 46 |
+
"types": "./dist/shared/index.d.ts"
|
| 47 |
+
}
|
| 48 |
+
},
|
| 49 |
+
"peerDependencies": {
|
| 50 |
+
"svelte": "^4.0.0"
|
| 51 |
+
},
|
| 52 |
+
"repository": {
|
| 53 |
+
"type": "git",
|
| 54 |
+
"url": "git+https://github.com/gradio-app/gradio.git",
|
| 55 |
+
"directory": "js/image"
|
| 56 |
+
}
|
| 57 |
+
}
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/image/shared/ClearImage.svelte
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import { createEventDispatcher } from "svelte";
|
| 3 |
+
import { IconButton, IconButtonWrapper } from "@gradio/atoms";
|
| 4 |
+
import { Clear } from "@gradio/icons";
|
| 5 |
+
|
| 6 |
+
const dispatch = createEventDispatcher();
|
| 7 |
+
</script>
|
| 8 |
+
|
| 9 |
+
<IconButtonWrapper>
|
| 10 |
+
<IconButton
|
| 11 |
+
Icon={Clear}
|
| 12 |
+
label="Remove Image"
|
| 13 |
+
on:click={(event) => {
|
| 14 |
+
dispatch("remove_image");
|
| 15 |
+
event.stopPropagation();
|
| 16 |
+
}}
|
| 17 |
+
/>
|
| 18 |
+
</IconButtonWrapper>
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/image/shared/ImagePreview.svelte
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import { createEventDispatcher, onMount } from "svelte";
|
| 3 |
+
import type { SelectData } from "@gradio/utils";
|
| 4 |
+
import { uploadToHuggingFace } from "@gradio/utils";
|
| 5 |
+
import {
|
| 6 |
+
BlockLabel,
|
| 7 |
+
Empty,
|
| 8 |
+
IconButton,
|
| 9 |
+
ShareButton,
|
| 10 |
+
IconButtonWrapper
|
| 11 |
+
} from "@gradio/atoms";
|
| 12 |
+
import { Download } from "@gradio/icons";
|
| 13 |
+
import { get_coordinates_of_clicked_image } from "./utils";
|
| 14 |
+
import Image from "./Image.svelte";
|
| 15 |
+
import { DownloadLink } from "@gradio/wasm/svelte";
|
| 16 |
+
import { Maximize, Minimize } from "@gradio/icons";
|
| 17 |
+
|
| 18 |
+
import { Image as ImageIcon } from "@gradio/icons";
|
| 19 |
+
import { type FileData } from "@gradio/client";
|
| 20 |
+
import type { I18nFormatter } from "@gradio/utils";
|
| 21 |
+
|
| 22 |
+
export let value: null | FileData;
|
| 23 |
+
export let label: string | undefined = undefined;
|
| 24 |
+
export let show_label: boolean;
|
| 25 |
+
export let show_download_button = true;
|
| 26 |
+
export let selectable = false;
|
| 27 |
+
export let show_share_button = false;
|
| 28 |
+
export let i18n: I18nFormatter;
|
| 29 |
+
export let show_fullscreen_button = true;
|
| 30 |
+
|
| 31 |
+
const dispatch = createEventDispatcher<{
|
| 32 |
+
change: string;
|
| 33 |
+
select: SelectData;
|
| 34 |
+
}>();
|
| 35 |
+
|
| 36 |
+
const handle_click = (evt: MouseEvent): void => {
|
| 37 |
+
let coordinates = get_coordinates_of_clicked_image(evt);
|
| 38 |
+
if (coordinates) {
|
| 39 |
+
dispatch("select", { index: coordinates, value: null });
|
| 40 |
+
}
|
| 41 |
+
};
|
| 42 |
+
|
| 43 |
+
let is_full_screen = false;
|
| 44 |
+
let image_container: HTMLElement;
|
| 45 |
+
|
| 46 |
+
onMount(() => {
|
| 47 |
+
document.addEventListener("fullscreenchange", () => {
|
| 48 |
+
is_full_screen = !!document.fullscreenElement;
|
| 49 |
+
});
|
| 50 |
+
});
|
| 51 |
+
|
| 52 |
+
const toggle_full_screen = async (): Promise<void> => {
|
| 53 |
+
if (!is_full_screen) {
|
| 54 |
+
await image_container.requestFullscreen();
|
| 55 |
+
} else {
|
| 56 |
+
await document.exitFullscreen();
|
| 57 |
+
is_full_screen = !is_full_screen;
|
| 58 |
+
}
|
| 59 |
+
};
|
| 60 |
+
</script>
|
| 61 |
+
|
| 62 |
+
<BlockLabel
|
| 63 |
+
{show_label}
|
| 64 |
+
Icon={ImageIcon}
|
| 65 |
+
label={!show_label ? "" : label || i18n("image.image")}
|
| 66 |
+
/>
|
| 67 |
+
{#if value === null || !value.url}
|
| 68 |
+
<Empty unpadded_box={true} size="large"><ImageIcon /></Empty>
|
| 69 |
+
{:else}
|
| 70 |
+
<div class="image-container" bind:this={image_container}>
|
| 71 |
+
<IconButtonWrapper>
|
| 72 |
+
{#if !is_full_screen && show_fullscreen_button}
|
| 73 |
+
<IconButton
|
| 74 |
+
Icon={Maximize}
|
| 75 |
+
label={is_full_screen ? "Exit full screen" : "View in full screen"}
|
| 76 |
+
on:click={toggle_full_screen}
|
| 77 |
+
/>
|
| 78 |
+
{/if}
|
| 79 |
+
|
| 80 |
+
{#if is_full_screen && show_fullscreen_button}
|
| 81 |
+
<IconButton
|
| 82 |
+
Icon={Minimize}
|
| 83 |
+
label={is_full_screen ? "Exit full screen" : "View in full screen"}
|
| 84 |
+
on:click={toggle_full_screen}
|
| 85 |
+
/>
|
| 86 |
+
{/if}
|
| 87 |
+
|
| 88 |
+
{#if show_download_button}
|
| 89 |
+
<DownloadLink href={value.url} download={value.orig_name || "image"}>
|
| 90 |
+
<IconButton Icon={Download} label={i18n("common.download")} />
|
| 91 |
+
</DownloadLink>
|
| 92 |
+
{/if}
|
| 93 |
+
{#if show_share_button}
|
| 94 |
+
<ShareButton
|
| 95 |
+
{i18n}
|
| 96 |
+
on:share
|
| 97 |
+
on:error
|
| 98 |
+
formatter={async (value) => {
|
| 99 |
+
if (!value) return "";
|
| 100 |
+
let url = await uploadToHuggingFace(value, "url");
|
| 101 |
+
return `<img src="${url}" />`;
|
| 102 |
+
}}
|
| 103 |
+
{value}
|
| 104 |
+
/>
|
| 105 |
+
{/if}
|
| 106 |
+
</IconButtonWrapper>
|
| 107 |
+
<button on:click={handle_click}>
|
| 108 |
+
<div class:selectable class="image-frame">
|
| 109 |
+
<Image src={value.url} alt="" loading="lazy" on:load />
|
| 110 |
+
</div>
|
| 111 |
+
</button>
|
| 112 |
+
</div>
|
| 113 |
+
{/if}
|
| 114 |
+
|
| 115 |
+
<style>
|
| 116 |
+
.image-container {
|
| 117 |
+
height: 100%;
|
| 118 |
+
position: relative;
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
.image-container button {
|
| 122 |
+
width: var(--size-full);
|
| 123 |
+
height: var(--size-full);
|
| 124 |
+
border-radius: var(--radius-lg);
|
| 125 |
+
|
| 126 |
+
display: flex;
|
| 127 |
+
align-items: center;
|
| 128 |
+
justify-content: center;
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
.image-frame {
|
| 132 |
+
width: auto;
|
| 133 |
+
height: 100%;
|
| 134 |
+
display: flex;
|
| 135 |
+
align-items: center;
|
| 136 |
+
justify-content: center;
|
| 137 |
+
}
|
| 138 |
+
.image-frame :global(img) {
|
| 139 |
+
width: var(--size-full);
|
| 140 |
+
height: var(--size-full);
|
| 141 |
+
object-fit: scale-down;
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
.selectable {
|
| 145 |
+
cursor: crosshair;
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
:global(.fullscreen-controls svg) {
|
| 149 |
+
position: relative;
|
| 150 |
+
top: 0px;
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
:global(.image-container:fullscreen) {
|
| 154 |
+
background-color: black;
|
| 155 |
+
display: flex;
|
| 156 |
+
justify-content: center;
|
| 157 |
+
align-items: center;
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
:global(.image-container:fullscreen img) {
|
| 161 |
+
max-width: 90vw;
|
| 162 |
+
max-height: 90vh;
|
| 163 |
+
object-fit: scale-down;
|
| 164 |
+
}
|
| 165 |
+
</style>
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/image/shared/ImageUploader.svelte
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import { createEventDispatcher, tick } from "svelte";
|
| 3 |
+
import { BlockLabel } from "@gradio/atoms";
|
| 4 |
+
import { Image as ImageIcon } from "@gradio/icons";
|
| 5 |
+
import {
|
| 6 |
+
type SelectData,
|
| 7 |
+
type I18nFormatter,
|
| 8 |
+
type ValueData
|
| 9 |
+
} from "@gradio/utils";
|
| 10 |
+
import { get_coordinates_of_clicked_image } from "./utils";
|
| 11 |
+
import Webcam from "./Webcam.svelte";
|
| 12 |
+
|
| 13 |
+
import { Upload } from "@gradio/upload";
|
| 14 |
+
import { FileData, type Client } from "@gradio/client";
|
| 15 |
+
import ClearImage from "./ClearImage.svelte";
|
| 16 |
+
import { SelectSource } from "@gradio/atoms";
|
| 17 |
+
import Image from "./Image.svelte";
|
| 18 |
+
import type { Base64File } from "./types";
|
| 19 |
+
|
| 20 |
+
export let value: null | FileData | Base64File = null;
|
| 21 |
+
export let label: string | undefined = undefined;
|
| 22 |
+
export let show_label: boolean;
|
| 23 |
+
|
| 24 |
+
type source_type = "upload" | "webcam" | "clipboard" | "microphone" | null;
|
| 25 |
+
|
| 26 |
+
export let sources: source_type[] = ["upload", "clipboard", "webcam"];
|
| 27 |
+
export let streaming = false;
|
| 28 |
+
export let pending = false;
|
| 29 |
+
export let mirror_webcam: boolean;
|
| 30 |
+
export let selectable = false;
|
| 31 |
+
export let root: string;
|
| 32 |
+
export let i18n: I18nFormatter;
|
| 33 |
+
export let max_file_size: number | null = null;
|
| 34 |
+
export let upload: Client["upload"];
|
| 35 |
+
export let stream_handler: Client["stream"];
|
| 36 |
+
export let stream_every: number;
|
| 37 |
+
|
| 38 |
+
export let modify_stream: (state: "open" | "closed" | "waiting") => void;
|
| 39 |
+
export let set_time_limit: (arg0: number) => void;
|
| 40 |
+
|
| 41 |
+
let upload_input: Upload;
|
| 42 |
+
export let uploading = false;
|
| 43 |
+
export let active_source: source_type = null;
|
| 44 |
+
|
| 45 |
+
function handle_upload({ detail }: CustomEvent<FileData>): void {
|
| 46 |
+
// only trigger streaming event if streaming
|
| 47 |
+
if (!streaming) {
|
| 48 |
+
value = detail;
|
| 49 |
+
dispatch("upload");
|
| 50 |
+
}
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
function handle_clear(): void {
|
| 54 |
+
value = null;
|
| 55 |
+
dispatch("clear");
|
| 56 |
+
dispatch("change", null);
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
async function handle_save(
|
| 60 |
+
img_blob: Blob | any,
|
| 61 |
+
event: "change" | "stream" | "upload"
|
| 62 |
+
): Promise<void> {
|
| 63 |
+
if (event === "stream") {
|
| 64 |
+
dispatch("stream", {
|
| 65 |
+
value: { url: img_blob } as Base64File,
|
| 66 |
+
is_value_data: true
|
| 67 |
+
});
|
| 68 |
+
return;
|
| 69 |
+
}
|
| 70 |
+
pending = true;
|
| 71 |
+
const f = await upload_input.load_files([
|
| 72 |
+
new File([img_blob], `image/${streaming ? "jpeg" : "png"}`)
|
| 73 |
+
]);
|
| 74 |
+
|
| 75 |
+
if (event === "change" || event === "upload") {
|
| 76 |
+
value = f?.[0] || null;
|
| 77 |
+
await tick();
|
| 78 |
+
dispatch("change");
|
| 79 |
+
}
|
| 80 |
+
pending = false;
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
$: active_streaming = streaming && active_source === "webcam";
|
| 84 |
+
$: if (uploading && !active_streaming) value = null;
|
| 85 |
+
|
| 86 |
+
const dispatch = createEventDispatcher<{
|
| 87 |
+
change?: never;
|
| 88 |
+
stream: ValueData;
|
| 89 |
+
clear?: never;
|
| 90 |
+
drag: boolean;
|
| 91 |
+
upload?: never;
|
| 92 |
+
select: SelectData;
|
| 93 |
+
end_stream: never;
|
| 94 |
+
}>();
|
| 95 |
+
|
| 96 |
+
export let dragging = false;
|
| 97 |
+
|
| 98 |
+
$: dispatch("drag", dragging);
|
| 99 |
+
|
| 100 |
+
function handle_click(evt: MouseEvent): void {
|
| 101 |
+
let coordinates = get_coordinates_of_clicked_image(evt);
|
| 102 |
+
if (coordinates) {
|
| 103 |
+
dispatch("select", { index: coordinates, value: null });
|
| 104 |
+
}
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
$: if (!active_source && sources) {
|
| 108 |
+
active_source = sources[0];
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
async function handle_select_source(
|
| 112 |
+
source: (typeof sources)[number]
|
| 113 |
+
): Promise<void> {
|
| 114 |
+
switch (source) {
|
| 115 |
+
case "clipboard":
|
| 116 |
+
upload_input.paste_clipboard();
|
| 117 |
+
break;
|
| 118 |
+
default:
|
| 119 |
+
break;
|
| 120 |
+
}
|
| 121 |
+
}
|
| 122 |
+
</script>
|
| 123 |
+
|
| 124 |
+
<BlockLabel {show_label} Icon={ImageIcon} label={label || "Image"} />
|
| 125 |
+
|
| 126 |
+
<div data-testid="image" class="image-container">
|
| 127 |
+
{#if value?.url && !active_streaming}
|
| 128 |
+
<ClearImage
|
| 129 |
+
on:remove_image={() => {
|
| 130 |
+
value = null;
|
| 131 |
+
dispatch("clear");
|
| 132 |
+
}}
|
| 133 |
+
/>
|
| 134 |
+
{/if}
|
| 135 |
+
<div
|
| 136 |
+
class="upload-container"
|
| 137 |
+
class:reduced-height={sources.length > 1}
|
| 138 |
+
style:width={value ? "auto" : "100%"}
|
| 139 |
+
>
|
| 140 |
+
<Upload
|
| 141 |
+
hidden={value !== null || active_source === "webcam"}
|
| 142 |
+
bind:this={upload_input}
|
| 143 |
+
bind:uploading
|
| 144 |
+
bind:dragging
|
| 145 |
+
filetype={active_source === "clipboard" ? "clipboard" : "image/*"}
|
| 146 |
+
on:load={handle_upload}
|
| 147 |
+
on:error
|
| 148 |
+
{root}
|
| 149 |
+
{max_file_size}
|
| 150 |
+
disable_click={!sources.includes("upload") || value !== null}
|
| 151 |
+
{upload}
|
| 152 |
+
{stream_handler}
|
| 153 |
+
>
|
| 154 |
+
{#if value === null}
|
| 155 |
+
<slot />
|
| 156 |
+
{/if}
|
| 157 |
+
</Upload>
|
| 158 |
+
{#if active_source === "webcam" && (streaming || (!streaming && !value))}
|
| 159 |
+
<Webcam
|
| 160 |
+
{root}
|
| 161 |
+
{value}
|
| 162 |
+
on:capture={(e) => handle_save(e.detail, "change")}
|
| 163 |
+
on:stream={(e) => handle_save(e.detail, "stream")}
|
| 164 |
+
on:error
|
| 165 |
+
on:drag
|
| 166 |
+
on:upload={(e) => handle_save(e.detail, "upload")}
|
| 167 |
+
on:close_stream
|
| 168 |
+
{mirror_webcam}
|
| 169 |
+
{stream_every}
|
| 170 |
+
{streaming}
|
| 171 |
+
mode="image"
|
| 172 |
+
include_audio={false}
|
| 173 |
+
{i18n}
|
| 174 |
+
{upload}
|
| 175 |
+
bind:modify_stream
|
| 176 |
+
bind:set_time_limit
|
| 177 |
+
/>
|
| 178 |
+
{:else if value !== null && !streaming}
|
| 179 |
+
<!-- svelte-ignore a11y-click-events-have-key-events-->
|
| 180 |
+
<!-- svelte-ignore a11y-no-static-element-interactions-->
|
| 181 |
+
<div class:selectable class="image-frame" on:click={handle_click}>
|
| 182 |
+
<Image src={value.url} alt={value.alt_text} />
|
| 183 |
+
</div>
|
| 184 |
+
{/if}
|
| 185 |
+
</div>
|
| 186 |
+
{#if sources.length > 1 || sources.includes("clipboard")}
|
| 187 |
+
<SelectSource
|
| 188 |
+
{sources}
|
| 189 |
+
bind:active_source
|
| 190 |
+
{handle_clear}
|
| 191 |
+
handle_select={handle_select_source}
|
| 192 |
+
/>
|
| 193 |
+
{/if}
|
| 194 |
+
</div>
|
| 195 |
+
|
| 196 |
+
<style>
|
| 197 |
+
.image-frame :global(img) {
|
| 198 |
+
width: var(--size-full);
|
| 199 |
+
height: var(--size-full);
|
| 200 |
+
object-fit: scale-down;
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
.image-frame {
|
| 204 |
+
object-fit: cover;
|
| 205 |
+
width: 100%;
|
| 206 |
+
height: 100%;
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
.upload-container {
|
| 210 |
+
display: flex;
|
| 211 |
+
align-items: center;
|
| 212 |
+
justify-content: center;
|
| 213 |
+
|
| 214 |
+
height: 100%;
|
| 215 |
+
flex-shrink: 1;
|
| 216 |
+
max-height: 100%;
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
.reduced-height {
|
| 220 |
+
height: calc(100% - var(--size-10));
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
.image-container {
|
| 224 |
+
display: flex;
|
| 225 |
+
height: 100%;
|
| 226 |
+
flex-direction: column;
|
| 227 |
+
justify-content: center;
|
| 228 |
+
align-items: center;
|
| 229 |
+
max-height: 100%;
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
.selectable {
|
| 233 |
+
cursor: crosshair;
|
| 234 |
+
}
|
| 235 |
+
</style>
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/image/shared/index.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export { default as Image } from "./Image.svelte";
|
| 2 |
+
export { default as StaticImage } from "./ImagePreview.svelte";
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/image/shared/utils.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export const get_coordinates_of_clicked_image = (
|
| 2 |
+
evt: MouseEvent
|
| 3 |
+
): [number, number] | null => {
|
| 4 |
+
let image;
|
| 5 |
+
if (evt.currentTarget instanceof Element) {
|
| 6 |
+
image = evt.currentTarget.querySelector("img") as HTMLImageElement;
|
| 7 |
+
} else {
|
| 8 |
+
return [NaN, NaN];
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
const imageRect = image.getBoundingClientRect();
|
| 12 |
+
const xScale = image.naturalWidth / imageRect.width;
|
| 13 |
+
const yScale = image.naturalHeight / imageRect.height;
|
| 14 |
+
if (xScale > yScale) {
|
| 15 |
+
const displayed_height = image.naturalHeight / xScale;
|
| 16 |
+
const y_offset = (imageRect.height - displayed_height) / 2;
|
| 17 |
+
var x = Math.round((evt.clientX - imageRect.left) * xScale);
|
| 18 |
+
var y = Math.round((evt.clientY - imageRect.top - y_offset) * xScale);
|
| 19 |
+
} else {
|
| 20 |
+
const displayed_width = image.naturalWidth / yScale;
|
| 21 |
+
const x_offset = (imageRect.width - displayed_width) / 2;
|
| 22 |
+
var x = Math.round((evt.clientX - imageRect.left - x_offset) * yScale);
|
| 23 |
+
var y = Math.round((evt.clientY - imageRect.top) * yScale);
|
| 24 |
+
}
|
| 25 |
+
if (x < 0 || x >= image.naturalWidth || y < 0 || y >= image.naturalHeight) {
|
| 26 |
+
return null;
|
| 27 |
+
}
|
| 28 |
+
return [x, y];
|
| 29 |
+
};
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/plot/Index.svelte
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script context="module" lang="ts">
|
| 2 |
+
export { default as BasePlot } from "./shared/Plot.svelte";
|
| 3 |
+
</script>
|
| 4 |
+
|
| 5 |
+
<script lang="ts">
|
| 6 |
+
import type { Gradio, SelectData } from "@gradio/utils";
|
| 7 |
+
import Plot from "./shared/Plot.svelte";
|
| 8 |
+
|
| 9 |
+
import { Block, BlockLabel } from "@gradio/atoms";
|
| 10 |
+
import { Plot as PlotIcon } from "@gradio/icons";
|
| 11 |
+
|
| 12 |
+
import { StatusTracker } from "@gradio/statustracker";
|
| 13 |
+
import type { LoadingStatus } from "@gradio/statustracker";
|
| 14 |
+
|
| 15 |
+
type ThemeMode = "system" | "light" | "dark";
|
| 16 |
+
|
| 17 |
+
export let value: null | string = null;
|
| 18 |
+
export let elem_id = "";
|
| 19 |
+
export let elem_classes: string[] = [];
|
| 20 |
+
export let visible = true;
|
| 21 |
+
export let loading_status: LoadingStatus;
|
| 22 |
+
export let label: string;
|
| 23 |
+
export let show_label: boolean;
|
| 24 |
+
export let container = true;
|
| 25 |
+
export let scale: number | null = null;
|
| 26 |
+
export let min_width: number | undefined = undefined;
|
| 27 |
+
export let theme_mode: ThemeMode;
|
| 28 |
+
export let caption: string;
|
| 29 |
+
export let bokeh_version: string | null;
|
| 30 |
+
export let gradio: Gradio<{
|
| 31 |
+
change: never;
|
| 32 |
+
clear_status: LoadingStatus;
|
| 33 |
+
select: SelectData;
|
| 34 |
+
}>;
|
| 35 |
+
export let show_actions_button = false;
|
| 36 |
+
export let _selectable = false;
|
| 37 |
+
export let x_lim: [number, number] | null = null;
|
| 38 |
+
</script>
|
| 39 |
+
|
| 40 |
+
<Block
|
| 41 |
+
padding={false}
|
| 42 |
+
{elem_id}
|
| 43 |
+
{elem_classes}
|
| 44 |
+
{visible}
|
| 45 |
+
{container}
|
| 46 |
+
{scale}
|
| 47 |
+
{min_width}
|
| 48 |
+
allow_overflow={false}
|
| 49 |
+
>
|
| 50 |
+
<BlockLabel
|
| 51 |
+
{show_label}
|
| 52 |
+
label={label || gradio.i18n("plot.plot")}
|
| 53 |
+
Icon={PlotIcon}
|
| 54 |
+
/>
|
| 55 |
+
<StatusTracker
|
| 56 |
+
autoscroll={gradio.autoscroll}
|
| 57 |
+
i18n={gradio.i18n}
|
| 58 |
+
{...loading_status}
|
| 59 |
+
on:clear_status={() => gradio.dispatch("clear_status", loading_status)}
|
| 60 |
+
/>
|
| 61 |
+
<Plot
|
| 62 |
+
{value}
|
| 63 |
+
{theme_mode}
|
| 64 |
+
{caption}
|
| 65 |
+
{bokeh_version}
|
| 66 |
+
{show_actions_button}
|
| 67 |
+
{gradio}
|
| 68 |
+
{_selectable}
|
| 69 |
+
{x_lim}
|
| 70 |
+
on:change={() => gradio.dispatch("change")}
|
| 71 |
+
on:select={(e) => gradio.dispatch("select", e.detail)}
|
| 72 |
+
/>
|
| 73 |
+
</Block>
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/plot/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@gradio/plot",
|
| 3 |
+
"version": "0.7.1",
|
| 4 |
+
"description": "Gradio UI packages",
|
| 5 |
+
"type": "module",
|
| 6 |
+
"author": "",
|
| 7 |
+
"license": "ISC",
|
| 8 |
+
"private": false,
|
| 9 |
+
"dependencies": {
|
| 10 |
+
"@gradio/atoms": "workspace:^",
|
| 11 |
+
"@gradio/icons": "workspace:^",
|
| 12 |
+
"@gradio/statustracker": "workspace:^",
|
| 13 |
+
"@gradio/theme": "workspace:^",
|
| 14 |
+
"@gradio/utils": "workspace:^",
|
| 15 |
+
"@rollup/plugin-json": "^6.0.0",
|
| 16 |
+
"plotly.js-dist-min": "^2.10.1",
|
| 17 |
+
"vega": "^5.23.0",
|
| 18 |
+
"vega-embed": "^6.25.0",
|
| 19 |
+
"vega-lite": "^5.12.0"
|
| 20 |
+
},
|
| 21 |
+
"devDependencies": {
|
| 22 |
+
"@gradio/preview": "workspace:^"
|
| 23 |
+
},
|
| 24 |
+
"main": "./Index.svelte",
|
| 25 |
+
"main_changeset": true,
|
| 26 |
+
"exports": {
|
| 27 |
+
"./package.json": "./package.json",
|
| 28 |
+
".": {
|
| 29 |
+
"gradio": "./Index.svelte",
|
| 30 |
+
"svelte": "./dist/Index.svelte",
|
| 31 |
+
"types": "./dist/Index.svelte.d.ts"
|
| 32 |
+
},
|
| 33 |
+
"./base": {
|
| 34 |
+
"gradio": "./shared/Plot.svelte",
|
| 35 |
+
"svelte": "./dist/shared/Plot.svelte",
|
| 36 |
+
"types": "./dist/shared/Plot.svelte.d.ts"
|
| 37 |
+
}
|
| 38 |
+
},
|
| 39 |
+
"peerDependencies": {
|
| 40 |
+
"svelte": "^4.0.0"
|
| 41 |
+
},
|
| 42 |
+
"repository": {
|
| 43 |
+
"type": "git",
|
| 44 |
+
"url": "git+https://github.com/gradio-app/gradio.git",
|
| 45 |
+
"directory": "js/plot"
|
| 46 |
+
}
|
| 47 |
+
}
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/plot/shared/Plot.svelte
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
//@ts-nocheck
|
| 3 |
+
import { Plot as PlotIcon } from "@gradio/icons";
|
| 4 |
+
import { Empty } from "@gradio/atoms";
|
| 5 |
+
import type { ThemeMode } from "js/core/src/components/types";
|
| 6 |
+
import type { Gradio, SelectData } from "@gradio/utils";
|
| 7 |
+
|
| 8 |
+
export let value;
|
| 9 |
+
export let colors: string[] = [];
|
| 10 |
+
export let theme_mode: ThemeMode;
|
| 11 |
+
export let caption: string;
|
| 12 |
+
export let bokeh_version: string | null;
|
| 13 |
+
export let show_actions_button: bool;
|
| 14 |
+
export let gradio: Gradio<{
|
| 15 |
+
select: SelectData;
|
| 16 |
+
}>;
|
| 17 |
+
export let x_lim: [number, number] | null = null;
|
| 18 |
+
export let _selectable: boolean;
|
| 19 |
+
|
| 20 |
+
let PlotComponent: any = null;
|
| 21 |
+
let _type = value?.type;
|
| 22 |
+
|
| 23 |
+
const plotTypeMapping = {
|
| 24 |
+
plotly: () => import("./plot_types/PlotlyPlot.svelte"),
|
| 25 |
+
bokeh: () => import("./plot_types/BokehPlot.svelte"),
|
| 26 |
+
altair: () => import("./plot_types/AltairPlot.svelte"),
|
| 27 |
+
matplotlib: () => import("./plot_types/MatplotlibPlot.svelte")
|
| 28 |
+
};
|
| 29 |
+
|
| 30 |
+
const is_browser = typeof window !== "undefined";
|
| 31 |
+
|
| 32 |
+
$: {
|
| 33 |
+
let type = value?.type;
|
| 34 |
+
if (type !== _type) {
|
| 35 |
+
PlotComponent = null;
|
| 36 |
+
}
|
| 37 |
+
if (type && type in plotTypeMapping && is_browser) {
|
| 38 |
+
plotTypeMapping[type]().then((module) => {
|
| 39 |
+
PlotComponent = module.default;
|
| 40 |
+
});
|
| 41 |
+
}
|
| 42 |
+
}
|
| 43 |
+
</script>
|
| 44 |
+
|
| 45 |
+
{#if value && PlotComponent}
|
| 46 |
+
<svelte:component
|
| 47 |
+
this={PlotComponent}
|
| 48 |
+
{value}
|
| 49 |
+
{colors}
|
| 50 |
+
{theme_mode}
|
| 51 |
+
{caption}
|
| 52 |
+
{bokeh_version}
|
| 53 |
+
{show_actions_button}
|
| 54 |
+
{gradio}
|
| 55 |
+
{_selectable}
|
| 56 |
+
{x_lim}
|
| 57 |
+
on:load
|
| 58 |
+
on:select
|
| 59 |
+
/>
|
| 60 |
+
{:else}
|
| 61 |
+
<Empty unpadded_box={true} size="large"><PlotIcon /></Empty>
|
| 62 |
+
{/if}
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/plot/shared/plot_types/AltairPlot.svelte
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
//@ts-nocheck
|
| 3 |
+
import { set_config } from "./altair_utils";
|
| 4 |
+
import { onMount, onDestroy } from "svelte";
|
| 5 |
+
import type { TopLevelSpec as Spec } from "vega-lite";
|
| 6 |
+
import vegaEmbed from "vega-embed";
|
| 7 |
+
import type { Gradio, SelectData } from "@gradio/utils";
|
| 8 |
+
import type { View } from "vega";
|
| 9 |
+
|
| 10 |
+
export let value;
|
| 11 |
+
export let colors: string[] = [];
|
| 12 |
+
export let caption: string;
|
| 13 |
+
export let show_actions_button: bool;
|
| 14 |
+
export let gradio: Gradio<{
|
| 15 |
+
select: SelectData;
|
| 16 |
+
}>;
|
| 17 |
+
let element: HTMLElement;
|
| 18 |
+
let parent_element: HTMLElement;
|
| 19 |
+
let view: View;
|
| 20 |
+
export let _selectable: bool;
|
| 21 |
+
|
| 22 |
+
let computed_style = window.getComputedStyle(document.body);
|
| 23 |
+
|
| 24 |
+
let old_spec: Spec;
|
| 25 |
+
let spec_width: number;
|
| 26 |
+
$: plot = value?.plot;
|
| 27 |
+
$: spec = JSON.parse(plot) as Spec;
|
| 28 |
+
$: if (spec && spec.params && !_selectable) {
|
| 29 |
+
spec.params = spec.params.filter((param) => param.name !== "brush");
|
| 30 |
+
}
|
| 31 |
+
$: if (old_spec !== spec) {
|
| 32 |
+
old_spec = spec;
|
| 33 |
+
spec_width = spec.width;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
$: if (value.chart) {
|
| 37 |
+
spec = set_config(spec, computed_style, value.chart as string, colors);
|
| 38 |
+
}
|
| 39 |
+
$: fit_width_to_parent =
|
| 40 |
+
spec.encoding?.column?.field ||
|
| 41 |
+
spec.encoding?.row?.field ||
|
| 42 |
+
value.chart === undefined
|
| 43 |
+
? false
|
| 44 |
+
: true; // vega seems to glitch with width when orientation is set
|
| 45 |
+
|
| 46 |
+
const get_width = (): number => {
|
| 47 |
+
return Math.min(
|
| 48 |
+
parent_element.offsetWidth,
|
| 49 |
+
spec_width || parent_element.offsetWidth
|
| 50 |
+
);
|
| 51 |
+
};
|
| 52 |
+
let resize_callback = (): void => {};
|
| 53 |
+
const renderPlot = (): void => {
|
| 54 |
+
if (fit_width_to_parent) {
|
| 55 |
+
spec.width = get_width();
|
| 56 |
+
}
|
| 57 |
+
vegaEmbed(element, spec, { actions: show_actions_button }).then(
|
| 58 |
+
function (result): void {
|
| 59 |
+
view = result.view;
|
| 60 |
+
resize_callback = () => {
|
| 61 |
+
view.signal("width", get_width()).run();
|
| 62 |
+
};
|
| 63 |
+
|
| 64 |
+
if (!_selectable) return;
|
| 65 |
+
const callback = (event, item): void => {
|
| 66 |
+
const brushValue = view.signal("brush");
|
| 67 |
+
if (brushValue) {
|
| 68 |
+
if (Object.keys(brushValue).length === 0) {
|
| 69 |
+
gradio.dispatch("select", {
|
| 70 |
+
value: null,
|
| 71 |
+
index: null,
|
| 72 |
+
selected: false
|
| 73 |
+
});
|
| 74 |
+
} else {
|
| 75 |
+
const key = Object.keys(brushValue)[0];
|
| 76 |
+
let range: [number, number] = brushValue[key].map(
|
| 77 |
+
(x) => x / 1000
|
| 78 |
+
);
|
| 79 |
+
gradio.dispatch("select", {
|
| 80 |
+
value: brushValue,
|
| 81 |
+
index: range,
|
| 82 |
+
selected: true
|
| 83 |
+
});
|
| 84 |
+
}
|
| 85 |
+
}
|
| 86 |
+
};
|
| 87 |
+
view.addEventListener("mouseup", callback);
|
| 88 |
+
view.addEventListener("touchup", callback);
|
| 89 |
+
}
|
| 90 |
+
);
|
| 91 |
+
};
|
| 92 |
+
let resizeObserver = new ResizeObserver(() => {
|
| 93 |
+
if (fit_width_to_parent && spec.width !== parent_element.offsetWidth) {
|
| 94 |
+
resize_callback();
|
| 95 |
+
}
|
| 96 |
+
});
|
| 97 |
+
onMount(() => {
|
| 98 |
+
renderPlot();
|
| 99 |
+
resizeObserver.observe(parent_element);
|
| 100 |
+
});
|
| 101 |
+
onDestroy(() => {
|
| 102 |
+
resizeObserver.disconnect();
|
| 103 |
+
});
|
| 104 |
+
</script>
|
| 105 |
+
|
| 106 |
+
<div data-testid={"altair"} class="altair layout" bind:this={parent_element}>
|
| 107 |
+
<div bind:this={element}></div>
|
| 108 |
+
{#if caption}
|
| 109 |
+
<div class="caption layout">
|
| 110 |
+
{caption}
|
| 111 |
+
</div>
|
| 112 |
+
{/if}
|
| 113 |
+
</div>
|
| 114 |
+
|
| 115 |
+
<style>
|
| 116 |
+
.altair :global(canvas) {
|
| 117 |
+
padding: 6px;
|
| 118 |
+
}
|
| 119 |
+
.altair :global(.vega-embed) {
|
| 120 |
+
padding: 0px !important;
|
| 121 |
+
}
|
| 122 |
+
.altair :global(.vega-actions) {
|
| 123 |
+
right: 0px !important;
|
| 124 |
+
}
|
| 125 |
+
.layout {
|
| 126 |
+
display: flex;
|
| 127 |
+
flex-direction: column;
|
| 128 |
+
justify-content: center;
|
| 129 |
+
align-items: center;
|
| 130 |
+
width: var(--size-full);
|
| 131 |
+
height: var(--size-full);
|
| 132 |
+
color: var(--body-text-color);
|
| 133 |
+
}
|
| 134 |
+
.altair {
|
| 135 |
+
display: flex;
|
| 136 |
+
flex-direction: column;
|
| 137 |
+
justify-content: center;
|
| 138 |
+
align-items: center;
|
| 139 |
+
width: var(--size-full);
|
| 140 |
+
height: var(--size-full);
|
| 141 |
+
}
|
| 142 |
+
.caption {
|
| 143 |
+
font-size: var(--text-sm);
|
| 144 |
+
margin-bottom: 6px;
|
| 145 |
+
}
|
| 146 |
+
:global(#vg-tooltip-element) {
|
| 147 |
+
font-family: var(--font) !important;
|
| 148 |
+
font-size: var(--text-xs) !important;
|
| 149 |
+
box-shadow: none !important;
|
| 150 |
+
background-color: var(--block-background-fill) !important;
|
| 151 |
+
border: 1px solid var(--border-color-primary) !important;
|
| 152 |
+
color: var(--body-text-color) !important;
|
| 153 |
+
}
|
| 154 |
+
:global(#vg-tooltip-element .key) {
|
| 155 |
+
color: var(--body-text-color-subdued) !important;
|
| 156 |
+
}
|
| 157 |
+
</style>
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/plot/shared/plot_types/MatplotlibPlot.svelte
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
export let value;
|
| 3 |
+
|
| 4 |
+
$: plot = value?.plot;
|
| 5 |
+
</script>
|
| 6 |
+
|
| 7 |
+
<div data-testid={"matplotlib"} class="matplotlib layout">
|
| 8 |
+
<img
|
| 9 |
+
src={plot}
|
| 10 |
+
alt={`${value.chart} plot visualising provided data`}
|
| 11 |
+
on:load
|
| 12 |
+
/>
|
| 13 |
+
</div>
|
| 14 |
+
|
| 15 |
+
<style>
|
| 16 |
+
.layout {
|
| 17 |
+
display: flex;
|
| 18 |
+
flex-direction: column;
|
| 19 |
+
justify-content: center;
|
| 20 |
+
align-items: center;
|
| 21 |
+
width: var(--size-full);
|
| 22 |
+
height: var(--size-full);
|
| 23 |
+
color: var(--body-text-color);
|
| 24 |
+
}
|
| 25 |
+
.matplotlib img {
|
| 26 |
+
object-fit: contain;
|
| 27 |
+
}
|
| 28 |
+
</style>
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/plot/shared/plot_types/PlotlyPlot.svelte
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
//@ts-nocheck
|
| 3 |
+
import Plotly from "plotly.js-dist-min";
|
| 4 |
+
import { afterUpdate, createEventDispatcher } from "svelte";
|
| 5 |
+
|
| 6 |
+
export let value;
|
| 7 |
+
|
| 8 |
+
$: plot = value?.plot;
|
| 9 |
+
|
| 10 |
+
let plot_div;
|
| 11 |
+
let plotly_global_style;
|
| 12 |
+
|
| 13 |
+
const dispatch = createEventDispatcher<{ load: undefined }>();
|
| 14 |
+
|
| 15 |
+
function load_plotly_css(): void {
|
| 16 |
+
if (!plotly_global_style) {
|
| 17 |
+
plotly_global_style = document.getElementById("plotly.js-style-global");
|
| 18 |
+
const plotly_style_clone = plotly_global_style.cloneNode();
|
| 19 |
+
plot_div.appendChild(plotly_style_clone);
|
| 20 |
+
for (const rule of plotly_global_style.sheet.cssRules) {
|
| 21 |
+
plotly_style_clone.sheet.insertRule(rule.cssText);
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
afterUpdate(async () => {
|
| 27 |
+
load_plotly_css();
|
| 28 |
+
|
| 29 |
+
let plotObj = JSON.parse(plot);
|
| 30 |
+
|
| 31 |
+
// the docs aren't very good but this works
|
| 32 |
+
plotObj.config = plotObj.config || {};
|
| 33 |
+
plotObj.config.responsive = true;
|
| 34 |
+
plotObj.responsive = true;
|
| 35 |
+
plotObj.layout.autosize = true;
|
| 36 |
+
|
| 37 |
+
plotObj.layout.title
|
| 38 |
+
? (plotObj.layout.margin = { autoexpand: true })
|
| 39 |
+
: (plotObj.layout.margin = { l: 0, r: 0, b: 0, t: 0 });
|
| 40 |
+
|
| 41 |
+
Plotly.react(plot_div, plotObj.data, plotObj.layout, plotObj.config);
|
| 42 |
+
Plotly.Plots.resize(plot_div);
|
| 43 |
+
|
| 44 |
+
plot_div.on("plotly_afterplot", () => {
|
| 45 |
+
dispatch("load");
|
| 46 |
+
});
|
| 47 |
+
});
|
| 48 |
+
</script>
|
| 49 |
+
|
| 50 |
+
<div data-testid={"plotly"} bind:this={plot_div} />
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/preview/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@gradio/preview",
|
| 3 |
+
"version": "0.12.0",
|
| 4 |
+
"description": "Gradio UI packages",
|
| 5 |
+
"type": "module",
|
| 6 |
+
"main": "dist/index.js",
|
| 7 |
+
"author": "",
|
| 8 |
+
"license": "ISC",
|
| 9 |
+
"private": false,
|
| 10 |
+
"scripts": {
|
| 11 |
+
"build:rollup": "rollup -c",
|
| 12 |
+
"build:vite": "vite build --ssr",
|
| 13 |
+
"build": "pnpm build:rollup && pnpm build:vite"
|
| 14 |
+
},
|
| 15 |
+
"devDependencies": {
|
| 16 |
+
"@rollup/plugin-commonjs": "^25.0.4",
|
| 17 |
+
"@rollup/plugin-json": "^6.0.0",
|
| 18 |
+
"@rollup/plugin-node-resolve": "^15.1.0",
|
| 19 |
+
"@rollup/plugin-typescript": "^11.1.2",
|
| 20 |
+
"rollup": "^3.28.0"
|
| 21 |
+
},
|
| 22 |
+
"dependencies": {
|
| 23 |
+
"@originjs/vite-plugin-commonjs": "^1.0.3",
|
| 24 |
+
"@rollup/plugin-sucrase": "^5.0.1",
|
| 25 |
+
"@sveltejs/vite-plugin-svelte": "^3.1.0",
|
| 26 |
+
"@types/which": "^3.0.0",
|
| 27 |
+
"coffeescript": "^2.7.0",
|
| 28 |
+
"lightningcss": "^1.21.7",
|
| 29 |
+
"pug": "^3.0.2",
|
| 30 |
+
"sass": "^1.66.1",
|
| 31 |
+
"stylus": "^0.63.0",
|
| 32 |
+
"sucrase": "^3.34.0",
|
| 33 |
+
"sugarss": "^4.0.1",
|
| 34 |
+
"svelte-hmr": "^0.16.0",
|
| 35 |
+
"svelte-preprocess": "^5.0.4",
|
| 36 |
+
"typescript": "^5.0.0",
|
| 37 |
+
"vite": "^5.2.9",
|
| 38 |
+
"which": "4.0.0",
|
| 39 |
+
"yootils": "^0.3.1"
|
| 40 |
+
},
|
| 41 |
+
"optionalDependencies": {
|
| 42 |
+
"svelte": "^4.0.0"
|
| 43 |
+
},
|
| 44 |
+
"exports": {
|
| 45 |
+
".": {
|
| 46 |
+
"default": "./dist/index.js",
|
| 47 |
+
"import": "./dist/index.js",
|
| 48 |
+
"gradio": "./src/index.ts",
|
| 49 |
+
"svelte": "./dist/src/index.js",
|
| 50 |
+
"types": "./dist/index.d.ts"
|
| 51 |
+
},
|
| 52 |
+
"./package.json": "./package.json"
|
| 53 |
+
}
|
| 54 |
+
}
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/preview/rollup.config.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// @ts-nocheck
|
| 2 |
+
import { createRequire } from "node:module";
|
| 3 |
+
import { join } from "path";
|
| 4 |
+
|
| 5 |
+
import ts from "@rollup/plugin-typescript";
|
| 6 |
+
import node from "@rollup/plugin-node-resolve";
|
| 7 |
+
import cjs from "@rollup/plugin-commonjs";
|
| 8 |
+
import json from "@rollup/plugin-json";
|
| 9 |
+
|
| 10 |
+
const onwarn = (warning, warn) => {
|
| 11 |
+
if (warning.plugin === "typescript") return;
|
| 12 |
+
if (warning.code === "CIRCULAR_DEPENDENCY") return;
|
| 13 |
+
if (warning.code === "EVAL") return;
|
| 14 |
+
|
| 15 |
+
warn(warning);
|
| 16 |
+
};
|
| 17 |
+
|
| 18 |
+
const require = createRequire(import.meta.url);
|
| 19 |
+
const dir = require.resolve("./package.json");
|
| 20 |
+
|
| 21 |
+
const output_svelte_dir = join(
|
| 22 |
+
dir,
|
| 23 |
+
"..",
|
| 24 |
+
"..",
|
| 25 |
+
"..",
|
| 26 |
+
"gradio",
|
| 27 |
+
"templates",
|
| 28 |
+
"frontend",
|
| 29 |
+
"assets",
|
| 30 |
+
"svelte"
|
| 31 |
+
);
|
| 32 |
+
|
| 33 |
+
const plugins = [node({ preferBuiltins: true }), json(), cjs(), ts()];
|
| 34 |
+
|
| 35 |
+
export default [
|
| 36 |
+
{
|
| 37 |
+
input: "src/svelte-submodules.ts",
|
| 38 |
+
output: {
|
| 39 |
+
file: join(output_svelte_dir, "svelte-submodules.js"),
|
| 40 |
+
format: "esm"
|
| 41 |
+
},
|
| 42 |
+
onwarn,
|
| 43 |
+
plugins
|
| 44 |
+
},
|
| 45 |
+
{
|
| 46 |
+
input: "src/svelte-internal.ts",
|
| 47 |
+
output: {
|
| 48 |
+
file: join(output_svelte_dir, "svelte.js"),
|
| 49 |
+
format: "esm"
|
| 50 |
+
},
|
| 51 |
+
onwarn,
|
| 52 |
+
plugins
|
| 53 |
+
}
|
| 54 |
+
];
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/preview/src/__pycache__/examine.cpython-310.pyc
ADDED
|
Binary file (2.37 kB). View file
|
|
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/preview/src/build.ts
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as fs from "fs";
|
| 2 |
+
import { join } from "path";
|
| 3 |
+
import { build } from "vite";
|
| 4 |
+
import { plugins, make_gradio_plugin } from "./plugins";
|
| 5 |
+
import type { PreRenderedChunk } from "rollup";
|
| 6 |
+
import { examine_module } from "./index";
|
| 7 |
+
|
| 8 |
+
interface BuildOptions {
|
| 9 |
+
component_dir: string;
|
| 10 |
+
root_dir: string;
|
| 11 |
+
python_path: string;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
export async function make_build({
|
| 15 |
+
component_dir,
|
| 16 |
+
root_dir,
|
| 17 |
+
python_path
|
| 18 |
+
}: BuildOptions): Promise<void> {
|
| 19 |
+
process.env.gradio_mode = "dev";
|
| 20 |
+
const svelte_dir = join(root_dir, "assets", "svelte");
|
| 21 |
+
|
| 22 |
+
const module_meta = examine_module(
|
| 23 |
+
component_dir,
|
| 24 |
+
root_dir,
|
| 25 |
+
python_path,
|
| 26 |
+
"build"
|
| 27 |
+
);
|
| 28 |
+
try {
|
| 29 |
+
for (const comp of module_meta) {
|
| 30 |
+
const template_dir = comp.template_dir;
|
| 31 |
+
const source_dir = comp.frontend_dir;
|
| 32 |
+
|
| 33 |
+
const pkg = JSON.parse(
|
| 34 |
+
fs.readFileSync(join(source_dir, "package.json"), "utf-8")
|
| 35 |
+
);
|
| 36 |
+
let component_config = {
|
| 37 |
+
plugins: [],
|
| 38 |
+
svelte: {
|
| 39 |
+
preprocess: []
|
| 40 |
+
},
|
| 41 |
+
build: {
|
| 42 |
+
target: []
|
| 43 |
+
},
|
| 44 |
+
optimizeDeps: {}
|
| 45 |
+
};
|
| 46 |
+
|
| 47 |
+
if (
|
| 48 |
+
comp.frontend_dir &&
|
| 49 |
+
fs.existsSync(join(comp.frontend_dir, "gradio.config.js"))
|
| 50 |
+
) {
|
| 51 |
+
const m = await import(
|
| 52 |
+
join("file://" + comp.frontend_dir, "gradio.config.js")
|
| 53 |
+
);
|
| 54 |
+
|
| 55 |
+
component_config.plugins = m.default.plugins || [];
|
| 56 |
+
component_config.svelte.preprocess = m.default.svelte?.preprocess || [];
|
| 57 |
+
component_config.build.target = m.default.build?.target || "modules";
|
| 58 |
+
component_config.optimizeDeps = m.default.optimizeDeps || {};
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
const exports: (string | any)[][] = [
|
| 62 |
+
["component", pkg.exports["."] as object],
|
| 63 |
+
["example", pkg.exports["./example"] as object]
|
| 64 |
+
].filter(([_, path]) => !!path);
|
| 65 |
+
|
| 66 |
+
for (const [entry, path] of exports) {
|
| 67 |
+
try {
|
| 68 |
+
const x = await build({
|
| 69 |
+
root: source_dir,
|
| 70 |
+
configFile: false,
|
| 71 |
+
plugins: [
|
| 72 |
+
...plugins(component_config),
|
| 73 |
+
make_gradio_plugin({ mode: "build", svelte_dir })
|
| 74 |
+
],
|
| 75 |
+
resolve: {
|
| 76 |
+
conditions: ["gradio"]
|
| 77 |
+
},
|
| 78 |
+
build: {
|
| 79 |
+
target: component_config.build.target,
|
| 80 |
+
emptyOutDir: true,
|
| 81 |
+
outDir: join(template_dir, entry as string),
|
| 82 |
+
lib: {
|
| 83 |
+
entry: join(source_dir, (path as any).gradio),
|
| 84 |
+
fileName: "index.js",
|
| 85 |
+
formats: ["es"]
|
| 86 |
+
},
|
| 87 |
+
minify: true,
|
| 88 |
+
rollupOptions: {
|
| 89 |
+
output: {
|
| 90 |
+
entryFileNames: (chunkInfo: PreRenderedChunk) => {
|
| 91 |
+
if (chunkInfo.isEntry) {
|
| 92 |
+
return "index.js";
|
| 93 |
+
}
|
| 94 |
+
return `${chunkInfo.name.toLocaleLowerCase()}.js`;
|
| 95 |
+
}
|
| 96 |
+
}
|
| 97 |
+
}
|
| 98 |
+
}
|
| 99 |
+
});
|
| 100 |
+
} catch (e) {
|
| 101 |
+
throw e;
|
| 102 |
+
}
|
| 103 |
+
}
|
| 104 |
+
}
|
| 105 |
+
} catch (e) {
|
| 106 |
+
throw e;
|
| 107 |
+
}
|
| 108 |
+
}
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/preview/src/compiler.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export * from "svelte/compiler";
|
| 2 |
+
export * as default from "svelte/compiler";
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/preview/src/dev.ts
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { join } from "path";
|
| 2 |
+
import * as fs from "fs";
|
| 3 |
+
import { createServer, createLogger } from "vite";
|
| 4 |
+
import { plugins, make_gradio_plugin } from "./plugins";
|
| 5 |
+
import { examine_module } from "./index";
|
| 6 |
+
import type { PreprocessorGroup } from "svelte/compiler";
|
| 7 |
+
|
| 8 |
+
const vite_messages_to_ignore = [
|
| 9 |
+
"Default and named imports from CSS files are deprecated.",
|
| 10 |
+
"The above dynamic import cannot be analyzed by Vite."
|
| 11 |
+
];
|
| 12 |
+
|
| 13 |
+
const logger = createLogger();
|
| 14 |
+
const originalWarning = logger.warn;
|
| 15 |
+
logger.warn = (msg, options) => {
|
| 16 |
+
if (vite_messages_to_ignore.some((m) => msg.includes(m))) return;
|
| 17 |
+
|
| 18 |
+
originalWarning(msg, options);
|
| 19 |
+
};
|
| 20 |
+
|
| 21 |
+
interface ServerOptions {
|
| 22 |
+
component_dir: string;
|
| 23 |
+
root_dir: string;
|
| 24 |
+
frontend_port: number;
|
| 25 |
+
backend_port: number;
|
| 26 |
+
host: string;
|
| 27 |
+
python_path: string;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
export async function create_server({
|
| 31 |
+
component_dir,
|
| 32 |
+
root_dir,
|
| 33 |
+
frontend_port,
|
| 34 |
+
backend_port,
|
| 35 |
+
host,
|
| 36 |
+
python_path
|
| 37 |
+
}: ServerOptions): Promise<void> {
|
| 38 |
+
process.env.gradio_mode = "dev";
|
| 39 |
+
const [imports, config] = await generate_imports(
|
| 40 |
+
component_dir,
|
| 41 |
+
root_dir,
|
| 42 |
+
python_path
|
| 43 |
+
);
|
| 44 |
+
|
| 45 |
+
const svelte_dir = join(root_dir, "assets", "svelte");
|
| 46 |
+
|
| 47 |
+
try {
|
| 48 |
+
const server = await createServer({
|
| 49 |
+
customLogger: logger,
|
| 50 |
+
mode: "development",
|
| 51 |
+
configFile: false,
|
| 52 |
+
root: root_dir,
|
| 53 |
+
server: {
|
| 54 |
+
port: frontend_port,
|
| 55 |
+
host: host,
|
| 56 |
+
fs: {
|
| 57 |
+
allow: [root_dir, component_dir]
|
| 58 |
+
}
|
| 59 |
+
},
|
| 60 |
+
resolve: {
|
| 61 |
+
conditions: ["gradio"]
|
| 62 |
+
},
|
| 63 |
+
build: {
|
| 64 |
+
target: config.build.target
|
| 65 |
+
},
|
| 66 |
+
optimizeDeps: config.optimizeDeps,
|
| 67 |
+
plugins: [
|
| 68 |
+
...plugins(config),
|
| 69 |
+
make_gradio_plugin({
|
| 70 |
+
mode: "dev",
|
| 71 |
+
backend_port,
|
| 72 |
+
svelte_dir,
|
| 73 |
+
imports
|
| 74 |
+
})
|
| 75 |
+
]
|
| 76 |
+
});
|
| 77 |
+
|
| 78 |
+
await server.listen();
|
| 79 |
+
|
| 80 |
+
console.info(
|
| 81 |
+
`[orange3]Frontend Server[/] (Go here): ${server.resolvedUrls?.local}`
|
| 82 |
+
);
|
| 83 |
+
} catch (e) {
|
| 84 |
+
console.error(e);
|
| 85 |
+
}
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
function find_frontend_folders(start_path: string): string[] {
|
| 89 |
+
if (!fs.existsSync(start_path)) {
|
| 90 |
+
console.warn("No directory found at:", start_path);
|
| 91 |
+
return [];
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
if (fs.existsSync(join(start_path, "pyproject.toml"))) return [start_path];
|
| 95 |
+
|
| 96 |
+
const results: string[] = [];
|
| 97 |
+
const dir = fs.readdirSync(start_path);
|
| 98 |
+
dir.forEach((dir) => {
|
| 99 |
+
const filepath = join(start_path, dir);
|
| 100 |
+
if (fs.existsSync(filepath)) {
|
| 101 |
+
if (fs.existsSync(join(filepath, "pyproject.toml")))
|
| 102 |
+
results.push(filepath);
|
| 103 |
+
}
|
| 104 |
+
});
|
| 105 |
+
|
| 106 |
+
return results;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
function to_posix(_path: string): string {
|
| 110 |
+
const isExtendedLengthPath = /^\\\\\?\\/.test(_path);
|
| 111 |
+
const hasNonAscii = /[^\u0000-\u0080]+/.test(_path);
|
| 112 |
+
|
| 113 |
+
if (isExtendedLengthPath || hasNonAscii) {
|
| 114 |
+
return _path;
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
return _path.replace(/\\/g, "/");
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
export interface ComponentConfig {
|
| 121 |
+
plugins: any[];
|
| 122 |
+
svelte: {
|
| 123 |
+
preprocess: PreprocessorGroup[];
|
| 124 |
+
extensions?: string[];
|
| 125 |
+
};
|
| 126 |
+
build: {
|
| 127 |
+
target: string | string[];
|
| 128 |
+
};
|
| 129 |
+
optimizeDeps: object;
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
async function generate_imports(
|
| 133 |
+
component_dir: string,
|
| 134 |
+
root: string,
|
| 135 |
+
python_path: string
|
| 136 |
+
): Promise<[string, ComponentConfig]> {
|
| 137 |
+
const components = find_frontend_folders(component_dir);
|
| 138 |
+
|
| 139 |
+
const component_entries = components.flatMap((component) => {
|
| 140 |
+
return examine_module(component, root, python_path, "dev");
|
| 141 |
+
});
|
| 142 |
+
if (component_entries.length === 0) {
|
| 143 |
+
console.info(
|
| 144 |
+
`No custom components were found in ${component_dir}. It is likely that dev mode does not work properly. Please pass the --gradio-path and --python-path CLI arguments so that gradio uses the right executables.`
|
| 145 |
+
);
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
let component_config: ComponentConfig = {
|
| 149 |
+
plugins: [],
|
| 150 |
+
svelte: {
|
| 151 |
+
preprocess: []
|
| 152 |
+
},
|
| 153 |
+
build: {
|
| 154 |
+
target: []
|
| 155 |
+
},
|
| 156 |
+
optimizeDeps: {}
|
| 157 |
+
};
|
| 158 |
+
|
| 159 |
+
await Promise.all(
|
| 160 |
+
component_entries.map(async (component) => {
|
| 161 |
+
if (
|
| 162 |
+
component.frontend_dir &&
|
| 163 |
+
fs.existsSync(join(component.frontend_dir, "gradio.config.js"))
|
| 164 |
+
) {
|
| 165 |
+
const m = await import(
|
| 166 |
+
join("file://" + component.frontend_dir, "gradio.config.js")
|
| 167 |
+
);
|
| 168 |
+
|
| 169 |
+
component_config.plugins = m.default.plugins || [];
|
| 170 |
+
component_config.svelte.preprocess = m.default.svelte?.preprocess || [];
|
| 171 |
+
component_config.build.target = m.default.build?.target || "modules";
|
| 172 |
+
component_config.optimizeDeps = m.default.optimizeDeps || {};
|
| 173 |
+
} else {
|
| 174 |
+
}
|
| 175 |
+
})
|
| 176 |
+
);
|
| 177 |
+
|
| 178 |
+
const imports = component_entries.reduce((acc, component) => {
|
| 179 |
+
const pkg = JSON.parse(
|
| 180 |
+
fs.readFileSync(join(component.frontend_dir, "package.json"), "utf-8")
|
| 181 |
+
);
|
| 182 |
+
|
| 183 |
+
const exports: Record<string, any | undefined> = {
|
| 184 |
+
component: pkg.exports["."],
|
| 185 |
+
example: pkg.exports["./example"]
|
| 186 |
+
};
|
| 187 |
+
|
| 188 |
+
if (!exports.component)
|
| 189 |
+
throw new Error(
|
| 190 |
+
"Could not find component entry point. Please check the exports field of your package.json."
|
| 191 |
+
);
|
| 192 |
+
|
| 193 |
+
const example = exports.example
|
| 194 |
+
? `example: () => import("/@fs/${to_posix(
|
| 195 |
+
join(component.frontend_dir, exports.example.gradio)
|
| 196 |
+
)}"),\n`
|
| 197 |
+
: "";
|
| 198 |
+
return `${acc}"${component.component_class_id}": {
|
| 199 |
+
${example}
|
| 200 |
+
component: () => import("/@fs/${to_posix(
|
| 201 |
+
join(component.frontend_dir, exports.component.gradio)
|
| 202 |
+
)}")
|
| 203 |
+
},\n`;
|
| 204 |
+
}, "");
|
| 205 |
+
|
| 206 |
+
return [`{${imports}}`, component_config];
|
| 207 |
+
}
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/preview/src/index.ts
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { type ChildProcess, spawn, spawnSync } from "node:child_process";
|
| 2 |
+
import * as net from "net";
|
| 3 |
+
|
| 4 |
+
import { create_server, type ComponentConfig } from "./dev";
|
| 5 |
+
import { make_build } from "./build";
|
| 6 |
+
import { join, dirname } from "path";
|
| 7 |
+
import { fileURLToPath } from "url";
|
| 8 |
+
|
| 9 |
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
| 10 |
+
|
| 11 |
+
export interface ComponentMeta {
|
| 12 |
+
name: string;
|
| 13 |
+
template_dir: string;
|
| 14 |
+
frontend_dir: string;
|
| 15 |
+
component_class_id: string;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
const args = process.argv.slice(2);
|
| 19 |
+
// get individual args as `--arg value` or `value`
|
| 20 |
+
|
| 21 |
+
function parse_args(args: string[]): Record<string, string> {
|
| 22 |
+
const arg_map: Record<string, string> = {};
|
| 23 |
+
for (let i = 0; i < args.length; i++) {
|
| 24 |
+
const arg = args[i];
|
| 25 |
+
if (arg.startsWith("--")) {
|
| 26 |
+
const name = arg.slice(2);
|
| 27 |
+
const value = args[i + 1];
|
| 28 |
+
arg_map[name] = value;
|
| 29 |
+
i++;
|
| 30 |
+
}
|
| 31 |
+
}
|
| 32 |
+
return arg_map;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
const parsed_args = parse_args(args);
|
| 36 |
+
|
| 37 |
+
async function run(): Promise<void> {
|
| 38 |
+
if (parsed_args.mode === "build") {
|
| 39 |
+
await make_build({
|
| 40 |
+
component_dir: parsed_args["component-directory"],
|
| 41 |
+
root_dir: parsed_args.root,
|
| 42 |
+
python_path: parsed_args["python-path"]
|
| 43 |
+
});
|
| 44 |
+
} else {
|
| 45 |
+
const [backend_port, frontend_port] = await find_free_ports(7860, 8860);
|
| 46 |
+
const options = {
|
| 47 |
+
component_dir: parsed_args["component-directory"],
|
| 48 |
+
root_dir: parsed_args.root,
|
| 49 |
+
frontend_port,
|
| 50 |
+
backend_port,
|
| 51 |
+
host: parsed_args.host,
|
| 52 |
+
...parsed_args
|
| 53 |
+
};
|
| 54 |
+
process.env.GRADIO_BACKEND_PORT = backend_port.toString();
|
| 55 |
+
|
| 56 |
+
const _process = spawn(
|
| 57 |
+
parsed_args["gradio-path"],
|
| 58 |
+
[parsed_args.app, "--watch-dirs", options.component_dir],
|
| 59 |
+
{
|
| 60 |
+
shell: true,
|
| 61 |
+
stdio: "pipe",
|
| 62 |
+
cwd: process.cwd(),
|
| 63 |
+
env: {
|
| 64 |
+
...process.env,
|
| 65 |
+
GRADIO_SERVER_PORT: backend_port.toString(),
|
| 66 |
+
PYTHONUNBUFFERED: "true"
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
);
|
| 70 |
+
|
| 71 |
+
_process.stdout.setEncoding("utf8");
|
| 72 |
+
_process.stderr.setEncoding("utf8");
|
| 73 |
+
|
| 74 |
+
function std_out(mode: "stdout" | "stderr") {
|
| 75 |
+
return function (data: Buffer): void {
|
| 76 |
+
const _data = data.toString();
|
| 77 |
+
|
| 78 |
+
if (_data.includes("Running on")) {
|
| 79 |
+
create_server({
|
| 80 |
+
component_dir: options.component_dir,
|
| 81 |
+
root_dir: options.root_dir,
|
| 82 |
+
frontend_port,
|
| 83 |
+
backend_port,
|
| 84 |
+
host: options.host,
|
| 85 |
+
python_path: parsed_args["python-path"]
|
| 86 |
+
});
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
process[mode].write(_data);
|
| 90 |
+
};
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
_process.stdout.on("data", std_out("stdout"));
|
| 94 |
+
_process.stderr.on("data", std_out("stderr"));
|
| 95 |
+
_process.on("exit", () => kill_process(_process));
|
| 96 |
+
_process.on("close", () => kill_process(_process));
|
| 97 |
+
_process.on("disconnect", () => kill_process(_process));
|
| 98 |
+
}
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
function kill_process(process: ChildProcess): void {
|
| 102 |
+
process.kill("SIGKILL");
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
export { create_server };
|
| 106 |
+
|
| 107 |
+
run();
|
| 108 |
+
|
| 109 |
+
export async function find_free_ports(
|
| 110 |
+
start_port: number,
|
| 111 |
+
end_port: number
|
| 112 |
+
): Promise<[number, number]> {
|
| 113 |
+
let found_ports: number[] = [];
|
| 114 |
+
|
| 115 |
+
for (let port = start_port; port < end_port; port++) {
|
| 116 |
+
if (await is_free_port(port)) {
|
| 117 |
+
found_ports.push(port);
|
| 118 |
+
if (found_ports.length === 2) {
|
| 119 |
+
return [found_ports[0], found_ports[1]];
|
| 120 |
+
}
|
| 121 |
+
}
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
throw new Error(
|
| 125 |
+
`Could not find free ports: there were not enough ports available.`
|
| 126 |
+
);
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
export function is_free_port(port: number): Promise<boolean> {
|
| 130 |
+
return new Promise((accept, reject) => {
|
| 131 |
+
const sock = net.createConnection(port, "127.0.0.1");
|
| 132 |
+
sock.once("connect", () => {
|
| 133 |
+
sock.end();
|
| 134 |
+
accept(false);
|
| 135 |
+
});
|
| 136 |
+
sock.once("error", (e) => {
|
| 137 |
+
sock.destroy();
|
| 138 |
+
//@ts-ignore
|
| 139 |
+
if (e.code === "ECONNREFUSED") {
|
| 140 |
+
accept(true);
|
| 141 |
+
} else {
|
| 142 |
+
reject(e);
|
| 143 |
+
}
|
| 144 |
+
});
|
| 145 |
+
});
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
function is_truthy<T>(value: T | null | undefined | false): value is T {
|
| 149 |
+
return value !== null && value !== undefined && value !== false;
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
export function examine_module(
|
| 153 |
+
component_dir: string,
|
| 154 |
+
root: string,
|
| 155 |
+
python_path: string,
|
| 156 |
+
mode: "build" | "dev"
|
| 157 |
+
): ComponentMeta[] {
|
| 158 |
+
const _process = spawnSync(
|
| 159 |
+
python_path,
|
| 160 |
+
[join(__dirname, "examine.py"), "-m", mode],
|
| 161 |
+
{
|
| 162 |
+
cwd: join(component_dir, "backend"),
|
| 163 |
+
stdio: "pipe"
|
| 164 |
+
}
|
| 165 |
+
);
|
| 166 |
+
const exceptions: string[] = [];
|
| 167 |
+
|
| 168 |
+
const components = _process.stdout
|
| 169 |
+
.toString()
|
| 170 |
+
.trim()
|
| 171 |
+
.split("\n")
|
| 172 |
+
.map((line) => {
|
| 173 |
+
if (line.startsWith("|EXCEPTION|")) {
|
| 174 |
+
exceptions.push(line.slice("|EXCEPTION|:".length));
|
| 175 |
+
}
|
| 176 |
+
const [name, template_dir, frontend_dir, component_class_id] =
|
| 177 |
+
line.split("~|~|~|~");
|
| 178 |
+
if (name && template_dir && frontend_dir && component_class_id) {
|
| 179 |
+
return {
|
| 180 |
+
name: name.trim(),
|
| 181 |
+
template_dir: template_dir.trim(),
|
| 182 |
+
frontend_dir: frontend_dir.trim(),
|
| 183 |
+
component_class_id: component_class_id.trim()
|
| 184 |
+
};
|
| 185 |
+
}
|
| 186 |
+
return false;
|
| 187 |
+
})
|
| 188 |
+
.filter(is_truthy);
|
| 189 |
+
if (exceptions.length > 0) {
|
| 190 |
+
console.info(
|
| 191 |
+
`While searching for gradio custom component source directories in ${component_dir}, the following exceptions were raised. If dev mode does not work properly please pass the --gradio-path and --python-path CLI arguments so that gradio uses the right executables: ${exceptions.join(
|
| 192 |
+
"\n"
|
| 193 |
+
)}`
|
| 194 |
+
);
|
| 195 |
+
}
|
| 196 |
+
return components;
|
| 197 |
+
}
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/preview/src/plugins.ts
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { Plugin, PluginOption } from "vite";
|
| 2 |
+
import { svelte } from "@sveltejs/vite-plugin-svelte";
|
| 3 |
+
import preprocess from "svelte-preprocess";
|
| 4 |
+
import { join } from "path";
|
| 5 |
+
import { type ComponentConfig } from "./dev";
|
| 6 |
+
import type { Preprocessor, PreprocessorGroup } from "svelte/compiler";
|
| 7 |
+
|
| 8 |
+
const svelte_codes_to_ignore: Record<string, string> = {
|
| 9 |
+
"reactive-component": "Icon"
|
| 10 |
+
};
|
| 11 |
+
|
| 12 |
+
const RE_SVELTE_IMPORT =
|
| 13 |
+
/import\s+([\w*{},\s]+)\s+from\s+['"](svelte|svelte\/internal)['"]/g;
|
| 14 |
+
const RE_BARE_SVELTE_IMPORT = /import ("|')svelte(\/\w+)*("|')(;)*/g;
|
| 15 |
+
export function plugins(config: ComponentConfig): PluginOption[] {
|
| 16 |
+
const _additional_plugins = config.plugins || [];
|
| 17 |
+
const _additional_svelte_preprocess = config.svelte?.preprocess || [];
|
| 18 |
+
const _svelte_extensions = (config.svelte?.extensions || [".svelte"]).map(
|
| 19 |
+
(ext) => {
|
| 20 |
+
if (ext.trim().startsWith(".")) {
|
| 21 |
+
return ext;
|
| 22 |
+
}
|
| 23 |
+
return `.${ext.trim()}`;
|
| 24 |
+
}
|
| 25 |
+
);
|
| 26 |
+
|
| 27 |
+
if (!_svelte_extensions.includes(".svelte")) {
|
| 28 |
+
_svelte_extensions.push(".svelte");
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
return [
|
| 32 |
+
svelte({
|
| 33 |
+
inspector: false,
|
| 34 |
+
onwarn(warning, handler) {
|
| 35 |
+
if (
|
| 36 |
+
svelte_codes_to_ignore.hasOwnProperty(warning.code) &&
|
| 37 |
+
svelte_codes_to_ignore[warning.code] &&
|
| 38 |
+
warning.message.includes(svelte_codes_to_ignore[warning.code])
|
| 39 |
+
) {
|
| 40 |
+
return;
|
| 41 |
+
}
|
| 42 |
+
handler!(warning);
|
| 43 |
+
},
|
| 44 |
+
prebundleSvelteLibraries: false,
|
| 45 |
+
hot: true,
|
| 46 |
+
compilerOptions: {
|
| 47 |
+
discloseVersion: false,
|
| 48 |
+
hydratable: true
|
| 49 |
+
},
|
| 50 |
+
extensions: _svelte_extensions,
|
| 51 |
+
preprocess: [
|
| 52 |
+
preprocess({
|
| 53 |
+
typescript: {
|
| 54 |
+
compilerOptions: {
|
| 55 |
+
declaration: false,
|
| 56 |
+
declarationMap: false
|
| 57 |
+
}
|
| 58 |
+
}
|
| 59 |
+
}),
|
| 60 |
+
...(_additional_svelte_preprocess as PreprocessorGroup[])
|
| 61 |
+
]
|
| 62 |
+
}),
|
| 63 |
+
..._additional_plugins
|
| 64 |
+
];
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
interface GradioPluginOptions {
|
| 68 |
+
mode: "dev" | "build";
|
| 69 |
+
svelte_dir: string;
|
| 70 |
+
backend_port?: number;
|
| 71 |
+
imports?: string;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
export function make_gradio_plugin({
|
| 75 |
+
mode,
|
| 76 |
+
svelte_dir,
|
| 77 |
+
backend_port,
|
| 78 |
+
imports
|
| 79 |
+
}: GradioPluginOptions): Plugin {
|
| 80 |
+
const v_id = "virtual:component-loader";
|
| 81 |
+
const resolved_v_id = "\0" + v_id;
|
| 82 |
+
return {
|
| 83 |
+
name: "gradio",
|
| 84 |
+
enforce: "pre",
|
| 85 |
+
transform(code) {
|
| 86 |
+
const new_code = code
|
| 87 |
+
.replace(RE_SVELTE_IMPORT, (str, $1, $2) => {
|
| 88 |
+
if ($1.trim().startsWith("type")) return str;
|
| 89 |
+
const identifier = $1.trim().startsWith("* as")
|
| 90 |
+
? $1.replace("* as", "").trim()
|
| 91 |
+
: $1.trim();
|
| 92 |
+
return `const ${identifier.replace(
|
| 93 |
+
" as ",
|
| 94 |
+
": "
|
| 95 |
+
)} = window.__gradio__svelte__internal;`;
|
| 96 |
+
})
|
| 97 |
+
.replace(RE_BARE_SVELTE_IMPORT, "");
|
| 98 |
+
return {
|
| 99 |
+
code: new_code,
|
| 100 |
+
map: null
|
| 101 |
+
};
|
| 102 |
+
},
|
| 103 |
+
resolveId(id) {
|
| 104 |
+
if (id === v_id) {
|
| 105 |
+
return resolved_v_id;
|
| 106 |
+
}
|
| 107 |
+
if (
|
| 108 |
+
id !== "svelte" &&
|
| 109 |
+
id !== "svelte/internal" &&
|
| 110 |
+
id.startsWith("svelte/")
|
| 111 |
+
) {
|
| 112 |
+
return join(svelte_dir, "svelte-submodules.js");
|
| 113 |
+
}
|
| 114 |
+
},
|
| 115 |
+
load(id) {
|
| 116 |
+
if (id === resolved_v_id) {
|
| 117 |
+
return `export default {};`;
|
| 118 |
+
}
|
| 119 |
+
},
|
| 120 |
+
transformIndexHtml(html) {
|
| 121 |
+
return mode === "dev"
|
| 122 |
+
? [
|
| 123 |
+
{
|
| 124 |
+
tag: "script",
|
| 125 |
+
children: `window.__GRADIO_DEV__ = "dev";
|
| 126 |
+
window.__GRADIO__SERVER_PORT__ = ${backend_port};
|
| 127 |
+
window.__GRADIO__CC__ = ${imports};`
|
| 128 |
+
}
|
| 129 |
+
]
|
| 130 |
+
: undefined;
|
| 131 |
+
}
|
| 132 |
+
};
|
| 133 |
+
}
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/preview/src/register.mjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { register } from "node:module";
|
| 2 |
+
|
| 3 |
+
register("./hooks.mjs", import.meta.url);
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/preview/src/svelte-disclose.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// @ts-ignore
|
| 2 |
+
export * from "svelte/internal/disclose-version";
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/preview/src/svelte-internal.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//@ts-ignore
|
| 2 |
+
export * from "svelte/internal";
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/preview/src/svelte-submodules.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export * from "svelte/transition";
|
| 2 |
+
export { spring, tweened } from "svelte/motion";
|
| 3 |
+
export * from "svelte/store";
|
| 4 |
+
export * from "svelte/easing";
|
| 5 |
+
export * from "svelte/animate";
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/preview/src/svelte.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export {
|
| 2 |
+
// this proxy is very important, to ensure that we always refer to the same base Component class which is critical for our components to work
|
| 3 |
+
SvelteComponent as SvelteComponentDev,
|
| 4 |
+
SvelteComponent,
|
| 5 |
+
onMount,
|
| 6 |
+
onDestroy,
|
| 7 |
+
beforeUpdate,
|
| 8 |
+
afterUpdate,
|
| 9 |
+
setContext,
|
| 10 |
+
getContext,
|
| 11 |
+
getAllContexts,
|
| 12 |
+
hasContext,
|
| 13 |
+
tick,
|
| 14 |
+
createEventDispatcher,
|
| 15 |
+
SvelteComponentTyped
|
| 16 |
+
// @ts-ignore
|
| 17 |
+
} from "svelte/internal";
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/preview/test/test/.gitignore
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.eggs/
|
| 2 |
+
dist/
|
| 3 |
+
*.pyc
|
| 4 |
+
__pycache__/
|
| 5 |
+
*.py[cod]
|
| 6 |
+
*$py.class
|
| 7 |
+
__tmp/*
|
| 8 |
+
*.pyi
|
| 9 |
+
node_modules
|
evalkit_tf437/lib/python3.10/site-packages/gradio/_frontend_code/preview/test/test/backend/gradio_test/__init__.py
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
from .test import Test
|
| 3 |
+
|
| 4 |
+
__all__ = ['Test']
|