1
<script context="module" lang="ts">
2
export { default as BaseChatBot } from "./shared/ChatBot.svelte";
6
import type { Gradio, SelectData, LikeData } from "@gradio/utils";
8
import ChatBot from "./shared/ChatBot.svelte";
9
import { Block, BlockLabel } from "@gradio/atoms";
10
import type { LoadingStatus } from "@gradio/statustracker";
11
import { Chat } from "@gradio/icons";
12
import type { FileData } from "@gradio/client";
13
import { StatusTracker } from "@gradio/statustracker";
15
export let elem_id = "";
16
export let elem_classes: string[] = [];
17
export let visible = true;
19
string | { file: FileData; alt_text: string | null } | null,
20
string | { file: FileData; alt_text: string | null } | null
22
export let scale: number | null = null;
23
export let min_width: number | undefined = undefined;
24
export let label: string;
25
export let show_label = true;
26
export let root: string;
27
export let _selectable = false;
28
export let likeable = false;
29
export let show_share_button = false;
30
export let rtl = false;
31
export let show_copy_button = false;
32
export let sanitize_html = true;
33
export let bubble_full_width = true;
34
export let layout: "bubble" | "panel" = "bubble";
35
export let render_markdown = true;
36
export let line_breaks = true;
37
export let latex_delimiters: {
42
export let gradio: Gradio<{
49
export let avatar_images: [FileData | null, FileData | null] = [null, null];
52
string | { file: FileData; alt_text: string | null } | null,
53
string | { file: FileData; alt_text: string | null } | null
56
const redirect_src_url = (src: string): string =>
57
src.replace('src="/file', `src="${root}file`);
59
function normalize_messages(
60
message: { file: FileData; alt_text: string | null } | null
61
): { file: FileData; alt_text: string | null } | null {
62
if (message === null) {
66
file: message?.file as FileData,
67
alt_text: message?.alt_text
72
? value.map(([user_msg, bot_msg]) => [
73
typeof user_msg === "string"
74
? redirect_src_url(user_msg)
75
: normalize_messages(user_msg),
76
typeof bot_msg === "string"
77
? redirect_src_url(bot_msg)
78
: normalize_messages(bot_msg)
82
export let loading_status: LoadingStatus | undefined = undefined;
83
export let height = 400;
94
allow_overflow={false}
98
autoscroll={gradio.autoscroll}
101
show_progress={loading_status.show_progress === "hidden"
106
<div class="wrapper">
112
label={label || "Chatbot"}
117
selectable={_selectable}
123
pending_message={loading_status?.status === "pending"}
126
on:change={() => gradio.dispatch("change", value)}
127
on:select={(e) => gradio.dispatch("select", e.detail)}
128
on:like={(e) => gradio.dispatch("like", e.detail)}
129
on:share={(e) => gradio.dispatch("share", e.detail)}
130
on:error={(e) => gradio.dispatch("error", e.detail)}
144
flex-direction: column;