@activepieces/piece-mistral-ai 0.2.2 → 0.2.4

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.
Files changed (37) hide show
  1. package/package.json +7 -13
  2. package/src/index.js +15 -37
  3. package/src/index.d.ts +0 -7
  4. package/src/index.d.ts.map +0 -1
  5. package/src/index.js.map +0 -1
  6. package/src/lib/actions/create-chat-completion.d.ts +0 -20
  7. package/src/lib/actions/create-chat-completion.d.ts.map +0 -1
  8. package/src/lib/actions/create-chat-completion.js +0 -84
  9. package/src/lib/actions/create-chat-completion.js.map +0 -1
  10. package/src/lib/actions/create-embeddings.d.ts +0 -10
  11. package/src/lib/actions/create-embeddings.d.ts.map +0 -1
  12. package/src/lib/actions/create-embeddings.js +0 -75
  13. package/src/lib/actions/create-embeddings.js.map +0 -1
  14. package/src/lib/actions/list-models.d.ts +0 -7
  15. package/src/lib/actions/list-models.d.ts.map +0 -1
  16. package/src/lib/actions/list-models.js +0 -33
  17. package/src/lib/actions/list-models.js.map +0 -1
  18. package/src/lib/actions/run-ocr.d.ts +0 -16
  19. package/src/lib/actions/run-ocr.d.ts.map +0 -1
  20. package/src/lib/actions/run-ocr.js +0 -202
  21. package/src/lib/actions/run-ocr.js.map +0 -1
  22. package/src/lib/actions/upload-file.d.ts +0 -10
  23. package/src/lib/actions/upload-file.d.ts.map +0 -1
  24. package/src/lib/actions/upload-file.js +0 -80
  25. package/src/lib/actions/upload-file.js.map +0 -1
  26. package/src/lib/common/auth.d.ts +0 -7
  27. package/src/lib/common/auth.d.ts.map +0 -1
  28. package/src/lib/common/auth.js +0 -100
  29. package/src/lib/common/auth.js.map +0 -1
  30. package/src/lib/common/props.d.ts +0 -8
  31. package/src/lib/common/props.d.ts.map +0 -1
  32. package/src/lib/common/props.js +0 -67
  33. package/src/lib/common/props.js.map +0 -1
  34. package/src/lib/common/request.d.ts +0 -13
  35. package/src/lib/common/request.d.ts.map +0 -1
  36. package/src/lib/common/request.js +0 -30
  37. package/src/lib/common/request.js.map +0 -1
