Skip to content

Commit e6ca146

Browse files
committed
App adjustments and Search Templates action
1 parent d3c73f9 commit e6ca146

File tree

3 files changed

+49
-69
lines changed

3 files changed

+49
-69
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import app from "../../tess_ai_by_pareto.app.mjs";
2+
3+
export default {
4+
key: "tess_ai_by_pareto-search-templates",
5+
name: "Search AI Templates",
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+
},
18+
type: {
19+
type: "string",
20+
label: "Type Filter",
21+
description: "Filter by template type",
22+
optional: true,
23+
},
24+
maxResults: {
25+
type: "integer",
26+
label: "Max Results",
27+
description: "The maximum number of results to return",
28+
optional: true,
29+
default: 15,
30+
min: 1,
31+
max: 1000,
32+
},
33+
},
34+
async run({ $ }) {
35+
const response = await this.app.searchTemplates({
36+
$,
37+
params: {
38+
q: this.query,
39+
type: this.type,
40+
per_page: this.maxResults,
41+
},
42+
});
43+
$.export("$summary", `Retrieved ${response.data?.length} templates`);
44+
return response;
45+
},
46+
};

components/tess_ai_by_pareto/actions/search-templates/search-templates.mjs

Lines changed: 0 additions & 32 deletions
This file was deleted.

components/tess_ai_by_pareto/tess_ai_by_pareto.app.mjs

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ export default {
3030
}));
3131
},
3232
},
33-
query: {
34-
type: "string",
35-
label: "Search Query",
36-
description: "The search query to find AI templates based on specific criteria.",
37-
},
3833
typeFilter: {
3934
type: "string",
4035
label: "Template Type",
@@ -97,19 +92,11 @@ export default {
9792
path: `/ai-templates/${templateId}`,
9893
});
9994
},
100-
async searchAiTemplates({
101-
query, typeFilter,
102-
}) {
103-
const params = {
104-
query,
105-
};
106-
if (typeFilter) {
107-
params.type = typeFilter;
108-
}
95+
async searchTemplates(args) {
10996
return this._makeRequest({
11097
method: "GET",
111-
path: "/ai-templates/search",
112-
params,
98+
path: "/templates",
99+
...args,
113100
});
114101
},
115102
async getAiTemplateResult({ executionId }) {
@@ -125,26 +112,5 @@ export default {
125112
...opts,
126113
});
127114
},
128-
async paginate(fn, ...opts) {
129-
let results = [];
130-
let hasMore = true;
131-
let page = 1;
132-
133-
while (hasMore) {
134-
const response = await fn({
135-
...opts,
136-
page,
137-
});
138-
if (response.items && response.items.length > 0) {
139-
results.push(...response.items);
140-
hasMore = response.hasMore;
141-
page += 1;
142-
} else {
143-
hasMore = false;
144-
}
145-
}
146-
147-
return results;
148-
},
149115
},
150116
};

0 commit comments

Comments
 (0)