Skip to content

Commit 9a24ee0

Browse files
authored
Tess AI by Pareto new components (#14381)
* Initial AI-generated code + ESLint fixes * Package/app updates * pnpm * App adjustments and Search Templates action * Execute Agent action + lots of improvements * Get Execution Response action * Removing 'find template details' * Component name fix
1 parent 84f8c78 commit 9a24ee0

File tree

7 files changed

+218
-7
lines changed

7 files changed

+218
-7
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { getQuestionProps } from "../../common/utils.mjs";
2+
import app from "../../tess_ai_by_pareto.app.mjs";
3+
4+
export default {
5+
key: "tess_ai_by_pareto-execute-agent",
6+
name: "Execute AI Agent",
7+
description:
8+
"Executes an AI Agent (template) with the given input. [See the documentation](https://tess.pareto.io/api/swagger#/default/f13b3be7386ce63d99fa4bdee0cf6c95)",
9+
version: "0.0.1",
10+
type: "action",
11+
props: {
12+
app,
13+
templateId: {
14+
propDefinition: [
15+
app,
16+
"templateId",
17+
],
18+
reloadProps: true,
19+
},
20+
},
21+
methods: {
22+
getQuestionProps,
23+
},
24+
async additionalProps() {
25+
const { questions } = await this.app.getTemplate(this.templateId);
26+
return this.getQuestionProps(questions);
27+
28+
},
29+
async run({ $ }) {
30+
/* eslint-disable no-unused-vars */
31+
const {
32+
app, templateId, getQuestionProps, ...data
33+
} = this;
34+
const response = await this.app.executeTemplate({
35+
$,
36+
templateId,
37+
data,
38+
});
39+
$.export(
40+
"$summary",
41+
`Executed AI agent ${response.id}`,
42+
);
43+
return response;
44+
},
45+
};
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import app from "../../tess_ai_by_pareto.app.mjs";
2+
3+
export default {
4+
key: "tess_ai_by_pareto-get-execution-response",
5+
name: "Get Agent Execution Response",
6+
description:
7+
"Retrieves the result of a previously executed AI Agent (template). [See the documentation](https://tess.pareto.io/api/swagger#/default/370b6709c5d9e8c17a76e1abb288e7ad)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
app,
12+
executionId: {
13+
type: "string",
14+
label: "Agent Execution ID",
15+
description:
16+
"The ID of the AI Agent (template) execution to retrieve the result for.",
17+
},
18+
},
19+
async run({ $ }) {
20+
const result = await this.app.getTemplateResponse({
21+
$,
22+
executionId: this.executionId,
23+
});
24+
$.export(
25+
"$summary",
26+
`Retrieved response for execution ID ${this.executionId}`,
27+
);
28+
return result;
29+
},
30+
};
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import app from "../../tess_ai_by_pareto.app.mjs";
2+
3+
export default {
4+
key: "tess_ai_by_pareto-search-ai-agents",
5+
name: "Search AI Agents",
6+
description:
7+
"Retrieve AI Agents (templates) that match the specified criteria. [See the documentation](https://tess.pareto.io/api/swagger#/default/201046139d07458d530ad3526e0b3c2f)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
app,
12+
query: {
13+
type: "string",
14+
label: "Search Query",
15+
description:
16+
"Search agents (templates) by title, description and long description.",
17+
optional: true,
18+
},
19+
type: {
20+
type: "string",
21+
label: "Type Filter",
22+
description: "Filter by template type",
23+
optional: true,
24+
},
25+
maxResults: {
26+
type: "integer",
27+
label: "Max Results",
28+
description: "The maximum number of results to return",
29+
optional: true,
30+
default: 15,
31+
min: 1,
32+
max: 1000,
33+
},
34+
},
35+
async run({ $ }) {
36+
const response = await this.app.searchTemplates({
37+
$,
38+
params: {
39+
q: this.query,
40+
type: this.type,
41+
per_page: this.maxResults,
42+
},
43+
});
44+
$.export("$summary", `Retrieved ${response.data?.length} templates`);
45+
return response;
46+
},
47+
};
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
export function getQuestionProps(questions) {
2+
function getQuestionPropType(type) {
3+
switch (type) {
4+
case "number":
5+
return "integer";
6+
default:
7+
return "string";
8+
}
9+
}
10+
11+
return (questions ?? []).reduce((obj, question) => {
12+
obj[question.name] = {
13+
type: getQuestionPropType(question.type),
14+
label: `Field: "${question.name}"`,
15+
description: `Type: \`${question.type}\`. Description: "${question.description}"`,
16+
options: question.options,
17+
optional: !question.required,
18+
};
19+
return obj;
20+
}, {});
21+
}

components/tess_ai_by_pareto/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/tess_ai_by_pareto",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Tess AI by Pareto Components",
55
"main": "tess_ai_by_pareto.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1417
}
15-
}
18+
}
Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,73 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "tess_ai_by_pareto",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
templateId: {
8+
type: "string",
9+
label: "AI Agent ID",
10+
description: "The ID of the AI Agent (template) to execute.",
11+
useQuery: true,
12+
async options({
13+
page = 0, query,
14+
}) {
15+
const response = await this.searchTemplates({
16+
params: {
17+
page: page + 1,
18+
q: query || undefined,
19+
},
20+
});
21+
return response?.data?.map((template) => ({
22+
label: template.title,
23+
value: template.id,
24+
}));
25+
},
26+
},
27+
},
528
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
29+
_baseUrl() {
30+
return "https://tess.pareto.io/api";
31+
},
32+
async _makeRequest({
33+
$ = this, path = "/", headers, ...otherOpts
34+
} = {}) {
35+
return axios($, {
36+
url: this._baseUrl() + path,
37+
headers: {
38+
...headers,
39+
"Authorization": `Bearer ${this.$auth.api_token}`,
40+
},
41+
...otherOpts,
42+
});
43+
},
44+
async executeTemplate({
45+
templateId, ...args
46+
}) {
47+
return this._makeRequest({
48+
method: "POST",
49+
path: `/templates/${templateId}/execute`,
50+
...args,
51+
});
52+
},
53+
async getTemplate(templateId) {
54+
return this._makeRequest({
55+
path: `/templates/${templateId}`,
56+
});
57+
},
58+
async searchTemplates(args) {
59+
return this._makeRequest({
60+
path: "/templates",
61+
...args,
62+
});
63+
},
64+
async getTemplateResponse({
65+
executionId, ...args
66+
}) {
67+
return this._makeRequest({
68+
path: `/template-responses/${executionId}`,
69+
...args,
70+
});
971
},
1072
},
1173
};

pnpm-lock.yaml

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)