|
41 | 41 | // Get field configs for the current spec_type |
42 | 42 | $: field_configs = spec_field_configs[spec_type] || [] |
43 | 43 |
|
| 44 | + let loading = false |
| 45 | + let loading_error: KilnError | null = null |
| 46 | +
|
44 | 47 | onMount(async () => { |
| 48 | + loading = true |
| 49 | +
|
45 | 50 | // Check if kiln-copilot is connected |
46 | 51 | try { |
47 | 52 | const { data, error } = await client.GET("/api/settings") |
48 | | - if (!error && data && data["kiln_copilot_api_key"]) { |
| 53 | + if (error) { |
| 54 | + throw error |
| 55 | + } |
| 56 | + if (!data) { |
| 57 | + throw new Error("Failed to load Kiln settings") |
| 58 | + } |
| 59 | + if (data["kiln_copilot_api_key"]) { |
49 | 60 | has_kiln_copilot = true |
| 61 | + } else { |
| 62 | + has_kiln_copilot = false |
50 | 63 | } |
51 | 64 | } catch (e) { |
52 | | - console.error("Failed to check kiln-copilot status", e) |
| 65 | + loading_error = createKilnError(e) |
53 | 66 | } |
54 | 67 |
|
55 | 68 | // Check for URL params first (fresh navigation from select_template) |
|
67 | 80 | initial_property_values = { ...formData.property_values } |
68 | 81 | evaluate_full_trace = formData.evaluate_full_trace |
69 | 82 | initialized = true |
| 83 | + loading = false |
70 | 84 | return |
71 | 85 | } |
72 | 86 |
|
|
106 | 120 | } |
107 | 121 |
|
108 | 122 | initialized = true |
| 123 | + loading = false |
109 | 124 | }) |
110 | 125 |
|
111 | 126 | let next_error: KilnError | null = null |
|
118 | 133 | let copilot_v_manual_dialog: Dialog | null = null |
119 | 134 | let has_kiln_copilot = false |
120 | 135 | let show_connect_kiln_steps = false |
121 | | - let connect_steps_component: ConnectKilnCopilotSteps | null = null |
122 | 136 |
|
123 | 137 | $: void (name, property_values, initialized, update_warn_before_unload()) |
124 | 138 |
|
|
255 | 269 | }, |
256 | 270 | ]} |
257 | 271 | > |
258 | | - <FormContainer |
259 | | - submit_label={has_kiln_copilot ? "Refine Spec with Copilot" : "Next"} |
260 | | - on:submit={check_kiln_copilot_and_proceed} |
261 | | - bind:error={next_error} |
262 | | - bind:submitting |
263 | | - {warn_before_unload} |
264 | | - > |
265 | | - <FormElement |
266 | | - label="Spec Name" |
267 | | - description="A short name for your own reference." |
268 | | - id="spec_name" |
269 | | - bind:value={name} |
270 | | - /> |
271 | | - |
272 | | - {#each field_configs as field (field.key)} |
| 272 | + {#if loading} |
| 273 | + <div class="w-full min-h-[50vh] flex justify-center items-center"> |
| 274 | + <div class="loading loading-spinner loading-lg"></div> |
| 275 | + </div> |
| 276 | + {:else if loading_error} |
| 277 | + <div class="text-error text-sm"> |
| 278 | + {loading_error.getMessage() || "An unknown error occurred"} |
| 279 | + </div> |
| 280 | + {:else} |
| 281 | + <FormContainer |
| 282 | + submit_label={has_kiln_copilot ? "Refine Spec with Copilot" : "Next"} |
| 283 | + on:submit={check_kiln_copilot_and_proceed} |
| 284 | + bind:error={next_error} |
| 285 | + bind:submitting |
| 286 | + {warn_before_unload} |
| 287 | + > |
273 | 288 | <FormElement |
274 | | - label={field.label} |
275 | | - id={field.key} |
276 | | - inputType="textarea" |
277 | | - disabled={field.disabled || false} |
278 | | - description={field.description} |
279 | | - height={field.height || "base"} |
280 | | - bind:value={property_values[field.key]} |
281 | | - optional={!field.required} |
282 | | - inline_action={initial_property_values[field.key] |
283 | | - ? { |
284 | | - handler: () => reset_field(field.key), |
285 | | - label: "Reset", |
286 | | - } |
287 | | - : undefined} |
| 289 | + label="Spec Name" |
| 290 | + description="A short name for your own reference." |
| 291 | + id="spec_name" |
| 292 | + bind:value={name} |
288 | 293 | /> |
289 | | - {/each} |
290 | 294 |
|
291 | | - {#if show_advanced_options} |
292 | | - <Collapse title="Advanced Options"> |
| 295 | + {#each field_configs as field (field.key)} |
293 | 296 | <FormElement |
294 | | - label="Include conversation history" |
295 | | - id="evaluate_full_trace" |
296 | | - inputType="checkbox" |
297 | | - bind:value={evaluate_full_trace} |
298 | | - disabled={full_trace_disabled} |
299 | | - description="When enabled, this spec will be judged on the full conversation history including intermediate steps and tool calls. When disabled, only the final answer is evaluated." |
300 | | - info_description={full_trace_disabled |
301 | | - ? "Tool use specs always evaluate the full conversation history to analyze tool calls." |
302 | | - : "Enable this for specs that need to evaluate reasoning steps, tool usage, or intermediate outputs."} |
| 297 | + label={field.label} |
| 298 | + id={field.key} |
| 299 | + inputType="textarea" |
| 300 | + disabled={field.disabled || false} |
| 301 | + description={field.description} |
| 302 | + height={field.height || "base"} |
| 303 | + bind:value={property_values[field.key]} |
| 304 | + optional={!field.required} |
| 305 | + inline_action={initial_property_values[field.key] |
| 306 | + ? { |
| 307 | + handler: () => reset_field(field.key), |
| 308 | + label: "Reset", |
| 309 | + } |
| 310 | + : undefined} |
303 | 311 | /> |
304 | | - </Collapse> |
| 312 | + {/each} |
| 313 | + |
| 314 | + {#if show_advanced_options} |
| 315 | + <Collapse title="Advanced Options"> |
| 316 | + <FormElement |
| 317 | + label="Include conversation history" |
| 318 | + id="evaluate_full_trace" |
| 319 | + inputType="checkbox" |
| 320 | + bind:value={evaluate_full_trace} |
| 321 | + disabled={full_trace_disabled} |
| 322 | + description="When enabled, this spec will be judged on the full conversation history including intermediate steps and tool calls. When disabled, only the final answer is evaluated." |
| 323 | + info_description={full_trace_disabled |
| 324 | + ? "Tool use specs always evaluate the full conversation history to analyze tool calls." |
| 325 | + : "Enable this for specs that need to evaluate reasoning steps, tool usage, or intermediate outputs."} |
| 326 | + /> |
| 327 | + </Collapse> |
| 328 | + {/if} |
| 329 | + </FormContainer> |
| 330 | + {#if has_kiln_copilot} |
| 331 | + <div class="flex flex-row gap-1 mt-2 justify-end"> |
| 332 | + <span class="text-xs text-gray-500">or</span> |
| 333 | + <button |
| 334 | + class="link underline text-xs text-gray-500" |
| 335 | + on:click={create_spec_from_form}>Create Spec Without Copilot</button |
| 336 | + > |
| 337 | + </div> |
305 | 338 | {/if} |
306 | | - </FormContainer> |
307 | | - {#if has_kiln_copilot} |
308 | | - <div class="flex flex-row gap-1 mt-2 justify-end"> |
309 | | - <span class="text-xs text-gray-500">or</span> |
310 | | - <button |
311 | | - class="link underline text-xs text-gray-500" |
312 | | - on:click={create_spec_from_form}>Create Spec Without Copilot</button |
313 | | - > |
314 | | - </div> |
315 | 339 | {/if} |
316 | 340 | </AppPage> |
317 | 341 | </div> |
|
333 | 357 | {#if show_connect_kiln_steps} |
334 | 358 | <div class="flex flex-col"> |
335 | 359 | <ConnectKilnCopilotSteps |
336 | | - bind:this={connect_steps_component} |
337 | 360 | showTitle={false} |
338 | 361 | onSuccess={handle_connect_success} |
339 | 362 | showCheckmark={has_kiln_copilot} |
|
0 commit comments