Skip to content

[ACTION] Zep - Memory APIs #17817 #17897

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 20, 2025
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
2 changes: 1 addition & 1 deletion components/zep/actions/add-memory/add-memory.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "zep-add-memory",
name: "Add Memory to Session",
description: "Adds memory to an existing session in Zep. [See the documentation](https://help.getzep.com/api-reference/memory/add)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
zep,
Expand Down
2 changes: 1 addition & 1 deletion components/zep/actions/add-user/add-user.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "zep-add-user",
name: "Add User",
description: "Adds a user in Zep. [See the documentation](https://help.getzep.com/api-reference/user/add)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
zep,
Expand Down
2 changes: 1 addition & 1 deletion components/zep/actions/create-session/create-session.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "zep-create-session",
name: "Create Session",
description: "Creates a new session in Zep. [See the documentation](https://help.getzep.com/api-reference/memory/add-session)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
zep,
Expand Down
51 changes: 51 additions & 0 deletions components/zep/actions/get-thread-messages/get-thread-messages.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import zep from "../../zep.app.mjs";

export default {
key: "zep-get-thread-messages",
name: "Get Thread Messages",
description: "Returns messages for the thread with the specified ID. [See the documentation](https://help.getzep.com/sdk-reference/thread/get)",
version: "0.0.1",
type: "action",
props: {
zep,
threadId: {
propDefinition: [
zep,
"threadId",
],
},
},
async run({ $ }) {
const allMessages = [];
let cursor = 0;
const limit = 100; // Tamanho da página

while (true) {
const response = await this.zep.getThreadMessages({
$,
threadId: this.threadId,
params: {
limit,
cursor,
},
});

if (!response.messages || response.messages.length === 0) {
break;
}

allMessages.push(...response.messages);

// Se recebemos menos mensagens que o limite, chegamos ao fim
if (response.messages.length < limit) {
break;
}

cursor += limit;
}

$.export("$summary", `Successfully retrieved ${allMessages.length} messages for the thread with ID: ${this.threadId}`);

return allMessages;
},
};
76 changes: 76 additions & 0 deletions components/zep/actions/get-threads/get-threads.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import zep from "../../zep.app.mjs";
import constants from "../../common/constants.mjs";

export default {
key: "zep-get-threads",
name: "Get Threads",
description: "Returns a paginated list of threads. [See the documentation](https://help.getzep.com/sdk-reference/thread/list-all)",
version: "0.0.1",
type: "action",
props: {
zep,
order_by: {
type: "string",
label: "Order By",
description: "Field to order by (e.g., updated_at).",
optional: true,
options: constants.SORT_OPTIONS,
},
asc: {
type: "boolean",
label: "Ascending",
description: "If true, results are returned in ascending order.",
optional: true,
},
maxResults: {
type: "integer",
label: "Max Results",
description: "Maximum number of threads to return across pages.",
optional: true,
default: 50,
},
},
async run({ $ }) {
const max = this.maxResults ?? 50;
const threads = [];

let page = 1;
while (threads.length < max) {
const pageSize = Math.min(1000, max - threads.length);
const params = {
page_number: page,
page_size: pageSize,
};

if (this.order_by) {
params.order_by = this.order_by;
}
if (typeof this.asc === "boolean") {
params.asc = this.asc;
}

const response = await this.zep.getThreads({
$,
params,
});

const pageThreads = response?.threads || [];
if (!Array.isArray(pageThreads) || pageThreads.length === 0) {
break;
}

threads.push(...pageThreads);
if (pageThreads.length < pageSize) {
break;
}

page += 1;
}

const plural = threads.length === 1
? ""
: "s";
$.export("$summary", `Successfully retrieved ${threads.length} thread${plural}`);
return threads;
},
};
2 changes: 1 addition & 1 deletion components/zep/actions/update-session/update-session.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "zep-update-session",
name: "Update Session",
description: "Updates an existing session in Zep. [See the documentation](https://help.getzep.com/api-reference/memory/update-session)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
zep,
Expand Down
8 changes: 8 additions & 0 deletions components/zep/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
SORT_OPTIONS: [
"created_at",
"updated_at",
"user_id",
"thread_id",
],
};
4 changes: 2 additions & 2 deletions components/zep/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/zep",
"version": "0.1.0",
"version": "0.2.0",
"description": "Pipedream Zep Components",
"main": "zep.app.mjs",
"keywords": [
Expand All @@ -13,6 +13,6 @@
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3"
"@pipedream/platform": "^3.1.0"
}
}
2 changes: 1 addition & 1 deletion components/zep/sources/new-message/new-message.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "zep-new-message",
name: "New Message in Session",
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)",
version: "0.0.1",
version: "0.0.3",
type: "source",
dedupe: "unique",
methods: {
Expand Down
2 changes: 1 addition & 1 deletion components/zep/sources/new-session/new-session.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "zep-new-session",
name: "New Session Created",
description: "Emit new event when a new session is created in Zep. [See the documentation](https://help.getzep.com/api-reference/memory/list-sessions)",
version: "0.0.1",
version: "0.0.3",
type: "source",
dedupe: "unique",
methods: {
Expand Down
4 changes: 2 additions & 2 deletions components/zep/sources/session-updated/session-updated.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import common from "../common/base.mjs";
export default {
...common,
key: "zep-session-updated",
name: "Session Updated",
name: "New Session Updated",
description: "Emit new event when an existing session is updated. [See the documentation](https://help.getzep.com/api-reference/memory/list-sessions)",
version: "0.0.1",
version: "0.0.3",
type: "source",
dedupe: "unique",
methods: {
Expand Down
47 changes: 46 additions & 1 deletion components/zep/zep.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,20 @@ export default {
})) || [];
},
},
threadId: {
type: "string",
label: "Thread ID",
description: "The ID of the thread",
async options({ page }) {
const { threads } = await this.getThreads({
params: {
page_number: page,
},
});

return threads?.map(({ thread_id }) => thread_id) || [];
},
},
factRatingInstructions: {
type: "object",
label: "Fact Rating Instructions",
Expand All @@ -58,10 +72,11 @@ export default {
_makeRequest({
$ = this,
path,
version,
...otherOpts
}) {
return axios($, {
url: `${this._baseUrl()}${path}`,
url: `${this._baseUrl(version)}${path}`,
headers: {
"authorization": `Api-Key ${this.$auth.api_key}`,
},
Expand Down Expand Up @@ -120,5 +135,35 @@ export default {
...opts,
});
},
getSession({
sessionId, ...opts
}) {
return this._makeRequest({
path: `/sessions/${sessionId}`,
...opts,
});
},
listSessionMemory({
sessionId, ...opts
}) {
return this._makeRequest({
path: `/sessions/${sessionId}/memory`,
...opts,
});
},
getThreads(opts = {}) {
return this._makeRequest({
path: "/threads",
...opts,
});
},
getThreadMessages({
threadId, ...opts
}) {
return this._makeRequest({
path: `/threads/${threadId}/messages`,
...opts,
});
},
},
};
4 changes: 2 additions & 2 deletions pnpm-lock.yaml

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

Loading