Upload folder using huggingface_hub
Browse files
6.2.1/chatbot/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "@gradio/chatbot",
|
| 3 |
-
"version": "0.29.
|
| 4 |
"description": "Gradio UI packages",
|
| 5 |
"type": "module",
|
| 6 |
"author": "",
|
|
|
|
| 1 |
{
|
| 2 |
"name": "@gradio/chatbot",
|
| 3 |
+
"version": "0.29.1",
|
| 4 |
"description": "Gradio UI packages",
|
| 5 |
"type": "module",
|
| 6 |
"author": "",
|
6.2.1/chatbot/shared/MessageContent.svelte
CHANGED
|
@@ -4,7 +4,7 @@
|
|
| 4 |
import { MarkdownCode as Markdown } from "@gradio/markdown-code";
|
| 5 |
import type { NormalisedMessage } from "../types";
|
| 6 |
import type { I18nFormatter } from "js/core/src/gradio_helper";
|
| 7 |
-
import type { Client } from "@gradio/client";
|
| 8 |
import type { ComponentType, SvelteComponent } from "svelte";
|
| 9 |
|
| 10 |
export let latex_delimiters: {
|
|
@@ -60,40 +60,35 @@
|
|
| 60 |
{allow_file_downloads}
|
| 61 |
/>
|
| 62 |
{:else if message.type === "component" && message.content.component === "file"}
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
<
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
"file"}
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
>
|
| 84 |
-
</
|
| 85 |
-
<span class="file-type"
|
| 86 |
-
>{(
|
| 87 |
-
message.content.value?.orig_name ||
|
| 88 |
-
message.content.value?.path ||
|
| 89 |
-
""
|
| 90 |
-
)
|
| 91 |
-
.split(".")
|
| 92 |
-
.pop()
|
| 93 |
-
.toUpperCase()}</span
|
| 94 |
-
>
|
| 95 |
</div>
|
| 96 |
-
|
| 97 |
{/if}
|
| 98 |
|
| 99 |
<style>
|
|
|
|
| 4 |
import { MarkdownCode as Markdown } from "@gradio/markdown-code";
|
| 5 |
import type { NormalisedMessage } from "../types";
|
| 6 |
import type { I18nFormatter } from "js/core/src/gradio_helper";
|
| 7 |
+
import type { Client, FileData } from "@gradio/client";
|
| 8 |
import type { ComponentType, SvelteComponent } from "svelte";
|
| 9 |
|
| 10 |
export let latex_delimiters: {
|
|
|
|
| 60 |
{allow_file_downloads}
|
| 61 |
/>
|
| 62 |
{:else if message.type === "component" && message.content.component === "file"}
|
| 63 |
+
{#each message.content.value as file_}
|
| 64 |
+
{@const file: FileData = file_ as FileData}
|
| 65 |
+
<div class="file-container">
|
| 66 |
+
<div class="file-icon">
|
| 67 |
+
<File />
|
| 68 |
+
</div>
|
| 69 |
+
<div class="file-info">
|
| 70 |
+
<a
|
| 71 |
+
data-testid="chatbot-file"
|
| 72 |
+
class="file-link"
|
| 73 |
+
href={file.url}
|
| 74 |
+
target="_blank"
|
| 75 |
+
download={window.__is_colab__
|
| 76 |
+
? null
|
| 77 |
+
: file?.orig_name || file?.path.split("/").pop() || "file"}
|
| 78 |
+
>
|
| 79 |
+
<span class="file-name"
|
| 80 |
+
>{file?.orig_name || file?.path.split("/").pop() || "file"}</span
|
| 81 |
+
>
|
| 82 |
+
</a>
|
| 83 |
+
<span class="file-type"
|
| 84 |
+
>{(file.orig_name || file.path || "")
|
| 85 |
+
.split(".")
|
| 86 |
+
.pop()
|
| 87 |
+
.toUpperCase()}</span
|
| 88 |
>
|
| 89 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
</div>
|
| 91 |
+
{/each}
|
| 92 |
{/if}
|
| 93 |
|
| 94 |
<style>
|
6.2.1/chatbot/shared/utils.ts
CHANGED
|
@@ -146,9 +146,16 @@ function convert_file_message_to_component_message(
|
|
| 146 |
message: File
|
| 147 |
): ComponentData {
|
| 148 |
const _file = Array.isArray(message.file) ? message.file[0] : message.file;
|
|
|
|
|
|
|
| 149 |
return {
|
| 150 |
-
component:
|
| 151 |
-
value:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
alt_text: message.alt_text,
|
| 153 |
constructor_args: {},
|
| 154 |
props: {}
|
|
|
|
| 146 |
message: File
|
| 147 |
): ComponentData {
|
| 148 |
const _file = Array.isArray(message.file) ? message.file[0] : message.file;
|
| 149 |
+
const component = get_component_for_mime_type(_file?.mime_type, _file);
|
| 150 |
+
// Ensure that value is always an array for files
|
| 151 |
return {
|
| 152 |
+
component: component,
|
| 153 |
+
value:
|
| 154 |
+
component === "file"
|
| 155 |
+
? Array.isArray(message.file)
|
| 156 |
+
? message.file
|
| 157 |
+
: [message.file]
|
| 158 |
+
: message.file,
|
| 159 |
alt_text: message.alt_text,
|
| 160 |
constructor_args: {},
|
| 161 |
props: {}
|