machineuser commited on
Commit
02898cb
1 Parent(s): efa0b5c

Sync widgets demo

Browse files
packages/widgets/src/lib/components/InferenceWidget/shared/WidgetOutputConvo/WidgetOutputConvo.svelte CHANGED
@@ -2,11 +2,11 @@
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
 
 
2
  import { afterUpdate } from "svelte";
3
 
4
  import { isFullyScrolled, scrollToMax } from "../../../../utils/ViewUtils.js";
5
+ import type { ChatMessage } from "../../shared/types.js";
6
  import WidgetOutputConvoBubble from "../WidgetOuputConvoBubble/WidgetOutputConvoBubble.svelte";
7
 
8
  export let modelId: string;
9
+ export let messages: ChatMessage[];
10
 
11
  let wrapperEl: HTMLElement;
12
 
packages/widgets/src/lib/components/InferenceWidget/shared/types.ts CHANGED
@@ -72,7 +72,7 @@ export interface ImageSegment {
72
  bitmap?: ImageBitmap;
73
  }
74
 
75
- export interface ConversationMessage {
76
  role: "user" | "assistant" | "system";
77
  content: string;
78
  }
 
72
  bitmap?: ImageBitmap;
73
  }
74
 
75
+ export interface ChatMessage {
76
  role: "user" | "assistant" | "system";
77
  content: string;
78
  }
packages/widgets/src/lib/components/InferenceWidget/widgets/ConversationalWidget/ConversationalWidget.svelte CHANGED
@@ -11,7 +11,7 @@
11
  import { SPECIAL_TOKENS_ATTRIBUTES } from "@huggingface/tasks";
12
  import { HfInference } from "@huggingface/inference";
13
 
14
- import type { ConversationMessage } from "../../shared/types.js";
15
  import WidgetOutputConvo from "../../shared/WidgetOutputConvo/WidgetOutputConvo.svelte";
16
  import WidgetQuickInput from "../../shared/WidgetQuickInput/WidgetQuickInput.svelte";
17
  import WidgetWrapper from "../../shared/WidgetWrapper/WidgetWrapper.svelte";
@@ -32,7 +32,7 @@
32
 
33
  $: isDisabled = $widgetStates?.[model.id]?.isDisabled;
34
 
35
- let messages: ConversationMessage[] = [];
36
  let error: string = "";
37
  let isLoading = false;
38
  let outputJson: string;
@@ -127,7 +127,7 @@
127
  let newMessage = {
128
  role: "assistant",
129
  content: "",
130
- } satisfies ConversationMessage;
131
  const previousMessages = [...messages];
132
  const tokenStream = inferenceClient.textGenerationStream({
133
  ...input,
 
11
  import { SPECIAL_TOKENS_ATTRIBUTES } from "@huggingface/tasks";
12
  import { HfInference } from "@huggingface/inference";
13
 
14
+ import type { ChatMessage } from "../../shared/types.js";
15
  import WidgetOutputConvo from "../../shared/WidgetOutputConvo/WidgetOutputConvo.svelte";
16
  import WidgetQuickInput from "../../shared/WidgetQuickInput/WidgetQuickInput.svelte";
17
  import WidgetWrapper from "../../shared/WidgetWrapper/WidgetWrapper.svelte";
 
32
 
33
  $: isDisabled = $widgetStates?.[model.id]?.isDisabled;
34
 
35
+ let messages: ChatMessage[] = [];
36
  let error: string = "";
37
  let isLoading = false;
38
  let outputJson: string;
 
127
  let newMessage = {
128
  role: "assistant",
129
  content: "",
130
+ } satisfies ChatMessage;
131
  const previousMessages = [...messages];
132
  const tokenStream = inferenceClient.textGenerationStream({
133
  ...input,