Spaces:
Running
Running
File size: 1,256 Bytes
0ea25d9 |
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 42 43 44 45 46 47 |
export type DataDict = Record<string, { date: string; close: number[] }[]>;
export async function apiGetLatestDataset() {
const r = await fetch("/api/dataset/latest");
if (!r.ok) throw new Error(await r.text());
return r.json();
}
export async function apiUpsertDataset(body: {
dataset_id: string;
name: string;
data: DataDict;
assets: string[];
dates: string[];
}) {
const r = await fetch("/api/dataset/upsert", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body),
});
if (!r.ok) throw new Error(await r.text());
return r.json();
}
export async function apiGetAnnotation(dataset_id: string, user_id: string) {
const url = `/api/annotation/get?dataset_id=${dataset_id}&user_id=${user_id}`;
const r = await fetch(url);
if (!r.ok) throw new Error(await r.text());
return r.json();
}
export async function apiUpsertAnnotation(body: {
dataset_id: string;
user_id: string;
selections: any[];
step: number;
window_len: number;
}) {
const r = await fetch("/api/annotation/upsert", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body),
});
if (!r.ok) throw new Error(await r.text());
return r.json();
}
|