@scopieflows/app-contextual-ai 0.1.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 +7 -0
- package/package.json +29 -0
- package/src/i18n/de.json +90 -0
- package/src/i18n/es.json +90 -0
- package/src/i18n/fr.json +90 -0
- package/src/i18n/ja.json +90 -0
- package/src/i18n/nl.json +90 -0
- package/src/i18n/pt.json +90 -0
- package/src/i18n/translation.json +90 -0
- package/src/i18n/zh.json +90 -0
- package/src/index.d.ts +8 -0
- package/src/index.js +82 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/create-agent.d.ts +13 -0
- package/src/lib/actions/create-agent.js +116 -0
- package/src/lib/actions/create-agent.js.map +1 -0
- package/src/lib/actions/create-datastore.d.ts +6 -0
- package/src/lib/actions/create-datastore.js +38 -0
- package/src/lib/actions/create-datastore.js.map +1 -0
- package/src/lib/actions/generate.d.ts +13 -0
- package/src/lib/actions/generate.js +93 -0
- package/src/lib/actions/generate.js.map +1 -0
- package/src/lib/actions/ingest-document.d.ts +12 -0
- package/src/lib/actions/ingest-document.js +112 -0
- package/src/lib/actions/ingest-document.js.map +1 -0
- package/src/lib/actions/invite-users.d.ts +7 -0
- package/src/lib/actions/invite-users.js +57 -0
- package/src/lib/actions/invite-users.js.map +1 -0
- package/src/lib/actions/parse-file.d.ts +12 -0
- package/src/lib/actions/parse-file.js +96 -0
- package/src/lib/actions/parse-file.js.map +1 -0
- package/src/lib/actions/query-agent.d.ts +12 -0
- package/src/lib/actions/query-agent.js +108 -0
- package/src/lib/actions/query-agent.js.map +1 -0
- package/src/lib/triggers/new-agent.d.ts +14 -0
- package/src/lib/triggers/new-agent.js +91 -0
- package/src/lib/triggers/new-agent.js.map +1 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ingestDocumentAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@scopieflows/pieces-framework");
|
|
6
|
+
const index_1 = require("../../index");
|
|
7
|
+
const contextual_client_1 = require("contextual-client");
|
|
8
|
+
exports.ingestDocumentAction = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: index_1.contextualAiAuth,
|
|
10
|
+
name: 'ingest_document',
|
|
11
|
+
displayName: 'Ingest Document',
|
|
12
|
+
description: 'Upload and ingest a document into a Contextual AI datastore',
|
|
13
|
+
props: {
|
|
14
|
+
datastoreId: pieces_framework_1.Property.Dropdown({
|
|
15
|
+
auth: index_1.contextualAiAuth,
|
|
16
|
+
displayName: 'Datastore',
|
|
17
|
+
description: 'Select the datastore to upload the document to',
|
|
18
|
+
required: true,
|
|
19
|
+
refreshers: [],
|
|
20
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
21
|
+
var _b, e_1, _c, _d;
|
|
22
|
+
try {
|
|
23
|
+
if (!auth) {
|
|
24
|
+
return {
|
|
25
|
+
disabled: true,
|
|
26
|
+
options: [],
|
|
27
|
+
placeholder: 'Please connect your account first',
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const { apiKey, baseUrl } = auth.props;
|
|
31
|
+
const client = new contextual_client_1.ContextualAI({
|
|
32
|
+
apiKey: apiKey,
|
|
33
|
+
baseURL: baseUrl || 'https://api.contextual.ai/v1',
|
|
34
|
+
});
|
|
35
|
+
const allDatastores = [];
|
|
36
|
+
try {
|
|
37
|
+
for (var _e = true, _f = tslib_1.__asyncValues(client.datastores.list()), _g; _g = yield _f.next(), _b = _g.done, !_b; _e = true) {
|
|
38
|
+
_d = _g.value;
|
|
39
|
+
_e = false;
|
|
40
|
+
const datastore = _d;
|
|
41
|
+
allDatastores.push(datastore);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
45
|
+
finally {
|
|
46
|
+
try {
|
|
47
|
+
if (!_e && !_b && (_c = _f.return)) yield _c.call(_f);
|
|
48
|
+
}
|
|
49
|
+
finally { if (e_1) throw e_1.error; }
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
options: allDatastores.map((datastore) => ({
|
|
53
|
+
label: datastore.name,
|
|
54
|
+
value: datastore.id,
|
|
55
|
+
})),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
return {
|
|
60
|
+
options: [],
|
|
61
|
+
error: 'Failed to fetch datastores. Please check your API key.',
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}),
|
|
65
|
+
}),
|
|
66
|
+
file: pieces_framework_1.Property.File({
|
|
67
|
+
displayName: 'Document File',
|
|
68
|
+
description: 'The document file to upload (PDF, HTML, DOC, DOCX, PPT, PPTX)',
|
|
69
|
+
required: true,
|
|
70
|
+
}),
|
|
71
|
+
customMetadata: pieces_framework_1.Property.Object({
|
|
72
|
+
displayName: 'Custom Metadata',
|
|
73
|
+
description: 'Optional custom metadata as key-value pairs (max 15 fields, 2KB total)',
|
|
74
|
+
required: false,
|
|
75
|
+
}),
|
|
76
|
+
configuration: pieces_framework_1.Property.LongText({
|
|
77
|
+
displayName: 'Configuration Override',
|
|
78
|
+
description: 'Optional configuration override in JSON format for this specific document',
|
|
79
|
+
required: false,
|
|
80
|
+
}),
|
|
81
|
+
},
|
|
82
|
+
run(_a) {
|
|
83
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
|
|
84
|
+
const { apiKey, baseUrl } = auth.props;
|
|
85
|
+
const { datastoreId, file, customMetadata, configuration } = propsValue;
|
|
86
|
+
const client = new contextual_client_1.ContextualAI({
|
|
87
|
+
apiKey: apiKey,
|
|
88
|
+
baseURL: baseUrl || 'https://api.contextual.ai/v1',
|
|
89
|
+
});
|
|
90
|
+
let metadataString;
|
|
91
|
+
if (customMetadata && Object.keys(customMetadata).length > 0) {
|
|
92
|
+
metadataString = JSON.stringify({
|
|
93
|
+
custom_metadata: customMetadata,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
const uploadableFile = yield (0, contextual_client_1.toFile)(file.data, file.filename || 'uploaded-file', {
|
|
97
|
+
type: file.extension ? `application/${file.extension}` : 'application/octet-stream',
|
|
98
|
+
});
|
|
99
|
+
const fileData = {
|
|
100
|
+
file: uploadableFile,
|
|
101
|
+
custom_metadata: metadataString,
|
|
102
|
+
configuration: configuration,
|
|
103
|
+
};
|
|
104
|
+
const response = yield client.datastores.documents.ingest(datastoreId, fileData);
|
|
105
|
+
return {
|
|
106
|
+
document_id: response.id,
|
|
107
|
+
status: 'Document ingestion started. Use the document ID to check status.',
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
//# sourceMappingURL=ingest-document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ingest-document.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/contextual-ai/src/lib/actions/ingest-document.ts"],"names":[],"mappings":";;;;AAAA,oEAAuE;AACvE,uCAA+C;AAC/C,yDAAyD;AAG5C,QAAA,oBAAoB,GAAG,IAAA,+BAAY,EAAC;IAC/C,IAAI,EAAE,wBAAgB;IACtB,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,iBAAiB;IAC9B,WAAW,EAAE,6DAA6D;IAC1E,KAAK,EAAE;QACL,WAAW,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAC7B,IAAI,EAAE,wBAAgB;YACtB,WAAW,EAAE,WAAW;YACxB,WAAW,EAAE,gDAAgD;YAC7D,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,EAAE;YACd,OAAO,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;;gBACtB,IAAI,CAAC;oBACH,IAAI,CAAC,IAAI,EAAE,CAAC;wBACV,OAAO;4BACL,QAAQ,EAAE,IAAI;4BACd,OAAO,EAAE,EAAE;4BACX,WA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
1
|
+
export declare const inviteUsersAction: import("@scopieflows/pieces-framework").IAction<import("@scopieflows/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
apiKey: import("@scopieflows/pieces-framework").SecretTextProperty<true>;
|
|
3
|
+
baseUrl: import("@scopieflows/pieces-framework").ShortTextProperty<false>;
|
|
4
|
+
}>, {
|
|
5
|
+
users: import("@scopieflows/pieces-framework").ArrayProperty<true>;
|
|
6
|
+
tenantShortName: import("@scopieflows/pieces-framework").ShortTextProperty<true>;
|
|
7
|
+
}>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.inviteUsersAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@scopieflows/pieces-framework");
|
|
6
|
+
const index_1 = require("../../index");
|
|
7
|
+
const contextual_client_1 = require("contextual-client");
|
|
8
|
+
exports.inviteUsersAction = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: index_1.contextualAiAuth,
|
|
10
|
+
name: 'invite_users',
|
|
11
|
+
displayName: 'Invite Users',
|
|
12
|
+
description: 'Invite new users to the Contextual AI workspace',
|
|
13
|
+
props: {
|
|
14
|
+
users: pieces_framework_1.Property.Array({
|
|
15
|
+
displayName: 'Users to Invite',
|
|
16
|
+
description: 'List of users to invite',
|
|
17
|
+
required: true,
|
|
18
|
+
properties: {
|
|
19
|
+
email: pieces_framework_1.Property.ShortText({
|
|
20
|
+
displayName: 'Email',
|
|
21
|
+
description: 'Email address of the user to invite',
|
|
22
|
+
required: true,
|
|
23
|
+
}),
|
|
24
|
+
},
|
|
25
|
+
}),
|
|
26
|
+
tenantShortName: pieces_framework_1.Property.ShortText({
|
|
27
|
+
displayName: 'Tenant Short Name',
|
|
28
|
+
description: 'The short name of the tenant/workspace',
|
|
29
|
+
required: true,
|
|
30
|
+
}),
|
|
31
|
+
},
|
|
32
|
+
run(_a) {
|
|
33
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
|
|
34
|
+
const { apiKey, baseUrl } = auth.props;
|
|
35
|
+
const { users, tenantShortName } = propsValue;
|
|
36
|
+
const client = new contextual_client_1.ContextualAI({
|
|
37
|
+
apiKey: apiKey,
|
|
38
|
+
baseURL: baseUrl || 'https://api.contextual.ai/v1',
|
|
39
|
+
});
|
|
40
|
+
const newUsers = users.map((user) => ({
|
|
41
|
+
email: user.email,
|
|
42
|
+
agent_level_roles: ['AGENT_LEVEL_USER'],
|
|
43
|
+
}));
|
|
44
|
+
const response = yield client.users.invite({
|
|
45
|
+
new_users: newUsers,
|
|
46
|
+
tenant_short_name: tenantShortName,
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
invited_users: response.invited_user_emails,
|
|
50
|
+
errors: response.error_details,
|
|
51
|
+
total_invited: response.invited_user_emails.length,
|
|
52
|
+
total_errors: Object.keys(response.error_details).length,
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=invite-users.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invite-users.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/contextual-ai/src/lib/actions/invite-users.ts"],"names":[],"mappings":";;;;AAAA,oEAAuE;AACvE,uCAA+C;AAC/C,yDAAiD;AAEpC,QAAA,iBAAiB,GAAG,IAAA,+BAAY,EAAC;IAC5C,IAAI,EAAE,wBAAgB;IACtB,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,cAAc;IAC3B,WAAW,EAAE,iDAAiD;IAC9D,KAAK,EAAE;QACL,KAAK,EAAE,2BAAQ,CAAC,KAAK,CAAC;YACpB,WAAW,EAAE,iBAAiB;YAC9B,WAAW,EAAE,yBAAyB;YACtC,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE;gBACV,KAAK,EAAE,2BAAQ,CAAC,SAAS,CAAC;oBACxB,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opieflows/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
apiKey: import("@scopieflows/pieces-framework").SecretTextProperty<true>;
|
|
3
|
+
baseUrl: import("@scopieflows/pieces-framework").ShortTextProperty<false>;
|
|
4
|
+
}>, {
|
|
5
|
+
file: import("@scopieflows/pieces-framework").FileProperty<true>;
|
|
6
|
+
parseMode: import("@scopieflows/pieces-framework").StaticDropdownProperty<string, true>;
|
|
7
|
+
pageRange: import("@scopieflows/pieces-framework").ShortTextProperty<false>;
|
|
8
|
+
enableDocumentHierarchy: import("@scopieflows/pieces-framework").CheckboxProperty<false>;
|
|
9
|
+
enableSplitTables: import("@scopieflows/pieces-framework").CheckboxProperty<false>;
|
|
10
|
+
maxSplitTableCells: import("@scopieflows/pieces-framework").NumberProperty<false>;
|
|
11
|
+
figureCaptionMode: import("@scopieflows/pieces-framework").StaticDropdownProperty<string, false>;
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseFileAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@scopieflows/pieces-framework");
|
|
6
|
+
const index_1 = require("../../index");
|
|
7
|
+
const contextual_client_1 = require("contextual-client");
|
|
8
|
+
exports.parseFileAction = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: index_1.contextualAiAuth,
|
|
10
|
+
name: 'parse_file',
|
|
11
|
+
displayName: 'Parse File',
|
|
12
|
+
description: 'Parse a document file into structured Markdown and/or JSON format',
|
|
13
|
+
props: {
|
|
14
|
+
file: pieces_framework_1.Property.File({
|
|
15
|
+
displayName: 'Document File',
|
|
16
|
+
description: 'The document file to parse (PDF, DOC, DOCX, PPT, PPTX)',
|
|
17
|
+
required: true,
|
|
18
|
+
}),
|
|
19
|
+
parseMode: pieces_framework_1.Property.StaticDropdown({
|
|
20
|
+
displayName: 'Parse Mode',
|
|
21
|
+
description: 'Parsing mode - basic for simple text, standard for complex documents',
|
|
22
|
+
required: true,
|
|
23
|
+
options: {
|
|
24
|
+
options: [
|
|
25
|
+
{ label: 'Basic (text-only)', value: 'basic' },
|
|
26
|
+
{ label: 'Standard (complex documents)', value: 'standard' },
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
defaultValue: 'standard',
|
|
30
|
+
}),
|
|
31
|
+
pageRange: pieces_framework_1.Property.ShortText({
|
|
32
|
+
displayName: 'Page Range',
|
|
33
|
+
description: 'Optional page range to parse (e.g., "0,1,2" or "0-2,5,6")',
|
|
34
|
+
required: false,
|
|
35
|
+
}),
|
|
36
|
+
enableDocumentHierarchy: pieces_framework_1.Property.Checkbox({
|
|
37
|
+
displayName: 'Enable Document Hierarchy',
|
|
38
|
+
description: 'Add table of contents with document structure (beta feature)',
|
|
39
|
+
required: false,
|
|
40
|
+
defaultValue: false,
|
|
41
|
+
}),
|
|
42
|
+
enableSplitTables: pieces_framework_1.Property.Checkbox({
|
|
43
|
+
displayName: 'Enable Split Tables',
|
|
44
|
+
description: 'Split large tables into multiple tables with headers',
|
|
45
|
+
required: false,
|
|
46
|
+
defaultValue: false,
|
|
47
|
+
}),
|
|
48
|
+
maxSplitTableCells: pieces_framework_1.Property.Number({
|
|
49
|
+
displayName: 'Max Split Table Cells',
|
|
50
|
+
description: 'Threshold for splitting large tables (only used when split tables is enabled)',
|
|
51
|
+
required: false,
|
|
52
|
+
}),
|
|
53
|
+
figureCaptionMode: pieces_framework_1.Property.StaticDropdown({
|
|
54
|
+
displayName: 'Figure Caption Mode',
|
|
55
|
+
description: 'How thorough figure captions should be',
|
|
56
|
+
required: false,
|
|
57
|
+
options: {
|
|
58
|
+
options: [
|
|
59
|
+
{ label: 'Concise', value: 'concise' },
|
|
60
|
+
{ label: 'Detailed (beta)', value: 'detailed' },
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
defaultValue: 'concise',
|
|
64
|
+
}),
|
|
65
|
+
},
|
|
66
|
+
run(_a) {
|
|
67
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
|
|
68
|
+
const { apiKey, baseUrl } = auth.props;
|
|
69
|
+
const { file, parseMode, pageRange, enableDocumentHierarchy, enableSplitTables, maxSplitTableCells, figureCaptionMode, } = propsValue;
|
|
70
|
+
const client = new contextual_client_1.ContextualAI({
|
|
71
|
+
apiKey: apiKey,
|
|
72
|
+
baseURL: baseUrl || 'https://api.contextual.ai/v1',
|
|
73
|
+
});
|
|
74
|
+
const parseParams = {
|
|
75
|
+
raw_file: file.data,
|
|
76
|
+
parse_mode: parseMode,
|
|
77
|
+
};
|
|
78
|
+
if (pageRange)
|
|
79
|
+
parseParams.page_range = pageRange;
|
|
80
|
+
if (enableDocumentHierarchy !== undefined)
|
|
81
|
+
parseParams.enable_document_hierarchy = enableDocumentHierarchy;
|
|
82
|
+
if (enableSplitTables !== undefined)
|
|
83
|
+
parseParams.enable_split_tables = enableSplitTables;
|
|
84
|
+
if (maxSplitTableCells !== undefined)
|
|
85
|
+
parseParams.max_split_table_cells = maxSplitTableCells;
|
|
86
|
+
if (figureCaptionMode)
|
|
87
|
+
parseParams.figure_caption_mode = figureCaptionMode;
|
|
88
|
+
const response = yield client.parse.create(parseParams);
|
|
89
|
+
return {
|
|
90
|
+
job_id: response.job_id,
|
|
91
|
+
status: 'Parse job started. Use the job ID to check status and get results.',
|
|
92
|
+
};
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
//# sourceMappingURL=parse-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-file.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/contextual-ai/src/lib/actions/parse-file.ts"],"names":[],"mappings":";;;;AAAA,oEAAuE;AACvE,uCAA+C;AAC/C,yDAAiD;AAEpC,QAAA,eAAe,GAAG,IAAA,+BAAY,EAAC;IAC1C,IAAI,EAAE,wBAAgB;IACtB,IAAI,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M,EAAE,oEAAoE;aAC7E,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const queryAgentAction: import("@scopieflows/pieces-framework").IAction<import("@scopieflows/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
apiKey: import("@scopieflows/pieces-framework").SecretTextProperty<true>;
|
|
3
|
+
baseUrl: import("@scopieflows/pieces-framework").ShortTextProperty<false>;
|
|
4
|
+
}>, {
|
|
5
|
+
agentId: import("@scopieflows/pieces-framework").DropdownProperty<string, true, import("@scopieflows/pieces-framework").CustomAuthProperty<{
|
|
6
|
+
apiKey: import("@scopieflows/pieces-framework").SecretTextProperty<true>;
|
|
7
|
+
baseUrl: import("@scopieflows/pieces-framework").ShortTextProperty<false>;
|
|
8
|
+
}>>;
|
|
9
|
+
message: import("@scopieflows/pieces-framework").LongTextProperty<true>;
|
|
10
|
+
conversationId: import("@scopieflows/pieces-framework").ShortTextProperty<false>;
|
|
11
|
+
includeRetrievalContent: import("@scopieflows/pieces-framework").CheckboxProperty<false>;
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.queryAgentAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@scopieflows/pieces-framework");
|
|
6
|
+
const index_1 = require("../../index");
|
|
7
|
+
const contextual_client_1 = require("contextual-client");
|
|
8
|
+
exports.queryAgentAction = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: index_1.contextualAiAuth,
|
|
10
|
+
name: 'query_agent',
|
|
11
|
+
displayName: 'Query Agent',
|
|
12
|
+
description: 'Send a message to a Contextual AI agent and get a response',
|
|
13
|
+
props: {
|
|
14
|
+
agentId: pieces_framework_1.Property.Dropdown({
|
|
15
|
+
auth: index_1.contextualAiAuth,
|
|
16
|
+
displayName: 'Agent',
|
|
17
|
+
description: 'Select the agent to query',
|
|
18
|
+
required: true,
|
|
19
|
+
refreshers: [],
|
|
20
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
21
|
+
var _b, e_1, _c, _d;
|
|
22
|
+
try {
|
|
23
|
+
if (!auth) {
|
|
24
|
+
return {
|
|
25
|
+
disabled: true,
|
|
26
|
+
options: [],
|
|
27
|
+
placeholder: 'Please connect your account first',
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const { apiKey, baseUrl } = auth.props;
|
|
31
|
+
const client = new contextual_client_1.ContextualAI({
|
|
32
|
+
apiKey: apiKey,
|
|
33
|
+
baseURL: baseUrl || 'https://api.contextual.ai/v1',
|
|
34
|
+
});
|
|
35
|
+
const allAgents = [];
|
|
36
|
+
try {
|
|
37
|
+
for (var _e = true, _f = tslib_1.__asyncValues(client.agents.list()), _g; _g = yield _f.next(), _b = _g.done, !_b; _e = true) {
|
|
38
|
+
_d = _g.value;
|
|
39
|
+
_e = false;
|
|
40
|
+
const agent = _d;
|
|
41
|
+
allAgents.push(agent);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
45
|
+
finally {
|
|
46
|
+
try {
|
|
47
|
+
if (!_e && !_b && (_c = _f.return)) yield _c.call(_f);
|
|
48
|
+
}
|
|
49
|
+
finally { if (e_1) throw e_1.error; }
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
options: allAgents.map((agent) => ({
|
|
53
|
+
label: agent.name,
|
|
54
|
+
value: agent.id,
|
|
55
|
+
})),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
return {
|
|
60
|
+
options: [],
|
|
61
|
+
error: 'Failed to fetch agents. Please check your API key.',
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}),
|
|
65
|
+
}),
|
|
66
|
+
message: pieces_framework_1.Property.LongText({
|
|
67
|
+
displayName: 'Message',
|
|
68
|
+
description: 'The message to send to the agent',
|
|
69
|
+
required: true,
|
|
70
|
+
}),
|
|
71
|
+
conversationId: pieces_framework_1.Property.ShortText({
|
|
72
|
+
displayName: 'Conversation ID',
|
|
73
|
+
description: 'Optional conversation ID to continue an existing conversation (leave empty for new conversation)',
|
|
74
|
+
required: false,
|
|
75
|
+
}),
|
|
76
|
+
includeRetrievalContent: pieces_framework_1.Property.Checkbox({
|
|
77
|
+
displayName: 'Include Retrieval Content',
|
|
78
|
+
description: 'Include the text of retrieved contents in the response',
|
|
79
|
+
required: false,
|
|
80
|
+
defaultValue: false,
|
|
81
|
+
}),
|
|
82
|
+
},
|
|
83
|
+
run(_a) {
|
|
84
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
|
|
85
|
+
const { apiKey, baseUrl } = auth.props;
|
|
86
|
+
const { agentId, message, conversationId, includeRetrievalContent } = propsValue;
|
|
87
|
+
const client = new contextual_client_1.ContextualAI({
|
|
88
|
+
apiKey: apiKey,
|
|
89
|
+
baseURL: baseUrl || 'https://api.contextual.ai/v1',
|
|
90
|
+
});
|
|
91
|
+
const messages = conversationId ? [] : [{ role: 'user', content: message }];
|
|
92
|
+
const response = yield client.agents.query.create(agentId, {
|
|
93
|
+
messages: messages,
|
|
94
|
+
conversation_id: conversationId,
|
|
95
|
+
include_retrieval_content_text: includeRetrievalContent,
|
|
96
|
+
});
|
|
97
|
+
return {
|
|
98
|
+
conversation_id: response.conversation_id,
|
|
99
|
+
message: response.message,
|
|
100
|
+
retrieval_contents: response.retrieval_contents,
|
|
101
|
+
attributions: response.attributions,
|
|
102
|
+
groundedness_scores: response.groundedness_scores,
|
|
103
|
+
message_id: response.message_id,
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
//# sourceMappingURL=query-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-agent.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/contextual-ai/src/lib/actions/query-agent.ts"],"names":[],"mappings":";;;;AAAA,oEAAuE;AACvE,uCAA+C;AAC/C,yDAAiD;AAGpC,QAAA,gBAAgB,GAAG,IAAA,+BAAY,EAAC;IAC3C,IAAI,EAAE,wBAAgB;IACtB,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,4DAA4D;IACzE,KAAK,EAAE;QACL,OAAO,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACzB,IAAI,EAAE,wBAAgB;YACtB,WAAW,EAAE,OAAO;YACpB,WAAW,EAAE,2BAA2B;YACxC,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,EAAE;YACd,OAAO,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;;gBACtB,IAAI,CAAC;oBACH,IAAI,CAAC,IAAI,EAAE,CAAC;wBACV,OAAO;4BACL,QAAQ,EAAE,IAAI;4BACd,OAAO,EAAE,EAAE;4BACX,WAAW,EAAE,mCAAmC;yBACjD,CAAC;oBACJ,CAAC;oBACD,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;oBACvC,MAAM,MAAM,GAAG,IAAI,gCAAY,CAAC;wBAC9B,MAAM,EAAE,MAAM;wBACd,OAAO,EAAE,OAAO,IAAI,8BAA8B;qBACnD,CAAC,CAAC;oBAEH,MAAM,SAAS,GAAY,EAAE,CAAC;;wBAC9B,KAA0B,eAAA,KAAA,sBAAA,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAA,IAAA,sDAAE,CAAC;4BAAvB,cAAoB;4BAApB,WAAoB;4BAAnC,MAAM,KAAK,KAAA,CAAA;4BACpB,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;wBACxB,CAAC;;;;;;;;;oBAED,OAAO;wBACL,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,KAAY,EAAE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AM,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE;gBACzD,QAAQ,EAAE,QAAQ;gBAClB,eAAe,EAAE,cAAc;gBAC/B,8BAA8B,EAAE,uBAAuB;aACxD,CAAC,CAAC;YAEH,OAAO;gBACL,eAAe,EAAE,QAAQ,CAAC,eAAe;gBACzC,OAAO,EAAE,QAAQ,CAAC,OAAO;gBACzB,kBAAkB,EAAE,QAAQ,CAAC,kBAAkB;gBAC/C,YAAY,EAAE,QAAQ,CAAC,YAAY;gBACnC,mBAAmB,EAAE,QAAQ,CAAC,mBAAmB;gBACjD,UAAU,EAAE,QAAQ,CAAC,UAAU;aAChC,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@scopieflows/pieces-framework';
|
|
2
|
+
export declare const newAgentTrigger: import("@scopieflows/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@scopieflows/pieces-framework").CustomAuthProperty<{
|
|
3
|
+
apiKey: import("@scopieflows/pieces-framework").SecretTextProperty<true>;
|
|
4
|
+
baseUrl: import("@scopieflows/pieces-framework").ShortTextProperty<false>;
|
|
5
|
+
}>, {}> | import("@scopieflows/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@scopieflows/pieces-framework").CustomAuthProperty<{
|
|
6
|
+
apiKey: import("@scopieflows/pieces-framework").SecretTextProperty<true>;
|
|
7
|
+
baseUrl: import("@scopieflows/pieces-framework").ShortTextProperty<false>;
|
|
8
|
+
}>, {}> | import("@scopieflows/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@scopieflows/pieces-framework").CustomAuthProperty<{
|
|
9
|
+
apiKey: import("@scopieflows/pieces-framework").SecretTextProperty<true>;
|
|
10
|
+
baseUrl: import("@scopieflows/pieces-framework").ShortTextProperty<false>;
|
|
11
|
+
}>, {}> | import("@scopieflows/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@scopieflows/pieces-framework").CustomAuthProperty<{
|
|
12
|
+
apiKey: import("@scopieflows/pieces-framework").SecretTextProperty<true>;
|
|
13
|
+
baseUrl: import("@scopieflows/pieces-framework").ShortTextProperty<false>;
|
|
14
|
+
}>, {}>;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newAgentTrigger = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@scopieflows/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@scopieflows/pieces-common");
|
|
7
|
+
const index_1 = require("../../index");
|
|
8
|
+
const contextual_client_1 = require("contextual-client");
|
|
9
|
+
const polling = {
|
|
10
|
+
strategy: pieces_common_1.DedupeStrategy.TIMEBASED,
|
|
11
|
+
items: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, lastFetchEpochMS }) {
|
|
12
|
+
var _b, e_1, _c, _d;
|
|
13
|
+
const { apiKey, baseUrl } = auth.props;
|
|
14
|
+
const client = new contextual_client_1.ContextualAI({
|
|
15
|
+
apiKey: apiKey,
|
|
16
|
+
baseURL: baseUrl || 'https://api.contextual.ai/v1',
|
|
17
|
+
});
|
|
18
|
+
const allAgents = [];
|
|
19
|
+
try {
|
|
20
|
+
for (var _e = true, _f = tslib_1.__asyncValues(client.agents.list()), _g; _g = yield _f.next(), _b = _g.done, !_b; _e = true) {
|
|
21
|
+
_d = _g.value;
|
|
22
|
+
_e = false;
|
|
23
|
+
const agent = _d;
|
|
24
|
+
allAgents.push(agent);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
28
|
+
finally {
|
|
29
|
+
try {
|
|
30
|
+
if (!_e && !_b && (_c = _f.return)) yield _c.call(_f);
|
|
31
|
+
}
|
|
32
|
+
finally { if (e_1) throw e_1.error; }
|
|
33
|
+
}
|
|
34
|
+
const newAgents = lastFetchEpochMS
|
|
35
|
+
? allAgents.filter(agent => {
|
|
36
|
+
return true;
|
|
37
|
+
})
|
|
38
|
+
: allAgents;
|
|
39
|
+
const items = newAgents.map((agent) => ({
|
|
40
|
+
epochMilliSeconds: Date.now(),
|
|
41
|
+
data: {
|
|
42
|
+
id: agent.id,
|
|
43
|
+
name: agent.name,
|
|
44
|
+
description: agent.description,
|
|
45
|
+
},
|
|
46
|
+
}));
|
|
47
|
+
return items;
|
|
48
|
+
}),
|
|
49
|
+
};
|
|
50
|
+
exports.newAgentTrigger = (0, pieces_framework_1.createTrigger)({
|
|
51
|
+
auth: index_1.contextualAiAuth,
|
|
52
|
+
name: 'new_agent',
|
|
53
|
+
displayName: 'New Agent',
|
|
54
|
+
description: 'Triggers when a new Contextual AI agent is created',
|
|
55
|
+
props: {},
|
|
56
|
+
type: pieces_framework_1.TriggerStrategy.POLLING,
|
|
57
|
+
sampleData: {
|
|
58
|
+
id: 'agent_123',
|
|
59
|
+
name: 'Sample Agent',
|
|
60
|
+
description: 'A sample agent for testing',
|
|
61
|
+
},
|
|
62
|
+
onEnable(context) {
|
|
63
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
yield pieces_common_1.pollingHelper.onEnable(polling, {
|
|
65
|
+
auth: context.auth,
|
|
66
|
+
store: context.store,
|
|
67
|
+
propsValue: context.propsValue,
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
onDisable(context) {
|
|
72
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
yield pieces_common_1.pollingHelper.onDisable(polling, {
|
|
74
|
+
auth: context.auth,
|
|
75
|
+
store: context.store,
|
|
76
|
+
propsValue: context.propsValue,
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
test(context) {
|
|
81
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
return yield pieces_common_1.pollingHelper.test(polling, context);
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
run(context) {
|
|
86
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
return yield pieces_common_1.pollingHelper.poll(polling, context);
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
//# sourceMappingURL=new-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-agent.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/contextual-ai/src/lib/triggers/new-agent.ts"],"names":[],"mappings":";;;;AAAA,oEAAkH;AAClH,8DAAoF;AACpF,uCAA+C;AAC/C,yDAAiD;AAGjD,MAAM,OAAO,GAA+F;IAC1G,QAAQ,EAAE,8BAAc,CAAC,SAAS;IAClC,KAAK,EAAE,KAAmC,EAAE,oDAA9B,EAAE,IAAI,EAAE,gBAAgB,EAAE;;QACtC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QACvC,MAAM,MAAM,GAAG,IAAI,gCAAY,CAAC;YAC9B,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,OAAO,IAAI,8BAA8B;SACnD,CAAC,CAAC;QAEH,MAAM,SAAS,GAAY,EAAE,CAAC;;YAC9B,KAA0B,eAAA,KAAA,sBAAA,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAA,IAAA,sDAAE,CAAC;gBAAvB,cAAoB;gBAApB,WAAoB;gBAAnC,MAAM,KAAK,KAAA,CAAA;gBACpB,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACxB,CAAC;;;;;;;;;QAED,MAAM,SAAS,GAAG,gBAAgB;YAChC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;gBACvB,OAAO,IAAI,CAAC;YACd,CAAC,CAAC;YACJ,CAAC,CAAC,SAAS,CAAC;QAEd,MAAM,KAAK,GAAG,SAAS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