@retab/node 0.0.48 → 0.0.52
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/README.md +8 -215
- package/dist/api/client.d.ts +2 -2
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +2 -2
- package/dist/api/documents/client.d.ts +3 -3
- package/dist/api/documents/client.d.ts.map +1 -1
- package/dist/api/documents/client.js +3 -3
- package/dist/api/projects/client.d.ts +15 -0
- package/dist/api/projects/client.d.ts.map +1 -0
- package/dist/api/projects/client.js +43 -0
- package/dist/api/projects/documents/client.d.ts +12 -0
- package/dist/api/projects/documents/client.d.ts.map +1 -0
- package/dist/api/projects/documents/client.js +39 -0
- package/dist/api/projects/iterations/client.d.ts +17 -0
- package/dist/api/projects/iterations/client.d.ts.map +1 -0
- package/dist/api/projects/iterations/client.js +64 -0
- package/dist/client.d.ts +1 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +6 -1
- package/dist/generated_types.d.ts +17837 -40090
- package/dist/generated_types.d.ts.map +1 -1
- package/dist/generated_types.js +309 -979
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/types.d.ts +188 -80
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +22 -1
- package/package.json +6 -9
- package/dist/api/consensus/client.d.ts +0 -7
- package/dist/api/consensus/client.d.ts.map +0 -1
- package/dist/api/consensus/client.js +0 -14
- package/dist/errors.d.ts +0 -34
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -53
- package/dist/resource.d.ts +0 -12
- package/dist/resource.d.ts.map +0 -1
- package/dist/resource.js +0 -19
- package/dist/resources/consensus/completions.d.ts +0 -66
- package/dist/resources/consensus/completions.d.ts.map +0 -1
- package/dist/resources/consensus/completions.js +0 -84
- package/dist/resources/consensus/index.d.ts +0 -72
- package/dist/resources/consensus/index.d.ts.map +0 -1
- package/dist/resources/consensus/index.js +0 -76
- package/dist/resources/consensus/responses.d.ts +0 -69
- package/dist/resources/consensus/responses.d.ts.map +0 -1
- package/dist/resources/consensus/responses.js +0 -99
- package/dist/resources/documents/extractions.d.ts +0 -74
- package/dist/resources/documents/extractions.d.ts.map +0 -1
- package/dist/resources/documents/extractions.js +0 -196
- package/dist/resources/documents/index.d.ts +0 -21
- package/dist/resources/documents/index.d.ts.map +0 -1
- package/dist/resources/documents/index.js +0 -55
- package/dist/resources/evaluations/documents.d.ts +0 -40
- package/dist/resources/evaluations/documents.d.ts.map +0 -1
- package/dist/resources/evaluations/documents.js +0 -123
- package/dist/resources/evaluations/index.d.ts +0 -14
- package/dist/resources/evaluations/index.d.ts.map +0 -1
- package/dist/resources/evaluations/index.js +0 -17
- package/dist/resources/evaluations/iterations.d.ts +0 -50
- package/dist/resources/evaluations/iterations.d.ts.map +0 -1
- package/dist/resources/evaluations/iterations.js +0 -156
- package/dist/resources/files.d.ts +0 -82
- package/dist/resources/files.d.ts.map +0 -1
- package/dist/resources/files.js +0 -150
- package/dist/resources/finetuning.d.ts +0 -105
- package/dist/resources/finetuning.d.ts.map +0 -1
- package/dist/resources/finetuning.js +0 -181
- package/dist/resources/index.d.ts +0 -11
- package/dist/resources/index.d.ts.map +0 -1
- package/dist/resources/index.js +0 -10
- package/dist/resources/models.d.ts +0 -57
- package/dist/resources/models.d.ts.map +0 -1
- package/dist/resources/models.js +0 -72
- package/dist/resources/processors/automations/endpoints.d.ts +0 -90
- package/dist/resources/processors/automations/endpoints.d.ts.map +0 -1
- package/dist/resources/processors/automations/endpoints.js +0 -145
- package/dist/resources/processors/automations/index.d.ts +0 -7
- package/dist/resources/processors/automations/index.d.ts.map +0 -1
- package/dist/resources/processors/automations/index.js +0 -6
- package/dist/resources/processors/automations/links.d.ts +0 -90
- package/dist/resources/processors/automations/links.d.ts.map +0 -1
- package/dist/resources/processors/automations/links.js +0 -149
- package/dist/resources/processors/automations/logs.d.ts +0 -35
- package/dist/resources/processors/automations/logs.d.ts.map +0 -1
- package/dist/resources/processors/automations/logs.js +0 -60
- package/dist/resources/processors/automations/mailboxes.d.ts +0 -102
- package/dist/resources/processors/automations/mailboxes.d.ts.map +0 -1
- package/dist/resources/processors/automations/mailboxes.js +0 -157
- package/dist/resources/processors/automations/outlook.d.ts +0 -114
- package/dist/resources/processors/automations/outlook.d.ts.map +0 -1
- package/dist/resources/processors/automations/outlook.js +0 -170
- package/dist/resources/processors/automations/tests.d.ts +0 -58
- package/dist/resources/processors/automations/tests.d.ts.map +0 -1
- package/dist/resources/processors/automations/tests.js +0 -90
- package/dist/resources/processors/index.d.ts +0 -303
- package/dist/resources/processors/index.d.ts.map +0 -1
- package/dist/resources/processors/index.js +0 -261
- package/dist/resources/schemas.d.ts +0 -63
- package/dist/resources/schemas.d.ts.map +0 -1
- package/dist/resources/schemas.js +0 -183
- package/dist/resources/secrets/external_api_keys.d.ts +0 -61
- package/dist/resources/secrets/external_api_keys.d.ts.map +0 -1
- package/dist/resources/secrets/external_api_keys.js +0 -120
- package/dist/resources/secrets/index.d.ts +0 -14
- package/dist/resources/secrets/index.d.ts.map +0 -1
- package/dist/resources/secrets/index.js +0 -17
- package/dist/resources/secrets/webhooks.d.ts +0 -73
- package/dist/resources/secrets/webhooks.d.ts.map +0 -1
- package/dist/resources/secrets/webhooks.js +0 -145
- package/dist/resources/usage.d.ts +0 -223
- package/dist/resources/usage.d.ts.map +0 -1
- package/dist/resources/usage.js +0 -310
- package/dist/types/ai_models.d.ts +0 -389
- package/dist/types/ai_models.d.ts.map +0 -1
- package/dist/types/ai_models.js +0 -145
- package/dist/types/automations/cron.d.ts +0 -28
- package/dist/types/automations/cron.d.ts.map +0 -1
- package/dist/types/automations/cron.js +0 -1
- package/dist/types/automations/endpoints.d.ts +0 -13
- package/dist/types/automations/endpoints.d.ts.map +0 -1
- package/dist/types/automations/endpoints.js +0 -1
- package/dist/types/automations/index.d.ts +0 -7
- package/dist/types/automations/index.d.ts.map +0 -1
- package/dist/types/automations/index.js +0 -6
- package/dist/types/automations/links.d.ts +0 -15
- package/dist/types/automations/links.d.ts.map +0 -1
- package/dist/types/automations/links.js +0 -1
- package/dist/types/automations/mailboxes.d.ts +0 -18
- package/dist/types/automations/mailboxes.d.ts.map +0 -1
- package/dist/types/automations/mailboxes.js +0 -1
- package/dist/types/automations/outlook.d.ts +0 -37
- package/dist/types/automations/outlook.d.ts.map +0 -1
- package/dist/types/automations/outlook.js +0 -1
- package/dist/types/automations/webhooks.d.ts +0 -13
- package/dist/types/automations/webhooks.d.ts.map +0 -1
- package/dist/types/automations/webhooks.js +0 -1
- package/dist/types/browser_canvas.d.ts +0 -4
- package/dist/types/browser_canvas.d.ts.map +0 -1
- package/dist/types/browser_canvas.js +0 -2
- package/dist/types/chat.d.ts +0 -99
- package/dist/types/chat.d.ts.map +0 -1
- package/dist/types/chat.js +0 -20
- package/dist/types/consensus.d.ts +0 -10
- package/dist/types/consensus.d.ts.map +0 -1
- package/dist/types/consensus.js +0 -1
- package/dist/types/db/annotations.d.ts +0 -108
- package/dist/types/db/annotations.d.ts.map +0 -1
- package/dist/types/db/annotations.js +0 -6
- package/dist/types/db/files.d.ts +0 -133
- package/dist/types/db/files.d.ts.map +0 -1
- package/dist/types/db/files.js +0 -5
- package/dist/types/documents/extractions.d.ts +0 -1849
- package/dist/types/documents/extractions.d.ts.map +0 -1
- package/dist/types/documents/extractions.js +0 -211
- package/dist/types/documents/processing.d.ts +0 -249
- package/dist/types/documents/processing.d.ts.map +0 -1
- package/dist/types/documents/processing.js +0 -6
- package/dist/types/evaluations/iterations.d.ts +0 -41
- package/dist/types/evaluations/iterations.d.ts.map +0 -1
- package/dist/types/evaluations/iterations.js +0 -1
- package/dist/types/jobs/base.d.ts +0 -162
- package/dist/types/jobs/base.d.ts.map +0 -1
- package/dist/types/jobs/base.js +0 -6
- package/dist/types/jobs/specialized.d.ts +0 -200
- package/dist/types/jobs/specialized.d.ts.map +0 -1
- package/dist/types/jobs/specialized.js +0 -37
- package/dist/types/logs.d.ts +0 -92
- package/dist/types/logs.d.ts.map +0 -1
- package/dist/types/logs.js +0 -1
- package/dist/types/mime.d.ts +0 -426
- package/dist/types/mime.d.ts.map +0 -1
- package/dist/types/mime.js +0 -48
- package/dist/types/modalities.d.ts +0 -31
- package/dist/types/modalities.d.ts.map +0 -1
- package/dist/types/modalities.js +0 -109
- package/dist/types/pagination.d.ts +0 -5
- package/dist/types/pagination.d.ts.map +0 -1
- package/dist/types/pagination.js +0 -1
- package/dist/types/schemas/enhancement.d.ts +0 -250
- package/dist/types/schemas/enhancement.d.ts.map +0 -1
- package/dist/types/schemas/enhancement.js +0 -6
- package/dist/types/schemas/generate.d.ts +0 -160
- package/dist/types/schemas/generate.d.ts.map +0 -1
- package/dist/types/schemas/generate.js +0 -19
- package/dist/types/schemas/object.d.ts +0 -116
- package/dist/types/schemas/object.d.ts.map +0 -1
- package/dist/types/schemas/object.js +0 -861
- package/dist/types/secrets/external_api_keys.d.ts +0 -27
- package/dist/types/secrets/external_api_keys.d.ts.map +0 -1
- package/dist/types/secrets/external_api_keys.js +0 -11
- package/dist/types/secrets/index.d.ts +0 -2
- package/dist/types/secrets/index.d.ts.map +0 -1
- package/dist/types/secrets/index.js +0 -1
- package/dist/types/standards.d.ts +0 -37
- package/dist/types/standards.d.ts.map +0 -1
- package/dist/types/standards.js +0 -1
- package/dist/utils/ai_models.d.ts +0 -10
- package/dist/utils/ai_models.d.ts.map +0 -1
- package/dist/utils/ai_models.js +0 -183
- package/dist/utils/batch_processing.d.ts +0 -227
- package/dist/utils/batch_processing.d.ts.map +0 -1
- package/dist/utils/batch_processing.js +0 -268
- package/dist/utils/benchmarking.d.ts +0 -115
- package/dist/utils/benchmarking.d.ts.map +0 -1
- package/dist/utils/benchmarking.js +0 -355
- package/dist/utils/chat.d.ts +0 -70
- package/dist/utils/chat.d.ts.map +0 -1
- package/dist/utils/chat.js +0 -79
- package/dist/utils/cost_calculation.d.ts +0 -26
- package/dist/utils/cost_calculation.d.ts.map +0 -1
- package/dist/utils/cost_calculation.js +0 -99
- package/dist/utils/datasets.d.ts +0 -135
- package/dist/utils/datasets.d.ts.map +0 -1
- package/dist/utils/datasets.js +0 -359
- package/dist/utils/display.d.ts +0 -108
- package/dist/utils/display.d.ts.map +0 -1
- package/dist/utils/display.js +0 -244
- package/dist/utils/hash.d.ts +0 -18
- package/dist/utils/hash.d.ts.map +0 -1
- package/dist/utils/hash.js +0 -31
- package/dist/utils/hashing.d.ts +0 -18
- package/dist/utils/hashing.d.ts.map +0 -1
- package/dist/utils/hashing.js +0 -28
- package/dist/utils/index.d.ts +0 -8
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -10
- package/dist/utils/json_schema.d.ts +0 -18
- package/dist/utils/json_schema.d.ts.map +0 -1
- package/dist/utils/json_schema.js +0 -334
- package/dist/utils/json_schema_utils.d.ts +0 -42
- package/dist/utils/json_schema_utils.d.ts.map +0 -1
- package/dist/utils/json_schema_utils.js +0 -212
- package/dist/utils/jsonl.d.ts +0 -60
- package/dist/utils/jsonl.d.ts.map +0 -1
- package/dist/utils/jsonl.js +0 -259
- package/dist/utils/mime.d.ts +0 -6
- package/dist/utils/mime.d.ts.map +0 -1
- package/dist/utils/mime.js +0 -129
- package/dist/utils/model_cards.d.ts +0 -219
- package/dist/utils/model_cards.d.ts.map +0 -1
- package/dist/utils/model_cards.js +0 -462
- package/dist/utils/prompt_optimization.d.ts +0 -96
- package/dist/utils/prompt_optimization.d.ts.map +0 -1
- package/dist/utils/prompt_optimization.js +0 -275
- package/dist/utils/responses.d.ts +0 -35
- package/dist/utils/responses.d.ts.map +0 -1
- package/dist/utils/responses.js +0 -37
- package/dist/utils/stream.d.ts +0 -13
- package/dist/utils/stream.d.ts.map +0 -1
- package/dist/utils/stream.js +0 -64
- package/dist/utils/stream_context_managers.d.ts +0 -147
- package/dist/utils/stream_context_managers.d.ts.map +0 -1
- package/dist/utils/stream_context_managers.js +0 -380
- package/dist/utils/usage.d.ts +0 -57
- package/dist/utils/usage.d.ts.map +0 -1
- package/dist/utils/usage.js +0 -97
- package/dist/utils/webhook_secrets.d.ts +0 -59
- package/dist/utils/webhook_secrets.d.ts.map +0 -1
- package/dist/utils/webhook_secrets.js +0 -107
- package/dist/utils/zod_to_json_schema.d.ts +0 -11
- package/dist/utils/zod_to_json_schema.d.ts.map +0 -1
- package/dist/utils/zod_to_json_schema.js +0 -123
package/dist/resources/usage.js
DELETED
|
@@ -1,310 +0,0 @@
|
|
|
1
|
-
import { SyncAPIResource, AsyncAPIResource } from '../resource.js';
|
|
2
|
-
// Global variable to track total cost
|
|
3
|
-
let totalCost = 0.0;
|
|
4
|
-
export class UsageMixin {
|
|
5
|
-
prepareMonthlyCreditsUsage() {
|
|
6
|
-
return {
|
|
7
|
-
method: 'GET',
|
|
8
|
-
url: '/v1/usage/monthly_credits',
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
prepareTotal(params = {}) {
|
|
12
|
-
const queryParams = {};
|
|
13
|
-
if (params.start_date) {
|
|
14
|
-
queryParams.start_date = params.start_date.toISOString();
|
|
15
|
-
}
|
|
16
|
-
if (params.end_date) {
|
|
17
|
-
queryParams.end_date = params.end_date.toISOString();
|
|
18
|
-
}
|
|
19
|
-
return {
|
|
20
|
-
method: 'GET',
|
|
21
|
-
url: '/v1/usage/total',
|
|
22
|
-
params: queryParams,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
prepareMailbox(params) {
|
|
26
|
-
const queryParams = {};
|
|
27
|
-
if (params.start_date) {
|
|
28
|
-
queryParams.start_date = params.start_date.toISOString();
|
|
29
|
-
}
|
|
30
|
-
if (params.end_date) {
|
|
31
|
-
queryParams.end_date = params.end_date.toISOString();
|
|
32
|
-
}
|
|
33
|
-
return {
|
|
34
|
-
method: 'GET',
|
|
35
|
-
url: `/v1/processors/automations/mailboxes/${params.email}/usage`,
|
|
36
|
-
params: queryParams,
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
prepareLink(params) {
|
|
40
|
-
const queryParams = {};
|
|
41
|
-
if (params.start_date) {
|
|
42
|
-
queryParams.start_date = params.start_date.toISOString();
|
|
43
|
-
}
|
|
44
|
-
if (params.end_date) {
|
|
45
|
-
queryParams.end_date = params.end_date.toISOString();
|
|
46
|
-
}
|
|
47
|
-
return {
|
|
48
|
-
method: 'GET',
|
|
49
|
-
url: `/v1/processors/automations/links/${params.link_id}/usage`,
|
|
50
|
-
params: queryParams,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
prepareSchema(params) {
|
|
54
|
-
const queryParams = {};
|
|
55
|
-
if (params.start_date) {
|
|
56
|
-
queryParams.start_date = params.start_date.toISOString();
|
|
57
|
-
}
|
|
58
|
-
if (params.end_date) {
|
|
59
|
-
queryParams.end_date = params.end_date.toISOString();
|
|
60
|
-
}
|
|
61
|
-
return {
|
|
62
|
-
method: 'GET',
|
|
63
|
-
url: `/v1/schemas/${params.schema_id}/usage`,
|
|
64
|
-
params: queryParams,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
prepareSchemaData(params) {
|
|
68
|
-
const queryParams = {};
|
|
69
|
-
if (params.start_date) {
|
|
70
|
-
queryParams.start_date = params.start_date.toISOString();
|
|
71
|
-
}
|
|
72
|
-
if (params.end_date) {
|
|
73
|
-
queryParams.end_date = params.end_date.toISOString();
|
|
74
|
-
}
|
|
75
|
-
return {
|
|
76
|
-
method: 'GET',
|
|
77
|
-
url: `/v1/schemas/${params.schema_data_id}/usage_data`,
|
|
78
|
-
params: queryParams,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
prepareLog(params) {
|
|
82
|
-
let logCompletionRequest;
|
|
83
|
-
if (params.response_format && typeof params.response_format === 'object') {
|
|
84
|
-
if ('json_schema' in params.response_format) {
|
|
85
|
-
const jsonSchema = params.response_format.json_schema;
|
|
86
|
-
if ('schema' in jsonSchema) {
|
|
87
|
-
logCompletionRequest = {
|
|
88
|
-
json_schema: jsonSchema.schema,
|
|
89
|
-
completion: params.completion,
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
throw new Error('Invalid response format');
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
throw new Error('Invalid response format');
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
throw new Error('Invalid response format');
|
|
102
|
-
}
|
|
103
|
-
return {
|
|
104
|
-
method: 'POST',
|
|
105
|
-
url: '/v1/usage/log',
|
|
106
|
-
data: logCompletionRequest,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
export class Usage extends SyncAPIResource {
|
|
111
|
-
constructor() {
|
|
112
|
-
super(...arguments);
|
|
113
|
-
this.mixin = new UsageMixin();
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Get monthly credits usage information.
|
|
117
|
-
* Credits are calculated dynamically based on MIME type and consumption.
|
|
118
|
-
*
|
|
119
|
-
* @returns Monthly usage data including credits consumed and limits
|
|
120
|
-
* @throws RetabAPIError if the API request fails
|
|
121
|
-
*/
|
|
122
|
-
monthlyCreditsUsage() {
|
|
123
|
-
const request = this.mixin.prepareMonthlyCreditsUsage();
|
|
124
|
-
const response = this._client._preparedRequest(request);
|
|
125
|
-
return response;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Get the total usage cost within an optional date range.
|
|
129
|
-
*
|
|
130
|
-
* @param start_date - Start date for usage calculation
|
|
131
|
-
* @param end_date - End date for usage calculation
|
|
132
|
-
* @returns The total usage cost
|
|
133
|
-
*/
|
|
134
|
-
total(_params = {}) {
|
|
135
|
-
return { value: totalCost, currency: 'USD' };
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Get the total usage cost for a mailbox within an optional date range.
|
|
139
|
-
*
|
|
140
|
-
* @param email - The email address of the mailbox
|
|
141
|
-
* @param start_date - Start date for usage calculation
|
|
142
|
-
* @param end_date - End date for usage calculation
|
|
143
|
-
* @returns The total usage cost
|
|
144
|
-
*/
|
|
145
|
-
mailbox(params) {
|
|
146
|
-
const request = this.mixin.prepareMailbox(params);
|
|
147
|
-
const response = this._client._preparedRequest(request);
|
|
148
|
-
return response;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Get the total usage cost for a link within an optional date range.
|
|
152
|
-
*
|
|
153
|
-
* @param link_id - The ID of the link
|
|
154
|
-
* @param start_date - Start date for usage calculation
|
|
155
|
-
* @param end_date - End date for usage calculation
|
|
156
|
-
* @returns The total usage cost
|
|
157
|
-
*/
|
|
158
|
-
link(params) {
|
|
159
|
-
const request = this.mixin.prepareLink(params);
|
|
160
|
-
const response = this._client._preparedRequest(request);
|
|
161
|
-
return response;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Get the total usage cost for a schema within an optional date range.
|
|
165
|
-
*
|
|
166
|
-
* @param schema_id - The ID of the schema
|
|
167
|
-
* @param start_date - Start date for usage calculation
|
|
168
|
-
* @param end_date - End date for usage calculation
|
|
169
|
-
* @returns The total usage cost
|
|
170
|
-
*/
|
|
171
|
-
schema(params) {
|
|
172
|
-
const request = this.mixin.prepareSchema(params);
|
|
173
|
-
const response = this._client._preparedRequest(request);
|
|
174
|
-
return response;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Get the total usage cost for a schema data within an optional date range.
|
|
178
|
-
*
|
|
179
|
-
* @param schema_data_id - The ID of the schema data
|
|
180
|
-
* @param start_date - Start date for usage calculation
|
|
181
|
-
* @param end_date - End date for usage calculation
|
|
182
|
-
* @returns The total usage cost
|
|
183
|
-
*/
|
|
184
|
-
schemaData(params) {
|
|
185
|
-
const request = this.mixin.prepareSchemaData(params);
|
|
186
|
-
const response = this._client._preparedRequest(request);
|
|
187
|
-
return response;
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Logs an OpenAI request completion as an automation log to make usage calculation possible.
|
|
191
|
-
*
|
|
192
|
-
* Example:
|
|
193
|
-
* ```typescript
|
|
194
|
-
* const client = new OpenAI();
|
|
195
|
-
* const completion = await client.beta.chat.completions.parse({
|
|
196
|
-
* model: "gpt-4o-2024-08-06",
|
|
197
|
-
* messages: [
|
|
198
|
-
* {"role": "developer", "content": "Extract the event information."},
|
|
199
|
-
* {"role": "user", "content": "Alice and Bob are going to a science fair on Friday."},
|
|
200
|
-
* ],
|
|
201
|
-
* response_format: CalendarEvent,
|
|
202
|
-
* });
|
|
203
|
-
* reclient.usage.log({
|
|
204
|
-
* response_format: CalendarEvent,
|
|
205
|
-
* completion: completion
|
|
206
|
-
* });
|
|
207
|
-
* ```
|
|
208
|
-
*
|
|
209
|
-
* @param response_format - The response format of the OpenAI request
|
|
210
|
-
* @param completion - The completion of the OpenAI request
|
|
211
|
-
* @returns The automation log
|
|
212
|
-
*/
|
|
213
|
-
log(params) {
|
|
214
|
-
const request = this.mixin.prepareLog(params);
|
|
215
|
-
const response = this._client._preparedRequest(request);
|
|
216
|
-
return response;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
export class AsyncUsage extends AsyncAPIResource {
|
|
220
|
-
constructor() {
|
|
221
|
-
super(...arguments);
|
|
222
|
-
this.mixin = new UsageMixin();
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Get monthly credits usage information asynchronously.
|
|
226
|
-
* Credits are calculated dynamically based on MIME type and consumption.
|
|
227
|
-
*
|
|
228
|
-
* @returns Monthly usage data including credits consumed and limits
|
|
229
|
-
* @throws RetabAPIError if the API request fails
|
|
230
|
-
*/
|
|
231
|
-
async monthlyCreditsUsage() {
|
|
232
|
-
const request = this.mixin.prepareMonthlyCreditsUsage();
|
|
233
|
-
const response = await this._client._preparedRequest(request);
|
|
234
|
-
return response;
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Get the total usage cost within an optional date range.
|
|
238
|
-
*
|
|
239
|
-
* @param start_date - Start date for usage calculation
|
|
240
|
-
* @param end_date - End date for usage calculation
|
|
241
|
-
* @returns The total usage cost
|
|
242
|
-
*/
|
|
243
|
-
async total(_params = {}) {
|
|
244
|
-
return { value: totalCost, currency: 'USD' };
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* Get the total usage cost for a mailbox within an optional date range.
|
|
248
|
-
*
|
|
249
|
-
* @param email - The email address of the mailbox
|
|
250
|
-
* @param start_date - Start date for usage calculation
|
|
251
|
-
* @param end_date - End date for usage calculation
|
|
252
|
-
* @returns The total usage cost
|
|
253
|
-
*/
|
|
254
|
-
async mailbox(params) {
|
|
255
|
-
const request = this.mixin.prepareMailbox(params);
|
|
256
|
-
const response = await this._client._preparedRequest(request);
|
|
257
|
-
return response;
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Get the total usage cost for a link within an optional date range.
|
|
261
|
-
*
|
|
262
|
-
* @param link_id - The ID of the link
|
|
263
|
-
* @param start_date - Start date for usage calculation
|
|
264
|
-
* @param end_date - End date for usage calculation
|
|
265
|
-
* @returns The total usage cost
|
|
266
|
-
*/
|
|
267
|
-
async link(params) {
|
|
268
|
-
const request = this.mixin.prepareLink(params);
|
|
269
|
-
const response = await this._client._preparedRequest(request);
|
|
270
|
-
return response;
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* Get the total usage cost for a schema within an optional date range.
|
|
274
|
-
*
|
|
275
|
-
* @param schema_id - The ID of the schema
|
|
276
|
-
* @param start_date - Start date for usage calculation
|
|
277
|
-
* @param end_date - End date for usage calculation
|
|
278
|
-
* @returns The total usage cost
|
|
279
|
-
*/
|
|
280
|
-
async schema(params) {
|
|
281
|
-
const request = this.mixin.prepareSchema(params);
|
|
282
|
-
const response = await this._client._preparedRequest(request);
|
|
283
|
-
return response;
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* Get the total usage cost for a schema data within an optional date range.
|
|
287
|
-
*
|
|
288
|
-
* @param schema_data_id - The ID of the schema data
|
|
289
|
-
* @param start_date - Start date for usage calculation
|
|
290
|
-
* @param end_date - End date for usage calculation
|
|
291
|
-
* @returns The total usage cost
|
|
292
|
-
*/
|
|
293
|
-
async schemaData(params) {
|
|
294
|
-
const request = this.mixin.prepareSchemaData(params);
|
|
295
|
-
const response = await this._client._preparedRequest(request);
|
|
296
|
-
return response;
|
|
297
|
-
}
|
|
298
|
-
/**
|
|
299
|
-
* Logs an OpenAI request completion as an automation log to make usage calculation possible.
|
|
300
|
-
*
|
|
301
|
-
* @param response_format - The response format of the OpenAI request
|
|
302
|
-
* @param completion - The completion of the OpenAI request
|
|
303
|
-
* @returns The automation log
|
|
304
|
-
*/
|
|
305
|
-
async log(params) {
|
|
306
|
-
const request = this.mixin.prepareLog(params);
|
|
307
|
-
const response = await this._client._preparedRequest(request);
|
|
308
|
-
return response;
|
|
309
|
-
}
|
|
310
|
-
}
|