|
55 | 55 | let inputMessage3 = $state(assistant?.exampleInputs[2] ?? ""); |
56 | 56 | let inputMessage4 = $state(assistant?.exampleInputs[3] ?? ""); |
57 | 57 |
|
58 | | - function resetErrors() { |
59 | | - errors = []; |
| 58 | + function clearError(field: string) { |
| 59 | + errors = errors.filter((e) => e.field !== field); |
60 | 60 | } |
61 | 61 |
|
62 | 62 | function onFilesChange(e: Event) { |
|
70 | 70 | return; |
71 | 71 | } |
72 | 72 | files = inputEl.files; |
73 | | - resetErrors(); |
| 73 | + clearError("avatar"); |
74 | 74 | deleteExistingAvatar = false; |
75 | 75 | } |
76 | 76 | } |
|
164 | 164 | } else { |
165 | 165 | $error = response.statusText; |
166 | 166 | } |
| 167 | + loading = false; |
167 | 168 | } |
168 | 169 | } else { |
169 | 170 | response = await fetch(`${base}/api/assistant`, { |
|
181 | 182 | } else { |
182 | 183 | $error = response.statusText; |
183 | 184 | } |
| 185 | + loading = false; |
184 | 186 | } |
185 | 187 | } |
186 | 188 | }} |
|
245 | 247 | e.stopPropagation(); |
246 | 248 | files = null; |
247 | 249 | deleteExistingAvatar = true; |
| 250 | + clearError("avatar"); |
248 | 251 | }} |
249 | 252 | class="mx-auto w-max text-center text-xs text-gray-600 hover:underline" |
250 | 253 | > |
|
271 | 274 | class="w-full rounded-lg border-2 border-gray-200 bg-gray-100 p-2" |
272 | 275 | placeholder="Assistant Name" |
273 | 276 | value={assistant?.name ?? ""} |
| 277 | + oninput={() => clearError("name")} |
274 | 278 | /> |
275 | 279 | <p class="text-xs text-red-500">{getError("name")}</p> |
276 | 280 | </label> |
|
282 | 286 | class="h-15 w-full rounded-lg border-2 border-gray-200 bg-gray-100 p-2" |
283 | 287 | placeholder="It knows everything about python" |
284 | 288 | value={assistant?.description ?? ""} |
| 289 | + oninput={() => clearError("description")} |
285 | 290 | ></textarea> |
286 | 291 | <p class="text-xs text-red-500">{getError("description")}</p> |
287 | 292 | </label> |
|
293 | 298 | name="modelId" |
294 | 299 | class="w-full rounded-lg border-2 border-gray-200 bg-gray-100 p-2" |
295 | 300 | bind:value={modelId} |
| 301 | + onchange={() => clearError("modelId")} |
296 | 302 | > |
297 | 303 | {#each models.filter((model) => !model.unlisted) as model} |
298 | 304 | <option value={model.id}>{model.displayName}</option> |
|
415 | 421 | placeholder="Start Message 1" |
416 | 422 | bind:value={inputMessage1} |
417 | 423 | class="w-full rounded-lg border-2 border-gray-200 bg-gray-100 p-2" |
| 424 | + oninput={() => clearError("inputMessage1")} |
418 | 425 | /> |
419 | 426 | <input |
420 | 427 | name="exampleInput2" |
421 | 428 | placeholder="Start Message 2" |
422 | 429 | bind:value={inputMessage2} |
423 | 430 | class="w-full rounded-lg border-2 border-gray-200 bg-gray-100 p-2" |
| 431 | + oninput={() => clearError("inputMessage1")} |
424 | 432 | /> |
425 | 433 |
|
426 | 434 | <input |
427 | 435 | name="exampleInput3" |
428 | 436 | placeholder="Start Message 3" |
429 | 437 | bind:value={inputMessage3} |
430 | 438 | class="w-full rounded-lg border-2 border-gray-200 bg-gray-100 p-2" |
| 439 | + oninput={() => clearError("inputMessage1")} |
431 | 440 | /> |
432 | 441 | <input |
433 | 442 | name="exampleInput4" |
434 | 443 | placeholder="Start Message 4" |
435 | 444 | bind:value={inputMessage4} |
436 | 445 | class="w-full rounded-lg border-2 border-gray-200 bg-gray-100 p-2" |
| 446 | + oninput={() => clearError("inputMessage1")} |
437 | 447 | /> |
438 | 448 | </div> |
439 | 449 | <p class="text-xs text-red-500">{getError("inputMessage1")}</p> |
|
524 | 534 | class="w-full rounded-lg border-2 border-gray-200 bg-gray-100 p-2" |
525 | 535 | placeholder="wikipedia.org,bbc.com" |
526 | 536 | value={assistant?.rag?.allowedDomains?.join(",") ?? ""} |
| 537 | + oninput={() => clearError("ragDomainList")} |
527 | 538 | /> |
528 | 539 | <p class="text-xs text-red-500">{getError("ragDomainList")}</p> |
529 | 540 | {/if} |
|
550 | 561 | class="w-full rounded-lg border-2 border-gray-200 bg-gray-100 p-2" |
551 | 562 | placeholder="https://raw.githubusercontent.com/huggingface/chat-ui/main/README.md" |
552 | 563 | value={assistant?.rag?.allowedLinks.join(",") ?? ""} |
| 564 | + oninput={() => clearError("ragLinkList")} |
553 | 565 | /> |
554 | 566 | <p class="text-xs text-red-500">{getError("ragLinkList")}</p> |
555 | 567 | {/if} |
|
605 | 617 | class="min-h-[8lh] flex-1 rounded-lg border-2 border-gray-200 bg-gray-100 p-2 text-sm" |
606 | 618 | placeholder="You'll act as..." |
607 | 619 | bind:value={systemPrompt} |
| 620 | + oninput={() => clearError("preprompt")} |
608 | 621 | ></textarea> |
609 | 622 | {#if modelId} |
610 | 623 | {@const model = models.find((_model) => _model.id === modelId)} |
|
0 commit comments