Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { getQuestionProps } from "../../common/utils.mjs";
import app from "../../tess_ai_by_pareto.app.mjs";

export default {
key: "tess_ai_by_pareto-execute-agent",
name: "Execute AI Agent",
description:
"Executes an AI Agent (template) with the given input. [See the documentation](https://tess.pareto.io/api/swagger#/default/f13b3be7386ce63d99fa4bdee0cf6c95)",
version: "0.0.1",
type: "action",
props: {
app,
templateId: {
propDefinition: [
app,
"templateId",
],
reloadProps: true,
},
},
methods: {
getQuestionProps,
},
async additionalProps() {
const { questions } = await this.app.getTemplate(this.templateId);
return this.getQuestionProps(questions);

},
async run({ $ }) {
/* eslint-disable no-unused-vars */
const {
app, templateId, getQuestionProps, ...data
} = this;
const response = await this.app.executeTemplate({
$,
templateId,
data,
});
$.export(
"$summary",
`Executed AI agent ${response.id}`,
);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import app from "../../tess_ai_by_pareto.app.mjs";

export default {
key: "tess_ai_by_pareto-get-execution-response",
name: "Get Agent Execution Response",
description:
"Retrieves the result of a previously executed AI Agent (template). [See the documentation](https://tess.pareto.io/api/swagger#/default/370b6709c5d9e8c17a76e1abb288e7ad)",
version: "0.0.1",
type: "action",
props: {
app,
executionId: {
type: "string",
label: "Agent Execution ID",
description:
"The ID of the AI Agent (template) execution to retrieve the result for.",
},
},
async run({ $ }) {
const result = await this.app.getTemplateResponse({
$,
executionId: this.executionId,
});
$.export(
"$summary",
`Retrieved response for execution ID ${this.executionId}`,
);
return result;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import app from "../../tess_ai_by_pareto.app.mjs";

export default {
key: "tess_ai_by_pareto-search-ai-agents",
name: "Search AI Agents",
description:
"Retrieve AI Agents (templates) that match the specified criteria. [See the documentation](https://tess.pareto.io/api/swagger#/default/201046139d07458d530ad3526e0b3c2f)",
version: "0.0.1",
type: "action",
props: {
app,
query: {
type: "string",
label: "Search Query",
description:
"Search agents (templates) by title, description and long description.",
optional: true,
},
type: {
type: "string",
label: "Type Filter",
description: "Filter by template type",
optional: true,
},
maxResults: {
type: "integer",
label: "Max Results",
description: "The maximum number of results to return",
optional: true,
default: 15,
min: 1,
max: 1000,
},
},
async run({ $ }) {
const response = await this.app.searchTemplates({
$,
params: {
q: this.query,
type: this.type,
per_page: this.maxResults,
},
});
$.export("$summary", `Retrieved ${response.data?.length} templates`);
return response;
},
};
21 changes: 21 additions & 0 deletions components/tess_ai_by_pareto/common/utils.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export function getQuestionProps(questions) {
function getQuestionPropType(type) {
switch (type) {
case "number":
return "integer";
default:
return "string";
}
}

return (questions ?? []).reduce((obj, question) => {
obj[question.name] = {
type: getQuestionPropType(question.type),
label: `Field: "${question.name}"`,
description: `Type: \`${question.type}\`. Description: "${question.description}"`,
options: question.options,
optional: !question.required,
};
return obj;
}, {});
}
7 changes: 5 additions & 2 deletions components/tess_ai_by_pareto/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/tess_ai_by_pareto",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Tess AI by Pareto Components",
"main": "tess_ai_by_pareto.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3"
}
}
}
70 changes: 66 additions & 4 deletions components/tess_ai_by_pareto/tess_ai_by_pareto.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,73 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "tess_ai_by_pareto",
propDefinitions: {},
propDefinitions: {
templateId: {
type: "string",
label: "AI Agent ID",
description: "The ID of the AI Agent (template) to execute.",
useQuery: true,
async options({
page = 0, query,
}) {
const response = await this.searchTemplates({
params: {
page: page + 1,
q: query || undefined,
},
});
return response?.data?.map((template) => ({
label: template.title,
value: template.id,
}));
},
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://tess.pareto.io/api";
},
async _makeRequest({
$ = this, path = "/", headers, ...otherOpts
} = {}) {
return axios($, {
url: this._baseUrl() + path,
headers: {
...headers,
"Authorization": `Bearer ${this.$auth.api_token}`,
},
...otherOpts,
});
},
async executeTemplate({
templateId, ...args
}) {
return this._makeRequest({
method: "POST",
path: `/templates/${templateId}/execute`,
...args,
});
},
async getTemplate(templateId) {
return this._makeRequest({
path: `/templates/${templateId}`,
});
},
async searchTemplates(args) {
return this._makeRequest({
path: "/templates",
...args,
});
},
async getTemplateResponse({
executionId, ...args
}) {
return this._makeRequest({
path: `/template-responses/${executionId}`,
...args,
});
},
},
};
27 changes: 15 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading