Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
machineuser commited on
Commit ·
575ec75
1
Parent(s): b6c4534
Sync widgets demo
Browse files202 unmodified lines20320420520620720820921013 unmodified lines224225226227228229230231232233202 unmodified lines} else {error = `Something went wrong with the request.`;}}} finally {isLoading = false;abort = undefined;}13 unmodified lines}async function applyWidgetExample(example: Example, opts: ExampleRunOpts = {}): Promise<void> {if ("text" in example) {messages = [{ role: "user", content: example.text }];} else {messages = [...example.messages];}if (opts.isPreview) {return;202 unmodified lines20320420520620720820921021121221321421521621713 unmodified lines231232233234235236237238239240241242243244202 unmodified lines} else {error = `Something went wrong with the request.`;}} else {clearConversation();}} finally {const isLastMsgFromUser = messages.at(-1)?.role === "user";if (error && isLastMsgFromUser) {// roles should alternate. therefore, if there was an error, we should remove last user message so that user can submit new user message afterwardsmessages = messages.slice(0, -1);}isLoading = false;abort = undefined;}13 unmodified lines}async function applyWidgetExample(example: Example, opts: ExampleRunOpts = {}): Promise<void> {clearConversation();if (opts.inferenceOpts?.isOnLoadCall) {// if isOnLoadCall do NOT trigger svelte UI update, the UI update will be triggered by getOutput if the example succeeds// otherwise, error will be suppressed so that user doesn't come to errored page on load// however, the user will still get the error after manually interacting with the widget if it is not isOnLoadCall"text" in example ? messages.push({ role: "user", content: example.text }) : messages.push(...example.messages);} else {"text" in example ? (messages = [{ role: "user", content: example.text }]) : (messages = [...example.messages]);}if (opts.isPreview) {return;
packages/widgets/src/lib/components/InferenceWidget/widgets/ConversationalWidget/ConversationalWidget.svelte+14-3