gradio/js/chatbot/static/StaticChatbot.svelte

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

127 lines
3.2 KiB
Svelte
Raw Normal View History

2022-03-08 21:35:42 +08:00
<script lang="ts">
import type { Gradio, SelectData, LikeData } from "@gradio/utils";
import ChatBot from "./ChatBot.svelte";
import { Block, BlockLabel } from "@gradio/atoms";
import type { LoadingStatus } from "@gradio/statustracker";
import { Chat } from "@gradio/icons";
import type { FileData } from "@gradio/upload";
import { normalise_file } from "@gradio/upload";
import { StatusTracker } from "@gradio/statustracker";
2022-03-29 21:10:35 +08:00
export let elem_id = "";
export let elem_classes: string[] = [];
export let visible = true;
export let value: [string | FileData | null, string | FileData | null][] = [];
export let scale: number | null = null;
export let min_width: number | undefined = undefined;
export let label: string;
export let show_label = true;
export let root: string;
export let root_url: null | string;
export let selectable = false;
export let likeable = false;
export let show_share_button = false;
export let rtl = false;
export let show_copy_button = false;
Adds kwarg to disable html sanitization in `gr.Chatbot()` (#5304) * disable sanitize * add changeset * Fix devcontainer postCreateCommand (#5289) * add chmod commands to grant execute permissions to each script before running them * increase the memory limit * Increase memory requirement to 8 * Setting a minimum specification for codespace machines * Rotate axes labels on LinePlot, BarPlot, and ScatterPlot (#5305) * add chmod commands to grant execute permissions to each script before running them * increase the memory limit * Increase memory requirement to 8 * Setting a minimum specification for codespace machines * Added label_angle parameter to LinePlot * add the x_label_angle and y_label_angle to the postprocess * Add x_label_angle and y_label_angle to ScatterPlot * Add x_label_angle and y_label_angle to BarPlot * Remove postCreateCommand update from this PR, it is in its own PR * Remove custumization on the devcontainer, it is on another PR * Remove extra line on the devcontainer, it is on another PR * add changeset * update the parameter definition in the docstring --------- Co-authored-by: Abubakar Abid <abubakar@huggingface.co> Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * `make_waveform()` twitter video resolution fix (#5296) * waveform res fix * add changeset * add changeset * Improve audio streaming (#5238) * changes * changes * add changeset * add changeset * chages * Update silver-clowns-brush.md * changes * chagers * changes * Update silver-clowns-brush.md * change * change --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: pngwn <hello@pngwn.io> * Tweaks to `icon` parameter in `gr.Button()` (#5285) * button * add changeset * fix * add changeset * add changeset * types * type fix * formatting * fix based on review * fix unit tests * stories --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * test * test --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: aliabid94 <aabid94@gmail.com> Co-authored-by: pngwn <hello@pngwn.io> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * Allow caching examples with streamed output (#5295) * changes * changes * add changeset * add changeset * chages * Update silver-clowns-brush.md * changes * chagers * changes * Update silver-clowns-brush.md * change * change * change * changes * chages * changes * add changeset * changes * changes * changes --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: pngwn <hello@pngwn.io> * Create event listener table for components on docs (#5298) * changes * changes * remove languages from code docs * fix img path in guide * rework event listeners * add changeset * remove console log * name it event arguments * Update js/_website/src/lib/components/EventListeners.svelte Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * Update js/_website/src/lib/components/EventListeners.svelte Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * requested changes --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * merge * fix (#5308) * only start listening for events after the components are mounted (#5312) * only start listening for events after the components are mounted * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * Restores missing part of bottom border on file component (#5313) * removes missing part of bottom border on file component * add changeset * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * chore: update versions (#5177) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * Test Blocks.svelte footer copy (#5307) * test test * fix test * tweak * tweak test name * ensure login form has correct styles (#5324) * fix changelog generation (#5328) * Add ignore scripts to pnpm i in pypi action (#5316) * add json generation to prepare * add changeset * remove pnpm prepare * add changeset * bring back prepare, add ignore scripts * delete changeset * add to right commadn * add frozen lockfile to gh_action_pypi * remove unused gh_action_pypi script * remove unused scripts --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * ensure dropdown stays open when identical data is passed in (#5323) * ensure dropwdown stays open when new data is passed in * add changeset * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * Fix ci again again again (#5329) * fix changelog generation * fix changelog generation * fix * chore: update versions (#5326) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * Fix ci again again again (#5330) * fix changelog generation * fix changelog generation * fix * fix script * Fix ci again again again (#5331) * fix changelog generation * fix changelog generation * fix * fix script * fix script * Fix ci again again again (#5332) * fix changelog generation * fix changelog generation * fix * fix script * fix script * fix vars * Fix ci again again again (#5333) * fix changelog generation * fix changelog generation * fix * fix script * fix script * fix vars * fix vars * Fix Checkbox select dispatch (#5340) * Fix bug * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * Minor bug fix sweep (#5284) * changes * changes * add changeset * changes * changes * fix box changes on website * add changeset * changes * changes * Revert "changes" This reverts commit 189b4e844a9d30a45f4d4fb855397ae592a9b725. * chanegs * changes * changes * changes * changes * add changeset * Update fancy-bats-deny.md --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: aliabd <ali.si3luwa@gmail.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * Fix: wrap avatar-image in a div to clip its shape (#5319) * fix: wrap avatar-image in a div to clip its shape and add data url support * add changeset * revert get file from data url * add changeset --------- Co-authored-by: Dawood Khan <dawoodkhan82@gmail.com> Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * chore: update versions (#5341) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * add kwarg to markdown * add changeset * config --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Faiga Alawad <faiga.alawd91@gmail.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> Co-authored-by: aliabid94 <aabid94@gmail.com> Co-authored-by: pngwn <hello@pngwn.io> Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Hannah <hannahblair@users.noreply.github.com> Co-authored-by: Freddy Boulton <alfonsoboulton@gmail.com> Co-authored-by: Keldos <Keldos.ljw@gmail.com>
2023-08-29 12:26:29 +08:00
export let sanitize_html = true;
export let bubble_full_width = true;
export let layout: "bubble" | "panel" = "bubble";
export let render_markdown = true;
export let latex_delimiters: {
left: string;
right: string;
display: boolean;
}[];
export let gradio: Gradio<{
change: typeof value;
select: SelectData;
share: ShareData;
error: string;
like: LikeData;
}>;
export let avatar_images: [string | null, string | null] = [null, null];
let _value: [string | FileData | null, string | FileData | null][];
const redirect_src_url = (src: string): string =>
src.replace('src="/file', `src="${root}file`);
2022-03-29 21:10:35 +08:00
$: _value = value
? value.map(([user_msg, bot_msg]) => [
typeof user_msg === "string"
? redirect_src_url(user_msg)
: normalise_file(user_msg, root, root_url),
typeof bot_msg === "string"
? redirect_src_url(bot_msg)
: normalise_file(bot_msg, root, root_url),
])
: [];
export let loading_status: LoadingStatus | undefined = undefined;
export let height = 400;
2022-03-08 21:35:42 +08:00
</script>
<Block
{elem_id}
{elem_classes}
{visible}
padding={false}
{scale}
{min_width}
{height}
allow_overflow={false}
>
{#if loading_status}
<StatusTracker
{...loading_status}
show_progress={loading_status.show_progress === "hidden"
? "hidden"
: "minimal"}
/>
{/if}
<div class="wrapper">
{#if show_label}
<BlockLabel
{show_label}
Icon={Chat}
float={false}
label={label || "Chatbot"}
/>
{/if}
<ChatBot
{selectable}
{likeable}
{show_share_button}
value={_value}
{latex_delimiters}
{render_markdown}
pending_message={loading_status?.status === "pending"}
{rtl}
{show_copy_button}
on:change={() => gradio.dispatch("change", value)}
on:select={(e) => gradio.dispatch("select", e.detail)}
on:like={(e) => gradio.dispatch("like", e.detail)}
on:share={(e) => gradio.dispatch("share", e.detail)}
on:error={(e) => gradio.dispatch("error", e.detail)}
{avatar_images}
Adds kwarg to disable html sanitization in `gr.Chatbot()` (#5304) * disable sanitize * add changeset * Fix devcontainer postCreateCommand (#5289) * add chmod commands to grant execute permissions to each script before running them * increase the memory limit * Increase memory requirement to 8 * Setting a minimum specification for codespace machines * Rotate axes labels on LinePlot, BarPlot, and ScatterPlot (#5305) * add chmod commands to grant execute permissions to each script before running them * increase the memory limit * Increase memory requirement to 8 * Setting a minimum specification for codespace machines * Added label_angle parameter to LinePlot * add the x_label_angle and y_label_angle to the postprocess * Add x_label_angle and y_label_angle to ScatterPlot * Add x_label_angle and y_label_angle to BarPlot * Remove postCreateCommand update from this PR, it is in its own PR * Remove custumization on the devcontainer, it is on another PR * Remove extra line on the devcontainer, it is on another PR * add changeset * update the parameter definition in the docstring --------- Co-authored-by: Abubakar Abid <abubakar@huggingface.co> Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * `make_waveform()` twitter video resolution fix (#5296) * waveform res fix * add changeset * add changeset * Improve audio streaming (#5238) * changes * changes * add changeset * add changeset * chages * Update silver-clowns-brush.md * changes * chagers * changes * Update silver-clowns-brush.md * change * change --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: pngwn <hello@pngwn.io> * Tweaks to `icon` parameter in `gr.Button()` (#5285) * button * add changeset * fix * add changeset * add changeset * types * type fix * formatting * fix based on review * fix unit tests * stories --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * test * test --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: aliabid94 <aabid94@gmail.com> Co-authored-by: pngwn <hello@pngwn.io> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * Allow caching examples with streamed output (#5295) * changes * changes * add changeset * add changeset * chages * Update silver-clowns-brush.md * changes * chagers * changes * Update silver-clowns-brush.md * change * change * change * changes * chages * changes * add changeset * changes * changes * changes --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: pngwn <hello@pngwn.io> * Create event listener table for components on docs (#5298) * changes * changes * remove languages from code docs * fix img path in guide * rework event listeners * add changeset * remove console log * name it event arguments * Update js/_website/src/lib/components/EventListeners.svelte Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * Update js/_website/src/lib/components/EventListeners.svelte Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * requested changes --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * merge * fix (#5308) * only start listening for events after the components are mounted (#5312) * only start listening for events after the components are mounted * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * Restores missing part of bottom border on file component (#5313) * removes missing part of bottom border on file component * add changeset * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * chore: update versions (#5177) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * Test Blocks.svelte footer copy (#5307) * test test * fix test * tweak * tweak test name * ensure login form has correct styles (#5324) * fix changelog generation (#5328) * Add ignore scripts to pnpm i in pypi action (#5316) * add json generation to prepare * add changeset * remove pnpm prepare * add changeset * bring back prepare, add ignore scripts * delete changeset * add to right commadn * add frozen lockfile to gh_action_pypi * remove unused gh_action_pypi script * remove unused scripts --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * ensure dropdown stays open when identical data is passed in (#5323) * ensure dropwdown stays open when new data is passed in * add changeset * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * Fix ci again again again (#5329) * fix changelog generation * fix changelog generation * fix * chore: update versions (#5326) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * Fix ci again again again (#5330) * fix changelog generation * fix changelog generation * fix * fix script * Fix ci again again again (#5331) * fix changelog generation * fix changelog generation * fix * fix script * fix script * Fix ci again again again (#5332) * fix changelog generation * fix changelog generation * fix * fix script * fix script * fix vars * Fix ci again again again (#5333) * fix changelog generation * fix changelog generation * fix * fix script * fix script * fix vars * fix vars * Fix Checkbox select dispatch (#5340) * Fix bug * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * Minor bug fix sweep (#5284) * changes * changes * add changeset * changes * changes * fix box changes on website * add changeset * changes * changes * Revert "changes" This reverts commit 189b4e844a9d30a45f4d4fb855397ae592a9b725. * chanegs * changes * changes * changes * changes * add changeset * Update fancy-bats-deny.md --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: aliabd <ali.si3luwa@gmail.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * Fix: wrap avatar-image in a div to clip its shape (#5319) * fix: wrap avatar-image in a div to clip its shape and add data url support * add changeset * revert get file from data url * add changeset --------- Co-authored-by: Dawood Khan <dawoodkhan82@gmail.com> Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * chore: update versions (#5341) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * add kwarg to markdown * add changeset * config --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Faiga Alawad <faiga.alawd91@gmail.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> Co-authored-by: aliabid94 <aabid94@gmail.com> Co-authored-by: pngwn <hello@pngwn.io> Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Hannah <hannahblair@users.noreply.github.com> Co-authored-by: Freddy Boulton <alfonsoboulton@gmail.com> Co-authored-by: Keldos <Keldos.ljw@gmail.com>
2023-08-29 12:26:29 +08:00
{sanitize_html}
{bubble_full_width}
{layout}
{root_url}
{root}
/>
</div>
</Block>
<style>
.wrapper {
display: flex;
position: relative;
flex-direction: column;
align-items: start;
width: 100%;
height: 100%;
}
</style>