Skip to content

Commit

Permalink
Fix frontend errors on ApiDocs and RecordingSnippet (#9786)
Browse files Browse the repository at this point in the history
* Fix frontend errors on ApiDocs and RecordingSnippet

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>
  • Loading branch information
3 people authored Nov 2, 2024
1 parent fc12496 commit f109497
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .changeset/late-candies-boil.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@gradio/core": minor
"gradio": minor
---

feat:Fix frontend errors on ApiDocs and RecordingSnippet
2 changes: 1 addition & 1 deletion js/core/src/Blocks.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@
on:close={(event) => {
set_api_docs_visible(false);
api_calls = [];
api_recorder_visible = event.detail.api_recorder_visible;
api_recorder_visible = event.detail?.api_recorder_visible;
}}
{dependencies}
{root}
Expand Down
1 change: 1 addition & 0 deletions js/core/src/api_docs/ApiDocs.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
{api_calls}
{dependencies}
{root}
api_prefix={app.api_prefix}
short_root={space_id || root}
{username}
/>
Expand Down
8 changes: 5 additions & 3 deletions js/core/src/api_docs/RecordingSnippet.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
export let dependencies: Dependency[];
export let short_root: string;
export let root: string;
export let api_prefix = "";
export let current_language: "python" | "javascript" | "bash";
export let username: string | null;
Expand All @@ -22,7 +23,9 @@
named_endpoints: any;
unnamed_endpoints: any;
}> {
let response = await fetch(root + "info/?all_endpoints=true");
let response = await fetch(
root.replace(/\/$/, "") + api_prefix + "/info/?all_endpoints=true"
);
let data = await response.json();
return data;
}
Expand Down Expand Up @@ -160,8 +163,7 @@ const app = await Client.connect(<span class="token string">"{short_root}"</span
await client.predict(<span
class="api-name">
"/{api_name}"</span
>{#if call},
{/if}{call});
>{#if call}, {call}{/if});
{/each}</pre>
</div>
</code>
Expand Down

0 comments on commit f109497

Please sign in to comment.