Skip to content

Commit

Permalink
Update webUI for new API in prior commit
Browse files Browse the repository at this point in the history
  • Loading branch information
scosman committed Oct 18, 2024
1 parent d02405c commit 7523138
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 72 deletions.
78 changes: 53 additions & 25 deletions app/web_ui/src/lib/api_schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,24 +175,25 @@ export interface paths {
patch?: never;
trace?: never;
};
"/api/projects/{project_id}/tasks/{task_id}/run": {
"/api/projects/{project_id}/tasks/{task_id}/runs/{run_id}": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get?: never;
/** Get Run */
get: operations["get_run_api_projects__project_id__tasks__task_id__runs__run_id__get"];
put?: never;
/** Run Task */
post: operations["run_task_api_projects__project_id__tasks__task_id__run_post"];
post?: never;
delete?: never;
options?: never;
head?: never;
patch?: never;
/** Update Run Route */
patch: operations["update_run_route_api_projects__project_id__tasks__task_id__runs__run_id__patch"];
trace?: never;
};
"/api/projects/{project_id}/tasks/{task_id}/runs/{run_id}": {
"/api/projects/{project_id}/tasks/{task_id}/run": {
parameters: {
query?: never;
header?: never;
Expand All @@ -201,12 +202,12 @@ export interface paths {
};
get?: never;
put?: never;
post?: never;
/** Run Task */
post: operations["run_task_api_projects__project_id__tasks__task_id__run_post"];
delete?: never;
options?: never;
head?: never;
/** Update Run Route */
patch: operations["update_run_route_api_projects__project_id__tasks__task_id__runs__run_id__patch"];
patch?: never;
trace?: never;
};
"/api/settings": {
Expand Down Expand Up @@ -279,7 +280,7 @@ export interface components {
*/
v: number;
/** Id */
id?: string;
id?: string | null;
/** Path */
path?: string | null;
/**
Expand Down Expand Up @@ -308,12 +309,6 @@ export interface components {
/** Structured Input */
structured_input?: Record<string, never> | null;
};
/** RunTaskResponse */
RunTaskResponse: {
run?: components["schemas"]["TaskRun"] | null;
/** Raw Output */
raw_output?: string | null;
};
/**
* TaskOutput
* @description An output for a specific task run.
Expand All @@ -325,7 +320,7 @@ export interface components {
*/
v: number;
/** Id */
id?: string;
id?: string | null;
/**
* Created At
* Format: date-time
Expand Down Expand Up @@ -358,7 +353,7 @@ export interface components {
*/
v: number;
/** Id */
id?: string;
id?: string | null;
/**
* Created At
* Format: date-time
Expand Down Expand Up @@ -400,7 +395,7 @@ export interface components {
*/
v: number;
/** Id */
id?: string;
id?: string | null;
/**
* Created At
* Format: date-time
Expand Down Expand Up @@ -762,19 +757,53 @@ export interface operations {
};
};
};
run_task_api_projects__project_id__tasks__task_id__run_post: {
get_run_api_projects__project_id__tasks__task_id__runs__run_id__get: {
parameters: {
query?: never;
header?: never;
path: {
project_id: string;
task_id: string;
run_id: string;
};
cookie?: never;
};
requestBody?: never;
responses: {
/** @description Successful Response */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["TaskRun"];
};
};
/** @description Validation Error */
422: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["HTTPValidationError"];
};
};
};
};
update_run_route_api_projects__project_id__tasks__task_id__runs__run_id__patch: {
parameters: {
query?: never;
header?: never;
path: {
project_id: string;
task_id: string;
run_id: string;
};
cookie?: never;
};
requestBody: {
content: {
"application/json": components["schemas"]["RunTaskRequest"];
"application/json": Record<string, never>;
};
};
responses: {
Expand All @@ -784,7 +813,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["RunTaskResponse"];
"application/json": components["schemas"]["TaskRun"];
};
};
/** @description Validation Error */
Expand All @@ -798,20 +827,19 @@ export interface operations {
};
};
};
update_run_route_api_projects__project_id__tasks__task_id__runs__run_id__patch: {
run_task_api_projects__project_id__tasks__task_id__run_post: {
parameters: {
query?: never;
header?: never;
path: {
project_id: string;
task_id: string;
run_id: string;
};
cookie?: never;
};
requestBody: {
content: {
"application/json": Record<string, never>;
"application/json": components["schemas"]["RunTaskRequest"];
};
};
responses: {
Expand Down
81 changes: 34 additions & 47 deletions app/web_ui/src/routes/(app)/run/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import Run from "./run.svelte"
import createClient from "openapi-fetch"
import { type components, type paths } from "$lib/api_schema.d"
import Output from "./output.svelte"
// TODO: implement checking input content
let warn_before_unload = false
Expand All @@ -27,45 +26,42 @@
$: provider = model.split("/")[0]
// TODO: remove test data
let response: components["schemas"]["RunTaskResponse"] | null = {
run: {
let response: components["schemas"]["TaskRun"] | null = {
v: 1,
id: "123",
input: "asdf",
model_type: "run",
input_source: {
type: "human",
properties: {
a: 1,
b: "asdf",
},
},
output: {
v: 1,
id: "123",
input: "asdf",
model_type: "run",
input_source: {
type: "human",
output:
'{"setup": "Why did the scarecrow win an award?", "punchline": "Because he was outstanding in his field!"}',
source: {
type: "synthetic",
properties: {
a: 1,
b: "asdf",
model_type: "openai/gpt_4o_mini",
},
},
output: {
model_type: "output",
rating: {
v: 1,
output: '{"a": 1, "b": "asdf"}',
source: {
type: "synthetic",
properties: {
model_type: "openai/gpt_4o_mini",
},
},
model_type: "output",
rating: {
v: 1,
id: "270303291267",
created_at: "2024-10-16T10:24:00.872146",
created_by: "scosman",
type: "five_star",
value: 4,
requirement_ratings: {
"570793306757": 3,
},
model_type: "task_output_rating",
id: "270303291267",
created_at: "2024-10-16T10:24:00.872146",
created_by: "scosman",
type: "five_star",
value: 4,
requirement_ratings: {
"570793306757": 3,
},
model_type: "task_output_rating",
},
},
raw_output:
'{"setup": "Why did the scarecrow win an award?", "punchline": "Because he was outstanding in his field!"}',
}
$: subtitle = $current_task ? "Task: " + $current_task.name : ""
Expand Down Expand Up @@ -187,22 +183,13 @@
</div>
</div>
{#if $current_task && !submitting && response != null && $current_project}
{#if response.run != null}
<div class="mt-10 xl:mt-32">
<Run
initial_run={response?.run}
task={$current_task}
project_id={$current_project.id}
/>
</div>
{:else if response?.raw_output}
<!-- The response.run object may be nil if the run isn't saved (env var option for this). We still want to show the output though. -->
<div class="text-xl font-bold mt-10 mb-4">Run Output</div>
<Output
structured={!!$current_task?.output_json_schema}
raw_output={response.raw_output}
<div class="mt-10 xl:mt-32">
<Run
initial_run={response}
task={$current_task}
project_id={$current_project.id}
/>
{/if}
</div>
{/if}
</div>
</AppPage>

0 comments on commit 7523138

Please sign in to comment.