UNPKG

mindee

Version:

Mindee Client Library for Node.js

70 lines (69 loc) 2.7 kB
import { InputSource } from "../../input/index.js"; import { StringDict } from "../../parsing/stringDict.js"; import { BaseHttpResponse } from "../../http/apiCore.js"; import { ApiSettingsV1 } from "./apiSettingsV1.js"; import { PredictParams } from "./httpParams.js"; /** * Endpoint for a product (OTS or Custom). */ export declare class Endpoint { #private; /** Settings relating to the API. */ settings: ApiSettingsV1; /** Root of the URL for API calls. */ urlRoot: string; /** URL of a product. */ urlName: string; /** Account owning the product. */ owner: string; /** Product's version, as a string. */ version: string; constructor(urlName: string, owner: string, version: string, settings: ApiSettingsV1); /** * Sends a document to the API and parses out the result. * Throws an error if the server's response contains one. * @param {PredictParams} params parameters relating to prediction options. * @category Synchronous * @returns a `Promise` containing parsing results. */ predict(params: PredictParams): Promise<BaseHttpResponse>; /** * Enqueues a prediction to the API. * Throws an error if the server's response contains one. * @param {PredictParams} params parameters relating to prediction options. * @category Asynchronous * @returns a `Promise` containing queue data. */ predictAsync(params: PredictParams): Promise<BaseHttpResponse>; private extractStatusMessage; /** * Requests the results of a queued document from the API. * Throws an error if the server's response contains one. * @param queueId The document's ID in the queue. * @category Asynchronous * @returns a `Promise` containing the parsed result. */ getQueuedDocument(queueId: string): Promise<BaseHttpResponse>; /** * Send a feedback * @param {string} documentId */ getDocument(documentId: string): Promise<BaseHttpResponse>; /** * Send a feedback * @param {string} documentId - ID of the document to send feedback to. * @param {StringDict} feedback - Feedback object to send. */ sendFeedback(documentId: string, feedback: StringDict): Promise<BaseHttpResponse>; /** * Send a file to a prediction API. * @param input * @param predictUrl * @param includeWords * @param fullText * @param cropper * @param rag * @param workflowId */ protected sendFileForPrediction(input: InputSource, predictUrl: string, includeWords?: boolean, fullText?: boolean, cropper?: boolean, rag?: boolean, workflowId?: string | undefined): Promise<BaseHttpResponse>; }