@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
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
import { SyncAPIResource, AsyncAPIResource } from '../../resource.js';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { prepareMimeDocument } from '../../utils/mime.js';
|
|
4
|
-
import { loadJsonSchema } from '../../utils/json_schema.js';
|
|
5
|
-
import { Endpoints, AsyncEndpoints, Links, AsyncLinks, Mailboxes, AsyncMailboxes, OutlookAutomations, AsyncOutlookAutomations, Tests, AsyncTests, Logs, AsyncLogs } from './automations/index.js';
|
|
6
|
-
// Processor configuration schema
|
|
7
|
-
const ProcessorConfigSchema = z.object({
|
|
8
|
-
id: z.string(),
|
|
9
|
-
name: z.string(),
|
|
10
|
-
json_schema: z.record(z.any()),
|
|
11
|
-
modality: z.string(),
|
|
12
|
-
model: z.string(),
|
|
13
|
-
temperature: z.number().optional(),
|
|
14
|
-
reasoning_effort: z.string().optional(),
|
|
15
|
-
image_resolution_dpi: z.number().optional(),
|
|
16
|
-
browser_canvas: z.string().optional(),
|
|
17
|
-
n_consensus: z.number().optional(),
|
|
18
|
-
created_at: z.string().optional(),
|
|
19
|
-
updated_at: z.string().optional(),
|
|
20
|
-
});
|
|
21
|
-
const ListMetadataSchema = z.object({
|
|
22
|
-
has_more: z.boolean().optional(),
|
|
23
|
-
total_count: z.number().optional(),
|
|
24
|
-
next_page_token: z.string().optional(),
|
|
25
|
-
previous_page_token: z.string().optional(),
|
|
26
|
-
}).optional();
|
|
27
|
-
const ListProcessorsSchema = z.object({
|
|
28
|
-
data: z.array(ProcessorConfigSchema),
|
|
29
|
-
list_metadata: ListMetadataSchema.optional(),
|
|
30
|
-
});
|
|
31
|
-
export class ProcessorsMixin {
|
|
32
|
-
prepareCreate(params) {
|
|
33
|
-
const { name, json_schema, modality = 'native', model = 'gpt-4o-mini', temperature, reasoning_effort, image_resolution_dpi, browser_canvas, n_consensus, } = params;
|
|
34
|
-
// Load the JSON schema from file path, string, or dict
|
|
35
|
-
const loadedSchema = loadJsonSchema(json_schema);
|
|
36
|
-
const configDict = {
|
|
37
|
-
name,
|
|
38
|
-
json_schema: loadedSchema,
|
|
39
|
-
modality,
|
|
40
|
-
model,
|
|
41
|
-
};
|
|
42
|
-
if (temperature !== undefined)
|
|
43
|
-
configDict.temperature = temperature;
|
|
44
|
-
if (reasoning_effort !== undefined)
|
|
45
|
-
configDict.reasoning_effort = reasoning_effort;
|
|
46
|
-
if (image_resolution_dpi !== undefined)
|
|
47
|
-
configDict.image_resolution_dpi = image_resolution_dpi;
|
|
48
|
-
if (browser_canvas !== undefined)
|
|
49
|
-
configDict.browser_canvas = browser_canvas;
|
|
50
|
-
if (n_consensus !== undefined)
|
|
51
|
-
configDict.n_consensus = n_consensus;
|
|
52
|
-
return {
|
|
53
|
-
method: 'POST',
|
|
54
|
-
url: '/v1/processors',
|
|
55
|
-
data: configDict,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
prepareList(params = {}) {
|
|
59
|
-
const { before, after, limit = 10, order = 'desc', name, modality, model, schema_id, schema_data_id, } = params;
|
|
60
|
-
const queryParams = {};
|
|
61
|
-
if (before !== undefined)
|
|
62
|
-
queryParams.before = before;
|
|
63
|
-
if (after !== undefined)
|
|
64
|
-
queryParams.after = after;
|
|
65
|
-
if (limit !== undefined)
|
|
66
|
-
queryParams.limit = limit;
|
|
67
|
-
if (order !== undefined)
|
|
68
|
-
queryParams.order = order;
|
|
69
|
-
if (name !== undefined)
|
|
70
|
-
queryParams.name = name;
|
|
71
|
-
if (modality !== undefined)
|
|
72
|
-
queryParams.modality = modality;
|
|
73
|
-
if (model !== undefined)
|
|
74
|
-
queryParams.model = model;
|
|
75
|
-
if (schema_id !== undefined)
|
|
76
|
-
queryParams.schema_id = schema_id;
|
|
77
|
-
if (schema_data_id !== undefined)
|
|
78
|
-
queryParams.schema_data_id = schema_data_id;
|
|
79
|
-
return {
|
|
80
|
-
method: 'GET',
|
|
81
|
-
url: '/v1/processors',
|
|
82
|
-
params: queryParams,
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
prepareGet(processor_id) {
|
|
86
|
-
return {
|
|
87
|
-
method: 'GET',
|
|
88
|
-
url: `/v1/processors/${processor_id}`,
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
prepareUpdate(params) {
|
|
92
|
-
const { processor_id, name, modality, image_resolution_dpi, browser_canvas, model, json_schema, temperature, reasoning_effort, n_consensus, } = params;
|
|
93
|
-
let loadedSchema = undefined;
|
|
94
|
-
if (json_schema !== undefined) {
|
|
95
|
-
loadedSchema = loadJsonSchema(json_schema);
|
|
96
|
-
}
|
|
97
|
-
const updateData = {};
|
|
98
|
-
if (name !== undefined)
|
|
99
|
-
updateData.name = name;
|
|
100
|
-
if (modality !== undefined)
|
|
101
|
-
updateData.modality = modality;
|
|
102
|
-
if (image_resolution_dpi !== undefined)
|
|
103
|
-
updateData.image_resolution_dpi = image_resolution_dpi;
|
|
104
|
-
if (browser_canvas !== undefined)
|
|
105
|
-
updateData.browser_canvas = browser_canvas;
|
|
106
|
-
if (model !== undefined)
|
|
107
|
-
updateData.model = model;
|
|
108
|
-
if (loadedSchema !== undefined)
|
|
109
|
-
updateData.json_schema = loadedSchema;
|
|
110
|
-
if (temperature !== undefined)
|
|
111
|
-
updateData.temperature = temperature;
|
|
112
|
-
if (reasoning_effort !== undefined)
|
|
113
|
-
updateData.reasoning_effort = reasoning_effort;
|
|
114
|
-
if (n_consensus !== undefined)
|
|
115
|
-
updateData.n_consensus = n_consensus;
|
|
116
|
-
return {
|
|
117
|
-
method: 'PUT',
|
|
118
|
-
url: `/v1/processors/${processor_id}`,
|
|
119
|
-
data: updateData,
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
prepareDelete(processor_id) {
|
|
123
|
-
return {
|
|
124
|
-
method: 'DELETE',
|
|
125
|
-
url: `/v1/processors/${processor_id}`,
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
prepareSubmit(params) {
|
|
129
|
-
const { processor_id, document, documents, temperature, seed, store = true, } = params;
|
|
130
|
-
if (!document && !documents) {
|
|
131
|
-
throw new Error("Either 'document' or 'documents' must be provided");
|
|
132
|
-
}
|
|
133
|
-
if (document && documents) {
|
|
134
|
-
throw new Error("Provide either 'document' (single) or 'documents' (multiple), not both");
|
|
135
|
-
}
|
|
136
|
-
const formData = {};
|
|
137
|
-
if (temperature !== undefined)
|
|
138
|
-
formData.temperature = temperature;
|
|
139
|
-
if (seed !== undefined)
|
|
140
|
-
formData.seed = seed;
|
|
141
|
-
if (store !== undefined)
|
|
142
|
-
formData.store = store;
|
|
143
|
-
const files = {};
|
|
144
|
-
if (document) {
|
|
145
|
-
const mimeDocument = prepareMimeDocument(document);
|
|
146
|
-
files.document = {
|
|
147
|
-
filename: mimeDocument.filename,
|
|
148
|
-
content: Buffer.from(mimeDocument.content, 'base64'),
|
|
149
|
-
mime_type: mimeDocument.mime_type,
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
else if (documents) {
|
|
153
|
-
files.documents = documents.map((doc) => {
|
|
154
|
-
const mimeDoc = prepareMimeDocument(doc);
|
|
155
|
-
return {
|
|
156
|
-
filename: mimeDoc.filename,
|
|
157
|
-
content: Buffer.from(mimeDoc.content, 'base64'),
|
|
158
|
-
mime_type: mimeDoc.mime_type,
|
|
159
|
-
};
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
return {
|
|
163
|
-
method: 'POST',
|
|
164
|
-
url: `/v1/processors/${processor_id}/submit`,
|
|
165
|
-
form_data: formData,
|
|
166
|
-
files,
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
export class Processors extends SyncAPIResource {
|
|
171
|
-
constructor() {
|
|
172
|
-
super(...arguments);
|
|
173
|
-
this.mixin = new ProcessorsMixin();
|
|
174
|
-
this.automations = {
|
|
175
|
-
endpoints: new Endpoints(this._client),
|
|
176
|
-
links: new Links(this._client),
|
|
177
|
-
mailboxes: new Mailboxes(this._client),
|
|
178
|
-
outlook: new OutlookAutomations(this._client),
|
|
179
|
-
tests: new Tests(this._client),
|
|
180
|
-
logs: new Logs(this._client),
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
create(params) {
|
|
184
|
-
const preparedRequest = this.mixin.prepareCreate(params);
|
|
185
|
-
const response = this._client._preparedRequest(preparedRequest);
|
|
186
|
-
const parsedResponse = ProcessorConfigSchema.parse(response);
|
|
187
|
-
console.log(`Processor ID: ${parsedResponse.id}. Processor available at https://www.retab.com/dashboard/processors/${parsedResponse.id}`);
|
|
188
|
-
return parsedResponse;
|
|
189
|
-
}
|
|
190
|
-
list(params = {}) {
|
|
191
|
-
const preparedRequest = this.mixin.prepareList(params);
|
|
192
|
-
const response = this._client._preparedRequest(preparedRequest);
|
|
193
|
-
return ListProcessorsSchema.parse(response);
|
|
194
|
-
}
|
|
195
|
-
get(processor_id) {
|
|
196
|
-
const preparedRequest = this.mixin.prepareGet(processor_id);
|
|
197
|
-
const response = this._client._preparedRequest(preparedRequest);
|
|
198
|
-
return ProcessorConfigSchema.parse(response);
|
|
199
|
-
}
|
|
200
|
-
update(params) {
|
|
201
|
-
const preparedRequest = this.mixin.prepareUpdate(params);
|
|
202
|
-
const response = this._client._preparedRequest(preparedRequest);
|
|
203
|
-
return ProcessorConfigSchema.parse(response);
|
|
204
|
-
}
|
|
205
|
-
delete(processor_id) {
|
|
206
|
-
const preparedRequest = this.mixin.prepareDelete(processor_id);
|
|
207
|
-
this._client._preparedRequest(preparedRequest);
|
|
208
|
-
console.log(`Processor Deleted. ID: ${processor_id}`);
|
|
209
|
-
}
|
|
210
|
-
submit(params) {
|
|
211
|
-
const preparedRequest = this.mixin.prepareSubmit(params);
|
|
212
|
-
const response = this._client._preparedRequest(preparedRequest);
|
|
213
|
-
return response;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
export class AsyncProcessors extends AsyncAPIResource {
|
|
217
|
-
constructor() {
|
|
218
|
-
super(...arguments);
|
|
219
|
-
this.mixin = new ProcessorsMixin();
|
|
220
|
-
this.automations = {
|
|
221
|
-
endpoints: new AsyncEndpoints(this._client),
|
|
222
|
-
links: new AsyncLinks(this._client),
|
|
223
|
-
mailboxes: new AsyncMailboxes(this._client),
|
|
224
|
-
outlook: new AsyncOutlookAutomations(this._client),
|
|
225
|
-
tests: new AsyncTests(this._client),
|
|
226
|
-
logs: new AsyncLogs(this._client),
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
async create(params) {
|
|
230
|
-
const preparedRequest = this.mixin.prepareCreate(params);
|
|
231
|
-
const response = await this._client._preparedRequest(preparedRequest);
|
|
232
|
-
const parsedResponse = ProcessorConfigSchema.parse(response);
|
|
233
|
-
console.log(`Processor ID: ${parsedResponse.id}. Processor available at https://www.retab.com/dashboard/processors/${parsedResponse.id}`);
|
|
234
|
-
return parsedResponse;
|
|
235
|
-
}
|
|
236
|
-
async list(params = {}) {
|
|
237
|
-
const preparedRequest = this.mixin.prepareList(params);
|
|
238
|
-
const response = await this._client._preparedRequest(preparedRequest);
|
|
239
|
-
return ListProcessorsSchema.parse(response);
|
|
240
|
-
}
|
|
241
|
-
async get(processor_id) {
|
|
242
|
-
const preparedRequest = this.mixin.prepareGet(processor_id);
|
|
243
|
-
const response = await this._client._preparedRequest(preparedRequest);
|
|
244
|
-
return ProcessorConfigSchema.parse(response);
|
|
245
|
-
}
|
|
246
|
-
async update(params) {
|
|
247
|
-
const preparedRequest = this.mixin.prepareUpdate(params);
|
|
248
|
-
const response = await this._client._preparedRequest(preparedRequest);
|
|
249
|
-
return ProcessorConfigSchema.parse(response);
|
|
250
|
-
}
|
|
251
|
-
async delete(processor_id) {
|
|
252
|
-
const preparedRequest = this.mixin.prepareDelete(processor_id);
|
|
253
|
-
await this._client._preparedRequest(preparedRequest);
|
|
254
|
-
console.log(`Processor Deleted. ID: ${processor_id}`);
|
|
255
|
-
}
|
|
256
|
-
async submit(params) {
|
|
257
|
-
const preparedRequest = this.mixin.prepareSubmit(params);
|
|
258
|
-
const response = await this._client._preparedRequest(preparedRequest);
|
|
259
|
-
return response;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { SyncAPIResource, AsyncAPIResource } from '../resource.js';
|
|
2
|
-
import { Schema } from '../types/schemas/object.js';
|
|
3
|
-
export type MIMEData = string | Buffer | {
|
|
4
|
-
filename: string;
|
|
5
|
-
content: Buffer;
|
|
6
|
-
mimeType: string;
|
|
7
|
-
};
|
|
8
|
-
export type Modality = 'native' | 'text';
|
|
9
|
-
export type BrowserCanvas = 'A3' | 'A4' | 'A5';
|
|
10
|
-
export type ChatCompletionReasoningEffort = 'low' | 'medium' | 'high';
|
|
11
|
-
export interface GenerateSchemaRequest {
|
|
12
|
-
documents: MIMEData[];
|
|
13
|
-
instructions?: string | null;
|
|
14
|
-
model: string;
|
|
15
|
-
temperature: number;
|
|
16
|
-
modality: Modality;
|
|
17
|
-
reasoning_effort: ChatCompletionReasoningEffort;
|
|
18
|
-
}
|
|
19
|
-
export interface EvaluateSchemaRequest {
|
|
20
|
-
documents: MIMEData[];
|
|
21
|
-
json_schema: Record<string, any>;
|
|
22
|
-
ground_truths?: Array<Record<string, any>> | null;
|
|
23
|
-
model: string;
|
|
24
|
-
reasoning_effort: ChatCompletionReasoningEffort;
|
|
25
|
-
modality: Modality;
|
|
26
|
-
image_resolution_dpi: number;
|
|
27
|
-
browser_canvas: BrowserCanvas;
|
|
28
|
-
n_consensus: number;
|
|
29
|
-
}
|
|
30
|
-
export interface EvaluateSchemaResponse {
|
|
31
|
-
[key: string]: any;
|
|
32
|
-
}
|
|
33
|
-
export interface EnhanceSchemaConfig {
|
|
34
|
-
[key: string]: any;
|
|
35
|
-
}
|
|
36
|
-
export interface EnhanceSchemaRequest {
|
|
37
|
-
json_schema: Record<string, any>;
|
|
38
|
-
documents: MIMEData[];
|
|
39
|
-
ground_truths?: Array<Record<string, any>> | null;
|
|
40
|
-
instructions?: string | null;
|
|
41
|
-
model: string;
|
|
42
|
-
temperature: number;
|
|
43
|
-
modality: Modality;
|
|
44
|
-
flat_likelihoods?: Array<Record<string, number>> | Record<string, number> | null;
|
|
45
|
-
tools_config: EnhanceSchemaConfig;
|
|
46
|
-
}
|
|
47
|
-
export declare class Schemas extends SyncAPIResource {
|
|
48
|
-
private mixin;
|
|
49
|
-
load(jsonSchema?: Record<string, any> | string | null, pydanticModel?: any | null): Schema;
|
|
50
|
-
generate(documents: Array<string | Buffer | MIMEData>, instructions?: string | null, model?: string, temperature?: number, modality?: Modality): Promise<Schema>;
|
|
51
|
-
evaluate(documents: Array<string | Buffer | MIMEData>, jsonSchema: Record<string, any>, groundTruths?: Array<Record<string, any>> | null, model?: string, reasoning_effort?: ChatCompletionReasoningEffort, modality?: Modality, imageResolutionDpi?: number, browserCanvas?: BrowserCanvas, nConsensus?: number): Promise<EvaluateSchemaResponse>;
|
|
52
|
-
enhance(jsonSchema: Record<string, any> | string, documents: Array<string | Buffer | MIMEData>, groundTruths?: Array<Record<string, any>> | null, instructions?: string | null, model?: string, temperature?: number, modality?: Modality, flatLikelihoods?: Array<Record<string, number>> | Record<string, number> | null, toolsConfig?: EnhanceSchemaConfig): Promise<Schema>;
|
|
53
|
-
get(schemaId: string): Promise<Schema>;
|
|
54
|
-
}
|
|
55
|
-
export declare class AsyncSchemas extends AsyncAPIResource {
|
|
56
|
-
private mixin;
|
|
57
|
-
load(jsonSchema?: Record<string, any> | string | null, pydanticModel?: any | null): Schema;
|
|
58
|
-
get(schemaId: string): Promise<Schema>;
|
|
59
|
-
generate(documents: Array<string | Buffer | MIMEData>, instructions?: string | null, model?: string, temperature?: number, modality?: Modality): Promise<Schema>;
|
|
60
|
-
evaluate(documents: Array<string | Buffer | MIMEData>, jsonSchema: Record<string, any>, groundTruths?: Array<Record<string, any>> | null, model?: string, reasoning_effort?: ChatCompletionReasoningEffort, modality?: Modality, imageResolutionDpi?: number, browserCanvas?: BrowserCanvas, nConsensus?: number): Promise<EvaluateSchemaResponse>;
|
|
61
|
-
enhance(jsonSchema: Record<string, any> | string, documents: Array<string | Buffer | MIMEData>, groundTruths?: Array<Record<string, any>> | null, instructions?: string | null, model?: string, temperature?: number, modality?: Modality, flatLikelihoods?: Array<Record<string, number>> | Record<string, number> | null, toolsConfig?: EnhanceSchemaConfig): Promise<Schema>;
|
|
62
|
-
}
|
|
63
|
-
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/resources/schemas.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEnE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAIpD,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AACjG,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;AACzC,MAAM,MAAM,aAAa,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAC/C,MAAM,MAAM,6BAA6B,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEtE,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,QA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AG,MAAM,EACxC,SAAS,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC,EAC5C,YAAY,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI,EAChD,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,EAC5B,KAAK,GAAE,MAA4B,EACnC,WAAW,GAAE,MAAU,EACvB,QAAQ,GAAE,QAAmB,EAC7B,eAAe,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,EAC/E,WAAW,CAAC,EAAE,mBAAmB,GAChC,OAAO,CAAC,MAAM,CAAC;CAgBnB"}
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { SyncAPIResource, AsyncAPIResource } from '../resource.js';
|
|
4
|
-
import { Schema } from '../types/schemas/object.js';
|
|
5
|
-
import { loadJsonSchema } from '../utils/json_schema_utils.js';
|
|
6
|
-
// Helper functions (simplified versions of Python utilities)
|
|
7
|
-
function assertValidModelSchemaGeneration(model) {
|
|
8
|
-
// Validate model for schema generation
|
|
9
|
-
const validModels = ['gpt-4o-2024-11-20', 'gpt-4o-mini', 'gpt-4o'];
|
|
10
|
-
if (!validModels.includes(model)) {
|
|
11
|
-
throw new Error(`Model ${model} not valid for schema generation`);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
function prepareMimeDocumentList(documents) {
|
|
15
|
-
return documents.map(doc => {
|
|
16
|
-
if (typeof doc === 'string') {
|
|
17
|
-
// If it's a file path, read the file
|
|
18
|
-
if (fs.existsSync(doc)) {
|
|
19
|
-
return {
|
|
20
|
-
filename: path.basename(doc),
|
|
21
|
-
content: fs.readFileSync(doc),
|
|
22
|
-
mimeType: getMimeType(doc),
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
// Otherwise treat as text content
|
|
26
|
-
return doc;
|
|
27
|
-
}
|
|
28
|
-
return doc;
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
function getMimeType(filePath) {
|
|
32
|
-
const ext = path.extname(filePath).toLowerCase();
|
|
33
|
-
const mimeTypes = {
|
|
34
|
-
'.pdf': 'application/pdf',
|
|
35
|
-
'.jpg': 'image/jpeg',
|
|
36
|
-
'.jpeg': 'image/jpeg',
|
|
37
|
-
'.png': 'image/png',
|
|
38
|
-
'.txt': 'text/plain',
|
|
39
|
-
'.json': 'application/json',
|
|
40
|
-
};
|
|
41
|
-
return mimeTypes[ext] || 'application/octet-stream';
|
|
42
|
-
}
|
|
43
|
-
class SchemasMixin {
|
|
44
|
-
prepareGenerate(documents, instructions, model = 'gpt-4o-2024-11-20', temperature = 0, modality = 'native', reasoning_effort = 'medium') {
|
|
45
|
-
assertValidModelSchemaGeneration(model);
|
|
46
|
-
const mimeDocuments = prepareMimeDocumentList(documents);
|
|
47
|
-
const request = {
|
|
48
|
-
documents: mimeDocuments,
|
|
49
|
-
instructions: instructions || undefined,
|
|
50
|
-
model,
|
|
51
|
-
temperature,
|
|
52
|
-
modality,
|
|
53
|
-
reasoning_effort,
|
|
54
|
-
};
|
|
55
|
-
return {
|
|
56
|
-
method: 'POST',
|
|
57
|
-
url: '/v1/schemas/generate',
|
|
58
|
-
data: request,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
prepareEvaluate(documents, jsonSchema, groundTruths, model = 'gpt-4o-mini', reasoning_effort = 'medium', modality = 'native', imageResolutionDpi = 96, browserCanvas = 'A4', nConsensus = 1) {
|
|
62
|
-
const mimeDocuments = prepareMimeDocumentList(documents);
|
|
63
|
-
const request = {
|
|
64
|
-
documents: mimeDocuments,
|
|
65
|
-
json_schema: jsonSchema,
|
|
66
|
-
ground_truths: groundTruths || undefined,
|
|
67
|
-
model,
|
|
68
|
-
reasoning_effort,
|
|
69
|
-
modality,
|
|
70
|
-
image_resolution_dpi: imageResolutionDpi,
|
|
71
|
-
browser_canvas: browserCanvas,
|
|
72
|
-
n_consensus: nConsensus,
|
|
73
|
-
};
|
|
74
|
-
return {
|
|
75
|
-
method: 'POST',
|
|
76
|
-
url: '/v1/schemas/evaluate',
|
|
77
|
-
data: request,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
prepareEnhance(jsonSchema, documents, groundTruths, instructions, model = 'gpt-4o-mini', temperature = 0.0, modality = 'native', flatLikelihoods, toolsConfig = {}) {
|
|
81
|
-
assertValidModelSchemaGeneration(model);
|
|
82
|
-
const mimeDocuments = prepareMimeDocumentList(documents);
|
|
83
|
-
const loadedJsonSchema = loadJsonSchema(jsonSchema);
|
|
84
|
-
const request = {
|
|
85
|
-
json_schema: loadedJsonSchema,
|
|
86
|
-
documents: mimeDocuments,
|
|
87
|
-
ground_truths: groundTruths || undefined,
|
|
88
|
-
instructions: instructions || undefined,
|
|
89
|
-
model,
|
|
90
|
-
temperature,
|
|
91
|
-
modality,
|
|
92
|
-
flat_likelihoods: flatLikelihoods || undefined,
|
|
93
|
-
tools_config: toolsConfig,
|
|
94
|
-
};
|
|
95
|
-
return {
|
|
96
|
-
method: 'POST',
|
|
97
|
-
url: '/v1/schemas/enhance',
|
|
98
|
-
data: request,
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
prepareGet(schemaId) {
|
|
102
|
-
return {
|
|
103
|
-
method: 'GET',
|
|
104
|
-
url: `/v1/schemas/${schemaId}`,
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
export class Schemas extends SyncAPIResource {
|
|
109
|
-
constructor() {
|
|
110
|
-
super(...arguments);
|
|
111
|
-
this.mixin = new SchemasMixin();
|
|
112
|
-
}
|
|
113
|
-
load(jsonSchema, pydanticModel) {
|
|
114
|
-
if (jsonSchema) {
|
|
115
|
-
return new Schema({ json_schema: loadJsonSchema(jsonSchema) });
|
|
116
|
-
}
|
|
117
|
-
else if (pydanticModel) {
|
|
118
|
-
return new Schema({ pydanticModel });
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
throw new Error('Either json_schema or pydantic_model must be provided');
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
async generate(documents, instructions, model = 'gpt-4o-2024-11-20', temperature = 0, modality = 'native') {
|
|
125
|
-
const preparedRequest = this.mixin.prepareGenerate(documents, instructions, model, temperature, modality);
|
|
126
|
-
const response = await this._client._preparedRequest(preparedRequest);
|
|
127
|
-
return Schema.validate(response);
|
|
128
|
-
}
|
|
129
|
-
async evaluate(documents, jsonSchema, groundTruths, model = 'gpt-4o-mini', reasoning_effort = 'medium', modality = 'native', imageResolutionDpi = 96, browserCanvas = 'A4', nConsensus = 1) {
|
|
130
|
-
const preparedRequest = this.mixin.prepareEvaluate(documents, jsonSchema, groundTruths, model, reasoning_effort, modality, imageResolutionDpi, browserCanvas, nConsensus);
|
|
131
|
-
const response = await this._client._preparedRequest(preparedRequest);
|
|
132
|
-
return response;
|
|
133
|
-
}
|
|
134
|
-
async enhance(jsonSchema, documents, groundTruths, instructions, model = 'gpt-4o-2024-11-20', temperature = 0, modality = 'native', flatLikelihoods, toolsConfig) {
|
|
135
|
-
const _toolsConfig = toolsConfig || {};
|
|
136
|
-
const preparedRequest = this.mixin.prepareEnhance(jsonSchema, documents, groundTruths, instructions, model, temperature, modality, flatLikelihoods, _toolsConfig);
|
|
137
|
-
const response = await this._client._preparedRequest(preparedRequest);
|
|
138
|
-
return new Schema({ json_schema: response.json_schema });
|
|
139
|
-
}
|
|
140
|
-
async get(schemaId) {
|
|
141
|
-
const preparedRequest = this.mixin.prepareGet(schemaId);
|
|
142
|
-
const response = await this._client._preparedRequest(preparedRequest);
|
|
143
|
-
return Schema.validate(response);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
export class AsyncSchemas extends AsyncAPIResource {
|
|
147
|
-
constructor() {
|
|
148
|
-
super(...arguments);
|
|
149
|
-
this.mixin = new SchemasMixin();
|
|
150
|
-
}
|
|
151
|
-
load(jsonSchema, pydanticModel) {
|
|
152
|
-
if (jsonSchema) {
|
|
153
|
-
return new Schema({ json_schema: loadJsonSchema(jsonSchema) });
|
|
154
|
-
}
|
|
155
|
-
else if (pydanticModel) {
|
|
156
|
-
return new Schema({ pydanticModel });
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
throw new Error('Either json_schema or pydantic_model must be provided');
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
async get(schemaId) {
|
|
163
|
-
const preparedRequest = this.mixin.prepareGet(schemaId);
|
|
164
|
-
const response = await this._client._preparedRequest(preparedRequest);
|
|
165
|
-
return Schema.validate(response);
|
|
166
|
-
}
|
|
167
|
-
async generate(documents, instructions, model = 'gpt-4o-2024-11-20', temperature = 0.0, modality = 'native') {
|
|
168
|
-
const preparedRequest = this.mixin.prepareGenerate(documents, instructions, model, temperature, modality);
|
|
169
|
-
const response = await this._client._preparedRequest(preparedRequest);
|
|
170
|
-
return Schema.validate(response);
|
|
171
|
-
}
|
|
172
|
-
async evaluate(documents, jsonSchema, groundTruths, model = 'gpt-4o-mini', reasoning_effort = 'medium', modality = 'native', imageResolutionDpi = 96, browserCanvas = 'A4', nConsensus = 1) {
|
|
173
|
-
const preparedRequest = this.mixin.prepareEvaluate(documents, jsonSchema, groundTruths, model, reasoning_effort, modality, imageResolutionDpi, browserCanvas, nConsensus);
|
|
174
|
-
const response = await this._client._preparedRequest(preparedRequest);
|
|
175
|
-
return response;
|
|
176
|
-
}
|
|
177
|
-
async enhance(jsonSchema, documents, groundTruths, instructions, model = 'gpt-4o-2024-11-20', temperature = 0, modality = 'native', flatLikelihoods, toolsConfig) {
|
|
178
|
-
const _toolsConfig = toolsConfig || {};
|
|
179
|
-
const preparedRequest = this.mixin.prepareEnhance(jsonSchema, documents, groundTruths, instructions, model, temperature, modality, flatLikelihoods, _toolsConfig);
|
|
180
|
-
const response = await this._client._preparedRequest(preparedRequest);
|
|
181
|
-
return new Schema({ json_schema: response.json_schema });
|
|
182
|
-
}
|
|
183
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { SyncAPIResource, AsyncAPIResource } from '../../resource.js';
|
|
2
|
-
import { PreparedRequest } from '../../types/standards.js';
|
|
3
|
-
import { AIProvider } from '../../types/ai_models.js';
|
|
4
|
-
import { ExternalAPIKey } from '../../types/secrets/external_api_keys.js';
|
|
5
|
-
export declare class ExternalAPIKeysMixin {
|
|
6
|
-
prepareCreate(provider: AIProvider, api_key: string): PreparedRequest;
|
|
7
|
-
prepareGet(provider: AIProvider): PreparedRequest;
|
|
8
|
-
prepareList(): PreparedRequest;
|
|
9
|
-
prepareDelete(provider: AIProvider): PreparedRequest;
|
|
10
|
-
}
|
|
11
|
-
export declare class ExternalAPIKeys extends SyncAPIResource {
|
|
12
|
-
private mixin;
|
|
13
|
-
/**
|
|
14
|
-
* Add or update an external API key.
|
|
15
|
-
*
|
|
16
|
-
* @param provider - The API provider (OpenAI, Anthropic, Gemini, xAI)
|
|
17
|
-
* @param api_key - The API key to store
|
|
18
|
-
* @returns Response indicating success
|
|
19
|
-
*/
|
|
20
|
-
create(provider: AIProvider, api_key: string): Promise<Record<string, any>>;
|
|
21
|
-
/**
|
|
22
|
-
* Get an external API key configuration.
|
|
23
|
-
*
|
|
24
|
-
* @param provider - The API provider to get the key for
|
|
25
|
-
* @returns The API key configuration
|
|
26
|
-
*/
|
|
27
|
-
get(provider: AIProvider): Promise<ExternalAPIKey>;
|
|
28
|
-
/**
|
|
29
|
-
* List all configured external API keys.
|
|
30
|
-
*
|
|
31
|
-
* @returns List of API key configurations
|
|
32
|
-
*/
|
|
33
|
-
list(): Promise<ExternalAPIKey[]>;
|
|
34
|
-
/**
|
|
35
|
-
* Delete an external API key configuration.
|
|
36
|
-
*
|
|
37
|
-
* @param provider - The API provider to delete the key for
|
|
38
|
-
* @returns Response indicating success
|
|
39
|
-
*/
|
|
40
|
-
delete(provider: AIProvider): Promise<Record<string, any>>;
|
|
41
|
-
}
|
|
42
|
-
export declare class AsyncExternalAPIKeys extends AsyncAPIResource {
|
|
43
|
-
private mixin;
|
|
44
|
-
/**
|
|
45
|
-
* Add or update an external API key asynchronously.
|
|
46
|
-
*/
|
|
47
|
-
create(provider: AIProvider, api_key: string): Promise<Record<string, any>>;
|
|
48
|
-
/**
|
|
49
|
-
* Get an external API key configuration asynchronously.
|
|
50
|
-
*/
|
|
51
|
-
get(provider: AIProvider): Promise<ExternalAPIKey>;
|
|
52
|
-
/**
|
|
53
|
-
* List all configured external API keys asynchronously.
|
|
54
|
-
*/
|
|
55
|
-
list(): Promise<ExternalAPIKey[]>;
|
|
56
|
-
/**
|
|
57
|
-
* Delete an external API key configuration asynchronously.
|
|
58
|
-
*/
|
|
59
|
-
delete(provider: AIProvider): Promise<Record<string, any>>;
|
|
60
|
-
}
|
|
61
|
-
//# sourceMappingURL=external_api_keys.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"external_api_keys.d.ts","sourceRoot":"","sources":["../../../src/resources/secrets/external_api_keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,cAAc,EAAyB,MAAM,0CAA0C,CAAC;AAEjG,qBAAa,oBAAoB;IAC/B,aAAa,CAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,GAAG,eAAe;IAarE,UAAU,CAAC,QAAQ,EAAE,UAAU,GAAG,eAAe;IAOjD,WAAW,IAAI,eAAe;IAO9B,aAAa,CAAC,QAAQ,EAAE,UAAU,GAAG,eAAe;CAMrD;AAED,qBAAa,eAAgB,SAAQ,eAAe;IAClD,OAAO,CAAC,KAAK,CAA8B;IAE3C;;;;;;OAMG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