@@ -1,75 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createEmbeddings = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_framework_1 = require("@activepieces/pieces-framework");
6
- const pieces_common_1 = require("@activepieces/pieces-common");
7
- const auth_1 = require("../common/auth");
8
- const props_1 = require("../common/props");
9
- const request_1 = require("../common/request");
10
- exports.createEmbeddings = (0, pieces_framework_1.createAction)({
11
- auth: auth_1.mistralAuth,
12
- name: 'create_embeddings',
13
- displayName: 'Create Embeddings',
14
- description: 'Creates new embedding in Mistral AI.',
15
- props: {
16
- input: pieces_framework_1.Property.Array({
17
- displayName: 'Input',
18
- description: 'The input text for which to create an embedding.',
19
- required: true,
20
- }),
21
- timeout: pieces_framework_1.Property.Number({ displayName: 'Timeout (ms)', required: false, defaultValue: 30000 }),
22
- },
23
- run(context) {
24
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
25
- var _a;
26
- const { input, timeout } = context.propsValue;
27
- const { baseUrl, headers } = request_1.mistralRequest.getConfig(context.auth);
28
- let inputArr = [];
29
- try {
30
- if (typeof input === 'string') {
31
- try {
32
- inputArr = JSON.parse(input);
33
- }
34
- catch (_b) {
35
- inputArr = input;
36
- }
37
- }
38
- inputArr = input;
39
- }
40
- catch (_c) {
41
- throw new Error('Input must be a non-empty string or a JSON array of non-empty strings');
42
- }
43
- const body = {
44
- model: 'mistral-embed',
45
- input: inputArr,
46
- };
47
- let lastErr;
48
- for (let attempt = 0; attempt <= 3; ++attempt) {
49
- try {
50
- const response = yield pieces_common_1.httpClient.sendRequest({
51
- method: pieces_common_1.HttpMethod.POST,
52
- url: `${baseUrl}/embeddings`,
53
- headers,
54
- body,
55
- timeout: timeout !== null && timeout !== void 0 ? timeout : 30000,
56
- });
57
- return response.body;
58
- }
59
- catch (e) {
60
- lastErr = e;
61
- const status = (_a = e.response) === null || _a === void 0 ? void 0 : _a.status;
62
- if (status === 429 || (status && status >= 500 && status < 600)) {
63
- if (attempt < 3) {
64
- yield new Promise((r) => setTimeout(r, 1000 * (attempt + 1)));
65
- continue;
66
- }
67
- }
68
- throw new Error((0, props_1.parseMistralError)(e));
69
- }
70
- }
71
- throw new Error((0, props_1.parseMistralError)(lastErr));
72
- });
73
- },
74
- });
75
- //# sourceMappingURL=create-embeddings.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create-embeddings.js","sourceRoot":"","sources":["../../../../src/lib/actions/create-embeddings.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAqE;AACrE,yCAA6C;AAC7C,2CAAoD;AACpD,+CAAmD;AAEtC,QAAA,gBAAgB,GAAG,IAAA,+BAAY,EAAC;IAC5C,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE,mBAAmB;IAChC,WAAW,EAAE,sCAAsC;IACnD,KAAK,EAAE;QACN,KAAK,EAAE,2BAAQ,CAAC,KAAK,CAAC;YACrB,WAAW,EAAE,OAAO;YACpB,WAAW,EAAE,kDAAkD;YAC/D,QAAQ,EAAE,IAAI;SACd,CAAC;QACF,OAAO,EAAE,2BAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,cAAc,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;KAC/F;IACK,GAAG,CAAC,OAAO;;;YAChB,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YAC9C,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,wBAAc,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACpE,IAAI,QAAQ,GAAa,EAAE,CAAC;YAC5B,IAAI,CAAC;gBACJ,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;oBAC/B,IAAI,CAAC;wBACJ,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK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AAI,KAAK,CAAC,IAAA,yBAAiB,EAAC,CAAC,CAAC,CAAC,CAAC;gBACvC,CAAC;YACF,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,IAAA,yBAAiB,EAAC,OAAO,CAAC,CAAC,CAAC;QAC7C,CAAC;KAAA;CACD,CAAC,CAAC"}
@@ -1,7 +0,0 @@
1
- export declare const listModels: import("@activepieces/pieces-framework").IAction<(import("@activepieces/pieces-framework").SecretTextProperty<true> | import("@activepieces/pieces-framework").CustomAuthProperty<{
2
- accountId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
- gatewayId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
4
- gatewayAuthToken: import("@activepieces/pieces-framework").SecretTextProperty<false>;
5
- mistralApiKey: import("@activepieces/pieces-framework").SecretTextProperty<false>;
6
- }>)[], {}>;
7
- //# sourceMappingURL=list-models.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"list-models.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/list-models.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,UAAU;;;;;UAoBrB,CAAC"}
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.listModels = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_framework_1 = require("@activepieces/pieces-framework");
6
- const pieces_common_1 = require("@activepieces/pieces-common");
7
- const auth_1 = require("../common/auth");
8
- const props_1 = require("../common/props");
9
- const request_1 = require("../common/request");
10
- exports.listModels = (0, pieces_framework_1.createAction)({
11
- auth: auth_1.mistralAuth,
12
- name: 'list_models',
13
- displayName: 'List Models',
14
- description: 'Retrieves a list of available Mistral AI models.',
15
- props: {},
16
- run(_a) {
17
- return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth }) {
18
- try {
19
- const { baseUrl, headers } = request_1.mistralRequest.getConfig(auth);
20
- const response = yield pieces_common_1.httpClient.sendRequest({
21
- method: pieces_common_1.HttpMethod.GET,
22
- url: `${baseUrl}/models`,
23
- headers,
24
- });
25
- return response.body;
26
- }
27
- catch (e) {
28
- throw new Error((0, props_1.parseMistralError)(e));
29
- }
30
- });
31
- },
32
- });
33
- //# sourceMappingURL=list-models.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"list-models.js","sourceRoot":"","sources":["../../../../src/lib/actions/list-models.ts"],"names":[],"mappings":";;;;AAAA,qEAA8D;AAC9D,+DAAqE;AACrE,yCAA6C;AAC7C,2CAAoD;AACpD,+CAAmD;AAEtC,QAAA,UAAU,GAAG,IAAA,+BAAY,EAAC;IACtC,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,kDAAkD;IAC/D,KAAK,EAAE,EAAE;IACH,GAAG;qEAAC,EAAE,IAAI,EAAE;YACjB,IAAI,CAAC;gBACJ,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,wBAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;gBAC5D,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC;oBAC7C,MAAM,EAAE,0BAAU,CAAC,GAAG;oBACtB,GAAG,EAAE,GAAG,OAAO,SAAS;oBACxB,OAAO;iBACP,CAAC,CAAC;gBAEH,OAAO,QAAQ,CAAC,IAAI,CAAC;YACtB,CAAC;YAAC,OAAO,CAAM,EAAE,CAAC;gBACjB,MAAM,IAAI,KAAK,CAAC,IAAA,yBAAiB,EAAC,CAAC,CAAC,CAAC,CAAC;YACvC,CAAC;QACF,CAAC;KAAA;CACD,CAAC,CAAC"}
@@ -1,16 +0,0 @@
1
- export declare const runOcr: import("@activepieces/pieces-framework").IAction<(import("@activepieces/pieces-framework").SecretTextProperty<true> | import("@activepieces/pieces-framework").CustomAuthProperty<{
2
- accountId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
- gatewayId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
4
- gatewayAuthToken: import("@activepieces/pieces-framework").SecretTextProperty<false>;
5
- mistralApiKey: import("@activepieces/pieces-framework").SecretTextProperty<false>;
6
- }>)[], {
7
- model: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
8
- documentSource: import("@activepieces/pieces-framework").StaticDropdownProperty<DocumentSource, false> | import("@activepieces/pieces-framework").StaticDropdownProperty<DocumentSource, true>;
9
- sourceFields: import("@activepieces/pieces-framework").DynamicProperties<true, undefined>;
10
- pages: import("@activepieces/pieces-framework").ArrayProperty<false>;
11
- includeImageBase64: import("@activepieces/pieces-framework").CheckboxProperty<false>;
12
- timeout: import("@activepieces/pieces-framework").NumberProperty<false>;
13
- }>;
14
- type DocumentSource = 'url' | 'fileId';
15
- export {};
16
- //# sourceMappingURL=run-ocr.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-ocr.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/run-ocr.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,MAAM;;;;;;;;;;;;EA6HjB,CAAC;AA8EH,KAAK,cAAc,GAAG,KAAK,GAAG,QAAQ,CAAC"}
@@ -1,202 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runOcr = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_framework_1 = require("@activepieces/pieces-framework");
6
- const pieces_common_1 = require("@activepieces/pieces-common");
7
- const auth_1 = require("../common/auth");
8
- const props_1 = require("../common/props");
9
- const request_1 = require("../common/request");
10
- const OCR_MODEL_OPTIONS = [
11
- { label: 'mistral-ocr-latest (Recommended)', value: 'mistral-ocr-latest' },
12
- { label: 'mistral-ocr-2505', value: 'mistral-ocr-2505' },
13
- ];
14
- exports.runOcr = (0, pieces_framework_1.createAction)({
15
- auth: auth_1.mistralAuth,
16
- name: 'run_ocr',
17
- displayName: 'Run OCR',
18
- description: 'Extract text from PDFs and images using mistral-ocr-latest. To OCR a file from a previous step, run Upload File first (with purpose=ocr) and pass the returned id here.',
19
- props: {
20
- model: pieces_framework_1.Property.StaticDropdown({
21
- displayName: 'Model',
22
- required: true,
23
- defaultValue: 'mistral-ocr-latest',
24
- options: { options: OCR_MODEL_OPTIONS },
25
- }),
26
- documentSource: pieces_framework_1.Property.StaticDropdown({
27
- displayName: 'Document Source',
28
- description: 'Where the document or image to OCR comes from.',
29
- required: true,
30
- defaultValue: 'url',
31
- options: {
32
- options: [
33
- { label: 'URL', value: 'url' },
34
- { label: 'Mistral file ID (uploaded earlier with purpose=ocr)', value: 'fileId' },
35
- ],
36
- },
37
- }),
38
- sourceFields: pieces_framework_1.Property.DynamicProperties({
39
- displayName: 'Document',
40
- required: true,
41
- refreshers: ['documentSource'],
42
- auth: pieces_framework_1.PieceAuth.None(),
43
- props: (propsValue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
44
- const source = propsValue['documentSource'];
45
- if (source === 'fileId') {
46
- const fields = {
47
- fileId: pieces_framework_1.Property.ShortText({
48
- displayName: 'File ID',
49
- description: 'A Mistral file ID returned from a prior Upload File step (purpose=ocr).',
50
- required: true,
51
- }),
52
- documentType: documentTypeDropdown(),
53
- };
54
- return fields;
55
- }
56
- const fields = {
57
- documentUrl: pieces_framework_1.Property.ShortText({
58
- displayName: 'URL',
59
- description: 'Public URL of the PDF or image to OCR.',
60
- required: true,
61
- }),
62
- documentType: documentTypeDropdown(),
63
- };
64
- return fields;
65
- }),
66
- }),
67
- pages: pieces_framework_1.Property.Array({
68
- displayName: 'Pages',
69
- description: 'Optional zero-based page indices to process. Leave empty for all pages.',
70
- required: false,
71
- }),
72
- includeImageBase64: pieces_framework_1.Property.Checkbox({
73
- displayName: 'Include Image Base64',
74
- description: 'Return embedded images encoded as base64 alongside the Markdown.',
75
- required: false,
76
- defaultValue: false,
77
- }),
78
- timeout: pieces_framework_1.Property.Number({
79
- displayName: 'Timeout (ms)',
80
- required: false,
81
- defaultValue: 120000,
82
- }),
83
- },
84
- run(context) {
85
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
86
- var _a, _b;
87
- const { model, documentSource, sourceFields, pages, includeImageBase64, timeout } = context.propsValue;
88
- const config = request_1.mistralRequest.getConfig(context.auth);
89
- const document = yield resolveDocument({
90
- source: documentSource,
91
- fields: sourceFields,
92
- config,
93
- timeout: timeout !== null && timeout !== void 0 ? timeout : 120000,
94
- });
95
- const body = {
96
- model,
97
- document,
98
- };
99
- const pageIndices = parsePageIndices(pages);
100
- if (pageIndices) {
101
- body['pages'] = pageIndices;
102
- }
103
- if (includeImageBase64) {
104
- body['include_image_base64'] = true;
105
- }
106
- let lastErr;
107
- for (let attempt = 0; attempt <= 3; ++attempt) {
108
- try {
109
- const response = yield pieces_common_1.httpClient.sendRequest({
110
- method: pieces_common_1.HttpMethod.POST,
111
- url: `${config.baseUrl}/ocr`,
112
- headers: Object.assign(Object.assign({}, config.headers), { 'Content-Type': 'application/json' }),
113
- body,
114
- timeout: timeout !== null && timeout !== void 0 ? timeout : 120000,
115
- });
116
- const markdown = ((_a = response.body.pages) !== null && _a !== void 0 ? _a : []).map((p) => { var _a; return (_a = p.markdown) !== null && _a !== void 0 ? _a : ''; }).join('\n\n');
117
- return Object.assign(Object.assign({}, response.body), { markdown });
118
- }
119
- catch (e) {
120
- lastErr = e;
121
- const status = (_b = e.response) === null || _b === void 0 ? void 0 : _b.status;
122
- if (status === 429 || (status && status >= 500 && status < 600)) {
123
- if (attempt < 3) {
124
- yield new Promise((r) => setTimeout(r, 1000 * (attempt + 1)));
125
- continue;
126
- }
127
- }
128
- throw new Error((0, props_1.parseMistralError)(e));
129
- }
130
- }
131
- throw new Error((0, props_1.parseMistralError)(lastErr));
132
- });
133
- },
134
- });
135
- function documentTypeDropdown() {
136
- return pieces_framework_1.Property.StaticDropdown({
137
- displayName: 'Document Type',
138
- description: 'Pick "Image" for PNG/JPG/WEBP, "Document" for PDFs.',
139
- required: true,
140
- defaultValue: 'document_url',
141
- options: {
142
- options: [
143
- { label: 'Document (PDF)', value: 'document_url' },
144
- { label: 'Image', value: 'image_url' },
145
- ],
146
- },
147
- });
148
- }
149
- function resolveDocument(_a) {
150
- return tslib_1.__awaiter(this, arguments, void 0, function* ({ source, fields, config, timeout, }) {
151
- var _b, _c, _d;
152
- const documentType = (_b = fields['documentType']) !== null && _b !== void 0 ? _b : 'document_url';
153
- if (source === 'fileId') {
154
- const fileId = (_c = fields['fileId']) === null || _c === void 0 ? void 0 : _c.trim();
155
- if (!fileId) {
156
- throw new Error('A Mistral file ID is required.');
157
- }
158
- const signedUrl = yield fetchSignedUrl({ fileId, config, timeout });
159
- return buildUrlDocument({ documentType, url: signedUrl });
160
- }
161
- const documentUrl = (_d = fields['documentUrl']) === null || _d === void 0 ? void 0 : _d.trim();
162
- if (!documentUrl) {
163
- throw new Error('A document URL is required.');
164
- }
165
- return buildUrlDocument({ documentType, url: documentUrl });
166
- });
167
- }
168
- function buildUrlDocument({ documentType, url }) {
169
- if (documentType === 'image_url') {
170
- return { type: 'image_url', image_url: url };
171
- }
172
- return { type: 'document_url', document_url: url };
173
- }
174
- function fetchSignedUrl(_a) {
175
- return tslib_1.__awaiter(this, arguments, void 0, function* ({ fileId, config, timeout }) {
176
- const response = yield pieces_common_1.httpClient.sendRequest({
177
- method: pieces_common_1.HttpMethod.GET,
178
- url: `${config.baseUrl}/files/${encodeURIComponent(fileId)}/url?expiry=24`,
179
- headers: config.headers,
180
- timeout,
181
- });
182
- if (!response.body.url) {
183
- throw new Error(`Could not fetch a signed URL for file ${fileId}.`);
184
- }
185
- return response.body.url;
186
- });
187
- }
188
- function parsePageIndices(raw) {
189
- if (!Array.isArray(raw) || raw.length === 0) {
190
- return null;
191
- }
192
- const indices = raw
193
- .map((entry) => {
194
- if (typeof entry === 'number')
195
- return entry;
196
- const parsed = Number(String(entry).trim());
197
- return Number.isFinite(parsed) ? parsed : null;
198
- })
199
- .filter((entry) => entry !== null && Number.isInteger(entry) && entry >= 0);
200
- return indices.length > 0 ? indices : null;
201
- }
202
- //# sourceMappingURL=run-ocr.js.map
@@ -1 +0,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,CAAC,OAAO;YACvB,OAAO;SACP,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,yCAAyC,MAAM,GAAG,CAAC,CAAC;QACrE,CAAC;QACD,OAAO,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC;IAC1B,CAAC;CAAA;AAED,SAAS,gBAAgB,CAAC,GAAY;IACrC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7C,OAAO,IAAI,CAAC;IACb,CAAC;IACD,MAAM,OAAO,GAAG,GAAG;SACjB,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QACd,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QAC5C,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QAC5C,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;IAChD,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,KAAK,EAAmB,EAAE,CAAC,KAAK,KAAK,IAAI,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC;IAC9F,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5C,CAAC"}
@@ -1,10 +0,0 @@
1
- export declare const uploadFile: import("@activepieces/pieces-framework").IAction<(import("@activepieces/pieces-framework").SecretTextProperty<true> | import("@activepieces/pieces-framework").CustomAuthProperty<{
2
- accountId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
- gatewayId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
4
- gatewayAuthToken: import("@activepieces/pieces-framework").SecretTextProperty<false>;
5
- mistralApiKey: import("@activepieces/pieces-framework").SecretTextProperty<false>;
6
- }>)[], {
7
- file: import("@activepieces/pieces-framework").FileProperty<true>;
8
- purpose: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
9
- }>;
10
- //# sourceMappingURL=upload-file.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"upload-file.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/upload-file.ts"],"names":[],"mappings":"AA2BA,eAAO,MAAM,UAAU;;;;;;;;EAqDrB,CAAC"}
@@ -1,80 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.uploadFile = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_framework_1 = require("@activepieces/pieces-framework");
6
- const pieces_common_1 = require("@activepieces/pieces-common");
7
- const auth_1 = require("../common/auth");
8
- const form_data_1 = tslib_1.__importDefault(require("form-data"));
9
- const props_1 = require("../common/props");
10
- const request_1 = require("../common/request");
11
- const SUPPORTED_PURPOSES = ['fine-tune', 'batch', 'ocr'];
12
- const MAX_FILE_SIZE_BYTES = 512 * 1024 * 1024;
13
- const ALLOWED_EXTENSIONS = [
14
- 'jsonl',
15
- 'txt',
16
- 'csv',
17
- 'pdf',
18
- 'docx',
19
- 'png',
20
- 'jpg',
21
- 'jpeg',
22
- 'mp3',
23
- 'mp4',
24
- ];
25
- function getFileExtension(filename) {
26
- const parts = filename.split('.');
27
- return parts.length > 1 ? parts.pop().toLowerCase() : '';
28
- }
29
- exports.uploadFile = (0, pieces_framework_1.createAction)({
30
- auth: auth_1.mistralAuth,
31
- name: 'upload_file',
32
- displayName: 'Upload File',
33
- description: 'Upload a file to Mistral AI (e.g., for fine-tuning or context storage).',
34
- props: {
35
- file: pieces_framework_1.Property.File({
36
- displayName: 'File',
37
- description: 'The file to upload (max 512MB).For fine tuning purspose provide .jsonl file.',
38
- required: true,
39
- }),
40
- purpose: pieces_framework_1.Property.StaticDropdown({
41
- displayName: 'Purpose',
42
- description: 'Purpose of the file.',
43
- required: true,
44
- options: {
45
- options: SUPPORTED_PURPOSES.map((p) => ({ label: p, value: p })),
46
- },
47
- }),
48
- },
49
- run(context) {
50
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
51
- const { file, purpose } = context.propsValue;
52
- if (!file)
53
- throw new Error('File is required');
54
- if (!SUPPORTED_PURPOSES.includes(purpose))
55
- throw new Error('Invalid purpose');
56
- if (file.data.byteLength > MAX_FILE_SIZE_BYTES)
57
- throw new Error('File exceeds 512MB limit');
58
- const ext = getFileExtension(file.filename);
59
- if (!ALLOWED_EXTENSIONS.includes(ext))
60
- throw new Error(`File extension .${ext} is not allowed`);
61
- const { baseUrl, headers } = request_1.mistralRequest.getConfig(context.auth);
62
- const form = new form_data_1.default();
63
- form.append('file', Buffer.from(file.data), file.filename);
64
- form.append('purpose', purpose);
65
- try {
66
- const response = yield pieces_common_1.httpClient.sendRequest({
67
- method: pieces_common_1.HttpMethod.POST,
68
- url: `${baseUrl}/files`,
69
- headers: Object.assign(Object.assign({}, headers), form.getHeaders()),
70
- body: form,
71
- });
72
- return response.body;
73
- }
74
- catch (e) {
75
- throw new Error((0, props_1.parseMistralError)(e));
76
- }
77
- });
78
- },
79
- });
80
- //# sourceMappingURL=upload-file.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"upload-file.js","sourceRoot":"","sources":["../../../../src/lib/actions/upload-file.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAqE;AACrE,yCAA6C;AAC7C,kEAAiC;AACjC,2CAAoD;AACpD,+CAAmD;AAEnD,MAAM,kBAAkB,GAAG,CAAC,WAAW,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AACzD,MAAM,mBAAmB,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AAC9C,MAAM,kBAAkB,GAAG;IAC1B,OAAO;IACP,KAAK;IACL,KAAK;IACL,KAAK;IAC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,CAAC,UAAU,GAAG,mBAAmB;gBAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;YAE5F,MAAM,GAAG,GAAG,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAE5C,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,GAAG,CAAC;gBAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,GAAG,iBAAiB,CAAC,CAAC;YAEhG,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,wBAAc,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACpE,MAAM,IAAI,GAAG,IAAI,mBAAQ,EAAE,CAAC;YAC5B,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC3D,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YAEhC,IAAI,CAAC;gBACJ,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC;oBAC7C,MAAM,EAAE,0BAAU,CAAC,IAAI;oBACvB,GAAG,EAAE,GAAG,OAAO,QAAQ;oBACvB,OAAO,kCACH,OAAO,GACP,IAAI,CAAC,UAAU,EAAE,CACpB;oBACD,IAAI,EAAE,IAAI;iBACV,CAAC,CAAC;gBACH,OAAO,QAAQ,CAAC,IAAI,CAAC;YACtB,CAAC;YAAC,OAAO,CAAM,EAAE,CAAC;gBACjB,MAAM,IAAI,KAAK,CAAC,IAAA,yBAAiB,EAAC,CAAC,CAAC,CAAC,CAAC;YACvC,CAAC;QACF,CAAC;KAAA;CACD,CAAC,CAAC"}
@@ -1,7 +0,0 @@
1
- export declare const mistralAuth: (import("@activepieces/pieces-framework").SecretTextProperty<true> | import("@activepieces/pieces-framework").CustomAuthProperty<{
2
- accountId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
- gatewayId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
4
- gatewayAuthToken: import("@activepieces/pieces-framework").SecretTextProperty<false>;
5
- mistralApiKey: import("@activepieces/pieces-framework").SecretTextProperty<false>;
6
- }>)[];
7
- //# sourceMappingURL=auth.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../src/lib/common/auth.ts"],"names":[],"mappings":"AAsFA,eAAO,MAAM,WAAW;;;;;KAAoD,CAAC"}
@@ -1,100 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mistralAuth = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_framework_1 = require("@activepieces/pieces-framework");
6
- const pieces_common_1 = require("@activepieces/pieces-common");
7
- const mistralDirectAuth = pieces_framework_1.PieceAuth.SecretText({
8
- displayName: 'API Key',
9
- description: `You can obtain your API key from the Mistral AI dashboard. Go to https://console.mistral.ai, generate an API key, and paste it here.`,
10
- required: true,
11
- validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
12
- var _b, _c, _d;
13
- try {
14
- yield pieces_common_1.httpClient.sendRequest({
15
- method: pieces_common_1.HttpMethod.GET,
16
- url: 'https://api.mistral.ai/v1/models',
17
- headers: {
18
- Authorization: `Bearer ${auth}`,
19
- },
20
- });
21
- return { valid: true };
22
- }
23
- catch (e) {
24
- if (((_b = e.response) === null || _b === void 0 ? void 0 : _b.status) === 401) {
25
- return { valid: false, error: 'Invalid API key. Please check your API key and try again.' };
26
- }
27
- if (((_c = e.response) === null || _c === void 0 ? void 0 : _c.status) === 429) {
28
- return { valid: false, error: 'Rate limit exceeded. Please wait and try again.' };
29
- }
30
- if ((_d = e.message) === null || _d === void 0 ? void 0 : _d.toLowerCase().includes('network')) {
31
- return { valid: false, error: 'Network error. Please check your internet connection.' };
32
- }
33
- return { valid: false, error: 'Authentication failed: ' + (e.message || 'Unknown error') };
34
- }
35
- }),
36
- });
37
- const mistralCloudflareGatewayAuth = pieces_framework_1.PieceAuth.CustomAuth({
38
- displayName: 'Cloudflare AI Gateway',
39
- description: 'Route Mistral calls through your Cloudflare AI Gateway. Provide a Mistral API key (key-in-request mode) or leave it blank if your gateway has Mistral configured as a stored key (BYOK).',
40
- required: true,
41
- props: {
42
- accountId: pieces_framework_1.Property.ShortText({
43
- displayName: 'Cloudflare Account ID',
44
- description: 'Your Cloudflare account ID (visible on the AI Gateway dashboard).',
45
- required: true,
46
- }),
47
- gatewayId: pieces_framework_1.Property.ShortText({
48
- displayName: 'Gateway ID',
49
- description: 'The slug of your AI Gateway (visible on the gateway settings page).',
50
- required: true,
51
- }),
52
- gatewayAuthToken: pieces_framework_1.PieceAuth.SecretText({
53
- displayName: 'Gateway Auth Token',
54
- description: 'Optional. Required only if your gateway has authentication enabled. Sent as cf-aig-authorization.',
55
- required: false,
56
- }),
57
- mistralApiKey: pieces_framework_1.PieceAuth.SecretText({
58
- displayName: 'Mistral API Key',
59
- description: 'Optional. Provide your Mistral key for key-in-request mode. Leave blank if Cloudflare injects the key via stored credentials (BYOK).',
60
- required: false,
61
- }),
62
- },
63
- validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
64
- var _b;
65
- const { accountId, gatewayId, gatewayAuthToken, mistralApiKey } = auth;
66
- try {
67
- yield pieces_common_1.httpClient.sendRequest({
68
- method: pieces_common_1.HttpMethod.GET,
69
- url: `https://gateway.ai.cloudflare.com/v1/${encodeURIComponent(accountId)}/${encodeURIComponent(gatewayId)}/mistral/v1/models`,
70
- headers: buildGatewayHeaders({ gatewayAuthToken, mistralApiKey }),
71
- });
72
- return { valid: true };
73
- }
74
- catch (e) {
75
- const status = (_b = e.response) === null || _b === void 0 ? void 0 : _b.status;
76
- if (status === 401 || status === 403) {
77
- return { valid: false, error: 'Authentication rejected by the gateway. Check your Mistral key and gateway auth token.' };
78
- }
79
- if (status === 404) {
80
- return { valid: false, error: 'Gateway not found. Check your account ID and gateway ID.' };
81
- }
82
- if (status === 429) {
83
- return { valid: false, error: 'Rate limit exceeded at the gateway. Please wait and try again.' };
84
- }
85
- return { valid: false, error: 'Gateway validation failed: ' + (e.message || 'Unknown error') };
86
- }
87
- }),
88
- });
89
- exports.mistralAuth = [mistralDirectAuth, mistralCloudflareGatewayAuth];
90
- function buildGatewayHeaders({ gatewayAuthToken, mistralApiKey }) {
91
- const headers = {};
92
- if (gatewayAuthToken) {
93
- headers['cf-aig-authorization'] = `Bearer ${gatewayAuthToken}`;
94
- }
95
- if (mistralApiKey) {
96
- headers['Authorization'] = `Bearer ${mistralApiKey}`;
97
- }
98
- return headers;
99
- }
100
- //# sourceMappingURL=auth.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../src/lib/common/auth.ts"],"names":[],"mappings":";;;;AAAA,qEAAqE;AACrE,+DAAqE;AAErE,MAAM,iBAAiB,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC9C,WAAW,EAAE,SAAS;IACtB,WAAW,EAAE,sIAAsI;IACnJ,QAAQ,EAAE,IAAI;IACd,QAAQ,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;;QACxB,IAAI,CAAC;YACJ,MAAM,0BAAU,CAAC,WAAW,CAAC;gBAC5B,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,GAAG,EAAE,kCAAkC;gBACvC,OAAO,EAAE;oBACR,aAAa,EAAE,UAAU,IAAI,EAAE;iBAC/B;aACD,CAAC,CAAC;YACH,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QACxB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YACjB,IAAI,CAAA,MAAA,CAAC,CAAC,QAAQ,0CAAE,MAAM,MAAK,GAAG,EAAE,CAAC;gBAChC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,2DAA2D,EAAE,CAAC;YAC7F,CAAC;YACD,IAAI,CAAA,MAAA,CAAC,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tH,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,IAAI,gBAAgB,EAAE,CAAC;QACtB,OAAO,CAAC,sBAAsB,CAAC,GAAG,UAAU,gBAAgB,EAAE,CAAC;IAChE,CAAC;IACD,IAAI,aAAa,EAAE,CAAC;QACnB,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,aAAa,EAAE,CAAC;IACtD,CAAC;IACD,OAAO,OAAO,CAAC;AAChB,CAAC"}
@@ -1,8 +0,0 @@
1
- export declare const modelDropdown: import("@activepieces/pieces-framework").DropdownProperty<string, true, (import("@activepieces/pieces-framework").SecretTextProperty<true> | import("@activepieces/pieces-framework").CustomAuthProperty<{
2
- accountId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
- gatewayId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
4
- gatewayAuthToken: import("@activepieces/pieces-framework").SecretTextProperty<false>;
5
- mistralApiKey: import("@activepieces/pieces-framework").SecretTextProperty<false>;
6
- }>)[]>;
7
- export declare function parseMistralError(e: any): string;
8
- //# sourceMappingURL=props.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../../src/lib/common/props.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,aAAa;;;;;MA6CxB,CAAC;AAEH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAKhD"}