Thomas G. Lopes commited on
Commit
e48cc8b
·
1 Parent(s): 22dad9f

substitute alerts with toasts

Browse files
src/lib/components/InferencePlayground/InferencePlayground.svelte CHANGED
@@ -25,6 +25,7 @@
25
  import ModelSelector from "./InferencePlaygroundModelSelector.svelte";
26
  import ModelSelectorModal from "./InferencePlaygroundModelSelectorModal.svelte";
27
  import InferencePlaygroundProjectSelect from "./InferencePlaygroundProjectSelect.svelte";
 
28
 
29
  const startMessageUser: ConversationMessage = { role: "user", content: "" };
30
 
@@ -123,7 +124,11 @@
123
  if ($project.conversations.length === 2) {
124
  prefix = `Error on ${idx === 0 ? "left" : "right"} conversation. `;
125
  }
126
- return alert(`${prefix}Messages must alternate between user/assistant roles.`);
 
 
 
 
127
  }
128
  }
129
 
@@ -146,10 +151,10 @@
146
  token.reset();
147
  }
148
  if (error.name !== "AbortError") {
149
- alert("error: " + error.message);
150
  }
151
  } else {
152
- alert("An unknown error occurred");
153
  }
154
  } finally {
155
  loading = false;
 
25
  import ModelSelector from "./InferencePlaygroundModelSelector.svelte";
26
  import ModelSelectorModal from "./InferencePlaygroundModelSelectorModal.svelte";
27
  import InferencePlaygroundProjectSelect from "./InferencePlaygroundProjectSelect.svelte";
28
+ import { addToast } from "../toaster.svelte.js";
29
 
30
  const startMessageUser: ConversationMessage = { role: "user", content: "" };
31
 
 
124
  if ($project.conversations.length === 2) {
125
  prefix = `Error on ${idx === 0 ? "left" : "right"} conversation. `;
126
  }
127
+ addToast({
128
+ title: "Failed to run inference",
129
+ description: `${prefix}Messages must alternate between user/assistant roles.`,
130
+ variant: "error",
131
+ });
132
  }
133
  }
134
 
 
151
  token.reset();
152
  }
153
  if (error.name !== "AbortError") {
154
+ addToast({ title: "Error", description: error.message, variant: "error" });
155
  }
156
  } else {
157
+ addToast({ title: "Error", description: "An unknown error occurred", variant: "error" });
158
  }
159
  } finally {
160
  loading = false;
src/lib/components/toaster.svelte.ts CHANGED
@@ -10,8 +10,8 @@ export const toaster = new Toaster<ToastData>({
10
  hover: "pause-all",
11
  });
12
 
13
- export function addToast(args: AddToastProps<ToastData>) {
14
- toaster.addToast(args);
15
  }
16
 
17
  export function removeToast(id: string) {
 
10
  hover: "pause-all",
11
  });
12
 
13
+ export function addToast(data: ToastData) {
14
+ toaster.addToast({ data });
15
  }
16
 
17
  export function removeToast(id: string) {