mindee 5.6.0 → 5.7.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/CHANGELOG.md +13 -0
- package/package.json +1 -3
- package/src/http/apiCore.d.ts +0 -7
- package/src/http/apiCore.js +0 -11
- package/src/http/baseSettings.js +2 -2
- package/src/http/dispatcher.d.ts +6 -0
- package/src/http/dispatcher.js +17 -0
- package/src/http/index.d.ts +1 -0
- package/src/http/index.js +1 -0
- package/src/input/urlInput.js +3 -2
- package/src/v1/http/baseEndpoint.d.ts +15 -0
- package/src/v1/http/baseEndpoint.js +17 -0
- package/src/v1/http/endpoint.d.ts +2 -5
- package/src/v1/http/endpoint.js +6 -6
- package/src/v1/http/workflowEndpoint.d.ts +2 -5
- package/src/v1/http/workflowEndpoint.js +5 -5
- package/src/v2/client.d.ts +9 -0
- package/src/v2/client.js +18 -1
- package/src/v2/clientOptions/{baseParameters.d.ts → baseProductParameters.d.ts} +7 -19
- package/src/v2/clientOptions/baseProductParameters.js +30 -0
- package/src/v2/clientOptions/baseSearchParameters.d.ts +26 -0
- package/src/v2/clientOptions/baseSearchParameters.js +23 -0
- package/src/v2/clientOptions/index.d.ts +2 -1
- package/src/v2/clientOptions/index.js +2 -1
- package/src/v2/http/mindeeApiV2.d.ts +16 -15
- package/src/v2/http/mindeeApiV2.js +33 -32
- package/src/v2/index.d.ts +2 -1
- package/src/v2/index.js +1 -0
- package/src/v2/parsing/inference/field/listField.d.ts +1 -1
- package/src/v2/parsing/inference/field/listField.js +9 -9
- package/src/v2/parsing/search/baseSearchResponse.d.ts +18 -0
- package/src/v2/parsing/search/baseSearchResponse.js +17 -0
- package/src/v2/parsing/search/index.d.ts +2 -0
- package/src/v2/parsing/search/index.js +2 -0
- package/src/v2/parsing/search/searchModels.d.ts +6 -0
- package/src/v2/parsing/search/searchModels.js +19 -0
- package/src/v2/parsing/search/searchRagDocument.d.ts +35 -0
- package/src/v2/parsing/search/searchRagDocument.js +16 -0
- package/src/v2/parsing/search/searchRagDocuments.d.ts +9 -0
- package/src/v2/parsing/search/searchRagDocuments.js +26 -0
- package/src/v2/parsing/search/searchResponse.d.ts +3 -13
- package/src/v2/parsing/search/searchResponse.js +3 -17
- package/src/v2/product/baseProduct.d.ts +5 -2
- package/src/v2/product/baseProduct.js +3 -0
- package/src/v2/product/classification/classification.d.ts +3 -3
- package/src/v2/product/classification/classification.js +3 -3
- package/src/v2/product/classification/params/classificationParameters.d.ts +4 -18
- package/src/v2/product/classification/params/classificationParameters.js +3 -17
- package/src/v2/product/crop/crop.d.ts +3 -3
- package/src/v2/product/crop/crop.js +3 -3
- package/src/v2/product/crop/params/cropParameters.d.ts +4 -18
- package/src/v2/product/crop/params/cropParameters.js +3 -17
- package/src/v2/product/extraction/extraction.d.ts +3 -3
- package/src/v2/product/extraction/extraction.js +3 -3
- package/src/v2/product/extraction/params/extractionParameters.d.ts +5 -21
- package/src/v2/product/extraction/params/extractionParameters.js +12 -32
- package/src/v2/product/ocr/ocr.d.ts +3 -3
- package/src/v2/product/ocr/ocr.js +3 -3
- package/src/v2/product/ocr/params/ocrParameters.d.ts +4 -18
- package/src/v2/product/ocr/params/ocrParameters.js +3 -17
- package/src/v2/product/split/params/splitParameters.d.ts +4 -18
- package/src/v2/product/split/params/splitParameters.js +3 -17
- package/src/v2/product/split/split.d.ts +3 -3
- package/src/v2/product/split/split.js +3 -3
- package/src/v2/search/baseSearch.d.ts +15 -0
- package/src/v2/search/baseSearch.js +19 -0
- package/src/v2/search/index.d.ts +6 -0
- package/src/v2/search/index.js +6 -0
- package/src/v2/search/models/index.d.ts +3 -0
- package/src/v2/search/models/index.js +3 -0
- package/src/v2/search/models/modelSearch.d.ts +14 -0
- package/src/v2/search/models/modelSearch.js +20 -0
- package/src/v2/search/models/modelSearchParameters.d.ts +24 -0
- package/src/v2/search/models/modelSearchParameters.js +22 -0
- package/src/v2/search/models/modelSearchResponse.d.ts +14 -0
- package/src/v2/search/models/modelSearchResponse.js +14 -0
- package/src/v2/search/ragDocuments/index.d.ts +3 -0
- package/src/v2/search/ragDocuments/index.js +3 -0
- package/src/v2/search/ragDocuments/ragDocumentSearch.d.ts +14 -0
- package/src/v2/search/ragDocuments/ragDocumentSearch.js +20 -0
- package/src/v2/search/ragDocuments/ragDocumentSearchParameters.d.ts +24 -0
- package/src/v2/search/ragDocuments/ragDocumentSearchParameters.js +24 -0
- package/src/v2/search/ragDocuments/ragDocumentSearchResponse.d.ts +14 -0
- package/src/v2/search/ragDocuments/ragDocumentSearchResponse.js +14 -0
- package/src/v2/clientOptions/baseParameters.js +0 -42
|
@@ -3,15 +3,15 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
3
3
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
4
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
5
|
};
|
|
6
|
-
var _MindeeApiV2_instances, _MindeeApiV2_processResponse;
|
|
6
|
+
var _MindeeApiV2_instances, _MindeeApiV2_paramsToFormData, _MindeeApiV2_processResponse;
|
|
7
7
|
import { ApiSettings } from "./apiSettings.js";
|
|
8
|
+
import { FormData } from "undici";
|
|
8
9
|
import { ErrorResponse, JobResponse, } from "../../v2/parsing/index.js";
|
|
9
10
|
import { sendRequestAndReadResponse } from "../../http/apiCore.js";
|
|
10
11
|
import { LocalInputSource } from "../../input/index.js";
|
|
11
12
|
import { MindeeDeserializationError, MindeeError } from "../../errors/index.js";
|
|
12
13
|
import { MindeeHttpErrorV2 } from "./errors.js";
|
|
13
14
|
import { logger } from "../../logger.js";
|
|
14
|
-
import { SearchResponse } from "../../v2/parsing/search/index.js";
|
|
15
15
|
/**
|
|
16
16
|
* Mindee V2 API handler.
|
|
17
17
|
*/
|
|
@@ -21,36 +21,13 @@ export class MindeeApiV2 {
|
|
|
21
21
|
this.settings = new ApiSettings({ dispatcher: dispatcher, apiKey: apiKey });
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
25
|
-
* @param name Optional name filter.
|
|
26
|
-
* @param modelType Optional model type filter.
|
|
27
|
-
* @returns a `Promise` containing the search response.
|
|
28
|
-
*/
|
|
29
|
-
async reqGetSearchModel(name, modelType) {
|
|
30
|
-
const queryParams = {};
|
|
31
|
-
if (name)
|
|
32
|
-
queryParams["name"] = name;
|
|
33
|
-
if (modelType)
|
|
34
|
-
queryParams["model_type"] = modelType;
|
|
35
|
-
const options = {
|
|
36
|
-
method: "GET",
|
|
37
|
-
headers: this.settings.baseHeaders,
|
|
38
|
-
hostname: this.settings.hostname,
|
|
39
|
-
path: "/v2/search/models",
|
|
40
|
-
queryParams: queryParams,
|
|
41
|
-
timeoutSecs: this.settings.timeoutSecs,
|
|
42
|
-
};
|
|
43
|
-
const response = await sendRequestAndReadResponse(this.settings.dispatcher, options);
|
|
44
|
-
return __classPrivateFieldGet(this, _MindeeApiV2_instances, "m", _MindeeApiV2_processResponse).call(this, response, SearchResponse);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Sends a document to the inference queue.
|
|
24
|
+
* Send a file to the asynchronous processing queue for inference processing.
|
|
48
25
|
* @param product Product to enqueue.
|
|
49
26
|
* @param inputSource Local or remote file as an input.
|
|
50
27
|
* @param params {ExtractionParameters} parameters relating to the enqueueing options.
|
|
51
28
|
*/
|
|
52
29
|
async reqPostProductEnqueue(product, inputSource, params) {
|
|
53
|
-
const form = params.
|
|
30
|
+
const form = __classPrivateFieldGet(this, _MindeeApiV2_instances, "m", _MindeeApiV2_paramsToFormData).call(this, params.getRequestParameters());
|
|
54
31
|
if (inputSource instanceof LocalInputSource) {
|
|
55
32
|
form.set("file", new Blob([inputSource.fileObject]), inputSource.filename);
|
|
56
33
|
}
|
|
@@ -73,7 +50,7 @@ export class MindeeApiV2 {
|
|
|
73
50
|
return __classPrivateFieldGet(this, _MindeeApiV2_instances, "m", _MindeeApiV2_processResponse).call(this, result, JobResponse);
|
|
74
51
|
}
|
|
75
52
|
/**
|
|
76
|
-
* Get the
|
|
53
|
+
* Get the status of an inference that was previously enqueued.
|
|
77
54
|
* Throws an error if the server's response contains an error.
|
|
78
55
|
* @param jobId The Job ID as returned by the enqueue request.
|
|
79
56
|
* @returns a `Promise` containing the job response.
|
|
@@ -82,7 +59,7 @@ export class MindeeApiV2 {
|
|
|
82
59
|
return this.reqGetJobByUrl(`https://${this.settings.hostname}/v2/jobs/${jobId}`);
|
|
83
60
|
}
|
|
84
61
|
/**
|
|
85
|
-
* Get the
|
|
62
|
+
* Get the status of an inference that was previously enqueued.
|
|
86
63
|
* Throws an error if the server's response contains an error.
|
|
87
64
|
* @param pollingUrl The polling URL as returned by a Job's pollingUrl property.
|
|
88
65
|
* @returns a `Promise` containing the job response.
|
|
@@ -100,7 +77,7 @@ export class MindeeApiV2 {
|
|
|
100
77
|
return __classPrivateFieldGet(this, _MindeeApiV2_instances, "m", _MindeeApiV2_processResponse).call(this, response, JobResponse);
|
|
101
78
|
}
|
|
102
79
|
/**
|
|
103
|
-
* Get the result of
|
|
80
|
+
* Get the result of an inference that was previously enqueued.
|
|
104
81
|
* Throws an error if the server's response contains an error.
|
|
105
82
|
* @param product
|
|
106
83
|
* @param inferenceId The inference ID for the result.
|
|
@@ -110,7 +87,7 @@ export class MindeeApiV2 {
|
|
|
110
87
|
return this.reqGetProductResultByUrl(product, `https://${this.settings.hostname}/v2/products/${product.slug}/results/${inferenceId}`);
|
|
111
88
|
}
|
|
112
89
|
/**
|
|
113
|
-
* Get the result of
|
|
90
|
+
* Get the result of an inference that was previously enqueued.
|
|
114
91
|
* Throws an error if the server's response contains an error.
|
|
115
92
|
* @param product
|
|
116
93
|
* @param url The URL as returned by a Job's resultUrl property.
|
|
@@ -128,8 +105,32 @@ export class MindeeApiV2 {
|
|
|
128
105
|
const response = await sendRequestAndReadResponse(this.settings.dispatcher, options, url);
|
|
129
106
|
return __classPrivateFieldGet(this, _MindeeApiV2_instances, "m", _MindeeApiV2_processResponse).call(this, response, product.responseClass);
|
|
130
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Searches for resources matching the given criteria.
|
|
110
|
+
* @param search
|
|
111
|
+
* @param parameters Search parameters.
|
|
112
|
+
* @returns a `Promise` containing the search response.
|
|
113
|
+
*/
|
|
114
|
+
async reqGetSearch(search, parameters) {
|
|
115
|
+
const options = {
|
|
116
|
+
method: "GET",
|
|
117
|
+
headers: this.settings.baseHeaders,
|
|
118
|
+
hostname: this.settings.hostname,
|
|
119
|
+
path: `/v2/search/${search.slug}`,
|
|
120
|
+
queryParams: parameters.getRequestParameters(),
|
|
121
|
+
timeoutSecs: this.settings.timeoutSecs,
|
|
122
|
+
};
|
|
123
|
+
const response = await sendRequestAndReadResponse(this.settings.dispatcher, options);
|
|
124
|
+
return __classPrivateFieldGet(this, _MindeeApiV2_instances, "m", _MindeeApiV2_processResponse).call(this, response, search.responseClass);
|
|
125
|
+
}
|
|
131
126
|
}
|
|
132
|
-
_MindeeApiV2_instances = new WeakSet(),
|
|
127
|
+
_MindeeApiV2_instances = new WeakSet(), _MindeeApiV2_paramsToFormData = function _MindeeApiV2_paramsToFormData(params) {
|
|
128
|
+
const form = new FormData();
|
|
129
|
+
for (const [key, value] of Object.entries(params)) {
|
|
130
|
+
form.set(key, value);
|
|
131
|
+
}
|
|
132
|
+
return form;
|
|
133
|
+
}, _MindeeApiV2_processResponse = function _MindeeApiV2_processResponse(result, responseClass) {
|
|
133
134
|
if (result.messageObj?.statusCode
|
|
134
135
|
&& (result.messageObj?.statusCode > 399 || result.messageObj?.statusCode < 200)) {
|
|
135
136
|
if (result.data?.status !== null) {
|
package/src/v2/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export * as http from "./http/index.js";
|
|
2
2
|
export * as parsing from "./parsing/index.js";
|
|
3
3
|
export * as product from "./product/index.js";
|
|
4
|
+
export * as search from "./search/index.js";
|
|
4
5
|
export { Client } from "./client.js";
|
|
5
6
|
export { JobResponse, ErrorResponse, LocalResponse, } from "./parsing/index.js";
|
|
6
|
-
export type {
|
|
7
|
+
export type { BaseProductParameters, TimerOptions } from "./clientOptions/index.js";
|
|
7
8
|
export { PollingOptions } from "./clientOptions/index.js";
|
package/src/v2/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * as http from "./http/index.js";
|
|
2
2
|
export * as parsing from "./parsing/index.js";
|
|
3
3
|
export * as product from "./product/index.js";
|
|
4
|
+
export * as search from "./search/index.js";
|
|
4
5
|
export { Client } from "./client.js";
|
|
5
6
|
export { JobResponse, ErrorResponse, LocalResponse, } from "./parsing/index.js";
|
|
6
7
|
export { PollingOptions } from "./clientOptions/index.js";
|
|
@@ -8,6 +8,7 @@ export declare class ListField extends BaseField {
|
|
|
8
8
|
* Items contained in the list.
|
|
9
9
|
*/
|
|
10
10
|
items: Array<ListField | ObjectField | SimpleField>;
|
|
11
|
+
constructor(serverResponse: StringDict, indentLevel?: number);
|
|
11
12
|
/**
|
|
12
13
|
* SimpleField items from the list.
|
|
13
14
|
*/
|
|
@@ -16,7 +17,6 @@ export declare class ListField extends BaseField {
|
|
|
16
17
|
* SimpleField items from the list.
|
|
17
18
|
*/
|
|
18
19
|
get objectItems(): Array<ObjectField>;
|
|
19
|
-
constructor(serverResponse: StringDict, indentLevel?: number);
|
|
20
20
|
/** Returns a readable representation of list items. */
|
|
21
21
|
toString(): string;
|
|
22
22
|
}
|
|
@@ -5,6 +5,15 @@ import { SimpleField } from "./simpleField.js";
|
|
|
5
5
|
import { createField } from "./fieldFactory.js";
|
|
6
6
|
/** List-valued inference field. */
|
|
7
7
|
export class ListField extends BaseField {
|
|
8
|
+
constructor(serverResponse, indentLevel = 0) {
|
|
9
|
+
super(serverResponse, indentLevel);
|
|
10
|
+
if (!Array.isArray(serverResponse["items"])) {
|
|
11
|
+
throw new MindeeDeserializationError(`Expected "items" to be an array in ${JSON.stringify(serverResponse)}.`);
|
|
12
|
+
}
|
|
13
|
+
this.items = serverResponse["items"].map((item) => {
|
|
14
|
+
return createField(item, indentLevel + 1);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
8
17
|
/**
|
|
9
18
|
* SimpleField items from the list.
|
|
10
19
|
*/
|
|
@@ -35,15 +44,6 @@ export class ListField extends BaseField {
|
|
|
35
44
|
}
|
|
36
45
|
return result;
|
|
37
46
|
}
|
|
38
|
-
constructor(serverResponse, indentLevel = 0) {
|
|
39
|
-
super(serverResponse, indentLevel);
|
|
40
|
-
if (!Array.isArray(serverResponse["items"])) {
|
|
41
|
-
throw new MindeeDeserializationError(`Expected "items" to be an array in ${JSON.stringify(serverResponse)}.`);
|
|
42
|
-
}
|
|
43
|
-
this.items = serverResponse["items"].map((item) => {
|
|
44
|
-
return createField(item, indentLevel + 1);
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
47
|
/** Returns a readable representation of list items. */
|
|
48
48
|
toString() {
|
|
49
49
|
if (!this.items || this.items.length === 0) {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { StringDict } from "../../../parsing/index.js";
|
|
2
|
+
import { BaseResponse } from "../../../v2/parsing/baseResponse.js";
|
|
3
|
+
import { PaginationMetadata } from "./paginationMetadata.js";
|
|
4
|
+
/**
|
|
5
|
+
* Base class for search responses.
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class BaseSearchResponse extends BaseResponse {
|
|
8
|
+
/**
|
|
9
|
+
* Pagination metadata.
|
|
10
|
+
*/
|
|
11
|
+
pagination: PaginationMetadata;
|
|
12
|
+
protected constructor(serverResponse: StringDict);
|
|
13
|
+
/**
|
|
14
|
+
* List of strings representing the search response.
|
|
15
|
+
*/
|
|
16
|
+
protected abstract bodyLines(): string[];
|
|
17
|
+
toString(): string;
|
|
18
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BaseResponse } from "../../../v2/parsing/baseResponse.js";
|
|
2
|
+
import { PaginationMetadata } from "./paginationMetadata.js";
|
|
3
|
+
/**
|
|
4
|
+
* Base class for search responses.
|
|
5
|
+
*/
|
|
6
|
+
export class BaseSearchResponse extends BaseResponse {
|
|
7
|
+
constructor(serverResponse) {
|
|
8
|
+
super(serverResponse);
|
|
9
|
+
this.pagination = new PaginationMetadata(serverResponse["pagination"]);
|
|
10
|
+
}
|
|
11
|
+
toString() {
|
|
12
|
+
const lines = this.bodyLines();
|
|
13
|
+
lines.push("Pagination Metadata", "###################");
|
|
14
|
+
lines.push(this.pagination.toString());
|
|
15
|
+
return lines.join("\n");
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -2,3 +2,5 @@ export { PaginationMetadata } from "./paginationMetadata.js";
|
|
|
2
2
|
export { SearchModel } from "./searchModel.js";
|
|
3
3
|
export { SearchResponse } from "./searchResponse.js";
|
|
4
4
|
export { ModelWebhook } from "./modelWebhook.js";
|
|
5
|
+
export { BaseSearchResponse } from "./baseSearchResponse.js";
|
|
6
|
+
export { SearchRagDocument } from "./searchRagDocument.js";
|
|
@@ -2,3 +2,5 @@ export { PaginationMetadata } from "./paginationMetadata.js";
|
|
|
2
2
|
export { SearchModel } from "./searchModel.js";
|
|
3
3
|
export { SearchResponse } from "./searchResponse.js";
|
|
4
4
|
export { ModelWebhook } from "./modelWebhook.js";
|
|
5
|
+
export { BaseSearchResponse } from "./baseSearchResponse.js";
|
|
6
|
+
export { SearchRagDocument } from "./searchRagDocument.js";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SearchModel } from "../../../v2/parsing/search/searchModel.js";
|
|
2
|
+
export class SearchModels extends Array {
|
|
3
|
+
constructor(serverResponse = []) {
|
|
4
|
+
super();
|
|
5
|
+
this.push(...serverResponse.map((item) => new SearchModel(item)));
|
|
6
|
+
}
|
|
7
|
+
toString() {
|
|
8
|
+
if (this.length === 0) {
|
|
9
|
+
return "\n";
|
|
10
|
+
}
|
|
11
|
+
const lines = [];
|
|
12
|
+
for (const model of this) {
|
|
13
|
+
lines.push(`* :Name: ${model.name}`);
|
|
14
|
+
lines.push(` :ID: ${model.id}`);
|
|
15
|
+
lines.push(` :Model Type: ${model.modelType}`);
|
|
16
|
+
}
|
|
17
|
+
return lines.join("\n");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { StringDict } from "../../../parsing/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Individual RAG document information.
|
|
4
|
+
*/
|
|
5
|
+
export declare class SearchRagDocument {
|
|
6
|
+
/**
|
|
7
|
+
* Unique identifier of the RAG document.
|
|
8
|
+
*/
|
|
9
|
+
id: string;
|
|
10
|
+
/**
|
|
11
|
+
* Model identifier linked to the RAG document.
|
|
12
|
+
*/
|
|
13
|
+
modelId: string;
|
|
14
|
+
/**
|
|
15
|
+
* Original filename of the uploaded document.
|
|
16
|
+
*/
|
|
17
|
+
filename: string;
|
|
18
|
+
/**
|
|
19
|
+
* Date and time of the document creation.
|
|
20
|
+
*/
|
|
21
|
+
createdAt: Date;
|
|
22
|
+
/**
|
|
23
|
+
* Number of times this document was used in an inference.
|
|
24
|
+
*/
|
|
25
|
+
totalMatches: number;
|
|
26
|
+
/**
|
|
27
|
+
* Date and time of the latest matching inference, if any.
|
|
28
|
+
*/
|
|
29
|
+
lastMatchAt?: Date;
|
|
30
|
+
/**
|
|
31
|
+
* Current status of the RAG document.
|
|
32
|
+
*/
|
|
33
|
+
status: string;
|
|
34
|
+
constructor(serverResponse: StringDict);
|
|
35
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Individual RAG document information.
|
|
3
|
+
*/
|
|
4
|
+
export class SearchRagDocument {
|
|
5
|
+
constructor(serverResponse) {
|
|
6
|
+
this.id = serverResponse["id"];
|
|
7
|
+
this.modelId = serverResponse["model_id"];
|
|
8
|
+
this.filename = serverResponse["filename"];
|
|
9
|
+
this.createdAt = new Date(serverResponse["created_at"]);
|
|
10
|
+
this.totalMatches = serverResponse["total_matches"];
|
|
11
|
+
this.lastMatchAt = serverResponse["last_match_at"]
|
|
12
|
+
? new Date(serverResponse["last_match_at"])
|
|
13
|
+
: undefined;
|
|
14
|
+
this.status = serverResponse["status"];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SearchRagDocument } from "../../../v2/parsing/search/searchRagDocument.js";
|
|
2
|
+
import { StringDict } from "../../../parsing/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* List of RAG documents.
|
|
5
|
+
*/
|
|
6
|
+
export declare class SearchRagDocuments extends Array<SearchRagDocument> {
|
|
7
|
+
constructor(serverResponse?: StringDict[]);
|
|
8
|
+
toString(): string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SearchRagDocument } from "../../../v2/parsing/search/searchRagDocument.js";
|
|
2
|
+
/**
|
|
3
|
+
* List of RAG documents.
|
|
4
|
+
*/
|
|
5
|
+
export class SearchRagDocuments extends Array {
|
|
6
|
+
constructor(serverResponse = []) {
|
|
7
|
+
super();
|
|
8
|
+
this.push(...serverResponse.map((item) => new SearchRagDocument(item)));
|
|
9
|
+
}
|
|
10
|
+
toString() {
|
|
11
|
+
if (this.length === 0) {
|
|
12
|
+
return "\n";
|
|
13
|
+
}
|
|
14
|
+
const lines = [];
|
|
15
|
+
for (const ragDocument of this) {
|
|
16
|
+
lines.push(`* :ID: ${ragDocument.id}`);
|
|
17
|
+
lines.push(` :Model ID: ${ragDocument.modelId}`);
|
|
18
|
+
lines.push(` :Filename: ${ragDocument.filename}`);
|
|
19
|
+
lines.push(` :Created At: ${ragDocument.createdAt}`);
|
|
20
|
+
lines.push(` :Total Matches: ${ragDocument.totalMatches}`);
|
|
21
|
+
lines.push(` :Last Match At: ${ragDocument.lastMatchAt}`);
|
|
22
|
+
lines.push(` :Status: ${ragDocument.status}`);
|
|
23
|
+
}
|
|
24
|
+
return lines.join("\n");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
import { StringDict } from "../../../parsing/index.js";
|
|
2
|
-
import {
|
|
3
|
-
import { PaginationMetadata } from "./paginationMetadata.js";
|
|
4
|
-
import { SearchModel } from "./searchModel.js";
|
|
2
|
+
import { ModelSearchResponse } from "../../../v2/search/models/modelSearchResponse.js";
|
|
5
3
|
/**
|
|
6
4
|
* Models search response.
|
|
5
|
+
* @deprecated Use `ModelSearchResponse` instead.
|
|
7
6
|
*/
|
|
8
|
-
export declare class SearchResponse extends
|
|
9
|
-
/**
|
|
10
|
-
* List of models returned by the search.
|
|
11
|
-
*/
|
|
12
|
-
models: SearchModel[];
|
|
13
|
-
/**
|
|
14
|
-
* Pagination metadata.
|
|
15
|
-
*/
|
|
16
|
-
pagination: PaginationMetadata;
|
|
7
|
+
export declare class SearchResponse extends ModelSearchResponse {
|
|
17
8
|
constructor(serverResponse: StringDict);
|
|
18
|
-
toString(): string;
|
|
19
9
|
}
|
|
@@ -1,24 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { PaginationMetadata } from "./paginationMetadata.js";
|
|
3
|
-
import { SearchModel } from "./searchModel.js";
|
|
1
|
+
import { ModelSearchResponse } from "../../../v2/search/models/modelSearchResponse.js";
|
|
4
2
|
/**
|
|
5
3
|
* Models search response.
|
|
4
|
+
* @deprecated Use `ModelSearchResponse` instead.
|
|
6
5
|
*/
|
|
7
|
-
export class SearchResponse extends
|
|
6
|
+
export class SearchResponse extends ModelSearchResponse {
|
|
8
7
|
constructor(serverResponse) {
|
|
9
8
|
super(serverResponse);
|
|
10
|
-
this.models = (serverResponse["models"] ?? []).map((model) => new SearchModel(model));
|
|
11
|
-
this.pagination = new PaginationMetadata(serverResponse["pagination"]);
|
|
12
|
-
}
|
|
13
|
-
toString() {
|
|
14
|
-
const lines = ["Models", "#######"];
|
|
15
|
-
for (const model of this.models) {
|
|
16
|
-
lines.push(`* :Name: ${model.name}`);
|
|
17
|
-
lines.push(` :ID: ${model.id}`);
|
|
18
|
-
lines.push(` :Model Type: ${model.modelType}`);
|
|
19
|
-
}
|
|
20
|
-
lines.push("Pagination", "##########");
|
|
21
|
-
lines.push(this.pagination.toString());
|
|
22
|
-
return lines.join("\n");
|
|
23
9
|
}
|
|
24
10
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseProductParameters } from "../../v2/index.js";
|
|
2
2
|
import { ResponseConstructor } from "../../v2/parsing/index.js";
|
|
3
3
|
/**
|
|
4
4
|
* Base class for all V2 product definitions.
|
|
@@ -6,7 +6,10 @@ import { ResponseConstructor } from "../../v2/parsing/index.js";
|
|
|
6
6
|
* Child classes are passed to the Client when making requests.
|
|
7
7
|
*/
|
|
8
8
|
export declare abstract class BaseProduct {
|
|
9
|
-
|
|
9
|
+
/** Parameter class accepted by this product. */
|
|
10
|
+
static get parametersClass(): new (...args: any[]) => BaseProductParameters;
|
|
11
|
+
/** Response class returned by this product. */
|
|
10
12
|
static get responseClass(): ResponseConstructor<any>;
|
|
13
|
+
/** API slug for this product. */
|
|
11
14
|
static get slug(): string;
|
|
12
15
|
}
|
|
@@ -4,12 +4,15 @@
|
|
|
4
4
|
* Child classes are passed to the Client when making requests.
|
|
5
5
|
*/
|
|
6
6
|
export class BaseProduct {
|
|
7
|
+
/** Parameter class accepted by this product. */
|
|
7
8
|
static get parametersClass() {
|
|
8
9
|
throw new Error("Must define static parameters property");
|
|
9
10
|
}
|
|
11
|
+
/** Response class returned by this product. */
|
|
10
12
|
static get responseClass() {
|
|
11
13
|
throw new Error("Must define static response property");
|
|
12
14
|
}
|
|
15
|
+
/** API slug for this product. */
|
|
13
16
|
static get slug() {
|
|
14
17
|
throw new Error("Must define static slug property");
|
|
15
18
|
}
|
|
@@ -5,10 +5,10 @@ import { BaseProduct } from "../../../v2/product/baseProduct.js";
|
|
|
5
5
|
* Automatically sort any image or scanned document into categories.
|
|
6
6
|
*/
|
|
7
7
|
export declare class Classification extends BaseProduct {
|
|
8
|
-
/**
|
|
8
|
+
/** @inheritDoc */
|
|
9
9
|
static get parametersClass(): typeof ClassificationParameters;
|
|
10
|
-
/**
|
|
10
|
+
/** @inheritDoc */
|
|
11
11
|
static get responseClass(): typeof ClassificationResponse;
|
|
12
|
-
/**
|
|
12
|
+
/** @inheritDoc */
|
|
13
13
|
static get slug(): string;
|
|
14
14
|
}
|
|
@@ -5,15 +5,15 @@ import { BaseProduct } from "../../../v2/product/baseProduct.js";
|
|
|
5
5
|
* Automatically sort any image or scanned document into categories.
|
|
6
6
|
*/
|
|
7
7
|
export class Classification extends BaseProduct {
|
|
8
|
-
/**
|
|
8
|
+
/** @inheritDoc */
|
|
9
9
|
static get parametersClass() {
|
|
10
10
|
return ClassificationParameters;
|
|
11
11
|
}
|
|
12
|
-
/**
|
|
12
|
+
/** @inheritDoc */
|
|
13
13
|
static get responseClass() {
|
|
14
14
|
return ClassificationResponse;
|
|
15
15
|
}
|
|
16
|
-
/**
|
|
16
|
+
/** @inheritDoc */
|
|
17
17
|
static get slug() {
|
|
18
18
|
return "classification";
|
|
19
19
|
}
|
|
@@ -1,21 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseProductParameters, BaseProductParametersConstructor } from "../../../../v2/clientOptions/baseProductParameters.js";
|
|
2
2
|
/**
|
|
3
|
-
* Parameters
|
|
4
|
-
*
|
|
5
|
-
* All fields are optional except `modelId`.
|
|
6
|
-
*
|
|
7
|
-
* @category ClientV2
|
|
8
|
-
* @example
|
|
9
|
-
* const params = {
|
|
10
|
-
* modelId: "YOUR_MODEL_ID",
|
|
11
|
-
* alias: "YOUR_ALIAS",
|
|
12
|
-
* webhookIds: ["YOUR_WEBHOOK_ID_1", "YOUR_WEBHOOK_ID_2"],
|
|
13
|
-
* pollingOptions: {
|
|
14
|
-
* initialDelaySec: 2,
|
|
15
|
-
* delaySec: 1.5,
|
|
16
|
-
* }
|
|
17
|
-
* };
|
|
3
|
+
* Parameters for sending a file to a Classification product.
|
|
18
4
|
*/
|
|
19
|
-
export declare class ClassificationParameters extends
|
|
20
|
-
constructor(params:
|
|
5
|
+
export declare class ClassificationParameters extends BaseProductParameters {
|
|
6
|
+
constructor(params: BaseProductParametersConstructor & {});
|
|
21
7
|
}
|
|
@@ -1,23 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseProductParameters } from "../../../../v2/clientOptions/baseProductParameters.js";
|
|
2
2
|
import { logger } from "../../../../logger.js";
|
|
3
3
|
/**
|
|
4
|
-
* Parameters
|
|
5
|
-
*
|
|
6
|
-
* All fields are optional except `modelId`.
|
|
7
|
-
*
|
|
8
|
-
* @category ClientV2
|
|
9
|
-
* @example
|
|
10
|
-
* const params = {
|
|
11
|
-
* modelId: "YOUR_MODEL_ID",
|
|
12
|
-
* alias: "YOUR_ALIAS",
|
|
13
|
-
* webhookIds: ["YOUR_WEBHOOK_ID_1", "YOUR_WEBHOOK_ID_2"],
|
|
14
|
-
* pollingOptions: {
|
|
15
|
-
* initialDelaySec: 2,
|
|
16
|
-
* delaySec: 1.5,
|
|
17
|
-
* }
|
|
18
|
-
* };
|
|
4
|
+
* Parameters for sending a file to a Classification product.
|
|
19
5
|
*/
|
|
20
|
-
export class ClassificationParameters extends
|
|
6
|
+
export class ClassificationParameters extends BaseProductParameters {
|
|
21
7
|
constructor(params) {
|
|
22
8
|
super({ ...params });
|
|
23
9
|
logger.debug("Classification parameters initialized.");
|
|
@@ -5,10 +5,10 @@ import { BaseProduct } from "../../../v2/product/baseProduct.js";
|
|
|
5
5
|
* Identify the borders of documents on each page, matching each one to a category.
|
|
6
6
|
*/
|
|
7
7
|
export declare class Crop extends BaseProduct {
|
|
8
|
-
/**
|
|
8
|
+
/** @inheritDoc */
|
|
9
9
|
static get parametersClass(): typeof CropParameters;
|
|
10
|
-
/**
|
|
10
|
+
/** @inheritDoc */
|
|
11
11
|
static get responseClass(): typeof CropResponse;
|
|
12
|
-
/**
|
|
12
|
+
/** @inheritDoc */
|
|
13
13
|
static get slug(): string;
|
|
14
14
|
}
|
|
@@ -5,15 +5,15 @@ import { BaseProduct } from "../../../v2/product/baseProduct.js";
|
|
|
5
5
|
* Identify the borders of documents on each page, matching each one to a category.
|
|
6
6
|
*/
|
|
7
7
|
export class Crop extends BaseProduct {
|
|
8
|
-
/**
|
|
8
|
+
/** @inheritDoc */
|
|
9
9
|
static get parametersClass() {
|
|
10
10
|
return CropParameters;
|
|
11
11
|
}
|
|
12
|
-
/**
|
|
12
|
+
/** @inheritDoc */
|
|
13
13
|
static get responseClass() {
|
|
14
14
|
return CropResponse;
|
|
15
15
|
}
|
|
16
|
-
/**
|
|
16
|
+
/** @inheritDoc */
|
|
17
17
|
static get slug() {
|
|
18
18
|
return "crop";
|
|
19
19
|
}
|
|
@@ -1,21 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseProductParameters, BaseProductParametersConstructor } from "../../../../v2/clientOptions/baseProductParameters.js";
|
|
2
2
|
/**
|
|
3
|
-
* Parameters
|
|
4
|
-
*
|
|
5
|
-
* All fields are optional except `modelId`.
|
|
6
|
-
*
|
|
7
|
-
* @category ClientV2
|
|
8
|
-
* @example
|
|
9
|
-
* const params = {
|
|
10
|
-
* modelId: "YOUR_MODEL_ID",
|
|
11
|
-
* alias: "YOUR_ALIAS",
|
|
12
|
-
* webhookIds: ["YOUR_WEBHOOK_ID_1", "YOUR_WEBHOOK_ID_2"],
|
|
13
|
-
* pollingOptions: {
|
|
14
|
-
* initialDelaySec: 2,
|
|
15
|
-
* delaySec: 1.5,
|
|
16
|
-
* }
|
|
17
|
-
* };
|
|
3
|
+
* Parameters for sending a file to a Crop product.
|
|
18
4
|
*/
|
|
19
|
-
export declare class CropParameters extends
|
|
20
|
-
constructor(params:
|
|
5
|
+
export declare class CropParameters extends BaseProductParameters {
|
|
6
|
+
constructor(params: BaseProductParametersConstructor & {});
|
|
21
7
|
}
|
|
@@ -1,23 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseProductParameters } from "../../../../v2/clientOptions/baseProductParameters.js";
|
|
2
2
|
import { logger } from "../../../../logger.js";
|
|
3
3
|
/**
|
|
4
|
-
* Parameters
|
|
5
|
-
*
|
|
6
|
-
* All fields are optional except `modelId`.
|
|
7
|
-
*
|
|
8
|
-
* @category ClientV2
|
|
9
|
-
* @example
|
|
10
|
-
* const params = {
|
|
11
|
-
* modelId: "YOUR_MODEL_ID",
|
|
12
|
-
* alias: "YOUR_ALIAS",
|
|
13
|
-
* webhookIds: ["YOUR_WEBHOOK_ID_1", "YOUR_WEBHOOK_ID_2"],
|
|
14
|
-
* pollingOptions: {
|
|
15
|
-
* initialDelaySec: 2,
|
|
16
|
-
* delaySec: 1.5,
|
|
17
|
-
* }
|
|
18
|
-
* };
|
|
4
|
+
* Parameters for sending a file to a Crop product.
|
|
19
5
|
*/
|
|
20
|
-
export class CropParameters extends
|
|
6
|
+
export class CropParameters extends BaseProductParameters {
|
|
21
7
|
constructor(params) {
|
|
22
8
|
super({ ...params });
|
|
23
9
|
logger.debug("Crop parameters initialized.");
|
|
@@ -5,10 +5,10 @@ import { BaseProduct } from "../../../v2/product/baseProduct.js";
|
|
|
5
5
|
* Automatically extract structured data from any image or scanned document.
|
|
6
6
|
*/
|
|
7
7
|
export declare class Extraction extends BaseProduct {
|
|
8
|
-
/**
|
|
8
|
+
/** @inheritDoc */
|
|
9
9
|
static get parametersClass(): typeof ExtractionParameters;
|
|
10
|
-
/**
|
|
10
|
+
/** @inheritDoc */
|
|
11
11
|
static get responseClass(): typeof ExtractionResponse;
|
|
12
|
-
/**
|
|
12
|
+
/** @inheritDoc */
|
|
13
13
|
static get slug(): string;
|
|
14
14
|
}
|