@gradio/core 1.0.0-dev.3 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/dist/src/Blocks.svelte +25 -10
- package/dist/src/Blocks.svelte.d.ts +2 -1
- package/dist/src/Login.svelte +13 -13
- package/dist/src/Login.svelte.d.ts +1 -0
- package/dist/src/api_docs/ApiDocs.svelte +19 -2
- package/dist/src/api_docs/ApiDocs.svelte.d.ts +1 -0
- package/dist/src/api_docs/ApiRecorder.svelte +0 -3
- package/dist/src/api_docs/CodeSnippet.svelte +63 -19
- package/dist/src/api_docs/CodeSnippet.svelte.d.ts +2 -1
- package/dist/src/api_docs/EndpointDetail.svelte +73 -17
- package/dist/src/api_docs/EndpointDetail.svelte.d.ts +3 -0
- package/dist/src/api_docs/MCPSnippet.svelte +21 -28
- package/dist/src/api_docs/MCPSnippet.svelte.d.ts +1 -0
- package/dist/src/api_docs/PercentileChart.svelte +125 -0
- package/dist/src/api_docs/PercentileChart.svelte.d.ts +22 -0
- package/dist/src/dependency.d.ts +14 -7
- package/dist/src/dependency.js +37 -19
- package/dist/src/init.svelte.d.ts +2 -2
- package/dist/src/init.svelte.js +26 -20
- package/dist/src/types.d.ts +2 -0
- package/package.json +60 -61
- package/src/Blocks.svelte +25 -10
- package/src/Login.svelte +13 -13
- package/src/api_docs/ApiDocs.svelte +19 -2
- package/src/api_docs/ApiRecorder.svelte +0 -3
- package/src/api_docs/CodeSnippet.svelte +63 -19
- package/src/api_docs/EndpointDetail.svelte +73 -17
- package/src/api_docs/MCPSnippet.svelte +21 -28
- package/src/api_docs/PercentileChart.svelte +125 -0
- package/src/dependency.ts +116 -72
- package/src/init.svelte.ts +24 -35
- package/src/types.ts +2 -0
package/package.json
CHANGED
|
@@ -1,68 +1,67 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradio/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"devDependencies": {
|
|
6
|
-
"@gradio/
|
|
7
|
-
"@gradio/
|
|
8
|
-
"@gradio/
|
|
9
|
-
"@gradio/
|
|
10
|
-
"@gradio/
|
|
11
|
-
"@gradio/
|
|
12
|
-
"@gradio/
|
|
13
|
-
"@gradio/
|
|
14
|
-
"@gradio/
|
|
15
|
-
"@gradio/
|
|
16
|
-
"@gradio/
|
|
17
|
-
"@gradio/colorpicker": "^0.5.0
|
|
18
|
-
"@gradio/
|
|
19
|
-
"@gradio/dataframe": "^0.21.0
|
|
20
|
-
"@gradio/
|
|
21
|
-
"@gradio/dataset": "^0.5.0
|
|
22
|
-
"@gradio/datetime": "^0.3.23
|
|
23
|
-
"@gradio/downloadbutton": "^0.4.13
|
|
24
|
-
"@gradio/
|
|
25
|
-
"@gradio/
|
|
26
|
-
"@gradio/
|
|
27
|
-
"@gradio/form": "^0.2.
|
|
28
|
-
"@gradio/fileexplorer": "^0.5.42
|
|
29
|
-
"@gradio/
|
|
30
|
-
"@gradio/
|
|
31
|
-
"@gradio/
|
|
32
|
-
"@gradio/
|
|
33
|
-
"@gradio/
|
|
34
|
-
"@gradio/imageeditor": "^0.18.2
|
|
35
|
-
"@gradio/
|
|
36
|
-
"@gradio/imageslider": "^0.3.1
|
|
37
|
-
"@gradio/
|
|
38
|
-
"@gradio/
|
|
39
|
-
"@gradio/
|
|
40
|
-
"@gradio/model3d": "^0.15.1
|
|
41
|
-
"@gradio/multimodaltextbox": "^0.11.0
|
|
42
|
-
"@gradio/nativeplot": "^0.9.0
|
|
43
|
-
"@gradio/
|
|
44
|
-
"@gradio/
|
|
45
|
-
"@gradio/plot": "^0.9.25
|
|
46
|
-
"@gradio/radio": "^0.8.0
|
|
47
|
-
"@gradio/row": "^0.
|
|
48
|
-
"@gradio/sidebar": "^0.1.24
|
|
49
|
-
"@gradio/
|
|
50
|
-
"@gradio/simpletextbox": "^0.3.31
|
|
51
|
-
"@gradio/
|
|
52
|
-
"@gradio/
|
|
53
|
-
"@gradio/
|
|
54
|
-
"@gradio/
|
|
55
|
-
"@gradio/
|
|
56
|
-
"@gradio/
|
|
57
|
-
"@gradio/
|
|
58
|
-
"@gradio/theme": "^0.5.0
|
|
59
|
-
"@gradio/timer": "^0.4.6
|
|
60
|
-
"@gradio/
|
|
61
|
-
"@gradio/
|
|
62
|
-
"@gradio/
|
|
63
|
-
"@gradio/
|
|
64
|
-
"@gradio/
|
|
65
|
-
"@gradio/vibeeditor": "^0.3.1-dev.2"
|
|
6
|
+
"@gradio/annotatedimage": "^0.10.1",
|
|
7
|
+
"@gradio/atoms": "^0.19.0",
|
|
8
|
+
"@gradio/box": "^0.2.26",
|
|
9
|
+
"@gradio/browserstate": "^0.3.3",
|
|
10
|
+
"@gradio/button": "^0.5.14",
|
|
11
|
+
"@gradio/checkbox": "^0.5.0",
|
|
12
|
+
"@gradio/chatbot": "^0.28.0",
|
|
13
|
+
"@gradio/client": "^2.0.0",
|
|
14
|
+
"@gradio/audio": "^0.20.0",
|
|
15
|
+
"@gradio/checkboxgroup": "^0.8.0",
|
|
16
|
+
"@gradio/accordion": "^0.5.25",
|
|
17
|
+
"@gradio/colorpicker": "^0.5.0",
|
|
18
|
+
"@gradio/code": "^0.16.0",
|
|
19
|
+
"@gradio/dataframe": "^0.21.0",
|
|
20
|
+
"@gradio/column": "^0.3.0",
|
|
21
|
+
"@gradio/dataset": "^0.5.0",
|
|
22
|
+
"@gradio/datetime": "^0.3.23",
|
|
23
|
+
"@gradio/downloadbutton": "^0.4.13",
|
|
24
|
+
"@gradio/dropdown": "^0.10.6",
|
|
25
|
+
"@gradio/fallback": "^0.4.30",
|
|
26
|
+
"@gradio/file": "^0.13.1",
|
|
27
|
+
"@gradio/form": "^0.2.27",
|
|
28
|
+
"@gradio/fileexplorer": "^0.5.42",
|
|
29
|
+
"@gradio/gallery": "^0.15.35",
|
|
30
|
+
"@gradio/group": "^0.3.0",
|
|
31
|
+
"@gradio/highlightedtext": "^0.9.14",
|
|
32
|
+
"@gradio/html": "^0.8.0",
|
|
33
|
+
"@gradio/image": "^0.24.0",
|
|
34
|
+
"@gradio/imageeditor": "^0.18.2",
|
|
35
|
+
"@gradio/icons": "^0.15.0",
|
|
36
|
+
"@gradio/imageslider": "^0.3.1",
|
|
37
|
+
"@gradio/json": "^0.5.32",
|
|
38
|
+
"@gradio/markdown": "^0.13.23",
|
|
39
|
+
"@gradio/label": "^0.5.22",
|
|
40
|
+
"@gradio/model3d": "^0.15.1",
|
|
41
|
+
"@gradio/multimodaltextbox": "^0.11.0",
|
|
42
|
+
"@gradio/nativeplot": "^0.9.0",
|
|
43
|
+
"@gradio/number": "^0.7.2",
|
|
44
|
+
"@gradio/paramviewer": "^0.9.0",
|
|
45
|
+
"@gradio/plot": "^0.9.25",
|
|
46
|
+
"@gradio/radio": "^0.8.0",
|
|
47
|
+
"@gradio/row": "^0.3.0",
|
|
48
|
+
"@gradio/sidebar": "^0.1.24",
|
|
49
|
+
"@gradio/simpledropdown": "^0.3.30",
|
|
50
|
+
"@gradio/simpletextbox": "^0.3.31",
|
|
51
|
+
"@gradio/slider": "^0.7.0",
|
|
52
|
+
"@gradio/simpleimage": "^0.9.1",
|
|
53
|
+
"@gradio/state": "^0.2.0",
|
|
54
|
+
"@gradio/tabitem": "^0.6.2",
|
|
55
|
+
"@gradio/tabs": "^0.5.2",
|
|
56
|
+
"@gradio/textbox": "^0.12.0",
|
|
57
|
+
"@gradio/statustracker": "^0.12.0",
|
|
58
|
+
"@gradio/theme": "^0.5.0",
|
|
59
|
+
"@gradio/timer": "^0.4.6",
|
|
60
|
+
"@gradio/upload": "^0.17.2",
|
|
61
|
+
"@gradio/utils": "^0.10.4",
|
|
62
|
+
"@gradio/uploadbutton": "^0.9.13",
|
|
63
|
+
"@gradio/video": "^0.17.0",
|
|
64
|
+
"@gradio/vibeeditor": "^0.3.1"
|
|
66
65
|
},
|
|
67
66
|
"msw": {
|
|
68
67
|
"workerDirectory": "public"
|
package/src/Blocks.svelte
CHANGED
|
@@ -40,7 +40,6 @@
|
|
|
40
40
|
import * as screen_recorder from "./screen_recorder";
|
|
41
41
|
|
|
42
42
|
import { DependencyManager } from "./dependency";
|
|
43
|
-
|
|
44
43
|
let {
|
|
45
44
|
root,
|
|
46
45
|
components,
|
|
@@ -67,7 +66,8 @@
|
|
|
67
66
|
search_params,
|
|
68
67
|
render_complete = false,
|
|
69
68
|
ready = $bindable(false),
|
|
70
|
-
reload_count = $bindable(0)
|
|
69
|
+
reload_count = $bindable(0),
|
|
70
|
+
add_new_message = $bindable()
|
|
71
71
|
}: {
|
|
72
72
|
root: string;
|
|
73
73
|
components: ComponentMeta[];
|
|
@@ -95,6 +95,7 @@
|
|
|
95
95
|
render_complete: boolean;
|
|
96
96
|
ready: boolean;
|
|
97
97
|
reload_count: number;
|
|
98
|
+
add_new_message: (title: string, message: string, type: string) => void;
|
|
98
99
|
} = $props();
|
|
99
100
|
|
|
100
101
|
components.forEach((comp) => {
|
|
@@ -136,11 +137,11 @@
|
|
|
136
137
|
// trigger_share(title, description);
|
|
137
138
|
// TODO: lets combine all of the into a log type with levels
|
|
138
139
|
} else if (event === "error") {
|
|
139
|
-
new_message("Error", data, -1, event, 10, true);
|
|
140
|
+
new_message("Error", data as string, -1, event, 10, true);
|
|
140
141
|
} else if (event === "warning") {
|
|
141
|
-
new_message("Warning", data, -1, event, 10, true);
|
|
142
|
+
new_message("Warning", data as string, -1, event, 10, true);
|
|
142
143
|
} else if (event === "info") {
|
|
143
|
-
new_message("Info", data, -1, event, 10, true);
|
|
144
|
+
new_message("Info", data as string, -1, event, 10, true);
|
|
144
145
|
} else if (event == "clear_status") {
|
|
145
146
|
app_tree.update_state(
|
|
146
147
|
id,
|
|
@@ -161,7 +162,7 @@
|
|
|
161
162
|
// so we need to pull out the correct id here.
|
|
162
163
|
if (event === "select" && id in app_tree.initial_tabs) {
|
|
163
164
|
// this is the id of the selected tab
|
|
164
|
-
id = data.id;
|
|
165
|
+
id = (data as { id: number }).id;
|
|
165
166
|
}
|
|
166
167
|
dep_manager.dispatch({
|
|
167
168
|
type: "event",
|
|
@@ -173,11 +174,14 @@
|
|
|
173
174
|
}
|
|
174
175
|
|
|
175
176
|
let api_calls: Payload[] = $state([]);
|
|
177
|
+
let last_api_call: Payload | null = $state(null);
|
|
176
178
|
// We need a callback to add to api_calls from the DependencyManager
|
|
177
179
|
// We can't update a state variable from inside the DependencyManager because
|
|
178
180
|
// svelte won't see it and won't update the UI.
|
|
179
181
|
let add_to_api_calls = (payload: Payload): void => {
|
|
180
|
-
|
|
182
|
+
last_api_call = payload;
|
|
183
|
+
if (!api_recorder_visible) return;
|
|
184
|
+
api_calls = [...api_calls, last_api_call];
|
|
181
185
|
};
|
|
182
186
|
|
|
183
187
|
let dep_manager = new DependencyManager(
|
|
@@ -228,14 +232,14 @@
|
|
|
228
232
|
let ApiDocs: ComponentType<ApiDocsInterface> | null = null;
|
|
229
233
|
let ApiRecorder: ComponentType<ApiRecorderInterface> | null = null;
|
|
230
234
|
let Settings: ComponentType<SettingsInterface> | null = null;
|
|
231
|
-
let VibeEditor:
|
|
235
|
+
let VibeEditor: any = $state(null);
|
|
232
236
|
|
|
233
237
|
async function loadApiDocs(): Promise<void> {
|
|
234
238
|
if (!ApiDocs || !ApiRecorder) {
|
|
235
239
|
const api_docs_module = await import("./api_docs/ApiDocs.svelte");
|
|
236
240
|
const api_recorder_module = await import("./api_docs/ApiRecorder.svelte");
|
|
237
|
-
if (!ApiDocs) ApiDocs = api_docs_module
|
|
238
|
-
if (!ApiRecorder) ApiRecorder = api_recorder_module
|
|
241
|
+
if (!ApiDocs) ApiDocs = api_docs_module?.default;
|
|
242
|
+
if (!ApiRecorder) ApiRecorder = api_recorder_module?.default;
|
|
239
243
|
}
|
|
240
244
|
}
|
|
241
245
|
|
|
@@ -312,6 +316,8 @@
|
|
|
312
316
|
});
|
|
313
317
|
}
|
|
314
318
|
|
|
319
|
+
add_new_message = new_message;
|
|
320
|
+
|
|
315
321
|
let _error_id = -1;
|
|
316
322
|
|
|
317
323
|
const MESSAGE_QUOTE_RE = /^'([^]+)'$/;
|
|
@@ -387,6 +393,10 @@
|
|
|
387
393
|
dep_manager.dispatch_load_events();
|
|
388
394
|
});
|
|
389
395
|
|
|
396
|
+
if (vibe_mode) {
|
|
397
|
+
void loadVibeEditor();
|
|
398
|
+
}
|
|
399
|
+
|
|
390
400
|
return () => {
|
|
391
401
|
mut.disconnect();
|
|
392
402
|
res.disconnect();
|
|
@@ -520,6 +530,7 @@
|
|
|
520
530
|
{space_id}
|
|
521
531
|
{api_calls}
|
|
522
532
|
{username}
|
|
533
|
+
{last_api_call}
|
|
523
534
|
/>
|
|
524
535
|
</div>
|
|
525
536
|
</div>
|
|
@@ -554,6 +565,10 @@
|
|
|
554
565
|
</div>
|
|
555
566
|
</div>
|
|
556
567
|
{/if}
|
|
568
|
+
|
|
569
|
+
{#if vibe_mode && VibeEditor}
|
|
570
|
+
<svelte:component this={VibeEditor} {app} {root} />
|
|
571
|
+
{/if}
|
|
557
572
|
</div>
|
|
558
573
|
|
|
559
574
|
{#if messages}
|
package/src/Login.svelte
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import
|
|
2
|
+
import { BaseForm } from "@gradio/form";
|
|
3
3
|
import { BaseTextbox as Textbox } from "@gradio/textbox";
|
|
4
4
|
import { BaseButton } from "@gradio/button";
|
|
5
|
-
import
|
|
5
|
+
import { BaseColumn } from "@gradio/column";
|
|
6
6
|
import { Block } from "@gradio/atoms";
|
|
7
|
-
import { _ } from "svelte-i18n";
|
|
8
7
|
export let root: string;
|
|
9
8
|
export let auth_message: string | null;
|
|
10
9
|
export let app_mode: boolean;
|
|
11
10
|
export let space_id: string | null;
|
|
11
|
+
export let i18n: (s: string) => string;
|
|
12
12
|
|
|
13
13
|
let username = "";
|
|
14
14
|
let password = "";
|
|
@@ -34,23 +34,23 @@
|
|
|
34
34
|
</script>
|
|
35
35
|
|
|
36
36
|
<div class="wrap" class:min-h-screen={app_mode}>
|
|
37
|
-
<
|
|
38
|
-
<h2>{
|
|
37
|
+
<BaseColumn variant="panel" min_width={480}>
|
|
38
|
+
<h2>{i18n("login.login")}</h2>
|
|
39
39
|
{#if auth_message}
|
|
40
40
|
<p class="auth">{@html auth_message}</p>
|
|
41
41
|
{/if}
|
|
42
42
|
{#if space_id}
|
|
43
43
|
<p class="auth">
|
|
44
|
-
{
|
|
44
|
+
{i18n("login.enable_cookies")}
|
|
45
45
|
</p>
|
|
46
46
|
{/if}
|
|
47
47
|
{#if incorrect_credentials}
|
|
48
|
-
<p class="creds">{
|
|
48
|
+
<p class="creds">{i18n("login.incorrect_credentials")}</p>
|
|
49
49
|
{/if}
|
|
50
|
-
<
|
|
50
|
+
<BaseForm>
|
|
51
51
|
<Block>
|
|
52
52
|
<Textbox
|
|
53
|
-
label={
|
|
53
|
+
label={i18n("login.username")}
|
|
54
54
|
lines={1}
|
|
55
55
|
show_label={true}
|
|
56
56
|
max_lines={1}
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
|
|
62
62
|
<Block>
|
|
63
63
|
<Textbox
|
|
64
|
-
label={
|
|
64
|
+
label={i18n("login.password")}
|
|
65
65
|
lines={1}
|
|
66
66
|
show_label={true}
|
|
67
67
|
max_lines={1}
|
|
@@ -70,12 +70,12 @@
|
|
|
70
70
|
bind:value={password}
|
|
71
71
|
/>
|
|
72
72
|
</Block>
|
|
73
|
-
</
|
|
73
|
+
</BaseForm>
|
|
74
74
|
|
|
75
75
|
<BaseButton size="lg" variant="primary" on:click={submit}
|
|
76
|
-
>{
|
|
76
|
+
>{i18n("login.login")}</BaseButton
|
|
77
77
|
>
|
|
78
|
-
</
|
|
78
|
+
</BaseColumn>
|
|
79
79
|
</div>
|
|
80
80
|
|
|
81
81
|
<style>
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
export let space_id: string | null;
|
|
30
30
|
export let root_node: ComponentMeta;
|
|
31
31
|
export let username: string | null;
|
|
32
|
+
export let last_api_call: Payload | null = null;
|
|
32
33
|
|
|
33
34
|
const js_docs =
|
|
34
35
|
"https://www.gradio.app/guides/getting-started-with-the-js-client";
|
|
@@ -54,6 +55,20 @@
|
|
|
54
55
|
export let api_calls: Payload[] = [];
|
|
55
56
|
let current_language: "python" | "javascript" | "bash" | "mcp" = "python";
|
|
56
57
|
|
|
58
|
+
$: sorted_dependencies = (() => {
|
|
59
|
+
const valid = dependencies.filter(
|
|
60
|
+
(dep) =>
|
|
61
|
+
dep.api_visibility === "public" &&
|
|
62
|
+
info?.named_endpoints?.["/" + dep.api_name]
|
|
63
|
+
);
|
|
64
|
+
if (info && last_api_call) {
|
|
65
|
+
const mostRecent = valid.find((dep) => dep.id === last_api_call.fn_index);
|
|
66
|
+
const others = valid.filter((dep) => dep.id !== last_api_call.fn_index);
|
|
67
|
+
return mostRecent ? [mostRecent, ...others] : valid;
|
|
68
|
+
}
|
|
69
|
+
return valid;
|
|
70
|
+
})();
|
|
71
|
+
|
|
57
72
|
function set_query_param(key: string, value: string) {
|
|
58
73
|
const url = new URL(window.location.href);
|
|
59
74
|
url.searchParams.set(key, value);
|
|
@@ -407,6 +422,7 @@
|
|
|
407
422
|
{file_data_present}
|
|
408
423
|
{mcp_docs}
|
|
409
424
|
{analytics}
|
|
425
|
+
{root}
|
|
410
426
|
bind:config_snippets
|
|
411
427
|
/>
|
|
412
428
|
</div>
|
|
@@ -465,8 +481,8 @@
|
|
|
465
481
|
{/if}
|
|
466
482
|
|
|
467
483
|
<div class:hidden={current_language === "mcp"}>
|
|
468
|
-
{#each
|
|
469
|
-
{#if
|
|
484
|
+
{#each sorted_dependencies as dependency}
|
|
485
|
+
{#if info.named_endpoints["/" + dependency.api_name]}
|
|
470
486
|
<div class="endpoint-container">
|
|
471
487
|
<CodeSnippet
|
|
472
488
|
endpoint_parameters={info.named_endpoints[
|
|
@@ -482,6 +498,7 @@
|
|
|
482
498
|
"/" + dependency.api_name
|
|
483
499
|
].description}
|
|
484
500
|
{analytics}
|
|
501
|
+
{last_api_call}
|
|
485
502
|
bind:markdown_code_snippets
|
|
486
503
|
/>
|
|
487
504
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type { ComponentMeta, Dependency } from "../types";
|
|
2
|
+
import type { ComponentMeta, Dependency, Payload } from "../types";
|
|
3
3
|
import CopyButton from "./CopyButton.svelte";
|
|
4
4
|
import { represent_value, is_potentially_nested_file_data } from "./utils";
|
|
5
5
|
import { Block } from "@gradio/atoms";
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
export let api_description: string | null = null;
|
|
25
25
|
export let analytics: Record<string, any>;
|
|
26
26
|
export let markdown_code_snippets: Record<string, Record<string, string>>;
|
|
27
|
+
export let last_api_call: Payload | null = null;
|
|
27
28
|
|
|
28
29
|
let python_code: HTMLElement;
|
|
29
30
|
let js_code: HTMLElement;
|
|
@@ -41,6 +42,27 @@
|
|
|
41
42
|
$: normalised_api_prefix = api_prefix ? api_prefix : "/";
|
|
42
43
|
$: normalised_root = root.replace(/\/$/, "");
|
|
43
44
|
|
|
45
|
+
$: is_most_recently_used = last_api_call?.fn_index === dependency.id;
|
|
46
|
+
|
|
47
|
+
$: actual_data =
|
|
48
|
+
is_most_recently_used && last_api_call?.data
|
|
49
|
+
? last_api_call.data.filter((d) => typeof d !== "undefined")
|
|
50
|
+
: null;
|
|
51
|
+
|
|
52
|
+
function getParameterValue(param: any, index: number): any {
|
|
53
|
+
if (
|
|
54
|
+
is_most_recently_used &&
|
|
55
|
+
actual_data &&
|
|
56
|
+
actual_data[index] !== undefined
|
|
57
|
+
) {
|
|
58
|
+
return actual_data[index];
|
|
59
|
+
}
|
|
60
|
+
return param.parameter_has_default !== undefined &&
|
|
61
|
+
param.parameter_has_default
|
|
62
|
+
? param.parameter_default
|
|
63
|
+
: param.example_input;
|
|
64
|
+
}
|
|
65
|
+
|
|
44
66
|
$: markdown_code_snippets[
|
|
45
67
|
dependency.api_name as keyof typeof markdown_code_snippets
|
|
46
68
|
] = {
|
|
@@ -55,6 +77,8 @@
|
|
|
55
77
|
api_name={dependency.api_name}
|
|
56
78
|
description={api_description}
|
|
57
79
|
{analytics}
|
|
80
|
+
{last_api_call}
|
|
81
|
+
dependency_id={dependency.id}
|
|
58
82
|
/>
|
|
59
83
|
<div class:hidden={current_language !== "python"}>
|
|
60
84
|
<Block>
|
|
@@ -71,14 +95,16 @@ client = Client(<span class="token string">"{space_id || root}"</span
|
|
|
71
95
|
>{#if username !== null}, auth=("{username}", **password**){/if})
|
|
72
96
|
result = client.<span class="highlight">predict</span
|
|
73
97
|
>(<!--
|
|
74
|
-
-->{#each endpoint_parameters as
|
|
98
|
+
-->{#each endpoint_parameters as param, i}<!--
|
|
75
99
|
-->
|
|
76
|
-
{parameter_name
|
|
77
|
-
? parameter_name + "="
|
|
100
|
+
{param.parameter_name
|
|
101
|
+
? param.parameter_name + "="
|
|
78
102
|
: ""}<span
|
|
103
|
+
class:recent-value={is_most_recently_used &&
|
|
104
|
+
actual_data?.[i] !== undefined}
|
|
79
105
|
>{represent_value(
|
|
80
|
-
|
|
81
|
-
python_type.type,
|
|
106
|
+
getParameterValue(param, i),
|
|
107
|
+
param.python_type.type,
|
|
82
108
|
"py"
|
|
83
109
|
)}</span
|
|
84
110
|
>,{/each}<!--
|
|
@@ -112,22 +138,26 @@ result = client.<span class="highlight">predict</span
|
|
|
112
138
|
const result = await client.predict(<span class="api-name"
|
|
113
139
|
>"/{dependency.api_name}"</span
|
|
114
140
|
>, { <!--
|
|
115
|
-
-->{#each endpoint_parameters as
|
|
116
|
-
-->{#if blob_components.includes(component)}<!--
|
|
141
|
+
-->{#each endpoint_parameters as param, i}<!--
|
|
142
|
+
-->{#if blob_components.includes(param.component)}<!--
|
|
117
143
|
-->
|
|
118
144
|
<span
|
|
119
145
|
class="example-inputs"
|
|
120
|
-
>{parameter_name}: example{component}</span
|
|
146
|
+
>{param.parameter_name}: example{param.component}</span
|
|
121
147
|
>, <!--
|
|
122
148
|
--><span class="desc"><!--
|
|
123
149
|
--></span
|
|
124
150
|
><!--
|
|
125
151
|
-->{:else}<!--
|
|
126
152
|
-->
|
|
127
|
-
<span
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
153
|
+
<span
|
|
154
|
+
class="example-inputs {is_most_recently_used &&
|
|
155
|
+
actual_data?.[i] !== undefined
|
|
156
|
+
? 'recent-value'
|
|
157
|
+
: ''}"
|
|
158
|
+
>{param.parameter_name}: {represent_value(
|
|
159
|
+
getParameterValue(param, i),
|
|
160
|
+
param.python_type.type,
|
|
131
161
|
"js"
|
|
132
162
|
)}</span
|
|
133
163
|
>, <!--
|
|
@@ -151,13 +181,18 @@ result = client.<span class="highlight">predict</span
|
|
|
151
181
|
|
|
152
182
|
<div bind:this={bash_post_code}>
|
|
153
183
|
<pre>curl -X POST {normalised_root}{normalised_api_prefix}/call/{dependency.api_name} -s -H "Content-Type: application/json" -d '{"{"}
|
|
154
|
-
"data": [{#each endpoint_parameters as
|
|
184
|
+
"data": [{#each endpoint_parameters as param, i}
|
|
155
185
|
<!--
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
186
|
+
--><span
|
|
187
|
+
class={is_most_recently_used && actual_data?.[i] !== undefined
|
|
188
|
+
? "recent-value"
|
|
189
|
+
: ""}
|
|
190
|
+
>{represent_value(
|
|
191
|
+
getParameterValue(param, i),
|
|
192
|
+
param.python_type.type,
|
|
193
|
+
"bash"
|
|
194
|
+
)}</span
|
|
195
|
+
>{#if i < endpoint_parameters.length - 1},
|
|
161
196
|
{/if}
|
|
162
197
|
{/each}
|
|
163
198
|
]{"}"}' \
|
|
@@ -211,6 +246,15 @@ result = client.<span class="highlight">predict</span
|
|
|
211
246
|
color: var(--color-accent);
|
|
212
247
|
}
|
|
213
248
|
|
|
249
|
+
.recent-value {
|
|
250
|
+
color: #fd7b00;
|
|
251
|
+
background: #fff4e6;
|
|
252
|
+
border: 1px solid #ffd9b3;
|
|
253
|
+
border-radius: var(--radius-sm);
|
|
254
|
+
padding: 1px 4px;
|
|
255
|
+
font-weight: var(--weight-medium);
|
|
256
|
+
}
|
|
257
|
+
|
|
214
258
|
.hidden {
|
|
215
259
|
display: none;
|
|
216
260
|
}
|
|
@@ -1,30 +1,45 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import type { Payload } from "../types";
|
|
2
3
|
export let api_name: string | null = null;
|
|
3
4
|
export let description: string | null = null;
|
|
4
5
|
export let analytics: Record<string, any>;
|
|
6
|
+
export let last_api_call: Payload | null = null;
|
|
7
|
+
export let dependency_id: number | null = null;
|
|
5
8
|
import { format_latency, get_color_from_success_rate } from "./utils";
|
|
9
|
+
import PercentileChart from "./PercentileChart.svelte";
|
|
6
10
|
|
|
7
11
|
const success_rate = api_name ? analytics[api_name]?.success_rate : 0;
|
|
8
12
|
const color = get_color_from_success_rate(success_rate);
|
|
13
|
+
$: is_most_recently_used = last_api_call?.fn_index === dependency_id;
|
|
9
14
|
</script>
|
|
10
15
|
|
|
11
16
|
<h3>
|
|
12
17
|
API name:
|
|
13
18
|
<span class="post">{"/" + api_name}</span>
|
|
14
|
-
<span class="desc">
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
<span class="desc">
|
|
20
|
+
{description}
|
|
21
|
+
{#if analytics && api_name && analytics[api_name]}
|
|
22
|
+
{@const endpoint_analytics = analytics[api_name]}
|
|
23
|
+
{@const p50 = endpoint_analytics.process_time_percentiles["50th"]}
|
|
24
|
+
{@const p90 = endpoint_analytics.process_time_percentiles["90th"]}
|
|
25
|
+
{@const p99 = endpoint_analytics.process_time_percentiles["99th"]}
|
|
26
|
+
<span class="analytics-inline">
|
|
27
|
+
<span class="analytics-content">
|
|
28
|
+
<span class="analytics-text-wrapper">
|
|
29
|
+
{endpoint_analytics.total_requests} requests ({Math.round(
|
|
30
|
+
success_rate * 100
|
|
31
|
+
)}% successful, p50: {format_latency(p50)})
|
|
32
|
+
</span>
|
|
33
|
+
<div class="analytics-tooltip">
|
|
34
|
+
<PercentileChart {p50} {p90} {p99} />
|
|
35
|
+
</div>
|
|
36
|
+
</span>
|
|
37
|
+
{#if is_most_recently_used}
|
|
38
|
+
<span class="most-recently-used">Most recently used</span>
|
|
39
|
+
{/if}
|
|
40
|
+
</span>
|
|
41
|
+
{/if}
|
|
42
|
+
</span>
|
|
28
43
|
</h3>
|
|
29
44
|
|
|
30
45
|
<style>
|
|
@@ -46,14 +61,55 @@
|
|
|
46
61
|
font-weight: var(--weight-semibold);
|
|
47
62
|
}
|
|
48
63
|
|
|
49
|
-
.analytics {
|
|
64
|
+
.analytics-inline {
|
|
65
|
+
display: inline-flex;
|
|
66
|
+
align-items: center;
|
|
67
|
+
gap: var(--size-2);
|
|
68
|
+
margin-left: var(--size-2);
|
|
50
69
|
color: var(--body-text-color-subdued);
|
|
51
|
-
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.analytics-content {
|
|
73
|
+
position: relative;
|
|
74
|
+
display: inline-block;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.analytics-text-wrapper {
|
|
78
|
+
cursor: help;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.analytics-tooltip {
|
|
82
|
+
position: absolute;
|
|
83
|
+
bottom: 100%;
|
|
84
|
+
left: 50%;
|
|
85
|
+
transform: translateX(-50%);
|
|
86
|
+
margin-bottom: var(--size-2);
|
|
87
|
+
opacity: 0;
|
|
88
|
+
pointer-events: none;
|
|
89
|
+
transition: opacity 0.2s ease;
|
|
90
|
+
z-index: 1000;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.analytics-content:hover .analytics-tooltip {
|
|
94
|
+
opacity: 1;
|
|
95
|
+
pointer-events: auto;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.most-recently-used {
|
|
99
|
+
display: inline-block;
|
|
100
|
+
color: #fd7b00;
|
|
101
|
+
background: #fff4e6;
|
|
102
|
+
border: 1px solid #ffd9b3;
|
|
103
|
+
border-radius: var(--radius-sm);
|
|
104
|
+
padding: var(--size-1) var(--size-2);
|
|
105
|
+
font-size: var(--text-sm);
|
|
106
|
+
font-weight: var(--weight-medium);
|
|
107
|
+
white-space: nowrap;
|
|
52
108
|
}
|
|
53
109
|
|
|
54
110
|
.desc {
|
|
55
111
|
color: var(--body-text-color);
|
|
56
112
|
font-size: var(--text-lg);
|
|
57
|
-
margin-
|
|
113
|
+
margin-left: var(--size-2);
|
|
58
114
|
}
|
|
59
115
|
</style>
|