@activepieces/piece-mistral-ai 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # pieces-mistral-ai
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build pieces-mistral-ai` to build the library.
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@activepieces/piece-mistral-ai",
3
+ "version": "0.0.1",
4
+ "dependencies": {
5
+ "@ai-sdk/anthropic": "1.2.12",
6
+ "@ai-sdk/google": "1.2.19",
7
+ "@ai-sdk/openai": "1.3.22",
8
+ "@ai-sdk/replicate": "0.2.8",
9
+ "@sinclair/typebox": "0.34.11",
10
+ "ai": "4.3.16",
11
+ "axios": "1.8.3",
12
+ "axios-retry": "4.4.1",
13
+ "deepmerge-ts": "7.1.0",
14
+ "fast-glob": "3.3.3",
15
+ "form-data": "4.0.0",
16
+ "mime-types": "2.1.35",
17
+ "nanoid": "3.3.8",
18
+ "semver": "7.6.0",
19
+ "zod": "3.25.76",
20
+ "@activepieces/pieces-common": "0.6.0",
21
+ "@activepieces/pieces-framework": "0.15.0",
22
+ "@activepieces/shared": "0.17.1",
23
+ "tslib": "2.8.1"
24
+ },
25
+ "overrides": {
26
+ "@tryfabric/martian": {
27
+ "@notionhq/client": "$@notionhq/client"
28
+ },
29
+ "vite": {
30
+ "rollup": "npm:@rollup/wasm-node"
31
+ }
32
+ },
33
+ "resolutions": {
34
+ "rollup": "npm:@rollup/wasm-node"
35
+ },
36
+ "types": "./src/index.d.ts",
37
+ "main": "./src/index.js",
38
+ "type": "commonjs"
39
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const mistralAi: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").SecretTextProperty<true>>;
package/src/index.js ADDED
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mistralAi = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const shared_1 = require("@activepieces/shared");
7
+ const create_chat_completion_1 = require("./lib/actions/create-chat-completion");
8
+ const create_embeddings_1 = require("./lib/actions/create-embeddings");
9
+ const upload_file_1 = require("./lib/actions/upload-file");
10
+ const list_models_1 = require("./lib/actions/list-models");
11
+ const auth_1 = require("./lib/common/auth");
12
+ const pieces_common_1 = require("@activepieces/pieces-common");
13
+ exports.mistralAi = (0, pieces_framework_1.createPiece)({
14
+ displayName: "Mistral AI",
15
+ description: "Mistral AI provides state-of-the-art open-weight and hosted language models for text generation, embeddings, and reasoning tasks.",
16
+ auth: auth_1.mistralAuth,
17
+ minimumSupportedRelease: "0.36.1",
18
+ logoUrl: "https://cdn.activepieces.com/pieces/mistral-ai.png",
19
+ authors: ["sparkybug"],
20
+ categories: [shared_1.PieceCategory.ARTIFICIAL_INTELLIGENCE],
21
+ actions: [
22
+ create_chat_completion_1.createChatCompletion,
23
+ create_embeddings_1.createEmbeddings,
24
+ upload_file_1.uploadFile,
25
+ list_models_1.listModels,
26
+ (0, pieces_common_1.createCustomApiCallAction)({
27
+ auth: auth_1.mistralAuth,
28
+ baseUrl: () => 'https://api.mistral.ai/v1',
29
+ authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
30
+ return {
31
+ Authorization: `Bearer ${auth}`
32
+ };
33
+ })
34
+ })
35
+ ],
36
+ triggers: [],
37
+ });
38
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/mistral-ai/src/index.ts"],"names":[],"mappings":";;;;AAAA,qEAA6D;AAC7D,iDAAqD;AACrD,iFAA4E;AAC5E,uEAAmE;AACnE,2DAAuD;AACvD,2DAAuD;AACvD,4CAAgD;AAChD,+DAAwE;AAE3D,QAAA,SAAS,GAAG,IAAA,8BAAW,EAAC;IACnC,WAAW,EAAE,YAAY;IACzB,WAAW,EAAE,mIAAmI;IAChJ,IAAI,EAAE,kBAAW;IACjB,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,oDAAoD;IAC7D,OAAO,EAAE,CAAC,WAAW,CAAC;IACtB,UAAU,EAAE,CAAC,sBAAa,CAAC,uBAAuB,CAAC;IACnD,OAAO,EAAE;QACP,6CAAoB;QACpB,oCAAgB;QAChB,wBAAU;QACV,wBAAU;QACV,IAAA,yCAAyB,EAAC;YACxB,IAAI,EAAC,kBAAW;YAChB,OAAO,EAAC,GAAE,EAAE,CAAA,2BAA2B;YACvC,WAAW,EAAC,CAAO,IAAI,EAAC,EAAE;gBACxB,OAAM;oBACJ,aAAa,EAAC,UAAU,IAAc,EAAE;iBACzC,CAAA;YACH,CAAC,CAAA;SACF,CAAC;KACH;IACD,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ export declare const createChatCompletion: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
2
+ model: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
3
+ prompt: import("@activepieces/pieces-framework").LongTextProperty<true>;
4
+ temperature: import("@activepieces/pieces-framework").NumberProperty<false>;
5
+ top_p: import("@activepieces/pieces-framework").NumberProperty<false>;
6
+ max_tokens: import("@activepieces/pieces-framework").NumberProperty<false>;
7
+ random_seed: import("@activepieces/pieces-framework").NumberProperty<false>;
8
+ timeout: import("@activepieces/pieces-framework").NumberProperty<false>;
9
+ }>;
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createChatCompletion = 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
+ exports.createChatCompletion = (0, pieces_framework_1.createAction)({
10
+ auth: auth_1.mistralAuth,
11
+ name: 'create_chat_completion',
12
+ displayName: 'Ask Mistral',
13
+ description: 'Ask Mistral anything you want!',
14
+ props: {
15
+ model: props_1.modelDropdown,
16
+ prompt: pieces_framework_1.Property.LongText({
17
+ displayName: 'Question',
18
+ required: true,
19
+ }),
20
+ temperature: pieces_framework_1.Property.Number({
21
+ displayName: 'Temperature',
22
+ required: false,
23
+ defaultValue: 1,
24
+ description: 'Controls randomness: Lowering results in less random completions. As the temperature approaches zero, the model will become deterministic and repetitive.',
25
+ }),
26
+ top_p: pieces_framework_1.Property.Number({
27
+ displayName: 'Top P',
28
+ required: false,
29
+ defaultValue: 1,
30
+ description: 'An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.',
31
+ }),
32
+ max_tokens: pieces_framework_1.Property.Number({ displayName: 'Max Tokens', required: false }),
33
+ random_seed: pieces_framework_1.Property.Number({ displayName: 'Random Seed', required: false }),
34
+ timeout: pieces_framework_1.Property.Number({ displayName: 'Timeout (ms)', required: false, defaultValue: 30000 }),
35
+ },
36
+ run(context) {
37
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
38
+ var _a;
39
+ const { model, temperature, top_p, max_tokens, random_seed, timeout, prompt } = context.propsValue;
40
+ const body = {
41
+ model,
42
+ messages: [
43
+ {
44
+ content: prompt,
45
+ role: 'user',
46
+ },
47
+ ],
48
+ temperature,
49
+ top_p,
50
+ max_tokens,
51
+ random_seed
52
+ };
53
+ let lastErr;
54
+ for (let attempt = 0; attempt <= 3; ++attempt) {
55
+ try {
56
+ const response = yield pieces_common_1.httpClient.sendRequest({
57
+ method: pieces_common_1.HttpMethod.POST,
58
+ url: 'https://api.mistral.ai/v1/chat/completions',
59
+ authentication: {
60
+ type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
61
+ token: context.auth,
62
+ },
63
+ body,
64
+ timeout: timeout !== null && timeout !== void 0 ? timeout : 30000,
65
+ });
66
+ const answer = response.body.choices[0].message.content;
67
+ return answer;
68
+ }
69
+ catch (e) {
70
+ lastErr = e;
71
+ const status = (_a = e.response) === null || _a === void 0 ? void 0 : _a.status;
72
+ if (status === 429 || (status && status >= 500 && status < 600)) {
73
+ if (attempt < 3) {
74
+ yield new Promise((r) => setTimeout(r, 1000 * (attempt + 1)));
75
+ continue;
76
+ }
77
+ }
78
+ throw new Error((0, props_1.parseMistralError)(e));
79
+ }
80
+ }
81
+ throw new Error((0, props_1.parseMistralError)(lastErr));
82
+ });
83
+ },
84
+ });
85
+ //# sourceMappingURL=create-chat-completion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-chat-completion.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/mistral-ai/src/lib/actions/create-chat-completion.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAyF;AACzF,yCAA6C;AAC7C,2CAAmE;AAEtD,QAAA,oBAAoB,GAAG,IAAA,+BAAY,EAAC;IAChD,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,wBAAwB;IAC9B,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,gCAAgC;IAC7C,KAAK,EAAE;QACN,KAAK,EAAE,qBAAa;QACpB,MAAM,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACzB,WAAW,EAAE,UAAU;YACvB,QAAQ,EAAE,IAAI;SACd,CAAC;QACF,WAAW,EAAE,2BAAQ,CAAC,MAAM,CAAC;YAC5B,WAAW,EAAE,aAAa;YAC1B,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,CAAC;YACf,WAAW,EACV,2JAA2J;SAC5J,CAAC;QACF,KAAK,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACtB,WAAW,EAAE,OAAO;YACpB,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,CAAC;YACf,WAAW,EACV,6OAA6O;SAC9O,CAAC;QACF,UAAU,EAAE,2BAA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AExD,OAAO,MAAM,CAAC;gBACf,CAAC;gBAAC,OAAO,CAAM,EAAE,CAAC;oBACjB,OAAO,GAAG,CAAC,CAAC;oBACZ,MAAM,MAAM,GAAG,MAAA,CAAC,CAAC,QAAQ,0CAAE,MAAM,CAAC;oBAClC,IAAI,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,IAAI,MAAM,IAAI,GAAG,IAAI,MAAM,GAAG,GAAG,CAAC,EAAE,CAAC;wBACjE,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;4BACjB,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;4BAC9D,SAAS;wBACV,CAAC;oBACF,CAAC;oBACD,MAAM,IAAI,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"}
@@ -0,0 +1,4 @@
1
+ export declare const createEmbeddings: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
2
+ input: import("@activepieces/pieces-framework").ArrayProperty<true>;
3
+ timeout: import("@activepieces/pieces-framework").NumberProperty<false>;
4
+ }>;
@@ -0,0 +1,76 @@
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
+ exports.createEmbeddings = (0, pieces_framework_1.createAction)({
10
+ auth: auth_1.mistralAuth,
11
+ name: 'create_embeddings',
12
+ displayName: 'Create Embeddings',
13
+ description: 'Creates new embedding in Mistral AI.',
14
+ props: {
15
+ input: pieces_framework_1.Property.Array({
16
+ displayName: 'Input',
17
+ description: 'The input text for which to create an embedding.',
18
+ required: true,
19
+ }),
20
+ timeout: pieces_framework_1.Property.Number({ displayName: 'Timeout (ms)', required: false, defaultValue: 30000 }),
21
+ },
22
+ run(context) {
23
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
24
+ var _a;
25
+ const { input, timeout } = context.propsValue;
26
+ let inputArr = [];
27
+ try {
28
+ if (typeof input === 'string') {
29
+ try {
30
+ inputArr = JSON.parse(input);
31
+ }
32
+ catch (_b) {
33
+ inputArr = input;
34
+ }
35
+ }
36
+ inputArr = input;
37
+ }
38
+ catch (_c) {
39
+ throw new Error('Input must be a non-empty string or a JSON array of non-empty strings');
40
+ }
41
+ const body = {
42
+ model: 'mistral-embed',
43
+ input: inputArr,
44
+ };
45
+ let lastErr;
46
+ for (let attempt = 0; attempt <= 3; ++attempt) {
47
+ try {
48
+ const response = yield pieces_common_1.httpClient.sendRequest({
49
+ method: pieces_common_1.HttpMethod.POST,
50
+ url: 'https://api.mistral.ai/v1/embeddings',
51
+ authentication: {
52
+ type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
53
+ token: context.auth,
54
+ },
55
+ body,
56
+ timeout: timeout !== null && timeout !== void 0 ? timeout : 30000,
57
+ });
58
+ return response.body;
59
+ }
60
+ catch (e) {
61
+ lastErr = e;
62
+ const status = (_a = e.response) === null || _a === void 0 ? void 0 : _a.status;
63
+ if (status === 429 || (status && status >= 500 && status < 600)) {
64
+ if (attempt < 3) {
65
+ yield new Promise((r) => setTimeout(r, 1000 * (attempt + 1)));
66
+ continue;
67
+ }
68
+ }
69
+ throw new Error((0, props_1.parseMistralError)(e));
70
+ }
71
+ }
72
+ throw new Error((0, props_1.parseMistralError)(lastErr));
73
+ });
74
+ },
75
+ });
76
+ //# sourceMappingURL=create-embeddings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-embeddings.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/mistral-ai/src/lib/actions/create-embeddings.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAyF;AACzF,yCAA6C;AAC7C,2CAAoD;AAEvC,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,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,CAAC,CAAC;oBAC9B,CAAC;oBAAC,WAAM,CAAC;wBACR,QAAQ,GAAG,KAAK,CAAC;oBAClB,CAAC;gBACF,CAAC;gBACD,QAAQ,GAAG,KAAiB,CAAC;YAC9B,CAAC;YAAC,WAAM,CAAC;gBACR,MAAM,IAAI,KAAK,CAAC,uEAAuE,CAAC,CAAC;YAC1F,CAAC;YACD,MAAM,IAAI,GAAG;gBACZ,KAAK,EAAE,eAAe;gBACtB,KAAK,EAAE,QAAQ;aACf,CAAC;YACF,IAAI,OAAO,CAAC;YACZ,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC;gBAC/C,IAAI,CAAC;oBACJ,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC;wBAC7C,MAAM,EAAE,0BAAU,CAAC,IAAI;wBACvB,GAAG,EAAE,sCAAsC;wBAC3C,cAAc,EAAE;4BACf,IAAI,EAAE,kCAAkB,CAAC,YAAY;4BACrC,KAAK,EAAE,OAAO,CAAC,IAAI;yBACnB;wBACD,IAAI;wBACJ,OAAO,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,KAAK;qBACzB,CAAC,CAAC;oBAEH,OAAO,QAAQ,CAAC,IAAI,CAAC;gBACtB,CAAC;gBAAC,OAAO,CAAM,EAAE,CAAC;oBACjB,OAAO,GAAG,CAAC,CAAC;oBACZ,MAAM,MAAM,GAAG,MAAA,CAAC,CAAC,QAAQ,0CAAE,MAAM,CAAC;oBAClC,IAAI,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,IAAI,MAAM,IAAI,GAAG,IAAI,MAAM,GAAG,GAAG,CAAC,EAAE,CAAC;wBACjE,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;4BACjB,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;4BAC9D,SAAS;wBACV,CAAC;oBACF,CAAC;oBACD,MAAM,IAAI,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"}
@@ -0,0 +1 @@
1
+ export declare const listModels: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {}>;
@@ -0,0 +1,34 @@
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
+ exports.listModels = (0, pieces_framework_1.createAction)({
10
+ auth: auth_1.mistralAuth,
11
+ name: 'list_models',
12
+ displayName: 'List Models',
13
+ description: 'Retrieves a list of available Mistral AI models.',
14
+ props: {},
15
+ run(_a) {
16
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth }) {
17
+ try {
18
+ const response = yield pieces_common_1.httpClient.sendRequest({
19
+ method: pieces_common_1.HttpMethod.GET,
20
+ url: 'https://api.mistral.ai/v1/models',
21
+ authentication: {
22
+ type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
23
+ token: auth,
24
+ },
25
+ });
26
+ return response.body;
27
+ }
28
+ catch (e) {
29
+ throw new Error((0, props_1.parseMistralError)(e));
30
+ }
31
+ });
32
+ },
33
+ });
34
+ //# sourceMappingURL=list-models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-models.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/mistral-ai/src/lib/actions/list-models.ts"],"names":[],"mappings":";;;;AAAA,qEAA8D;AAC9D,+DAAyF;AACzF,yCAA6C;AAC7C,2CAAoD;AAEvC,QAAA,UAAU,GAAG,IAAA,+BAAY,EAAC;IACrC,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,aAAa;IACpB,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,kDAAkD;IAC9D,KAAK,EAAE,EAAE;IACH,GAAG;qEAAC,EAAE,IAAI,EAAE;YAChB,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC;oBAC5C,MAAM,EAAE,0BAAU,CAAC,GAAG;oBACtB,GAAG,EAAE,kCAAkC;oBACvC,cAAc,EAAE;wBACd,IAAI,EAAE,kCAAkB,CAAC,YAAY;wBACrC,KAAK,EAAE,IAAc;qBACtB;iBACF,CAAC,CAAC;gBAEH,OAAO,QAAQ,CAAC,IAAI,CAAC;YACvB,CAAC;YAAC,OAAO,CAAM,EAAE,CAAC;gBACjB,MAAM,IAAI,KAAK,CAAC,IAAA,yBAAiB,EAAC,CAAC,CAAC,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare const uploadFile: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
2
+ file: import("@activepieces/pieces-framework").FileProperty<true>;
3
+ purpose: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
4
+ }>;
@@ -0,0 +1,82 @@
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 SUPPORTED_PURPOSES = ['fine-tune', 'batch', 'ocr'];
11
+ const MAX_FILE_SIZE_BYTES = 512 * 1024 * 1024;
12
+ const ALLOWED_EXTENSIONS = [
13
+ 'jsonl',
14
+ 'txt',
15
+ 'csv',
16
+ 'pdf',
17
+ 'docx',
18
+ 'png',
19
+ 'jpg',
20
+ 'jpeg',
21
+ 'mp3',
22
+ 'mp4',
23
+ ];
24
+ function getFileExtension(filename) {
25
+ const parts = filename.split('.');
26
+ return parts.length > 1 ? parts.pop().toLowerCase() : '';
27
+ }
28
+ exports.uploadFile = (0, pieces_framework_1.createAction)({
29
+ auth: auth_1.mistralAuth,
30
+ name: 'upload_file',
31
+ displayName: 'Upload File',
32
+ description: 'Upload a file to Mistral AI (e.g., for fine-tuning or context storage).',
33
+ props: {
34
+ file: pieces_framework_1.Property.File({
35
+ displayName: 'File',
36
+ description: 'The file to upload (max 512MB).For fine tuning purspose provide .jsonl file.',
37
+ required: true,
38
+ }),
39
+ purpose: pieces_framework_1.Property.StaticDropdown({
40
+ displayName: 'Purpose',
41
+ description: 'Purpose of the file.',
42
+ required: true,
43
+ options: {
44
+ options: SUPPORTED_PURPOSES.map((p) => ({ label: p, value: p })),
45
+ },
46
+ }),
47
+ },
48
+ run(context) {
49
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
50
+ const { file, purpose } = context.propsValue;
51
+ if (!file)
52
+ throw new Error('File is required');
53
+ if (!SUPPORTED_PURPOSES.includes(purpose))
54
+ throw new Error('Invalid purpose');
55
+ if (file.data.byteLength > MAX_FILE_SIZE_BYTES)
56
+ throw new Error('File exceeds 512MB limit');
57
+ const ext = getFileExtension(file.filename);
58
+ if (!ALLOWED_EXTENSIONS.includes(ext))
59
+ throw new Error(`File extension .${ext} is not allowed`);
60
+ const form = new form_data_1.default();
61
+ form.append('file', Buffer.from(file.data), file.filename);
62
+ form.append('purpose', purpose);
63
+ try {
64
+ const response = yield pieces_common_1.httpClient.sendRequest({
65
+ method: pieces_common_1.HttpMethod.POST,
66
+ url: 'https://api.mistral.ai/v1/files',
67
+ authentication: {
68
+ type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
69
+ token: context.auth,
70
+ },
71
+ headers: Object.assign({}, form.getHeaders()),
72
+ body: form,
73
+ });
74
+ return response.body;
75
+ }
76
+ catch (e) {
77
+ throw new Error((0, props_1.parseMistralError)(e));
78
+ }
79
+ });
80
+ },
81
+ });
82
+ //# sourceMappingURL=upload-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload-file.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/mistral-ai/src/lib/actions/upload-file.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AAC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AAC,IAAA,yBAAiB,EAAC,CAAC,CAAC,CAAC,CAAC;YACvC,CAAC;QACF,CAAC;KAAA;CACD,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const mistralAuth: import("@activepieces/pieces-framework").SecretTextProperty<true>;
@@ -0,0 +1,38 @@
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
+ exports.mistralAuth = 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
+ authentication: {
18
+ type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
19
+ token: auth,
20
+ },
21
+ });
22
+ return { valid: true };
23
+ }
24
+ catch (e) {
25
+ if (((_b = e.response) === null || _b === void 0 ? void 0 : _b.status) === 401) {
26
+ return { valid: false, error: 'Invalid API key. Please check your API key and try again.' };
27
+ }
28
+ if (((_c = e.response) === null || _c === void 0 ? void 0 : _c.status) === 429) {
29
+ return { valid: false, error: 'Rate limit exceeded. Please wait and try again.' };
30
+ }
31
+ if ((_d = e.message) === null || _d === void 0 ? void 0 : _d.toLowerCase().includes('network')) {
32
+ return { valid: false, error: 'Network error. Please check your internet connection.' };
33
+ }
34
+ return { valid: false, error: 'Authentication failed: ' + (e.message || 'Unknown error') };
35
+ }
36
+ }),
37
+ });
38
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","s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E,CAAC;QAC5F,CAAC;IACF,CAAC,CAAA;CACD,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const modelDropdown: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
2
+ export declare function parseMistralError(e: any): string;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.modelDropdown = void 0;
4
+ exports.parseMistralError = parseMistralError;
5
+ const tslib_1 = require("tslib");
6
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
7
+ const pieces_common_1 = require("@activepieces/pieces-common");
8
+ exports.modelDropdown = pieces_framework_1.Property.Dropdown({
9
+ displayName: 'Model',
10
+ description: 'Select a Mistral model. List is fetched live from your account.',
11
+ required: true,
12
+ refreshers: [],
13
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
14
+ if (!auth) {
15
+ return {
16
+ disabled: true,
17
+ placeholder: 'Please connect your account first.',
18
+ options: [],
19
+ };
20
+ }
21
+ try {
22
+ const response = yield pieces_common_1.httpClient.sendRequest({
23
+ method: pieces_common_1.HttpMethod.GET,
24
+ url: 'https://api.mistral.ai/v1/models',
25
+ authentication: {
26
+ type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
27
+ token: auth,
28
+ },
29
+ });
30
+ const models = response.body.data || [];
31
+ const options = models.map((model) => ({
32
+ label: model.name || model.id,
33
+ value: model.id,
34
+ }));
35
+ if (options.length === 0) {
36
+ return {
37
+ disabled: true,
38
+ placeholder: 'No models found for your account.',
39
+ options: [],
40
+ };
41
+ }
42
+ return {
43
+ disabled: false,
44
+ options,
45
+ };
46
+ }
47
+ catch (_b) {
48
+ return {
49
+ disabled: true,
50
+ placeholder: 'Failed to load models. Check your API key and network.',
51
+ options: [],
52
+ };
53
+ }
54
+ }),
55
+ });
56
+ function parseMistralError(e) {
57
+ var _a, _b, _c, _d;
58
+ if ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error)
59
+ return e.response.data.error;
60
+ if ((_d = (_c = e.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.message)
61
+ return e.response.data.message;
62
+ if (e.message)
63
+ return e.message;
64
+ return 'Unknown error';
65
+ }
66
+ //# sourceMappingURL=props.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"props.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/mistral-ai/src/lib/common/props.ts"],"names":[],"mappings":";;;AAmDA,8CAKC;;AAxDD,qEAA0E;AAC1E,+DAAyF;AAE5E,QAAA,aAAa,GAAG,2BAAQ,CAAC,QAAQ,CAAC;IAC9C,WAAW,EAAE,OAAO;IACpB,WAAW,EAAE,iEAAiE;IAC9E,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,EAAE;IACd,OAAO,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;QACvB,IAAI,CAAC,IAAI,EAAE,CAAC;YACX,OAAO;gBACN,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,oCAAoC;gBACjD,OAAO,EAAE,EAAE;aACX,CAAC;QACH,CAAC;QACD,IAAI,CAAC;YACJ,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAmC;gBAC/E,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,GAAG,EAAE,kCAAkC;gBACvC,cAAc,EAAE;oBACf,IAAI,EAAE,kCAAkB,CAAC,YAAY;oBACrC,KAAK,EAAE,IAAc;iBACrB;aACD,CAAC,CAAC;YACH,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;YACxC,MAAM,OAAO,GAA6B,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;gBAChE,KAAK,EAAE,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,EAAE;gBAC7B,KAAK,EAAE,KAAK,CAAC,EAAE;aACf,CAA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