diff --git a/.changeset/fifty-crabs-mix.md b/.changeset/fifty-crabs-mix.md new file mode 100644 index 0000000000000..20c43be3f4d27 --- /dev/null +++ b/.changeset/fifty-crabs-mix.md @@ -0,0 +1,6 @@ +--- +"@gradio/chatbot": patch +"gradio": patch +--- + +fix:Some agent low-hanging issues diff --git a/js/chatbot/Chatbot.stories.svelte b/js/chatbot/Chatbot.stories.svelte index 2d15c1f25a386..da8bc2abf7e8c 100644 --- a/js/chatbot/Chatbot.stories.svelte +++ b/js/chatbot/Chatbot.stories.svelte @@ -422,3 +422,22 @@ This document is a showcase of various Markdown capabilities.`, ] }} /> + + diff --git a/js/chatbot/shared/Component.svelte b/js/chatbot/shared/Component.svelte index a06864c1116dd..12c1f48d1950f 100644 --- a/js/chatbot/shared/Component.svelte +++ b/js/chatbot/shared/Component.svelte @@ -39,19 +39,21 @@ on:load /> {:else if type === "audio"} - +
+ +
{:else if type === "video"} import { is_component_message, is_last_bot_message } from "../shared/utils"; - import { File } from "@gradio/icons"; + import { Image } from "@gradio/image/shared"; - import Component from "./Component.svelte"; import type { FileData, Client } from "@gradio/client"; import type { NormalisedMessage } from "../types"; - import MessageBox from "./MessageBox.svelte"; - import { MarkdownCode as Markdown } from "@gradio/markdown-code"; + import type { I18nFormatter } from "js/core/src/gradio_helper"; import type { ComponentType, SvelteComponent } from "svelte"; import ButtonPanel from "./ButtonPanel.svelte"; + import MessageContent from "./MessageContent.svelte"; + import MessageBox from "./MessageBox.svelte"; export let value: NormalisedMessage[]; export let avatar_img: FileData | null; @@ -148,86 +148,50 @@ dir={rtl ? "rtl" : "ltr"} aria-label={role + "'s message: " + get_message_label_data(message)} > - {#if message.type === "text"} -
- {#if message?.metadata?.title} - - - - {:else} - - {/if} -
- {:else if message.type === "component" && message.content.component in _components} - + + + {:else} + 0 && - display_consecutive_in_same_bubble} - {i18n} - {upload} {_fetch} - on:load={() => scroll()} + {scroll} {allow_file_downloads} + {display_consecutive_in_same_bubble} + {i18n} + {line_breaks} /> - {:else if message.type === "component" && message.content.component === "file"} -
-
- -
-
- - {message.content.value?.orig_name || - message.content.value?.path.split("/").pop() || - "file"} - - {( - message.content.value?.orig_name || - message.content.value?.path || - "" - ) - .split(".") - .pop() - .toUpperCase()} -
-
{/if} @@ -447,10 +411,6 @@ } } - .message-content { - padding: var(--spacing-sm) var(--spacing-xl); - } - .avatar-container { align-self: flex-start; position: relative; @@ -594,52 +554,4 @@ .panel .message { margin-bottom: var(--spacing-md); } - - .file-container { - display: flex; - align-items: center; - gap: var(--spacing-lg); - padding: var(--spacing-lg); - border-radius: var(--radius-lg); - width: fit-content; - margin: var(--spacing-sm) 0; - } - - .file-icon { - display: flex; - align-items: center; - justify-content: center; - color: var(--body-text-color); - } - - .file-icon :global(svg) { - width: var(--size-7); - height: var(--size-7); - } - - .file-info { - display: flex; - flex-direction: column; - } - - .file-link { - text-decoration: none; - color: var(--body-text-color); - display: flex; - flex-direction: column; - gap: var(--spacing-xs); - } - - .file-name { - font-family: var(--font); - font-size: var(--text-md); - font-weight: 500; - } - - .file-type { - font-family: var(--font); - font-size: var(--text-sm); - color: var(--body-text-color-subdued); - text-transform: uppercase; - } diff --git a/js/chatbot/shared/MessageBox.svelte b/js/chatbot/shared/MessageBox.svelte index 5affb8369c008..30f4fbf64d48d 100644 --- a/js/chatbot/shared/MessageBox.svelte +++ b/js/chatbot/shared/MessageBox.svelte @@ -1,33 +1,41 @@ - + {#if expanded} +
+ +
+ {/if} + + diff --git a/js/spa/test/chatbot_with_tools.spec.ts b/js/spa/test/chatbot_with_tools.spec.ts index 652d3a5bade7c..b19f72d1c5882 100644 --- a/js/spa/test/chatbot_with_tools.spec.ts +++ b/js/spa/test/chatbot_with_tools.spec.ts @@ -5,7 +5,7 @@ test("Chatbot can support agentic demos by displaying messages with metadata", a }) => { await page.getByRole("button", { name: "Get San Francisco Weather" }).click(); await expect( - await page.locator("button").filter({ hasText: "💥 Error" }).nth(1) + await page.locator("div").filter({ hasText: "💥 Error" }).nth(1) ).toBeVisible(); await expect( page.locator("span").filter({ hasText: "🛠️ Used tool" })