Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
machineuser
commited on
Commit
·
316b7a8
1
Parent(s):
15913a8
Sync widgets demo
Browse files
packages/widgets/src/lib/components/InferenceWidget/shared/WidgetOutputConvo/WidgetOutputConvo.svelte
CHANGED
@@ -2,13 +2,11 @@
|
|
2 |
import { afterUpdate } from "svelte";
|
3 |
|
4 |
import { isFullyScrolled, scrollToMax } from "../../../../utils/ViewUtils.js";
|
|
|
5 |
import WidgetOutputConvoBubble from "../WidgetOuputConvoBubble/WidgetOutputConvoBubble.svelte";
|
6 |
|
7 |
export let modelId: string;
|
8 |
-
export let messages:
|
9 |
-
role: string;
|
10 |
-
content: string;
|
11 |
-
}>;
|
12 |
|
13 |
let wrapperEl: HTMLElement;
|
14 |
|
|
|
2 |
import { afterUpdate } from "svelte";
|
3 |
|
4 |
import { isFullyScrolled, scrollToMax } from "../../../../utils/ViewUtils.js";
|
5 |
+
import type { ConversationMessage } from "../../shared/types.js";
|
6 |
import WidgetOutputConvoBubble from "../WidgetOuputConvoBubble/WidgetOutputConvoBubble.svelte";
|
7 |
|
8 |
export let modelId: string;
|
9 |
+
export let messages: ConversationMessage[];
|
|
|
|
|
|
|
10 |
|
11 |
let wrapperEl: HTMLElement;
|
12 |
|
packages/widgets/src/lib/components/InferenceWidget/shared/types.ts
CHANGED
@@ -71,3 +71,8 @@ export interface ImageSegment {
|
|
71 |
imgData?: ImageData;
|
72 |
bitmap?: ImageBitmap;
|
73 |
}
|
|
|
|
|
|
|
|
|
|
|
|
71 |
imgData?: ImageData;
|
72 |
bitmap?: ImageBitmap;
|
73 |
}
|
74 |
+
|
75 |
+
export interface ConversationMessage {
|
76 |
+
role: "user" | "assistant" | "system";
|
77 |
+
content: string;
|
78 |
+
}
|
packages/widgets/src/lib/components/InferenceWidget/widgets/ConversationalWidget/ConversationalWidget.svelte
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
import { Template } from "@huggingface/jinja";
|
5 |
import type { SpecialTokensMap, TokenizerConfig, WidgetExampleTextInput } from "@huggingface/tasks";
|
6 |
import { SPECIAL_TOKENS_ATTRIBUTES } from "@huggingface/tasks";
|
7 |
-
|
8 |
import WidgetOutputConvo from "../../shared/WidgetOutputConvo/WidgetOutputConvo.svelte";
|
9 |
import WidgetQuickInput from "../../shared/WidgetQuickInput/WidgetQuickInput.svelte";
|
10 |
import WidgetWrapper from "../../shared/WidgetWrapper/WidgetWrapper.svelte";
|
@@ -22,13 +22,8 @@
|
|
22 |
|
23 |
$: isDisabled = $widgetStates?.[model.id]?.isDisabled;
|
24 |
|
25 |
-
interface Message {
|
26 |
-
role: string;
|
27 |
-
content: string;
|
28 |
-
}
|
29 |
-
|
30 |
let computeTime = "";
|
31 |
-
let messages:
|
32 |
let error: string = "";
|
33 |
let isLoading = false;
|
34 |
let modelLoading = {
|
@@ -150,7 +145,7 @@
|
|
150 |
}
|
151 |
}
|
152 |
|
153 |
-
function parseOutput(body: unknown, chat:
|
154 |
if (Array.isArray(body) && body.length) {
|
155 |
const text = body[0]?.generated_text ?? "";
|
156 |
|
|
|
4 |
import { Template } from "@huggingface/jinja";
|
5 |
import type { SpecialTokensMap, TokenizerConfig, WidgetExampleTextInput } from "@huggingface/tasks";
|
6 |
import { SPECIAL_TOKENS_ATTRIBUTES } from "@huggingface/tasks";
|
7 |
+
import type { ConversationMessage } from "../../shared/types.js";
|
8 |
import WidgetOutputConvo from "../../shared/WidgetOutputConvo/WidgetOutputConvo.svelte";
|
9 |
import WidgetQuickInput from "../../shared/WidgetQuickInput/WidgetQuickInput.svelte";
|
10 |
import WidgetWrapper from "../../shared/WidgetWrapper/WidgetWrapper.svelte";
|
|
|
22 |
|
23 |
$: isDisabled = $widgetStates?.[model.id]?.isDisabled;
|
24 |
|
|
|
|
|
|
|
|
|
|
|
25 |
let computeTime = "";
|
26 |
+
let messages: ConversationMessage[] = [];
|
27 |
let error: string = "";
|
28 |
let isLoading = false;
|
29 |
let modelLoading = {
|
|
|
145 |
}
|
146 |
}
|
147 |
|
148 |
+
function parseOutput(body: unknown, chat: ConversationMessage[]): ConversationMessage[] {
|
149 |
if (Array.isArray(body) && body.length) {
|
150 |
const text = body[0]?.generated_text ?? "";
|
151 |
|