From 887f916727547661f181389c4525af64b2baf8ac Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Mon, 21 Oct 2024 03:30:04 -0300 Subject: [PATCH 1/8] Initial AI-generated code + ESLint fixes --- .../execute-template/execute-template.mjs | 35 ++++ .../find-template-details.mjs | 25 +++ .../get-execution-response.mjs | 25 +++ .../search-templates/search-templates.mjs | 32 ++++ components/tess_ai_by_pareto/package.json | 2 +- .../tess_ai_by_pareto.app.mjs | 150 +++++++++++++++++- 6 files changed, 266 insertions(+), 3 deletions(-) create mode 100644 components/tess_ai_by_pareto/actions/execute-template/execute-template.mjs create mode 100644 components/tess_ai_by_pareto/actions/find-template-details/find-template-details.mjs create mode 100644 components/tess_ai_by_pareto/actions/get-execution-response/get-execution-response.mjs create mode 100644 components/tess_ai_by_pareto/actions/search-templates/search-templates.mjs diff --git a/components/tess_ai_by_pareto/actions/execute-template/execute-template.mjs b/components/tess_ai_by_pareto/actions/execute-template/execute-template.mjs new file mode 100644 index 0000000000000..809fbf43af8a2 --- /dev/null +++ b/components/tess_ai_by_pareto/actions/execute-template/execute-template.mjs @@ -0,0 +1,35 @@ +import tess_ai_by_pareto from "../../tess_ai_by_pareto.app.mjs"; + +export default { + key: "tess_ai_by_pareto-execute-template", + name: "Execute AI Template", + description: "Executes an AI template and returns the execution ID. [See the documentation]()", + version: "0.0.{{ts}}", + type: "action", + props: { + tess_ai_by_pareto, + templateId: { + propDefinition: [ + "tess_ai_by_pareto", + "templateId", + ], + }, + inputs: { + propDefinition: [ + "tess_ai_by_pareto", + "inputs", + ], + optional: true, + }, + }, + async run({ $ }) { + const response = await this.tess_ai_by_pareto.executeAiTemplate({ + templateId: this.templateId, + inputs: this.inputs, + }); + $.export("$summary", `Executed AI template with Execution ID ${response.id}`); + return { + executionId: response.id, + }; + }, +}; diff --git a/components/tess_ai_by_pareto/actions/find-template-details/find-template-details.mjs b/components/tess_ai_by_pareto/actions/find-template-details/find-template-details.mjs new file mode 100644 index 0000000000000..564a514604397 --- /dev/null +++ b/components/tess_ai_by_pareto/actions/find-template-details/find-template-details.mjs @@ -0,0 +1,25 @@ +import tess_ai_by_pareto from "../../tess_ai_by_pareto.app.mjs"; + +export default { + key: "tess_ai_by_pareto-find-template-details", + name: "Find AI Template Details", + description: "Retrieves detailed information about a specific AI template. [See the documentation]()", + version: "0.0.{{ts}}", + type: "action", + props: { + tess_ai_by_pareto, + templateId: { + propDefinition: [ + "tess_ai_by_pareto", + "templateId", + ], + }, + }, + async run({ $ }) { + const response = await this.tess_ai_by_pareto.getAiTemplateDetails({ + templateId: this.templateId, + }); + $.export("$summary", `Retrieved details for AI template ${this.templateId}`); + return response; + }, +}; diff --git a/components/tess_ai_by_pareto/actions/get-execution-response/get-execution-response.mjs b/components/tess_ai_by_pareto/actions/get-execution-response/get-execution-response.mjs new file mode 100644 index 0000000000000..ecdbf1b2089e1 --- /dev/null +++ b/components/tess_ai_by_pareto/actions/get-execution-response/get-execution-response.mjs @@ -0,0 +1,25 @@ +import tess_ai_by_pareto from "../../tess_ai_by_pareto.app.mjs"; + +export default { + key: "tess_ai_by_pareto-get-execution-response", + name: "Get AI Execution Response", + description: "Retrieves the result of a previously executed AI template (image, text, or video). [See the documentation]().", + version: "0.0.{{ts}}", + type: "action", + props: { + tess_ai_by_pareto, + executionId: { + propDefinition: [ + "tess_ai_by_pareto", + "executionId", + ], + }, + }, + async run({ $ }) { + const result = await this.tess_ai_by_pareto.getAiTemplateResult({ + executionId: this.executionId, + }); + $.export("$summary", `Retrieved AI Execution Result for Execution ID ${this.executionId}`); + return result; + }, +}; diff --git a/components/tess_ai_by_pareto/actions/search-templates/search-templates.mjs b/components/tess_ai_by_pareto/actions/search-templates/search-templates.mjs new file mode 100644 index 0000000000000..3bcebe11c6524 --- /dev/null +++ b/components/tess_ai_by_pareto/actions/search-templates/search-templates.mjs @@ -0,0 +1,32 @@ +import tess_ai_by_pareto from "../../tess_ai_by_pareto.app.mjs"; + +export default { + key: "tess_ai_by_pareto-search-templates", + name: "Search AI Templates", + description: "Searches for AI templates created by users based on specific criteria. [See the documentation]()", + version: "0.0.{{ts}}", + type: "action", + props: { + tess_ai_by_pareto, + query: { + propDefinition: [ + "tess_ai_by_pareto", + "query", + ], + }, + typeFilter: { + propDefinition: [ + "tess_ai_by_pareto", + "typeFilter", + ], + }, + }, + async run({ $ }) { + const response = await this.tess_ai_by_pareto.searchAiTemplates({ + query: this.query, + typeFilter: this.typeFilter, + }); + $.export("$summary", `Found ${response.templates.length} templates`); + return response; + }, +}; diff --git a/components/tess_ai_by_pareto/package.json b/components/tess_ai_by_pareto/package.json index 16ca35b5f25dc..75dade693bb83 100644 --- a/components/tess_ai_by_pareto/package.json +++ b/components/tess_ai_by_pareto/package.json @@ -12,4 +12,4 @@ "publishConfig": { "access": "public" } -} \ No newline at end of file +} diff --git a/components/tess_ai_by_pareto/tess_ai_by_pareto.app.mjs b/components/tess_ai_by_pareto/tess_ai_by_pareto.app.mjs index a07f40f61533f..7e18a3f0d3797 100644 --- a/components/tess_ai_by_pareto/tess_ai_by_pareto.app.mjs +++ b/components/tess_ai_by_pareto/tess_ai_by_pareto.app.mjs @@ -1,11 +1,157 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "tess_ai_by_pareto", - propDefinitions: {}, + version: "0.0.{{ts}}", + propDefinitions: { + templateId: { + type: "string", + label: "AI Template ID", + description: "The ID of the AI template to execute or retrieve details for.", + async options() { + const templates = await this.searchAiTemplates({ + query: "", + }); + return templates.templates.map((template) => ({ + label: template.name, + value: template.id, + })); + }, + }, + executionId: { + type: "string", + label: "AI Execution ID", + description: "The ID of the AI template execution to retrieve the result for.", + async options() { + const executions = await this.listExecutions(); + return executions.executions.map((execution) => ({ + label: execution.id, + value: execution.id, + })); + }, + }, + query: { + type: "string", + label: "Search Query", + description: "The search query to find AI templates based on specific criteria.", + }, + typeFilter: { + type: "string", + label: "Template Type", + description: "Filter templates by type (image, text, video).", + optional: true, + options: [ + { + label: "Image", + value: "image", + }, + { + label: "Text", + value: "text", + }, + { + label: "Video", + value: "video", + }, + ], + }, + inputs: { + type: "string[]", + label: "Inputs", + description: "An array of JSON strings representing inputs for the template execution.", + optional: true, + }, + }, methods: { - // this.$auth contains connected account data authKeys() { console.log(Object.keys(this.$auth)); }, + _baseUrl() { + return "https://tess.pareto.io/api"; + }, + async _makeRequest(opts = {}) { + const { + $, method = "GET", path = "/", headers, ...otherOpts + } = opts; + return axios($ || this, { + method, + url: this._baseUrl() + path, + headers: { + ...headers, + "Authorization": `Bearer ${this.$auth.api_token}`, + "Content-Type": "application/json", + }, + ...otherOpts, + }); + }, + async executeAiTemplate({ + templateId, inputs, + }) { + return this._makeRequest({ + method: "POST", + path: `/ai-templates/${templateId}/execute`, + data: { + inputs: inputs + ? inputs.map((input) => JSON.parse(input)) + : [], + }, + }); + }, + async getAiTemplateDetails({ templateId }) { + return this._makeRequest({ + method: "GET", + path: `/ai-templates/${templateId}`, + }); + }, + async searchAiTemplates({ + query, typeFilter, + }) { + const params = { + query, + }; + if (typeFilter) { + params.type = typeFilter; + } + return this._makeRequest({ + method: "GET", + path: "/ai-templates/search", + params, + }); + }, + async getAiTemplateResult({ executionId }) { + return this._makeRequest({ + method: "GET", + path: `/ai-executions/${executionId}/result`, + }); + }, + async listExecutions(opts = {}) { + return this._makeRequest({ + method: "GET", + path: "/ai-executions", + ...opts, + }); + }, + async paginate(fn, ...opts) { + let results = []; + let hasMore = true; + let page = 1; + + while (hasMore) { + const response = await fn({ + ...opts, + page, + }); + if (response.items && response.items.length > 0) { + results.push(...response.items); + hasMore = response.hasMore; + page += 1; + } else { + hasMore = false; + } + } + + return results; + }, }, }; From 11c00283970f0374a58d312db3f92e90714abcbb Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Tue, 22 Oct 2024 15:11:26 -0300 Subject: [PATCH 2/8] Package/app updates --- components/tess_ai_by_pareto/package.json | 5 ++++- .../tess_ai_by_pareto/tess_ai_by_pareto.app.mjs | 15 ++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/components/tess_ai_by_pareto/package.json b/components/tess_ai_by_pareto/package.json index 75dade693bb83..8060e0938e483 100644 --- a/components/tess_ai_by_pareto/package.json +++ b/components/tess_ai_by_pareto/package.json @@ -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": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3" } } diff --git a/components/tess_ai_by_pareto/tess_ai_by_pareto.app.mjs b/components/tess_ai_by_pareto/tess_ai_by_pareto.app.mjs index 7e18a3f0d3797..90638d25f9d9f 100644 --- a/components/tess_ai_by_pareto/tess_ai_by_pareto.app.mjs +++ b/components/tess_ai_by_pareto/tess_ai_by_pareto.app.mjs @@ -3,7 +3,6 @@ import { axios } from "@pipedream/platform"; export default { type: "app", app: "tess_ai_by_pareto", - version: "0.0.{{ts}}", propDefinitions: { templateId: { type: "string", @@ -64,23 +63,17 @@ export default { }, }, methods: { - authKeys() { - console.log(Object.keys(this.$auth)); - }, _baseUrl() { return "https://tess.pareto.io/api"; }, - async _makeRequest(opts = {}) { - const { - $, method = "GET", path = "/", headers, ...otherOpts - } = opts; - return axios($ || this, { - method, + async _makeRequest({ + $ = this, path = "/", headers, ...otherOpts + } = {}) { + return axios($, { url: this._baseUrl() + path, headers: { ...headers, "Authorization": `Bearer ${this.$auth.api_token}`, - "Content-Type": "application/json", }, ...otherOpts, }); From d3c73f929740d352792775886698dc6a8d5f8ff3 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Tue, 22 Oct 2024 15:15:11 -0300 Subject: [PATCH 3/8] pnpm --- pnpm-lock.yaml | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e4c6e295e7fcc..63541669d2bbe 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10092,7 +10092,10 @@ importers: '@pipedream/platform': 1.5.1 components/tess_ai_by_pareto: - specifiers: {} + specifiers: + '@pipedream/platform': ^3.0.3 + dependencies: + '@pipedream/platform': 3.0.3 components/test_app_for_oauth_bug: specifiers: {} @@ -16176,12 +16179,12 @@ packages: kuler: 2.0.0 dev: false - /@definitelytyped/header-parser/0.2.12: - resolution: {integrity: sha512-UYtSXiLMhzRFKh7xHMkgiWsscgHxIndmjetaptZMMS0EOvfhUTuEM68GpjiCtz5shXw22Vacs1vDTAkKGDhNmg==} + /@definitelytyped/header-parser/0.2.13: + resolution: {integrity: sha512-m7YEtGhwAjmQyJQFQ7q8+hTGTiC/WrdRATvw8fyTwgW+RiWUt8MAeehuFj4txnCYXDcLO0ozuW5gNrLoYR4Ubg==} engines: {node: '>=18.18.0'} dependencies: '@definitelytyped/typescript-versions': 0.1.4 - '@definitelytyped/utils': 0.1.7 + '@definitelytyped/utils': 0.1.8 semver: 7.6.3 dev: true @@ -16190,8 +16193,8 @@ packages: engines: {node: '>=18.18.0'} dev: true - /@definitelytyped/utils/0.1.7: - resolution: {integrity: sha512-t58AeNg6+mvyMnBHyPC6JQqWMW0Iwyb+vlpBz4V0d0iDY9H8gGCnLFg9vtN1nC+JXfTXBlf9efu9unMUeaPCiA==} + /@definitelytyped/utils/0.1.8: + resolution: {integrity: sha512-4JINx4Rttha29f50PBsJo48xZXx/He5yaIWJRwVarhYAN947+S84YciHl+AIhQNRPAFkg8+5qFngEGtKxQDWXA==} engines: {node: '>=18.18.0'} dependencies: '@qiwi/npm-registry-client': 8.9.1 @@ -24553,7 +24556,7 @@ packages: peerDependencies: typescript: '*' dependencies: - '@definitelytyped/header-parser': 0.2.12 + '@definitelytyped/header-parser': 0.2.13 command-exists: 1.2.9 rimraf: 3.0.2 semver: 6.3.1 @@ -24568,7 +24571,7 @@ packages: peerDependencies: typescript: '*' dependencies: - '@definitelytyped/header-parser': 0.2.12 + '@definitelytyped/header-parser': 0.2.13 command-exists: 1.2.9 rimraf: 3.0.2 semver: 6.3.1 @@ -24584,9 +24587,9 @@ packages: peerDependencies: typescript: '>= 3.0.0-dev || >= 3.1.0-dev || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.7.0-dev || >= 3.8.0-dev || >= 3.9.0-dev || >= 4.0.0-dev' dependencies: - '@definitelytyped/header-parser': 0.2.12 + '@definitelytyped/header-parser': 0.2.13 '@definitelytyped/typescript-versions': 0.1.4 - '@definitelytyped/utils': 0.1.7 + '@definitelytyped/utils': 0.1.8 dts-critic: 3.3.11_typescript@5.2.2 fs-extra: 6.0.1 json-stable-stringify: 1.0.2 @@ -24604,9 +24607,9 @@ packages: peerDependencies: typescript: '>= 3.0.0-dev || >= 3.1.0-dev || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.7.0-dev || >= 3.8.0-dev || >= 3.9.0-dev || >= 4.0.0-dev' dependencies: - '@definitelytyped/header-parser': 0.2.12 + '@definitelytyped/header-parser': 0.2.13 '@definitelytyped/typescript-versions': 0.1.4 - '@definitelytyped/utils': 0.1.7 + '@definitelytyped/utils': 0.1.8 dts-critic: 3.3.11_typescript@5.5.4 fs-extra: 6.0.1 json-stable-stringify: 1.0.2 From e6ca146df46f7c36d2ee15a8738daaafe72c3c5f Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Tue, 22 Oct 2024 15:33:25 -0300 Subject: [PATCH 4/8] App adjustments and Search Templates action --- .../search-ai-agents/search-ai-agents.mjs | 46 +++++++++++++++++++ .../search-templates/search-templates.mjs | 32 ------------- .../tess_ai_by_pareto.app.mjs | 40 ++-------------- 3 files changed, 49 insertions(+), 69 deletions(-) create mode 100644 components/tess_ai_by_pareto/actions/search-ai-agents/search-ai-agents.mjs delete mode 100644 components/tess_ai_by_pareto/actions/search-templates/search-templates.mjs diff --git a/components/tess_ai_by_pareto/actions/search-ai-agents/search-ai-agents.mjs b/components/tess_ai_by_pareto/actions/search-ai-agents/search-ai-agents.mjs new file mode 100644 index 0000000000000..5ab6675dc9001 --- /dev/null +++ b/components/tess_ai_by_pareto/actions/search-ai-agents/search-ai-agents.mjs @@ -0,0 +1,46 @@ +import app from "../../tess_ai_by_pareto.app.mjs"; + +export default { + key: "tess_ai_by_pareto-search-templates", + name: "Search AI Templates", + 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.", + }, + 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; + }, +}; diff --git a/components/tess_ai_by_pareto/actions/search-templates/search-templates.mjs b/components/tess_ai_by_pareto/actions/search-templates/search-templates.mjs deleted file mode 100644 index 3bcebe11c6524..0000000000000 --- a/components/tess_ai_by_pareto/actions/search-templates/search-templates.mjs +++ /dev/null @@ -1,32 +0,0 @@ -import tess_ai_by_pareto from "../../tess_ai_by_pareto.app.mjs"; - -export default { - key: "tess_ai_by_pareto-search-templates", - name: "Search AI Templates", - description: "Searches for AI templates created by users based on specific criteria. [See the documentation]()", - version: "0.0.{{ts}}", - type: "action", - props: { - tess_ai_by_pareto, - query: { - propDefinition: [ - "tess_ai_by_pareto", - "query", - ], - }, - typeFilter: { - propDefinition: [ - "tess_ai_by_pareto", - "typeFilter", - ], - }, - }, - async run({ $ }) { - const response = await this.tess_ai_by_pareto.searchAiTemplates({ - query: this.query, - typeFilter: this.typeFilter, - }); - $.export("$summary", `Found ${response.templates.length} templates`); - return response; - }, -}; diff --git a/components/tess_ai_by_pareto/tess_ai_by_pareto.app.mjs b/components/tess_ai_by_pareto/tess_ai_by_pareto.app.mjs index 90638d25f9d9f..706abc5a0ec5b 100644 --- a/components/tess_ai_by_pareto/tess_ai_by_pareto.app.mjs +++ b/components/tess_ai_by_pareto/tess_ai_by_pareto.app.mjs @@ -30,11 +30,6 @@ export default { })); }, }, - query: { - type: "string", - label: "Search Query", - description: "The search query to find AI templates based on specific criteria.", - }, typeFilter: { type: "string", label: "Template Type", @@ -97,19 +92,11 @@ export default { path: `/ai-templates/${templateId}`, }); }, - async searchAiTemplates({ - query, typeFilter, - }) { - const params = { - query, - }; - if (typeFilter) { - params.type = typeFilter; - } + async searchTemplates(args) { return this._makeRequest({ method: "GET", - path: "/ai-templates/search", - params, + path: "/templates", + ...args, }); }, async getAiTemplateResult({ executionId }) { @@ -125,26 +112,5 @@ export default { ...opts, }); }, - async paginate(fn, ...opts) { - let results = []; - let hasMore = true; - let page = 1; - - while (hasMore) { - const response = await fn({ - ...opts, - page, - }); - if (response.items && response.items.length > 0) { - results.push(...response.items); - hasMore = response.hasMore; - page += 1; - } else { - hasMore = false; - } - } - - return results; - }, }, }; From 0d337d59060c5d55737cda38362cd103dfd4c5a9 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Tue, 22 Oct 2024 16:52:34 -0300 Subject: [PATCH 5/8] Execute Agent action + lots of improvements --- .../actions/execute-agent/execute-agent.mjs | 45 +++++++++++++ .../execute-template/execute-template.mjs | 35 ---------- .../search-ai-agents/search-ai-agents.mjs | 1 + components/tess_ai_by_pareto/common/utils.mjs | 21 ++++++ .../tess_ai_by_pareto.app.mjs | 64 ++++++------------- 5 files changed, 86 insertions(+), 80 deletions(-) create mode 100644 components/tess_ai_by_pareto/actions/execute-agent/execute-agent.mjs delete mode 100644 components/tess_ai_by_pareto/actions/execute-template/execute-template.mjs create mode 100644 components/tess_ai_by_pareto/common/utils.mjs diff --git a/components/tess_ai_by_pareto/actions/execute-agent/execute-agent.mjs b/components/tess_ai_by_pareto/actions/execute-agent/execute-agent.mjs new file mode 100644 index 0000000000000..439152ceabaab --- /dev/null +++ b/components/tess_ai_by_pareto/actions/execute-agent/execute-agent.mjs @@ -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.{{ts}}", + 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; + }, +}; diff --git a/components/tess_ai_by_pareto/actions/execute-template/execute-template.mjs b/components/tess_ai_by_pareto/actions/execute-template/execute-template.mjs deleted file mode 100644 index 809fbf43af8a2..0000000000000 --- a/components/tess_ai_by_pareto/actions/execute-template/execute-template.mjs +++ /dev/null @@ -1,35 +0,0 @@ -import tess_ai_by_pareto from "../../tess_ai_by_pareto.app.mjs"; - -export default { - key: "tess_ai_by_pareto-execute-template", - name: "Execute AI Template", - description: "Executes an AI template and returns the execution ID. [See the documentation]()", - version: "0.0.{{ts}}", - type: "action", - props: { - tess_ai_by_pareto, - templateId: { - propDefinition: [ - "tess_ai_by_pareto", - "templateId", - ], - }, - inputs: { - propDefinition: [ - "tess_ai_by_pareto", - "inputs", - ], - optional: true, - }, - }, - async run({ $ }) { - const response = await this.tess_ai_by_pareto.executeAiTemplate({ - templateId: this.templateId, - inputs: this.inputs, - }); - $.export("$summary", `Executed AI template with Execution ID ${response.id}`); - return { - executionId: response.id, - }; - }, -}; diff --git a/components/tess_ai_by_pareto/actions/search-ai-agents/search-ai-agents.mjs b/components/tess_ai_by_pareto/actions/search-ai-agents/search-ai-agents.mjs index 5ab6675dc9001..519fe1c56dc2b 100644 --- a/components/tess_ai_by_pareto/actions/search-ai-agents/search-ai-agents.mjs +++ b/components/tess_ai_by_pareto/actions/search-ai-agents/search-ai-agents.mjs @@ -14,6 +14,7 @@ export default { label: "Search Query", description: "Search agents (templates) by title, description and long description.", + optional: true, }, type: { type: "string", diff --git a/components/tess_ai_by_pareto/common/utils.mjs b/components/tess_ai_by_pareto/common/utils.mjs new file mode 100644 index 0000000000000..b21ac571c51cd --- /dev/null +++ b/components/tess_ai_by_pareto/common/utils.mjs @@ -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; + }, {}); +} diff --git a/components/tess_ai_by_pareto/tess_ai_by_pareto.app.mjs b/components/tess_ai_by_pareto/tess_ai_by_pareto.app.mjs index 706abc5a0ec5b..6329fa7525859 100644 --- a/components/tess_ai_by_pareto/tess_ai_by_pareto.app.mjs +++ b/components/tess_ai_by_pareto/tess_ai_by_pareto.app.mjs @@ -6,14 +6,20 @@ export default { propDefinitions: { templateId: { type: "string", - label: "AI Template ID", - description: "The ID of the AI template to execute or retrieve details for.", - async options() { - const templates = await this.searchAiTemplates({ - query: "", + 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 templates.templates.map((template) => ({ - label: template.name, + return response?.data?.map((template) => ({ + label: template.title, value: template.id, })); }, @@ -30,32 +36,6 @@ export default { })); }, }, - typeFilter: { - type: "string", - label: "Template Type", - description: "Filter templates by type (image, text, video).", - optional: true, - options: [ - { - label: "Image", - value: "image", - }, - { - label: "Text", - value: "text", - }, - { - label: "Video", - value: "video", - }, - ], - }, - inputs: { - type: "string[]", - label: "Inputs", - description: "An array of JSON strings representing inputs for the template execution.", - optional: true, - }, }, methods: { _baseUrl() { @@ -73,28 +53,22 @@ export default { ...otherOpts, }); }, - async executeAiTemplate({ - templateId, inputs, + async executeTemplate({ + templateId, ...args }) { return this._makeRequest({ method: "POST", - path: `/ai-templates/${templateId}/execute`, - data: { - inputs: inputs - ? inputs.map((input) => JSON.parse(input)) - : [], - }, + path: `/templates/${templateId}/execute`, + ...args, }); }, - async getAiTemplateDetails({ templateId }) { + async getTemplate(templateId) { return this._makeRequest({ - method: "GET", - path: `/ai-templates/${templateId}`, + path: `/templates/${templateId}`, }); }, async searchTemplates(args) { return this._makeRequest({ - method: "GET", path: "/templates", ...args, }); From 975a341d28391d29324b888634c65a15c5f52acf Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Tue, 22 Oct 2024 16:55:44 -0300 Subject: [PATCH 6/8] Get Execution Response action --- .../get-execution-response.mjs | 27 +++++++++++-------- .../tess_ai_by_pareto.app.mjs | 27 ++++--------------- 2 files changed, 21 insertions(+), 33 deletions(-) diff --git a/components/tess_ai_by_pareto/actions/get-execution-response/get-execution-response.mjs b/components/tess_ai_by_pareto/actions/get-execution-response/get-execution-response.mjs index ecdbf1b2089e1..79546f275d361 100644 --- a/components/tess_ai_by_pareto/actions/get-execution-response/get-execution-response.mjs +++ b/components/tess_ai_by_pareto/actions/get-execution-response/get-execution-response.mjs @@ -1,25 +1,30 @@ -import tess_ai_by_pareto from "../../tess_ai_by_pareto.app.mjs"; +import app from "../../tess_ai_by_pareto.app.mjs"; export default { key: "tess_ai_by_pareto-get-execution-response", - name: "Get AI Execution Response", - description: "Retrieves the result of a previously executed AI template (image, text, or video). [See the documentation]().", - version: "0.0.{{ts}}", + 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: { - tess_ai_by_pareto, + app, executionId: { - propDefinition: [ - "tess_ai_by_pareto", - "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.tess_ai_by_pareto.getAiTemplateResult({ + const result = await this.app.getTemplateResponse({ + $, executionId: this.executionId, }); - $.export("$summary", `Retrieved AI Execution Result for Execution ID ${this.executionId}`); + $.export( + "$summary", + `Retrieved response for execution ID ${this.executionId}`, + ); return result; }, }; diff --git a/components/tess_ai_by_pareto/tess_ai_by_pareto.app.mjs b/components/tess_ai_by_pareto/tess_ai_by_pareto.app.mjs index 6329fa7525859..3769360ea2446 100644 --- a/components/tess_ai_by_pareto/tess_ai_by_pareto.app.mjs +++ b/components/tess_ai_by_pareto/tess_ai_by_pareto.app.mjs @@ -24,18 +24,6 @@ export default { })); }, }, - executionId: { - type: "string", - label: "AI Execution ID", - description: "The ID of the AI template execution to retrieve the result for.", - async options() { - const executions = await this.listExecutions(); - return executions.executions.map((execution) => ({ - label: execution.id, - value: execution.id, - })); - }, - }, }, methods: { _baseUrl() { @@ -73,17 +61,12 @@ export default { ...args, }); }, - async getAiTemplateResult({ executionId }) { - return this._makeRequest({ - method: "GET", - path: `/ai-executions/${executionId}/result`, - }); - }, - async listExecutions(opts = {}) { + async getTemplateResponse({ + executionId, ...args + }) { return this._makeRequest({ - method: "GET", - path: "/ai-executions", - ...opts, + path: `/template-responses/${executionId}`, + ...args, }); }, }, From 9b001e8a1cbcd42e6c15fdbeed1574acb4dacbad Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Tue, 22 Oct 2024 16:57:26 -0300 Subject: [PATCH 7/8] Removing 'find template details' --- .../actions/execute-agent/execute-agent.mjs | 2 +- .../find-template-details.mjs | 25 ------------------- 2 files changed, 1 insertion(+), 26 deletions(-) delete mode 100644 components/tess_ai_by_pareto/actions/find-template-details/find-template-details.mjs diff --git a/components/tess_ai_by_pareto/actions/execute-agent/execute-agent.mjs b/components/tess_ai_by_pareto/actions/execute-agent/execute-agent.mjs index 439152ceabaab..6f0805e8eeebc 100644 --- a/components/tess_ai_by_pareto/actions/execute-agent/execute-agent.mjs +++ b/components/tess_ai_by_pareto/actions/execute-agent/execute-agent.mjs @@ -6,7 +6,7 @@ export default { 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.{{ts}}", + version: "0.0.1", type: "action", props: { app, diff --git a/components/tess_ai_by_pareto/actions/find-template-details/find-template-details.mjs b/components/tess_ai_by_pareto/actions/find-template-details/find-template-details.mjs deleted file mode 100644 index 564a514604397..0000000000000 --- a/components/tess_ai_by_pareto/actions/find-template-details/find-template-details.mjs +++ /dev/null @@ -1,25 +0,0 @@ -import tess_ai_by_pareto from "../../tess_ai_by_pareto.app.mjs"; - -export default { - key: "tess_ai_by_pareto-find-template-details", - name: "Find AI Template Details", - description: "Retrieves detailed information about a specific AI template. [See the documentation]()", - version: "0.0.{{ts}}", - type: "action", - props: { - tess_ai_by_pareto, - templateId: { - propDefinition: [ - "tess_ai_by_pareto", - "templateId", - ], - }, - }, - async run({ $ }) { - const response = await this.tess_ai_by_pareto.getAiTemplateDetails({ - templateId: this.templateId, - }); - $.export("$summary", `Retrieved details for AI template ${this.templateId}`); - return response; - }, -}; From 1d8c9332692c520bedb9be5e4948b57d43c2167e Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Wed, 30 Oct 2024 16:39:48 -0300 Subject: [PATCH 8/8] Component name fix --- .../actions/search-ai-agents/search-ai-agents.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/tess_ai_by_pareto/actions/search-ai-agents/search-ai-agents.mjs b/components/tess_ai_by_pareto/actions/search-ai-agents/search-ai-agents.mjs index 519fe1c56dc2b..0d418cd82bee0 100644 --- a/components/tess_ai_by_pareto/actions/search-ai-agents/search-ai-agents.mjs +++ b/components/tess_ai_by_pareto/actions/search-ai-agents/search-ai-agents.mjs @@ -1,8 +1,8 @@ import app from "../../tess_ai_by_pareto.app.mjs"; export default { - key: "tess_ai_by_pareto-search-templates", - name: "Search AI Templates", + 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",