@activepieces/piece-claude 0.4.7 → 0.4.9

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/src/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export declare const claude: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").SecretTextProperty<true>>;
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,MAAM,mHAqBjB,CAAC"}
package/src/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAwE;AACxE,2DAAsD;AACtD,gDAA8C;AAC9C,iDAAqD;AACrD,mFAAoF;AACpF,qCAAwC;AAE3B,QAAA,MAAM,GAAG,IAAA,8BAAW,EAAC;IAChC,WAAW,EAAE,kBAAkB;IAC/B,IAAI,EAAE,iBAAU;IAChB,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,gDAAgD;IACzD,UAAU,EAAE,CAAC,sBAAa,CAAC,uBAAuB,CAAC;IACnD,OAAO,EAAE,CAAC,aAAa,EAAC,YAAY,CAAC;IACrC,OAAO,EAAE;QACP,uBAAS;QACT,qDAA2B;QAC3B,IAAA,yCAAyB,EAAC;YACxB,IAAI,EAAE,iBAAU;YAChB,OAAO,EAAE,GAAG,EAAE,CAAC,gBAAO;YACtB,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAC1B,OAAO;oBACL,WAAW,EAAE,GAAG,IAAI,CAAC,WAAW,EAAE;iBACnC,CAAC;YACJ,CAAC,CAAA;SACF,CAAC;KACH;IACD,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC"}
@@ -1,10 +0,0 @@
1
- export declare const extractStructuredDataAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
2
- model: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").SecretTextProperty<true>>;
3
- text: import("@activepieces/pieces-framework").LongTextProperty<false>;
4
- image: import("@activepieces/pieces-framework").FileProperty<false>;
5
- prompt: import("@activepieces/pieces-framework").LongTextProperty<false>;
6
- mode: import("@activepieces/pieces-framework").StaticDropdownProperty<"simple" | "advanced", false> | import("@activepieces/pieces-framework").StaticDropdownProperty<"simple" | "advanced", true>;
7
- schema: import("@activepieces/pieces-framework").DynamicProperties<true, import("@activepieces/pieces-framework").SecretTextProperty<true>>;
8
- maxTokens: import("@activepieces/pieces-framework").NumberProperty<false>;
9
- }>;
10
- //# sourceMappingURL=extract-structured-data.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"extract-structured-data.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/extract-structured-data.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,2BAA2B;;;;;;;;EAuQtC,CAAC"}
@@ -1,236 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractStructuredDataAction = void 0;
4
- const tslib_1 = require("tslib");
5
- const auth_1 = require("../auth");
6
- const pieces_framework_1 = require("@activepieces/pieces-framework");
7
- const shared_1 = require("@activepieces/shared");
8
- const sdk_1 = tslib_1.__importDefault(require("@anthropic-ai/sdk"));
9
- const ajv_1 = tslib_1.__importDefault(require("ajv"));
10
- const mime_types_1 = tslib_1.__importDefault(require("mime-types"));
11
- const common_1 = require("../common/common");
12
- exports.extractStructuredDataAction = (0, pieces_framework_1.createAction)({
13
- auth: auth_1.claudeAuth,
14
- name: 'extract-structured-data',
15
- displayName: 'Extract Structured Data',
16
- description: 'Extract structured data from provided text,image or PDF.',
17
- props: {
18
- model: common_1.modelDropdown,
19
- text: pieces_framework_1.Property.LongText({
20
- displayName: 'Text',
21
- description: 'Text to extract structured data from.',
22
- required: false,
23
- }),
24
- image: pieces_framework_1.Property.File({
25
- displayName: 'Image/PDF',
26
- description: 'Image or PDF to extract structured data from.',
27
- required: false,
28
- }),
29
- prompt: pieces_framework_1.Property.LongText({
30
- displayName: 'Guide Prompt',
31
- description: 'Prompt to guide the AI.',
32
- defaultValue: 'Extract the following data from the provided data.',
33
- required: false,
34
- }),
35
- mode: pieces_framework_1.Property.StaticDropdown({
36
- displayName: 'Data Schema Type',
37
- description: 'For complex schema, you can use advanced mode.',
38
- required: true,
39
- defaultValue: 'simple',
40
- options: {
41
- disabled: false,
42
- options: [
43
- { label: 'Simple', value: 'simple' },
44
- { label: 'Advanced', value: 'advanced' },
45
- ],
46
- },
47
- }),
48
- schema: pieces_framework_1.Property.DynamicProperties({
49
- auth: auth_1.claudeAuth,
50
- displayName: 'Data Definition',
51
- required: true,
52
- refreshers: ['mode'],
53
- props: (propsValue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
54
- const mode = propsValue['mode'];
55
- if (mode === 'advanced') {
56
- return {
57
- fields: pieces_framework_1.Property.Json({
58
- displayName: 'JSON Schema',
59
- description: 'Learn more about JSON Schema here: https://json-schema.org/learn/getting-started-step-by-step',
60
- required: true,
61
- defaultValue: {
62
- type: 'object',
63
- properties: {
64
- name: {
65
- type: 'string',
66
- },
67
- age: {
68
- type: 'number',
69
- },
70
- },
71
- required: ['name'],
72
- },
73
- }),
74
- };
75
- }
76
- return {
77
- fields: pieces_framework_1.Property.Array({
78
- displayName: 'Data Definition',
79
- required: true,
80
- properties: {
81
- name: pieces_framework_1.Property.ShortText({
82
- displayName: 'Name',
83
- description: 'Provide the name of the value you want to extract from the unstructured text. The name should be unique and short. ',
84
- required: true,
85
- }),
86
- description: pieces_framework_1.Property.LongText({
87
- displayName: 'Description',
88
- description: 'Brief description of the data, this hints for the AI on what to look for',
89
- required: false,
90
- }),
91
- type: pieces_framework_1.Property.StaticDropdown({
92
- displayName: 'Data Type',
93
- description: 'Type of parameter.',
94
- required: true,
95
- defaultValue: 'string',
96
- options: {
97
- disabled: false,
98
- options: [
99
- { label: 'Text', value: 'string' },
100
- { label: 'Number', value: 'number' },
101
- { label: 'Boolean', value: 'boolean' },
102
- ],
103
- },
104
- }),
105
- isRequired: pieces_framework_1.Property.Checkbox({
106
- displayName: 'Fail if Not present?',
107
- required: true,
108
- defaultValue: false,
109
- }),
110
- },
111
- }),
112
- };
113
- }),
114
- }),
115
- maxTokens: pieces_framework_1.Property.Number({
116
- displayName: 'Maximum Tokens',
117
- required: false,
118
- description: "The maximum number of tokens to generate. Requests can use up to 2,048 or 4,096 tokens shared between prompt and completion, don't set the value to maximum and leave some tokens for the input. The exact limit varies by model. (One token is roughly 4 characters for normal English text)",
119
- }),
120
- },
121
- run(context) {
122
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
123
- var _a;
124
- const { model, text, image, schema, prompt, maxTokens } = context.propsValue;
125
- if (!text && !image) {
126
- throw new Error('Please provide text or image/PDF to extract data from.');
127
- }
128
- let params;
129
- if (context.propsValue.mode === 'advanced') {
130
- const ajv = new ajv_1.default();
131
- const isValidSchema = ajv.validateSchema(schema);
132
- if (!isValidSchema) {
133
- throw new Error(JSON.stringify({
134
- message: 'Invalid JSON schema',
135
- errors: ajv.errors,
136
- }));
137
- }
138
- params = schema['fields'];
139
- }
140
- else {
141
- params = {
142
- type: 'object',
143
- properties: schema['fields'].reduce((acc, field) => {
144
- acc[field.name] = {
145
- type: field.type,
146
- description: field.description,
147
- };
148
- return acc;
149
- }, {}),
150
- required: schema['fields']
151
- .filter((field) => field.isRequired)
152
- .map((field) => field.name),
153
- };
154
- }
155
- const anthropic = new sdk_1.default({
156
- apiKey: context.auth.secret_text,
157
- });
158
- const messages = [
159
- {
160
- role: 'user',
161
- content: prompt !== null && prompt !== void 0 ? prompt : 'Use optical character recognition (OCR) to extract from provided data.',
162
- },
163
- ];
164
- if (!(0, shared_1.isNil)(text) && text !== '') {
165
- messages.push({
166
- role: 'user',
167
- content: text,
168
- });
169
- }
170
- if (image) {
171
- const mediaType = image.extension
172
- ? mime_types_1.default.lookup(image.extension)
173
- : 'image/jpeg';
174
- if (mediaType === 'application/pdf') {
175
- messages.push({
176
- role: 'user',
177
- content: [
178
- {
179
- type: 'document',
180
- source: {
181
- type: 'base64',
182
- media_type: 'application/pdf',
183
- data: image.base64,
184
- },
185
- },
186
- ],
187
- });
188
- }
189
- else {
190
- messages.push({
191
- role: 'user',
192
- content: [
193
- {
194
- type: 'image',
195
- source: {
196
- type: 'base64',
197
- media_type: mediaType,
198
- data: image.base64,
199
- },
200
- },
201
- ],
202
- });
203
- }
204
- }
205
- const response = yield anthropic.messages.create({
206
- model: model,
207
- messages,
208
- tools: [
209
- {
210
- name: 'extract_structured_data',
211
- description: 'Extract the following data from the provided data.',
212
- input_schema: params,
213
- },
214
- ],
215
- tool_choice: { type: 'tool', name: 'extract_structured_data' },
216
- max_tokens: maxTokens !== null && maxTokens !== void 0 ? maxTokens : 2000,
217
- });
218
- const toolCallsResponse = response.content.filter((choice) => choice.type === 'tool_use');
219
- const toolCall = toolCallsResponse[0];
220
- const choices = response.content
221
- .filter((choice) => choice.type === 'text')
222
- .map((choice) => ({
223
- content: choice.text,
224
- role: 'assistant',
225
- }));
226
- const args = toolCall.input;
227
- if ((0, shared_1.isNil)(args)) {
228
- throw new Error(JSON.stringify({
229
- message: (_a = choices[0].content) !== null && _a !== void 0 ? _a : 'Failed to extract structured data from the input.',
230
- }));
231
- }
232
- return args;
233
- });
234
- },
235
- });
236
- //# sourceMappingURL=extract-structured-data.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"extract-structured-data.js","sourceRoot":"","sources":["../../../../src/lib/actions/extract-structured-data.ts"],"names":[],"mappings":";;;;AAAA,kCAAqC;AACrC,qEAAwE;AACxE,iDAA6C;AAC7C,oEAA0C;AAE1C,sDAAsB;AACtB,oEAA8B;AAC9B,6CAAiD;AAEpC,QAAA,2BAA2B,GAAG,IAAA,+BAAY,EAAC;IACtD,IAAI,EAAE,iBAAU;IAChB,IAAI,EAAE,yB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,IAAI,IAAA,cAAK,EAAC,IAAI,CAAC,EAAE,CAAC;gBAChB,MAAM,IAAI,KAAK,CACb,IAAI,CAAC,SAAS,CAAC;oBACb,OAAO,EACL,MAAA,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,mCAClB,mDAAmD;iBACtD,CAAC,CACH,CAAC;YACJ,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -1,12 +0,0 @@
1
- export declare const askClaude: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
2
- model: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").SecretTextProperty<true>>;
3
- systemPrompt: import("@activepieces/pieces-framework").LongTextProperty<false>;
4
- temperature: import("@activepieces/pieces-framework").NumberProperty<false>;
5
- maxTokens: import("@activepieces/pieces-framework").NumberProperty<false>;
6
- prompt: import("@activepieces/pieces-framework").LongTextProperty<true>;
7
- image: import("@activepieces/pieces-framework").FileProperty<false>;
8
- roles: import("@activepieces/pieces-framework").JsonProperty<false>;
9
- thinkingMode: import("@activepieces/pieces-framework").CheckboxProperty<false>;
10
- thinkingModeParams: import("@activepieces/pieces-framework").DynamicProperties<false, import("@activepieces/pieces-framework").SecretTextProperty<true>>;
11
- }>;
12
- //# sourceMappingURL=send-prompt.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"send-prompt.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/send-prompt.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,SAAS;;;;;;;;;;EAuNpB,CAAC"}
@@ -1,205 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.askClaude = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_framework_1 = require("@activepieces/pieces-framework");
6
- const sdk_1 = tslib_1.__importDefault(require("@anthropic-ai/sdk"));
7
- const mime_types_1 = tslib_1.__importDefault(require("mime-types"));
8
- const auth_1 = require("../auth");
9
- const zod_1 = require("zod");
10
- const pieces_common_1 = require("@activepieces/pieces-common");
11
- const shared_1 = require("@activepieces/shared");
12
- const common_1 = require("../common/common");
13
- const DEFAULT_TOKENS_FOR_THINKING_MODE = 1024;
14
- exports.askClaude = (0, pieces_framework_1.createAction)({
15
- auth: auth_1.claudeAuth,
16
- name: 'ask_claude',
17
- displayName: 'Ask Claude',
18
- description: 'Ask Claude anything you want!',
19
- props: {
20
- model: common_1.modelDropdown,
21
- systemPrompt: pieces_framework_1.Property.LongText({
22
- displayName: 'System Prompt',
23
- required: false,
24
- defaultValue: "You're a helpful assistant.",
25
- }),
26
- temperature: pieces_framework_1.Property.Number({
27
- displayName: 'Temperature',
28
- required: false,
29
- description: 'Controls randomness: Lowering results in less random completions. As the temperature approaches zero, the model will become deterministic and repetitive.',
30
- }),
31
- maxTokens: pieces_framework_1.Property.Number({
32
- displayName: 'Maximum Tokens',
33
- required: false,
34
- description: "The maximum number of tokens to generate. Requests can use up to 2,048 or 4,096 tokens shared between prompt and completion, don't set the value to maximum and leave some tokens for the input. The exact limit varies by model. (One token is roughly 4 characters for normal English text)",
35
- }),
36
- prompt: pieces_framework_1.Property.LongText({
37
- displayName: 'Question',
38
- required: true,
39
- }),
40
- image: pieces_framework_1.Property.File({
41
- displayName: 'Image (URL)',
42
- required: false,
43
- description: 'URL of image to be used as input for the model.',
44
- }),
45
- roles: pieces_framework_1.Property.Json({
46
- displayName: 'Roles',
47
- required: false,
48
- defaultValue: [],
49
- description: `Array of roles to specify more accurate response.Please check [guide to Input Messages](https://docs.anthropic.com/en/api/messages-examples#vision).`,
50
- }),
51
- thinkingMode: pieces_framework_1.Property.Checkbox({
52
- displayName: 'Extended Thinking Mode',
53
- required: false,
54
- defaultValue: false,
55
- description: 'Uses claude 3.7 sonnet enhanced reasoning capabilities for complex tasks.',
56
- }),
57
- thinkingModeParams: pieces_framework_1.Property.DynamicProperties({
58
- auth: auth_1.claudeAuth,
59
- displayName: '',
60
- refreshers: ['thinkingMode'],
61
- required: false,
62
- props: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, thinkingMode }) {
63
- if (!auth || !thinkingMode)
64
- return {};
65
- const props = {};
66
- props['budgetTokens'] = pieces_framework_1.Property.Number({
67
- displayName: 'Budget Tokens',
68
- required: true,
69
- defaultValue: DEFAULT_TOKENS_FOR_THINKING_MODE,
70
- description: 'This parameter determines the maximum number of tokens Claude is allowed to use for its internal reasoning process.Your budget tokens must always be less than the max tokens specified.',
71
- });
72
- return props;
73
- }),
74
- }),
75
- },
76
- run(_a) {
77
- return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
78
- var _b, _c, _d, _e;
79
- yield pieces_common_1.propsValidation.validateZod(propsValue, {
80
- temperature: zod_1.z.number().min(0).max(1.0).optional(),
81
- });
82
- const anthropic = new sdk_1.default({
83
- apiKey: auth.secret_text,
84
- });
85
- let billingIssue = false;
86
- let unauthorized = false;
87
- let model = 'claude-3-haiku-20240307';
88
- if (propsValue.model) {
89
- model = propsValue.model;
90
- }
91
- const temperature = (0, shared_1.isNil)(propsValue.temperature)
92
- ? undefined
93
- : Number(propsValue.temperature);
94
- let maxTokens = 1000;
95
- if (propsValue.maxTokens) {
96
- maxTokens = Number(propsValue.maxTokens);
97
- }
98
- let systemPrompt = 'You are a helpful assistant.';
99
- if (propsValue.systemPrompt) {
100
- systemPrompt = propsValue.systemPrompt;
101
- }
102
- const rolesArray = propsValue.roles
103
- ? propsValue.roles
104
- : [];
105
- const rolesEnum = ['user', 'assistant'];
106
- const roles = rolesArray.map((item) => {
107
- if (!rolesEnum.includes(item.role)) {
108
- throw new Error('The only available roles are: [user, assistant]');
109
- }
110
- return item;
111
- });
112
- const defaultMimeType = 'image/jpeg';
113
- roles.unshift({
114
- role: 'user',
115
- content: [
116
- {
117
- type: 'text',
118
- text: propsValue['prompt'],
119
- },
120
- ...(propsValue.image
121
- ? [
122
- {
123
- type: 'image',
124
- source: {
125
- type: 'base64',
126
- media_type: propsValue.image.extension
127
- ? mime_types_1.default.lookup(propsValue.image.extension) || defaultMimeType
128
- : defaultMimeType,
129
- data: propsValue.image.base64,
130
- },
131
- },
132
- ]
133
- : []),
134
- ],
135
- });
136
- const maxRetries = 4;
137
- let retries = 0;
138
- let response;
139
- while (retries < maxRetries) {
140
- try {
141
- if (propsValue.thinkingMode) {
142
- const budgetTokens = propsValue.thinkingModeParams
143
- ? propsValue.thinkingModeParams['budgetTokens']
144
- : 1024;
145
- const req = yield anthropic.messages.create({
146
- model: 'claude-3-7-sonnet-20250219',
147
- max_tokens: maxTokens,
148
- system: systemPrompt,
149
- thinking: {
150
- type: 'enabled',
151
- budget_tokens: budgetTokens !== null && budgetTokens !== void 0 ? budgetTokens : DEFAULT_TOKENS_FOR_THINKING_MODE,
152
- },
153
- messages: roles,
154
- });
155
- response = req.content
156
- .filter((block) => block.type === 'text')[0]
157
- .text.trim();
158
- }
159
- else {
160
- const params = Object.assign({ model: model, max_tokens: maxTokens, system: systemPrompt, messages: roles }, (0, shared_1.spreadIfDefined)('temperature', temperature));
161
- const req = yield anthropic.messages.create(params);
162
- response = (_b = req.content[0].text) === null || _b === void 0 ? void 0 : _b.trim();
163
- }
164
- break; // Break out of the loop if the request is successful
165
- }
166
- catch (e) {
167
- if ((_c = e === null || e === void 0 ? void 0 : e.type) === null || _c === void 0 ? void 0 : _c.includes('rate_limit_error')) {
168
- billingIssue = true;
169
- if (retries + 1 === maxRetries) {
170
- throw e;
171
- }
172
- // Calculate the time delay for the next retry using exponential backoff
173
- const delay = Math.pow(6, retries) * 1000;
174
- console.log(`Retrying in ${delay} milliseconds...`);
175
- yield sleep(delay); // Wait for the calculated delay
176
- retries++;
177
- break;
178
- }
179
- else {
180
- if ((_e = (_d = e === null || e === void 0 ? void 0 : e.error) === null || _d === void 0 ? void 0 : _d.type) === null || _e === void 0 ? void 0 : _e.includes('not_found_error')) {
181
- unauthorized = true;
182
- throw e;
183
- }
184
- const new_error = e;
185
- throw e;
186
- // throw {
187
- // error: new_error.error.message,
188
- // };
189
- }
190
- }
191
- }
192
- if (billingIssue) {
193
- throw new Error(common_1.billingIssueMessage);
194
- }
195
- if (unauthorized) {
196
- throw new Error(common_1.unauthorizedMessage);
197
- }
198
- return response;
199
- });
200
- },
201
- });
202
- function sleep(ms) {
203
- return new Promise((resolve) => setTimeout(resolve, ms));
204
- }
205
- //# sourceMappingURL=send-prompt.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"send-prompt.js","sourceRoot":"","sources":["../../../../src/lib/actions/send-prompt.ts"],"names":[],"mappings":";;;;AAAA,qEAIwC;AACxC,oEAA0C;AAC1C,oEAA8B;AAC9B,kCAAqC;AAErC,6BAAwB;AACxB,+DAA8D;AAC9D,iDAA8D;AAC9D,6CAA2F;AAC3F,MAAM,gCAAgC,GAAG,IAAI,CAAC;AACjC,QAAA,SAAS,GAAG,IAAA,+BAAY,EAAC;IACpC,IAAI,EAAE,iBAAU;IAChB,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,YAAY;IACzB,WAAW,EAAE,+BAA+B;IAC5C,KAAK,EAAE;QACL,KAAK,EAAE,sBAAa;QACpB,YAAY,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAC9B,WAAW,EAAE,eAAe;YAC5B,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,6BAA6B;SAC5C,CAAC;QACF,WAAW,EAAE,2BAAQ,CAAC,MAAM,CAAC;YAC3B,WAAW,EAAE,aAAa;YAC1B,QAAQ,EAAE,KAAK;YACf,WAAW,EACT,2JAA2J;SAC9J,CAAC;QACF,SAAS,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACzB,WAAW,EAAE,gBAAgB;YAC7B,QAAQ,EAAE,KAAK;YACf,WAAW,EACT,+RAA+R;SAClS,CAAC;QACF,MAAM,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACxB,WAAW,EAAE,UAAU;YACvB,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,KAAK,E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CAAC,uBAAD,CAAC,CAAE,KAAK,0CAAE,IAAI,0CAAE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC;4BAChD,YAAY,GAAG,IAAI,CAAC;4BACpB,MAAM,CAAC,CAAC;wBACV,CAAC;wBACD,MAAM,SAAS,GAAG,CAMjB,CAAC;wBACF,MAAM,CAAC,CAAC;wBACR,UAAU;wBACV,oCAAoC;wBACpC,KAAK;oBACP,CAAC;gBACH,CAAC;YACH,CAAC;YACD,IAAI,YAAY,EAAE,CAAC;gBACjB,MAAM,IAAI,KAAK,CAAC,4BAAmB,CAAC,CAAC;YACvC,CAAC;YACD,IAAI,YAAY,EAAE,CAAC;gBACjB,MAAM,IAAI,KAAK,CAAC,4BAAmB,CAAC,CAAC;YACvC,CAAC;YACD,OAAO,QAAQ,CAAC;QAClB,CAAC;KAAA;CACF,CAAC,CAAC;AAEH,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC"}
package/src/lib/auth.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export declare const claudeAuth: import("@activepieces/pieces-framework").SecretTextProperty<true>;
2
- //# sourceMappingURL=auth.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/lib/auth.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,mEAQrB,CAAC"}
package/src/lib/auth.js DELETED
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.claudeAuth = void 0;
4
- const pieces_framework_1 = require("@activepieces/pieces-framework");
5
- exports.claudeAuth = pieces_framework_1.PieceAuth.SecretText({
6
- displayName: 'API Key',
7
- required: true,
8
- description: `Follow these instructions to get your Claude API Key:
9
-
10
- 1. Visit the following website: https://console.anthropic.com/settings/keys.
11
- 2. Once on the website, locate and click on the option to obtain your Claude API Key.
12
- `,
13
- });
14
- //# sourceMappingURL=auth.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/lib/auth.ts"],"names":[],"mappings":";;;AAAA,qEAA2D;AAE9C,QAAA,UAAU,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC7C,WAAW,EAAE,SAAS;IACtB,QAAQ,EAAE,IAAI;IACd,WAAW,EAAE;;;;CAId;CACA,CAAC,CAAC"}
@@ -1,5 +0,0 @@
1
- export declare const baseUrl = "https://api.anthropic.com/v1";
2
- export declare const billingIssueMessage = "Error Occurred: 429 \n\n\n1. Ensure that you have enough tokens on your Anthropic platform. \n\n2. Generate a new API key. \n\n3. Attempt the process again. \n\n\nFor guidance, visit: https://console.anthropic.com/settings/plans";
3
- export declare const unauthorizedMessage = "Error Occurred: 401 \n\n\nEnsure that your API key is valid. \n\n";
4
- export declare const modelDropdown: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").SecretTextProperty<true>>;
5
- //# sourceMappingURL=common.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../src/lib/common/common.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,OAAO,iCAAiC,CAAC;AAEtD,eAAO,MAAM,mBAAmB,yOAMkC,CAAC;AAEnE,eAAO,MAAM,mBAAmB,sEAG/B,CAAC;AAEF,eAAO,MAAM,aAAa,4IAyCxB,CAAC"}
@@ -1,75 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.modelDropdown = exports.unauthorizedMessage = exports.billingIssueMessage = exports.baseUrl = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_framework_1 = require("@activepieces/pieces-framework");
6
- const sdk_1 = tslib_1.__importDefault(require("@anthropic-ai/sdk"));
7
- const auth_1 = require("../auth");
8
- exports.baseUrl = 'https://api.anthropic.com/v1';
9
- exports.billingIssueMessage = `Error Occurred: 429 \n
10
-
11
- 1. Ensure that you have enough tokens on your Anthropic platform. \n
12
- 2. Generate a new API key. \n
13
- 3. Attempt the process again. \n
14
-
15
- For guidance, visit: https://console.anthropic.com/settings/plans`;
16
- exports.unauthorizedMessage = `Error Occurred: 401 \n
17
-
18
- Ensure that your API key is valid. \n
19
- `;
20
- exports.modelDropdown = pieces_framework_1.Property.Dropdown({
21
- auth: auth_1.claudeAuth,
22
- displayName: 'Model',
23
- description: 'The model which will generate the completion. Some models are suitable for natural language tasks, others specialize in code.',
24
- required: true,
25
- refreshers: [],
26
- options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
27
- var _b, e_1, _c, _d;
28
- if (!auth) {
29
- return {
30
- disabled: true,
31
- placeholder: 'Enter your API key first',
32
- options: [],
33
- };
34
- }
35
- try {
36
- const anthropic = new sdk_1.default({ apiKey: auth.secret_text });
37
- const models = [];
38
- try {
39
- for (var _e = true, _f = tslib_1.__asyncValues(anthropic.models.list({ limit: 1000 })), _g; _g = yield _f.next(), _b = _g.done, !_b; _e = true) {
40
- _d = _g.value;
41
- _e = false;
42
- const model = _d;
43
- models.push(model);
44
- }
45
- }
46
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
47
- finally {
48
- try {
49
- if (!_e && !_b && (_c = _f.return)) yield _c.call(_f);
50
- }
51
- finally { if (e_1) throw e_1.error; }
52
- }
53
- models.sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime());
54
- const options = models.map((model) => {
55
- var _a;
56
- return ({
57
- label: (_a = model.display_name) !== null && _a !== void 0 ? _a : model.id,
58
- value: model.id,
59
- });
60
- });
61
- return {
62
- disabled: false,
63
- options,
64
- };
65
- }
66
- catch (_h) {
67
- return {
68
- disabled: true,
69
- options: [],
70
- placeholder: "Couldn't load models, check your API key or try again.",
71
- };
72
- }
73
- }),
74
- });
75
- //# sourceMappingURL=common.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":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