-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathdisplay_information.ts
More file actions
41 lines (37 loc) · 1.06 KB
/
display_information.ts
File metadata and controls
41 lines (37 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { z } from "zod";
import type { DataType } from "../types/index.js";
export namespace DisplayInformation {
export const baseSchema = z.object({
title: z.string(),
summary: z.object({
preview: z.string(),
overview: z.string(),
}),
dataFormatInformation: z.string().optional(),
model: z.string().optional(),
sampleDataset: z
.object({
// URL to download a dataset for the task, is displayed in the UI when asking to connect data
link: z.string(),
// Instructions to download, unzip, and connect the right file of the sample dataset
instructions: z.string(),
})
.optional(),
});
export const dataTypeToSchema = {
image: z.object({
// url to an image
dataExample: z.string().optional(),
}),
tabular: z.object({
dataExample: z
.array(z.object({ name: z.string(), data: z.string() }))
.optional(),
}),
text: z.object({
dataExample: z.string().optional(),
}),
} satisfies Record<DataType, unknown>;
}
export type DisplayInformation<D extends DataType> =
(typeof DisplayInformation.dataTypeToSchema)[D];