Skip to content

Commit 7a52d0d

Browse files
authored
Merging pull request #17897
* Added actions * Added actions * Added actions
1 parent 4174d02 commit 7a52d0d

File tree

13 files changed

+193
-13
lines changed

13 files changed

+193
-13
lines changed

components/zep/actions/add-memory/add-memory.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "zep-add-memory",
66
name: "Add Memory to Session",
77
description: "Adds memory to an existing session in Zep. [See the documentation](https://help.getzep.com/api-reference/memory/add)",
8-
version: "0.0.1",
8+
version: "0.0.2",
99
type: "action",
1010
props: {
1111
zep,

components/zep/actions/add-user/add-user.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "zep-add-user",
66
name: "Add User",
77
description: "Adds a user in Zep. [See the documentation](https://help.getzep.com/api-reference/user/add)",
8-
version: "0.0.1",
8+
version: "0.0.2",
99
type: "action",
1010
props: {
1111
zep,

components/zep/actions/create-session/create-session.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "zep-create-session",
66
name: "Create Session",
77
description: "Creates a new session in Zep. [See the documentation](https://help.getzep.com/api-reference/memory/add-session)",
8-
version: "0.0.1",
8+
version: "0.0.2",
99
type: "action",
1010
props: {
1111
zep,
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import zep from "../../zep.app.mjs";
2+
3+
export default {
4+
key: "zep-get-thread-messages",
5+
name: "Get Thread Messages",
6+
description: "Returns messages for the thread with the specified ID. [See the documentation](https://help.getzep.com/sdk-reference/thread/get)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
zep,
11+
threadId: {
12+
propDefinition: [
13+
zep,
14+
"threadId",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const allMessages = [];
20+
let cursor = 0;
21+
const limit = 100; // Tamanho da página
22+
23+
while (true) {
24+
const response = await this.zep.getThreadMessages({
25+
$,
26+
threadId: this.threadId,
27+
params: {
28+
limit,
29+
cursor,
30+
},
31+
});
32+
33+
if (!response.messages || response.messages.length === 0) {
34+
break;
35+
}
36+
37+
allMessages.push(...response.messages);
38+
39+
// Se recebemos menos mensagens que o limite, chegamos ao fim
40+
if (response.messages.length < limit) {
41+
break;
42+
}
43+
44+
cursor += limit;
45+
}
46+
47+
$.export("$summary", `Successfully retrieved ${allMessages.length} messages for the thread with ID: ${this.threadId}`);
48+
49+
return allMessages;
50+
},
51+
};
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import zep from "../../zep.app.mjs";
2+
import constants from "../../common/constants.mjs";
3+
4+
export default {
5+
key: "zep-get-threads",
6+
name: "Get Threads",
7+
description: "Returns a paginated list of threads. [See the documentation](https://help.getzep.com/sdk-reference/thread/list-all)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
zep,
12+
order_by: {
13+
type: "string",
14+
label: "Order By",
15+
description: "Field to order by (e.g., updated_at).",
16+
optional: true,
17+
options: constants.SORT_OPTIONS,
18+
},
19+
asc: {
20+
type: "boolean",
21+
label: "Ascending",
22+
description: "If true, results are returned in ascending order.",
23+
optional: true,
24+
},
25+
maxResults: {
26+
type: "integer",
27+
label: "Max Results",
28+
description: "Maximum number of threads to return across pages.",
29+
optional: true,
30+
default: 50,
31+
},
32+
},
33+
async run({ $ }) {
34+
const max = this.maxResults ?? 50;
35+
const threads = [];
36+
37+
let page = 1;
38+
while (threads.length < max) {
39+
const pageSize = Math.min(1000, max - threads.length);
40+
const params = {
41+
page_number: page,
42+
page_size: pageSize,
43+
};
44+
45+
if (this.order_by) {
46+
params.order_by = this.order_by;
47+
}
48+
if (typeof this.asc === "boolean") {
49+
params.asc = this.asc;
50+
}
51+
52+
const response = await this.zep.getThreads({
53+
$,
54+
params,
55+
});
56+
57+
const pageThreads = response?.threads || [];
58+
if (!Array.isArray(pageThreads) || pageThreads.length === 0) {
59+
break;
60+
}
61+
62+
threads.push(...pageThreads);
63+
if (pageThreads.length < pageSize) {
64+
break;
65+
}
66+
67+
page += 1;
68+
}
69+
70+
const plural = threads.length === 1
71+
? ""
72+
: "s";
73+
$.export("$summary", `Successfully retrieved ${threads.length} thread${plural}`);
74+
return threads;
75+
},
76+
};

components/zep/actions/update-session/update-session.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "zep-update-session",
66
name: "Update Session",
77
description: "Updates an existing session in Zep. [See the documentation](https://help.getzep.com/api-reference/memory/update-session)",
8-
version: "0.0.1",
8+
version: "0.0.2",
99
type: "action",
1010
props: {
1111
zep,
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default {
2+
SORT_OPTIONS: [
3+
"created_at",
4+
"updated_at",
5+
"user_id",
6+
"thread_id",
7+
],
8+
};

components/zep/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/zep",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"description": "Pipedream Zep Components",
55
"main": "zep.app.mjs",
66
"keywords": [
@@ -13,6 +13,6 @@
1313
"access": "public"
1414
},
1515
"dependencies": {
16-
"@pipedream/platform": "^3.0.3"
16+
"@pipedream/platform": "^3.1.0"
1717
}
1818
}

components/zep/sources/new-message/new-message.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "zep-new-message",
66
name: "New Message in Session",
77
description: "Emit new event when a message is added to a session. [See the documentation](https://help.getzep.com/api-reference/memory/get-session-messages)",
8-
version: "0.0.1",
8+
version: "0.0.3",
99
type: "source",
1010
dedupe: "unique",
1111
methods: {

components/zep/sources/new-session/new-session.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "zep-new-session",
66
name: "New Session Created",
77
description: "Emit new event when a new session is created in Zep. [See the documentation](https://help.getzep.com/api-reference/memory/list-sessions)",
8-
version: "0.0.1",
8+
version: "0.0.3",
99
type: "source",
1010
dedupe: "unique",
1111
methods: {

0 commit comments

Comments
 (0)