export type GetApiApiNlpLogPidArgs = {pid: number}; export type GetApiApiNlpLogPidOptions = {baseUrl: string, cookieAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Return log messages for an ongoing training * * GET /api/nlp/log/{pid} * * Also accepts auth: basicAuth */ export const getApiApiNlpLogPid = async (args: GetApiApiNlpLogPidArgs, options: GetApiApiNlpLogPidOptions) => { const {baseUrl, fetch: fetchFn = fetch, cookieAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/text") if (cookieAuth !== undefined) cookies.push("teipublisher.com.login=" + encodeURIComponent(cookieAuth)) const url = `${baseUrl.replace(/\/+$/, '')}/api/nlp/log/${encodeURIComponent(String(args.pid))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.text() };