mindee 5.6.1 → 5.7.1
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 +14 -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/parsing/{localResponseBase.d.ts → baseLocalResponse.d.ts} +6 -2
- package/src/parsing/{localResponseBase.js → baseLocalResponse.js} +32 -7
- package/src/pdf/pdfCompressor.js +0 -17
- 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/v1/parsing/localResponse.d.ts +2 -2
- package/src/v1/parsing/localResponse.js +2 -2
- 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/inference/field/ragMetadata.d.ts +1 -1
- package/src/v2/parsing/inference/field/ragMetadata.js +1 -1
- package/src/v2/parsing/localResponse.d.ts +2 -2
- package/src/v2/parsing/localResponse.js +2 -2
- package/src/v2/parsing/search/baseSearchResponse.d.ts +19 -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/modelWebhook.d.ts +1 -1
- package/src/v2/parsing/search/modelWebhook.js +1 -1
- package/src/v2/parsing/search/paginationMetadata.d.ts +1 -1
- package/src/v2/parsing/search/paginationMetadata.js +1 -1
- package/src/v2/parsing/search/searchModel.d.ts +2 -2
- package/src/v2/parsing/search/searchModel.js +1 -1
- package/src/v2/parsing/search/searchModels.d.ts +9 -0
- package/src/v2/parsing/search/searchModels.js +22 -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 +19 -0
- package/src/v2/search/models/modelSearch.js +25 -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
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base parameters for searches.
|
|
3
|
+
*/
|
|
4
|
+
export class BaseSearchParameters {
|
|
5
|
+
constructor(params) {
|
|
6
|
+
this.page = params.page;
|
|
7
|
+
this.perPage = params.perPage;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Gets the request parameters for the search request.
|
|
11
|
+
* @returns A `Record` mapping parameter names to their string values.
|
|
12
|
+
*/
|
|
13
|
+
getRequestParameters() {
|
|
14
|
+
const parameters = {};
|
|
15
|
+
if (this.page !== null && this.page !== undefined && this.page > 0) {
|
|
16
|
+
parameters["page"] = this.page.toString();
|
|
17
|
+
}
|
|
18
|
+
if (this.perPage !== null && this.perPage !== undefined && this.perPage > 0) {
|
|
19
|
+
parameters["per_page"] = this.perPage.toString();
|
|
20
|
+
}
|
|
21
|
+
return parameters;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { PollingOptions } from "./pollingOptions.js";
|
|
2
2
|
export type { PollingOptionsConstructor, TimerOptions, } from "./pollingOptions.js";
|
|
3
|
-
export {
|
|
3
|
+
export { BaseProductParameters } from "./baseProductParameters.js";
|
|
4
|
+
export { BaseSearchParameters } from "./baseSearchParameters.js";
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { ApiSettings } from "./apiSettings.js";
|
|
2
2
|
import { Dispatcher } from "undici";
|
|
3
|
-
import {
|
|
3
|
+
import { BaseProductParameters } from "../../v2/index.js";
|
|
4
|
+
import { BaseSearchParameters } from "../../v2/clientOptions/baseSearchParameters.js";
|
|
4
5
|
import { JobResponse } from "../../v2/parsing/index.js";
|
|
5
6
|
import { InputSource } from "../../input/index.js";
|
|
6
7
|
import { BaseProduct } from "../../v2/product/baseProduct.js";
|
|
7
|
-
import {
|
|
8
|
+
import { BaseSearch } from "../../v2/search/baseSearch.js";
|
|
8
9
|
/**
|
|
9
10
|
* Mindee V2 API handler.
|
|
10
11
|
*/
|
|
@@ -13,35 +14,28 @@ export declare class MindeeApiV2 {
|
|
|
13
14
|
settings: ApiSettings;
|
|
14
15
|
constructor(dispatcher?: Dispatcher, apiKey?: string);
|
|
15
16
|
/**
|
|
16
|
-
*
|
|
17
|
-
* @param name Optional name filter.
|
|
18
|
-
* @param modelType Optional model type filter.
|
|
19
|
-
* @returns a `Promise` containing the search response.
|
|
20
|
-
*/
|
|
21
|
-
reqGetSearchModel(name?: string, modelType?: string): Promise<SearchResponse>;
|
|
22
|
-
/**
|
|
23
|
-
* Sends a document to the inference queue.
|
|
17
|
+
* Send a file to the asynchronous processing queue for inference processing.
|
|
24
18
|
* @param product Product to enqueue.
|
|
25
19
|
* @param inputSource Local or remote file as an input.
|
|
26
20
|
* @param params {ExtractionParameters} parameters relating to the enqueueing options.
|
|
27
21
|
*/
|
|
28
|
-
reqPostProductEnqueue(product: typeof BaseProduct, inputSource: InputSource, params:
|
|
22
|
+
reqPostProductEnqueue(product: typeof BaseProduct, inputSource: InputSource, params: BaseProductParameters): Promise<JobResponse>;
|
|
29
23
|
/**
|
|
30
|
-
* Get the
|
|
24
|
+
* Get the status of an inference that was previously enqueued.
|
|
31
25
|
* Throws an error if the server's response contains an error.
|
|
32
26
|
* @param jobId The Job ID as returned by the enqueue request.
|
|
33
27
|
* @returns a `Promise` containing the job response.
|
|
34
28
|
*/
|
|
35
29
|
reqGetJobById(jobId: string): Promise<JobResponse>;
|
|
36
30
|
/**
|
|
37
|
-
* Get the
|
|
31
|
+
* Get the status of an inference that was previously enqueued.
|
|
38
32
|
* Throws an error if the server's response contains an error.
|
|
39
33
|
* @param pollingUrl The polling URL as returned by a Job's pollingUrl property.
|
|
40
34
|
* @returns a `Promise` containing the job response.
|
|
41
35
|
*/
|
|
42
36
|
reqGetJobByUrl(pollingUrl: string): Promise<JobResponse>;
|
|
43
37
|
/**
|
|
44
|
-
* Get the result of
|
|
38
|
+
* Get the result of an inference that was previously enqueued.
|
|
45
39
|
* Throws an error if the server's response contains an error.
|
|
46
40
|
* @param product
|
|
47
41
|
* @param inferenceId The inference ID for the result.
|
|
@@ -49,11 +43,18 @@ export declare class MindeeApiV2 {
|
|
|
49
43
|
*/
|
|
50
44
|
reqGetProductResultById<P extends typeof BaseProduct>(product: P, inferenceId: string): Promise<InstanceType<P["responseClass"]>>;
|
|
51
45
|
/**
|
|
52
|
-
* Get the result of
|
|
46
|
+
* Get the result of an inference that was previously enqueued.
|
|
53
47
|
* Throws an error if the server's response contains an error.
|
|
54
48
|
* @param product
|
|
55
49
|
* @param url The URL as returned by a Job's resultUrl property.
|
|
56
50
|
* @returns a `Promise` containing the parsed result.
|
|
57
51
|
*/
|
|
58
52
|
reqGetProductResultByUrl<P extends typeof BaseProduct>(product: P, url: string): Promise<InstanceType<P["responseClass"]>>;
|
|
53
|
+
/**
|
|
54
|
+
* Retrieves a list of resources with the given criteria.
|
|
55
|
+
* @param search Search definition class to use.
|
|
56
|
+
* @param parameters Search parameters.
|
|
57
|
+
* @returns a `Promise` containing the search response.
|
|
58
|
+
*/
|
|
59
|
+
reqGetSearch<S extends typeof BaseSearch>(search: S, parameters: BaseSearchParameters): Promise<InstanceType<S["responseClass"]>>;
|
|
59
60
|
}
|
|
@@ -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
|
+
* Retrieves a list of resources with the given criteria.
|
|
110
|
+
* @param search Search definition class to use.
|
|
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) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StringDict } from "../../../../parsing/stringDict.js";
|
|
2
|
-
/** Metadata
|
|
2
|
+
/** Metadata about the RAG operation. */
|
|
3
3
|
export declare class RagMetadata {
|
|
4
4
|
/**
|
|
5
5
|
* The UUID of the matched document used during the RAG operation.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { StringDict } from "../../parsing/stringDict.js";
|
|
2
|
-
import {
|
|
2
|
+
import { BaseLocalResponse } from "../../parsing/baseLocalResponse.js";
|
|
3
3
|
import { BaseResponse } from "./baseResponse.js";
|
|
4
4
|
/**
|
|
5
5
|
* Local response loaded from a file.
|
|
6
6
|
* Note: Has to be initialized through init() before use.
|
|
7
7
|
*/
|
|
8
|
-
export declare class LocalResponse extends
|
|
8
|
+
export declare class LocalResponse extends BaseLocalResponse {
|
|
9
9
|
/**
|
|
10
10
|
* Deserialize the loaded local response into a product response class.
|
|
11
11
|
*
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { MindeeError } from "../../errors/index.js";
|
|
2
|
-
import {
|
|
2
|
+
import { BaseLocalResponse } from "../../parsing/baseLocalResponse.js";
|
|
3
3
|
/**
|
|
4
4
|
* Local response loaded from a file.
|
|
5
5
|
* Note: Has to be initialized through init() before use.
|
|
6
6
|
*/
|
|
7
|
-
export class LocalResponse extends
|
|
7
|
+
export class LocalResponse extends BaseLocalResponse {
|
|
8
8
|
/**
|
|
9
9
|
* Deserialize the loaded local response into a product response class.
|
|
10
10
|
*
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
* Lines composing the response-specific body (header + items).
|
|
15
|
+
* @returns An array of body lines.
|
|
16
|
+
*/
|
|
17
|
+
protected abstract bodyLines(): string[];
|
|
18
|
+
toString(): string;
|
|
19
|
+
}
|
|
@@ -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";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { StringDict } from "../../../parsing/index.js";
|
|
2
2
|
import { ModelWebhook } from "./modelWebhook.js";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Individual model information.
|
|
5
5
|
*/
|
|
6
6
|
export declare class SearchModel {
|
|
7
7
|
/**
|
|
@@ -17,7 +17,7 @@ export declare class SearchModel {
|
|
|
17
17
|
*/
|
|
18
18
|
modelType: string;
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* List of webhooks associated with the model.
|
|
21
21
|
*/
|
|
22
22
|
webhooks: ModelWebhook[];
|
|
23
23
|
constructor(serverResponse: StringDict);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SearchModel } from "../../../v2/parsing/search/searchModel.js";
|
|
2
|
+
import { StringDict } from "../../../parsing/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* List of search models.
|
|
5
|
+
*/
|
|
6
|
+
export declare class SearchModels extends Array<SearchModel> {
|
|
7
|
+
constructor(serverResponse?: StringDict[]);
|
|
8
|
+
toString(): string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SearchModel } from "../../../v2/parsing/search/searchModel.js";
|
|
2
|
+
/**
|
|
3
|
+
* List of search models.
|
|
4
|
+
*/
|
|
5
|
+
export class SearchModels extends Array {
|
|
6
|
+
constructor(serverResponse = []) {
|
|
7
|
+
super();
|
|
8
|
+
this.push(...serverResponse.map((item) => new SearchModel(item)));
|
|
9
|
+
}
|
|
10
|
+
toString() {
|
|
11
|
+
if (this.length === 0) {
|
|
12
|
+
return "\n";
|
|
13
|
+
}
|
|
14
|
+
const lines = [];
|
|
15
|
+
for (const model of this) {
|
|
16
|
+
lines.push(`* :Name: ${model.name}`);
|
|
17
|
+
lines.push(` :ID: ${model.id}`);
|
|
18
|
+
lines.push(` :Model Type: ${model.modelType}`);
|
|
19
|
+
}
|
|
20
|
+
return lines.join("\n");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -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
|
}
|