diff --git a/js/chatbot/shared/ButtonPanel.svelte b/js/chatbot/shared/ButtonPanel.svelte index 8388c0bee5d74..9f721d116a0b6 100644 --- a/js/chatbot/shared/ButtonPanel.svelte +++ b/js/chatbot/shared/ButtonPanel.svelte @@ -5,7 +5,7 @@ import type { NormalisedMessage, TextMessage, ThoughtNode } from "../types"; import { Retry, Undo, Edit, Check, Clear } from "@gradio/icons"; import { IconButtonWrapper, IconButton } from "@gradio/atoms"; - import { all_text } from "./utils"; + import { all_text, is_all_text } from "./utils"; export let likeable: boolean; export let feedback_options: string[]; @@ -24,18 +24,7 @@ export let layout: "bubble" | "panel"; export let dispatch: any; - function is_all_text( - message: NormalisedMessage[] | NormalisedMessage - ): message is TextMessage[] | TextMessage { - return ( - (Array.isArray(message) && - message.every((m) => typeof m.content === "string")) || - (!Array.isArray(message) && typeof message.content === "string") - ); - } - $: message_text = is_all_text(message) ? all_text(message) : ""; - $: show_copy = show_copy_button && message && is_all_text(message); diff --git a/js/chatbot/shared/utils.ts b/js/chatbot/shared/utils.ts index 7237486a88a95..d0ca141f2b563 100644 --- a/js/chatbot/shared/utils.ts +++ b/js/chatbot/shared/utils.ts @@ -319,3 +319,13 @@ export function all_text(message: TextMessage[] | TextMessage): string { } return message.content; } + +export function is_all_text( + message: NormalisedMessage[] | NormalisedMessage +): message is TextMessage[] | TextMessage { + return ( + (Array.isArray(message) && + message.every((m) => typeof m.content === "string")) || + (!Array.isArray(message) && typeof message.content === "string") + ); +}