@epfml/discojs 3.0.1-p20250814105822.0 → 3.0.1-p20250924150135.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aggregator/get.d.ts +3 -3
- package/dist/aggregator/get.js +1 -2
- package/dist/client/client.d.ts +6 -6
- package/dist/client/decentralized/decentralized_client.d.ts +1 -1
- package/dist/client/decentralized/peer_pool.d.ts +1 -1
- package/dist/client/federated/federated_client.d.ts +1 -1
- package/dist/client/local_client.d.ts +1 -1
- package/dist/client/utils.d.ts +2 -2
- package/dist/client/utils.js +19 -10
- package/dist/default_tasks/cifar10.d.ts +2 -2
- package/dist/default_tasks/cifar10.js +9 -8
- package/dist/default_tasks/lus_covid.d.ts +2 -2
- package/dist/default_tasks/lus_covid.js +9 -8
- package/dist/default_tasks/mnist.d.ts +2 -2
- package/dist/default_tasks/mnist.js +9 -8
- package/dist/default_tasks/simple_face.d.ts +2 -2
- package/dist/default_tasks/simple_face.js +9 -8
- package/dist/default_tasks/tinder_dog.d.ts +1 -1
- package/dist/default_tasks/tinder_dog.js +12 -10
- package/dist/default_tasks/titanic.d.ts +2 -2
- package/dist/default_tasks/titanic.js +20 -33
- package/dist/default_tasks/wikitext.d.ts +2 -2
- package/dist/default_tasks/wikitext.js +16 -13
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/models/gpt/config.d.ts +2 -2
- package/dist/models/hellaswag.d.ts +2 -3
- package/dist/models/hellaswag.js +3 -4
- package/dist/models/index.d.ts +2 -3
- package/dist/models/index.js +2 -3
- package/dist/models/tokenizer.d.ts +24 -14
- package/dist/models/tokenizer.js +42 -21
- package/dist/processing/index.d.ts +4 -5
- package/dist/processing/index.js +16 -21
- package/dist/serialization/coder.d.ts +5 -1
- package/dist/serialization/coder.js +4 -1
- package/dist/serialization/index.d.ts +4 -0
- package/dist/serialization/index.js +1 -0
- package/dist/serialization/task.d.ts +5 -0
- package/dist/serialization/task.js +34 -0
- package/dist/task/display_information.d.ts +91 -14
- package/dist/task/display_information.js +34 -58
- package/dist/task/index.d.ts +5 -5
- package/dist/task/index.js +4 -3
- package/dist/task/task.d.ts +837 -10
- package/dist/task/task.js +49 -21
- package/dist/task/task_handler.d.ts +4 -4
- package/dist/task/task_handler.js +14 -18
- package/dist/task/task_provider.d.ts +3 -3
- package/dist/task/training_information.d.ts +157 -35
- package/dist/task/training_information.js +85 -110
- package/dist/training/disco.d.ts +8 -8
- package/dist/training/disco.js +2 -1
- package/dist/training/trainer.d.ts +3 -3
- package/dist/training/trainer.js +2 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/validator.d.ts +4 -4
- package/dist/validator.js +7 -6
- package/package.json +4 -7
- package/dist/processing/text.d.ts +0 -21
- package/dist/processing/text.js +0 -36
- package/dist/task/data_example.d.ts +0 -5
- package/dist/task/data_example.js +0 -14
- package/dist/task/summary.d.ts +0 -5
- package/dist/task/summary.js +0 -13
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { Tokenizer } from './index.js';
|
|
1
2
|
import { GPT } from './index.js';
|
|
2
|
-
import {
|
|
3
|
-
import { ONNXModel } from './onnx.js';
|
|
3
|
+
import type { ONNXModel } from './onnx.js';
|
|
4
4
|
export declare const HELLASWAG_URL = "https://raw.githubusercontent.com/rowanz/hellaswag/master/data/hellaswag_val.jsonl";
|
|
5
5
|
/**
|
|
6
6
|
* Represents a single example from the HellaSwag dataset.
|
|
@@ -15,7 +15,6 @@ export interface HellaSwagExample {
|
|
|
15
15
|
label: number;
|
|
16
16
|
}
|
|
17
17
|
export type HellaSwagDataset = HellaSwagExample[];
|
|
18
|
-
type Tokenizer = PreTrainedTokenizer;
|
|
19
18
|
type ModelType = GPT | ONNXModel;
|
|
20
19
|
/**
|
|
21
20
|
* Evaluates the model on a given HellaSwag dataset.
|
package/dist/models/hellaswag.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as tf from '@tensorflow/tfjs';
|
|
2
|
-
import { GPT } from './index.js';
|
|
3
|
-
import { tokenize } from '../processing/text.js';
|
|
4
2
|
import { List } from 'immutable';
|
|
3
|
+
import { GPT } from './index.js';
|
|
5
4
|
export const HELLASWAG_URL = 'https://raw.githubusercontent.com/rowanz/hellaswag/master/data/hellaswag_val.jsonl';
|
|
6
5
|
// Computes the log likelihood of the input sequence using the tfjs model
|
|
7
6
|
// The input sequence is expected to be a concatenation of the context and the ending
|
|
@@ -85,11 +84,11 @@ export async function evaluate(model, tokenizer, dataset, print = true) {
|
|
|
85
84
|
let correct = 0;
|
|
86
85
|
let total = 0;
|
|
87
86
|
for (const example of dataset) {
|
|
88
|
-
const endingTokens = example.endings.map(e => tokenize(
|
|
87
|
+
const endingTokens = example.endings.map(e => tokenizer.tokenize(`${example.ctx} ${e}`, {
|
|
89
88
|
truncation: true,
|
|
90
89
|
max_length: 128
|
|
91
90
|
}).toArray());
|
|
92
|
-
const ctxTokens = tokenize(
|
|
91
|
+
const ctxTokens = tokenizer.tokenize(example.ctx, {
|
|
93
92
|
truncation: true,
|
|
94
93
|
max_length: 128
|
|
95
94
|
}).toArray();
|
package/dist/models/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export { Model } from './model.js';
|
|
2
2
|
export { BatchLogs, EpochLogs, ValidationMetrics } from "./logs.js";
|
|
3
|
+
export { Tokenizer } from "./tokenizer.js";
|
|
3
4
|
export { GPT } from './gpt/index.js';
|
|
4
5
|
export { ONNXModel } from './onnx.js';
|
|
5
6
|
export { GPTConfig } from './gpt/config.js';
|
|
6
|
-
export { evaluate as evaluate_hellaswag } from
|
|
7
|
+
export { evaluate as evaluate_hellaswag, HellaSwagDataset, HellaSwagExample, HELLASWAG_URL, } from "./hellaswag.js";
|
|
7
8
|
export { TFJS } from './tfjs.js';
|
|
8
|
-
export { getTaskTokenizer } from './tokenizer.js';
|
|
9
|
-
export { evaluate, HellaSwagDataset, HellaSwagExample, HELLASWAG_URL } from './hellaswag.js';
|
package/dist/models/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export { Model } from './model.js';
|
|
2
2
|
export { EpochLogs } from "./logs.js";
|
|
3
|
+
export { Tokenizer } from "./tokenizer.js";
|
|
3
4
|
export { GPT } from './gpt/index.js';
|
|
4
5
|
export { ONNXModel } from './onnx.js';
|
|
5
|
-
export { evaluate as evaluate_hellaswag } from
|
|
6
|
+
export { evaluate as evaluate_hellaswag, HELLASWAG_URL, } from "./hellaswag.js";
|
|
6
7
|
export { TFJS } from './tfjs.js';
|
|
7
|
-
export { getTaskTokenizer } from './tokenizer.js';
|
|
8
|
-
export { evaluate, HELLASWAG_URL } from './hellaswag.js';
|
|
@@ -1,14 +1,24 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { type PreTrainedTokenizer } from "@xenova/transformers";
|
|
2
|
+
import { List } from "immutable";
|
|
3
|
+
type PaddingSide = "left" | "right";
|
|
4
|
+
type TokenizeConfig = {
|
|
5
|
+
padding?: undefined;
|
|
6
|
+
truncation?: false;
|
|
7
|
+
} | (({
|
|
8
|
+
padding: PaddingSide;
|
|
9
|
+
truncation?: true;
|
|
10
|
+
} | {
|
|
11
|
+
truncation: true;
|
|
12
|
+
padding?: PaddingSide;
|
|
13
|
+
}) & {
|
|
14
|
+
max_length: number;
|
|
15
|
+
});
|
|
16
|
+
export declare class Tokenizer {
|
|
17
|
+
#private;
|
|
18
|
+
readonly name: string;
|
|
19
|
+
constructor(name: string, to_wrap: PreTrainedTokenizer);
|
|
20
|
+
static from_pretrained(name: string): Promise<Tokenizer>;
|
|
21
|
+
tokenize(text: string, config?: TokenizeConfig): List<number>;
|
|
22
|
+
decode(tokens: number[]): string;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
package/dist/models/tokenizer.js
CHANGED
|
@@ -1,26 +1,47 @@
|
|
|
1
|
-
import { AutoTokenizer, env } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export async function getTaskTokenizer(task) {
|
|
14
|
-
let tokenizer = task.trainingInformation.tokenizer;
|
|
15
|
-
if (tokenizer === undefined)
|
|
16
|
-
throw Error('No tokenizer specified in the task training information');
|
|
17
|
-
if (typeof tokenizer == 'string') {
|
|
18
|
-
// Needs to be false in order to prevent transformers.js from reading the local cache
|
|
1
|
+
import { AutoTokenizer, env, } from "@xenova/transformers";
|
|
2
|
+
import { List } from "immutable";
|
|
3
|
+
// serializable wrapper around PreTrainedTokenizer
|
|
4
|
+
export class Tokenizer {
|
|
5
|
+
name;
|
|
6
|
+
#wrapped;
|
|
7
|
+
constructor(name, to_wrap) {
|
|
8
|
+
this.name = name;
|
|
9
|
+
this.#wrapped = to_wrap;
|
|
10
|
+
}
|
|
11
|
+
static async from_pretrained(name) {
|
|
12
|
+
// Needs to be false in order to prevent transformers.js from reading the local cache
|
|
19
13
|
// and triggering an error when running in the browser
|
|
20
14
|
// Reference: https://medium.com/@GenerationAI/transformers-js-onnx-runtime-webgpu-46c3e58d547c
|
|
21
15
|
env.allowLocalModels = false;
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
const to_wrap = await AutoTokenizer.from_pretrained(name);
|
|
17
|
+
return new Tokenizer(name, to_wrap);
|
|
18
|
+
}
|
|
19
|
+
tokenize(text, config = {}) {
|
|
20
|
+
if (config.padding || config.truncation)
|
|
21
|
+
if (!Number.isInteger(config.max_length))
|
|
22
|
+
throw new Error("max_length should be an integer");
|
|
23
|
+
if (config.padding) {
|
|
24
|
+
// The padding side is set as an attribute, not in the config
|
|
25
|
+
this.#wrapped.padding_side = config.padding ?? "left";
|
|
26
|
+
config.truncation = true;
|
|
27
|
+
}
|
|
28
|
+
const tokenizerResult = this.#wrapped(text, {
|
|
29
|
+
padding: config.padding !== undefined,
|
|
30
|
+
truncation: config.truncation,
|
|
31
|
+
max_length: "max_length" in config ? config.max_length : undefined,
|
|
32
|
+
return_tensor: false,
|
|
33
|
+
});
|
|
34
|
+
if (typeof tokenizerResult !== "object" ||
|
|
35
|
+
tokenizerResult === null ||
|
|
36
|
+
!("input_ids" in tokenizerResult) ||
|
|
37
|
+
!isArrayOfNumber(tokenizerResult.input_ids))
|
|
38
|
+
throw new Error("tokenizer returned unexpected type");
|
|
39
|
+
return List(tokenizerResult.input_ids);
|
|
24
40
|
}
|
|
25
|
-
|
|
41
|
+
decode(tokens) {
|
|
42
|
+
return this.#wrapped.decode(tokens);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function isArrayOfNumber(raw) {
|
|
46
|
+
return Array.isArray(raw) && raw.every((e) => typeof e === "number");
|
|
26
47
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/** Dataset shapers, convenient to map with */
|
|
2
|
-
import type { Dataset, DataFormat, DataType, Task } from "../index.js";
|
|
2
|
+
import type { Dataset, DataFormat, DataType, Task, Network } from "../index.js";
|
|
3
3
|
export * from "./image.js";
|
|
4
4
|
export * from "./tabular.js";
|
|
5
|
-
export
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function postprocess<D extends DataType>(task: Task<D>, encoded: DataFormat.ModelEncoded[D][1]): Promise<DataFormat.Inferred[D]>;
|
|
5
|
+
export declare function preprocess<D extends DataType, N extends Network>(task: Task<D, N>, dataset: Dataset<DataFormat.Raw[D]>): Dataset<DataFormat.ModelEncoded[D]>;
|
|
6
|
+
export declare function preprocessWithoutLabel<D extends DataType>(task: Task<D, Network>, dataset: Dataset<DataFormat.RawWithoutLabel[D]>): Dataset<DataFormat.ModelEncoded[D][0]>;
|
|
7
|
+
export declare function postprocess<D extends DataType>(task: Task<D, Network>, encoded: DataFormat.ModelEncoded[D][1]): DataFormat.Inferred[D];
|
package/dist/processing/index.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
/** Dataset shapers, convenient to map with */
|
|
2
2
|
import { List } from "immutable";
|
|
3
|
-
import { models } from "../index.js";
|
|
4
3
|
import * as processing from "./index.js";
|
|
5
4
|
export * from "./image.js";
|
|
6
5
|
export * from "./tabular.js";
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
switch (task.trainingInformation.dataType) {
|
|
6
|
+
export function preprocess(task, dataset) {
|
|
7
|
+
switch (task.dataType) {
|
|
10
8
|
case "image": {
|
|
11
9
|
// cast as typescript doesn't reduce generic type
|
|
12
10
|
const d = dataset;
|
|
@@ -32,18 +30,17 @@ export async function preprocess(task, dataset) {
|
|
|
32
30
|
case "text": {
|
|
33
31
|
// cast as typescript doesn't reduce generic type
|
|
34
32
|
const d = dataset;
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return d.map(text => processing.tokenize(tokenizer, text))
|
|
33
|
+
const { contextLength, tokenizer } = task.trainingInformation;
|
|
34
|
+
return d
|
|
35
|
+
.map((text) => tokenizer.tokenize(text))
|
|
39
36
|
.flatten()
|
|
40
37
|
.batch(contextLength + 1, 1)
|
|
41
38
|
.map((tokens) => [tokens.pop(), tokens.last()]);
|
|
42
39
|
}
|
|
43
40
|
}
|
|
44
41
|
}
|
|
45
|
-
export
|
|
46
|
-
switch (task.
|
|
42
|
+
export function preprocessWithoutLabel(task, dataset) {
|
|
43
|
+
switch (task.dataType) {
|
|
47
44
|
case "image": {
|
|
48
45
|
// cast as typescript doesn't reduce generic type
|
|
49
46
|
const d = dataset;
|
|
@@ -59,22 +56,20 @@ export async function preprocessWithoutLabel(task, dataset) {
|
|
|
59
56
|
case "text": {
|
|
60
57
|
// cast as typescript doesn't reduce generic type
|
|
61
58
|
const d = dataset;
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return d.map(text => processing.tokenize(tokenizer, text))
|
|
59
|
+
const { contextLength, tokenizer } = task.trainingInformation;
|
|
60
|
+
return d
|
|
61
|
+
.map((text) => tokenizer.tokenize(text))
|
|
66
62
|
.flatten()
|
|
67
63
|
.batch(contextLength);
|
|
68
64
|
}
|
|
69
65
|
}
|
|
70
66
|
}
|
|
71
|
-
export
|
|
72
|
-
switch (task.
|
|
67
|
+
export function postprocess(task, encoded) {
|
|
68
|
+
switch (task.dataType) {
|
|
73
69
|
case "image": {
|
|
74
70
|
// cast as typescript doesn't reduce generic type
|
|
75
71
|
const index = encoded;
|
|
76
|
-
const
|
|
77
|
-
const labels = List(LABEL_LIST);
|
|
72
|
+
const labels = List(task.trainingInformation.LABEL_LIST);
|
|
78
73
|
const v = labels.get(index);
|
|
79
74
|
if (v === undefined)
|
|
80
75
|
throw new Error("index not found in labels");
|
|
@@ -88,9 +83,9 @@ export async function postprocess(task, encoded) {
|
|
|
88
83
|
case "text": {
|
|
89
84
|
// cast as typescript doesn't reduce generic type
|
|
90
85
|
const token = encoded;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
86
|
+
return task.trainingInformation.tokenizer.decode([
|
|
87
|
+
token,
|
|
88
|
+
]);
|
|
94
89
|
}
|
|
95
90
|
}
|
|
96
91
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export type Encoded = Uint8Array;
|
|
2
2
|
export declare function isEncoded(raw: unknown): raw is Encoded;
|
|
3
|
-
|
|
3
|
+
type Encodable = null | undefined | boolean | number | string | Float32Array | ArrayBuffer | Encodable[] | {
|
|
4
|
+
[_: string]: Encodable;
|
|
5
|
+
};
|
|
6
|
+
export declare function encode(serialized: Encodable): Encoded;
|
|
4
7
|
export declare function decode(encoded: Encoded): unknown;
|
|
8
|
+
export {};
|
|
@@ -44,7 +44,10 @@ CODEC.register({
|
|
|
44
44
|
copy(raw),
|
|
45
45
|
});
|
|
46
46
|
export function encode(serialized) {
|
|
47
|
-
return msgpack.encode(serialized, {
|
|
47
|
+
return msgpack.encode(serialized, {
|
|
48
|
+
extensionCodec: CODEC,
|
|
49
|
+
ignoreUndefined: true,
|
|
50
|
+
});
|
|
48
51
|
}
|
|
49
52
|
export function decode(encoded) {
|
|
50
53
|
return msgpack.decode(encoded, { extensionCodec: CODEC });
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export * as model from './model.js';
|
|
2
|
+
export * as task from "./task.js";
|
|
2
3
|
export * as weights from './weights.js';
|
|
3
4
|
export type { Encoded } from "./coder.js";
|
|
4
5
|
export { isEncoded } from "./coder.js";
|
|
6
|
+
export type JSON = null | undefined | boolean | number | string | JSON[] | {
|
|
7
|
+
[_: string]: JSON;
|
|
8
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { DataType, Network } from "../index.js";
|
|
2
|
+
import { Task } from "../index.js";
|
|
3
|
+
import type { JSON } from "./index.js";
|
|
4
|
+
export declare function serializeToJSON(task: Task<DataType, Network>): JSON;
|
|
5
|
+
export declare function deserializeFromJSON(serialized: JSON): Promise<Task<DataType, Network>>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { Task, Tokenizer } from "../index.js";
|
|
3
|
+
export function serializeToJSON(task) {
|
|
4
|
+
switch (task.dataType) {
|
|
5
|
+
case "image":
|
|
6
|
+
case "tabular":
|
|
7
|
+
return task;
|
|
8
|
+
case "text": {
|
|
9
|
+
return {
|
|
10
|
+
...task,
|
|
11
|
+
trainingInformation: {
|
|
12
|
+
...task.trainingInformation,
|
|
13
|
+
tokenizer: task.trainingInformation.tokenizer.name,
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export async function deserializeFromJSON(serialized) {
|
|
20
|
+
return await z
|
|
21
|
+
.object({
|
|
22
|
+
trainingInformation: z
|
|
23
|
+
.object({
|
|
24
|
+
tokenizer: z
|
|
25
|
+
.string()
|
|
26
|
+
.transform((name) => Tokenizer.from_pretrained(name))
|
|
27
|
+
.optional(),
|
|
28
|
+
})
|
|
29
|
+
.passthrough(),
|
|
30
|
+
})
|
|
31
|
+
.passthrough()
|
|
32
|
+
.pipe(Task.schema)
|
|
33
|
+
.parseAsync(serialized);
|
|
34
|
+
}
|
|
@@ -1,15 +1,92 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { DataType } from "../types/index.js";
|
|
3
|
+
export declare namespace DisplayInformation {
|
|
4
|
+
const baseSchema: z.ZodObject<{
|
|
5
|
+
title: z.ZodString;
|
|
6
|
+
summary: z.ZodObject<{
|
|
7
|
+
preview: z.ZodString;
|
|
8
|
+
overview: z.ZodString;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
preview: string;
|
|
11
|
+
overview: string;
|
|
12
|
+
}, {
|
|
13
|
+
preview: string;
|
|
14
|
+
overview: string;
|
|
15
|
+
}>;
|
|
16
|
+
dataFormatInformation: z.ZodOptional<z.ZodString>;
|
|
17
|
+
model: z.ZodOptional<z.ZodString>;
|
|
18
|
+
sampleDataset: z.ZodOptional<z.ZodObject<{
|
|
19
|
+
link: z.ZodString;
|
|
20
|
+
instructions: z.ZodString;
|
|
21
|
+
}, "strip", z.ZodTypeAny, {
|
|
22
|
+
link: string;
|
|
23
|
+
instructions: string;
|
|
24
|
+
}, {
|
|
25
|
+
link: string;
|
|
26
|
+
instructions: string;
|
|
27
|
+
}>>;
|
|
28
|
+
}, "strip", z.ZodTypeAny, {
|
|
29
|
+
title: string;
|
|
30
|
+
summary: {
|
|
31
|
+
preview: string;
|
|
32
|
+
overview: string;
|
|
33
|
+
};
|
|
34
|
+
dataFormatInformation?: string | undefined;
|
|
35
|
+
model?: string | undefined;
|
|
36
|
+
sampleDataset?: {
|
|
37
|
+
link: string;
|
|
38
|
+
instructions: string;
|
|
39
|
+
} | undefined;
|
|
40
|
+
}, {
|
|
41
|
+
title: string;
|
|
42
|
+
summary: {
|
|
43
|
+
preview: string;
|
|
44
|
+
overview: string;
|
|
45
|
+
};
|
|
46
|
+
dataFormatInformation?: string | undefined;
|
|
47
|
+
model?: string | undefined;
|
|
48
|
+
sampleDataset?: {
|
|
49
|
+
link: string;
|
|
50
|
+
instructions: string;
|
|
51
|
+
} | undefined;
|
|
52
|
+
}>;
|
|
53
|
+
const dataTypeToSchema: {
|
|
54
|
+
image: z.ZodObject<{
|
|
55
|
+
dataExample: z.ZodOptional<z.ZodString>;
|
|
56
|
+
}, "strip", z.ZodTypeAny, {
|
|
57
|
+
dataExample?: string | undefined;
|
|
58
|
+
}, {
|
|
59
|
+
dataExample?: string | undefined;
|
|
60
|
+
}>;
|
|
61
|
+
tabular: z.ZodObject<{
|
|
62
|
+
dataExample: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
63
|
+
name: z.ZodString;
|
|
64
|
+
data: z.ZodString;
|
|
65
|
+
}, "strip", z.ZodTypeAny, {
|
|
66
|
+
name: string;
|
|
67
|
+
data: string;
|
|
68
|
+
}, {
|
|
69
|
+
name: string;
|
|
70
|
+
data: string;
|
|
71
|
+
}>, "many">>;
|
|
72
|
+
}, "strip", z.ZodTypeAny, {
|
|
73
|
+
dataExample?: {
|
|
74
|
+
name: string;
|
|
75
|
+
data: string;
|
|
76
|
+
}[] | undefined;
|
|
77
|
+
}, {
|
|
78
|
+
dataExample?: {
|
|
79
|
+
name: string;
|
|
80
|
+
data: string;
|
|
81
|
+
}[] | undefined;
|
|
82
|
+
}>;
|
|
83
|
+
text: z.ZodObject<{
|
|
84
|
+
dataExample: z.ZodOptional<z.ZodString>;
|
|
85
|
+
}, "strip", z.ZodTypeAny, {
|
|
86
|
+
dataExample?: string | undefined;
|
|
87
|
+
}, {
|
|
88
|
+
dataExample?: string | undefined;
|
|
89
|
+
}>;
|
|
90
|
+
};
|
|
14
91
|
}
|
|
15
|
-
export
|
|
92
|
+
export type DisplayInformation<D extends DataType> = (typeof DisplayInformation.dataTypeToSchema)[D];
|
|
@@ -1,59 +1,35 @@
|
|
|
1
|
-
import {
|
|
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
|
-
if (dataExample !== undefined && !(Array.isArray(dataExample) &&
|
|
37
|
-
dataExample.every(isDataExample))) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
if (headers !== undefined && !(Array.isArray(headers) &&
|
|
41
|
-
headers.every((e) => typeof e === 'string'))) {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
const repack = {
|
|
45
|
-
dataExample,
|
|
46
|
-
dataExampleImage,
|
|
47
|
-
dataExampleText,
|
|
48
|
-
dataFormatInformation,
|
|
49
|
-
sampleDatasetLink,
|
|
50
|
-
sampleDatasetInstructions,
|
|
51
|
-
headers,
|
|
52
|
-
model,
|
|
53
|
-
summary,
|
|
54
|
-
taskTitle,
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export var DisplayInformation;
|
|
3
|
+
(function (DisplayInformation) {
|
|
4
|
+
DisplayInformation.baseSchema = z.object({
|
|
5
|
+
title: z.string(),
|
|
6
|
+
summary: z.object({
|
|
7
|
+
preview: z.string(),
|
|
8
|
+
overview: z.string(),
|
|
9
|
+
}),
|
|
10
|
+
dataFormatInformation: z.string().optional(),
|
|
11
|
+
model: z.string().optional(),
|
|
12
|
+
sampleDataset: z
|
|
13
|
+
.object({
|
|
14
|
+
// URL to download a dataset for the task, is displayed in the UI when asking to connect data
|
|
15
|
+
link: z.string(),
|
|
16
|
+
// Instructions to download, unzip, and connect the right file of the sample dataset
|
|
17
|
+
instructions: z.string(),
|
|
18
|
+
})
|
|
19
|
+
.optional(),
|
|
20
|
+
});
|
|
21
|
+
DisplayInformation.dataTypeToSchema = {
|
|
22
|
+
image: z.object({
|
|
23
|
+
// url to an image
|
|
24
|
+
dataExample: z.string().optional(),
|
|
25
|
+
}),
|
|
26
|
+
tabular: z.object({
|
|
27
|
+
dataExample: z
|
|
28
|
+
.array(z.object({ name: z.string(), data: z.string() }))
|
|
29
|
+
.optional(),
|
|
30
|
+
}),
|
|
31
|
+
text: z.object({
|
|
32
|
+
dataExample: z.string().optional(),
|
|
33
|
+
}),
|
|
55
34
|
};
|
|
56
|
-
|
|
57
|
-
const _total = repack;
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
35
|
+
})(DisplayInformation || (DisplayInformation = {}));
|
package/dist/task/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export
|
|
5
|
-
export { pushTask, fetchTasks } from
|
|
1
|
+
export { Task } from "./task.js";
|
|
2
|
+
export type { TaskProvider } from "./task_provider.js";
|
|
3
|
+
export { DisplayInformation } from "./display_information.js";
|
|
4
|
+
export { TrainingInformation } from "./training_information.js";
|
|
5
|
+
export { pushTask, fetchTasks } from "./task_handler.js";
|
package/dist/task/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
1
|
+
export { Task } from "./task.js";
|
|
2
|
+
export { DisplayInformation } from "./display_information.js";
|
|
3
|
+
export { TrainingInformation } from "./training_information.js";
|
|
4
|
+
export { pushTask, fetchTasks } from "./task_handler.js";
|