-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
New Components - zep #15616
base: master
Are you sure you want to change the base?
New Components - zep #15616
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 3 Skipped Deployments
|
WalkthroughThis pull request extends the Zep component by introducing several new modules for session management and event handling. New action modules for adding memory, creating sessions, and updating sessions have been added alongside new source modules to manage new messages, new sessions, and session updates. Additionally, utility functions for JSON parsing were introduced, and the Zep app now includes extra API request methods and properties. The package configuration was updated with a new version and dependency details. Changes
Sequence Diagram(s)sequenceDiagram
participant C as Client
participant M as Module (Action/Source)
participant Z as Zep App
participant API as External API
C->>M: Invoke run() with parameters
M->>Z: Call respective method (createSession, addMemoryToSession, updateSession, etc.)
Z->>API: _makeRequest(payload)
API-->>Z: Return API response
Z-->>M: Return summary response
M-->>C: Output summary message
Suggested labels
Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 ESLint
components/zep/actions/update-session/update-session.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs components/zep/actions/add-memory/add-memory.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs components/zep/actions/create-session/create-session.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (11)
components/zep/zep.app.mjs (3)
6-21
: Return labeled options forsessionId
Currently, the code returns just an array of session IDs. Consider returning an array of{ value, label }
objects for improved user clarity in the UI.
40-50
: Consider adding validation or defaults
While it’s valid to keepfactRatingInstructions
andmetadata
free-form, adding optional validation or default values can help handle edge cases.
53-68
: Add more robust error handling
Consider wrapping theaxios
call in a try/catch block or leveraging Pipedream’s error-handling features. Also, to follow conventional headers, use “Authorization” instead of “authorization” for clarity.components/zep/common/utils.mjs (2)
1-9
: Handle potential JSON parsing errors inparseObject
Ifobj
is not valid JSON when it's a string,JSON.parse(obj)
will throw an exception. Consider a try/catch or a fallback to avoid runtime errors.
11-25
: Handle potential JSON parsing errors inparseArray
Ifarr
is an invalid JSON string,JSON.parse(arr)
will throw. Adding error handling or defaults can make the function more robust.components/zep/actions/update-session/update-session.mjs (1)
41-41
: Fix typo in success message.There's a typo in the word "session".
Apply this diff to fix the typo:
- $.export("$summary", `Successfully updated ssession with ID ${this.sessionId}`); + $.export("$summary", `Successfully updated session with ID ${this.sessionId}`);components/zep/actions/create-session/create-session.mjs (1)
7-7
: Update documentation link.The documentation link uses "add-session" instead of "create-session" which might be confusing.
Apply this diff to update the link:
- description: "Creates a new session in Zep. [See the documentation](https://help.getzep.com/api-reference/memory/add-session)", + description: "Creates a new session in Zep. [See the documentation](https://help.getzep.com/api-reference/memory/create-session)",components/zep/actions/add-memory/add-memory.mjs (2)
18-22
: Enhance messages prop description with a complete example.The current example shows a single message object. Consider providing a more comprehensive example that demonstrates multiple messages with different role types.
- description: "An array of message objects, where each message contains a role (`norole`, `system`, `assistant`, `user`, `function`, or `tool`) and content. Example: `[{ \"content\": \"content\", \"role_type\": \"norole\" }]` [See the documentation](https://help.getzep.com/api-reference/memory/add) for more information", + description: "An array of message objects, where each message contains a role (`norole`, `system`, `assistant`, `user`, `function`, or `tool`) and content. Example: `[{ \"content\": \"Hello\", \"role_type\": \"user\" }, { \"content\": \"Hi there!\", \"role_type\": \"assistant\" }]` [See the documentation](https://help.getzep.com/api-reference/memory/add) for more information",
42-54
: Add error handling for message parsing.The
parseArray
function could throw an error if the messages are not properly formatted. Consider adding try-catch block to handle potential parsing errors gracefully.async run({ $ }) { + let parsedMessages; + try { + parsedMessages = utils.parseArray(this.messages); + } catch (error) { + throw new Error(`Failed to parse messages: ${error.message}`); + } const response = await this.zep.addMemoryToSession({ sessionId: this.sessionId, data: { - messages: utils.parseArray(this.messages), + messages: parsedMessages, factInstruction: this.factInstruction, returnContext: this.returnContext, summaryInstruction: this.summaryInstruction, }, }); $.export("$summary", `Added memory to session ${this.sessionId}`); return response; },components/zep/sources/common/base.mjs (2)
31-31
: Extract magic number into a named constant.The page size limit of 1000 should be extracted into a named constant for better maintainability.
+const MAX_PAGE_SIZE = 1000; + export default { // ... methods: { async getSessions({ lastTs, orderBy, max, }) { const params = { - page_size: max || 1000, + page_size: max || MAX_PAGE_SIZE,
70-77
: Extract magic number into a named constant.The event limit of 25 in the deploy hook should be extracted into a named constant for better maintainability.
+const INITIAL_EVENT_LIMIT = 25; + export default { // ... hooks: { async deploy() { - await this.processEvent(25); + await this.processEvent(INITIAL_EVENT_LIMIT); }, },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (10)
components/zep/actions/add-memory/add-memory.mjs
(1 hunks)components/zep/actions/create-session/create-session.mjs
(1 hunks)components/zep/actions/update-session/update-session.mjs
(1 hunks)components/zep/common/utils.mjs
(1 hunks)components/zep/package.json
(2 hunks)components/zep/sources/common/base.mjs
(1 hunks)components/zep/sources/new-message/new-message.mjs
(1 hunks)components/zep/sources/new-session/new-session.mjs
(1 hunks)components/zep/sources/session-updated/session-updated.mjs
(1 hunks)components/zep/zep.app.mjs
(1 hunks)
🧰 Additional context used
🪛 GitHub Check: Lint Code Base
components/zep/sources/session-updated/session-updated.mjs
[warning] 6-6:
Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: pnpm publish
- GitHub Check: Verify TypeScript components
- GitHub Check: Publish TypeScript components
🔇 Additional comments (13)
components/zep/zep.app.mjs (3)
1-2
: Validate environment for@pipedream/platform
usage
This import appears correct for Pipedream, but please ensure that the environment supports the@pipedream/platform
package.
22-39
: LGTM
This approach foruserId
provides a user-friendly label combining the first and last names.
69-113
:✅ Verification successful
Verify endpoints and param consistency
All these methods look appropriate, but confirm the naming and parameters match the actual API docs.
🏁 Script executed:
#!/bin/bash # Searching for references to Zep endpoints rg -A3 '"sessions-ordered"' rg -A3 '"users-ordered"' rg -A3 '"messages"' rg -A3 '"sessions"'Length of output: 7199
API Endpoints and Parameter Naming Verified
I've reviewed the code along with repository references and found that the endpoints and parameter destructuring in the Zep implementation conform to the patterns used elsewhere in our codebase. In particular:
/sessions-ordered
&/users-ordered
These endpoints appear to be unique to this Zep integration. Their naming is consistent with their purpose in listing sessions and users.
listMessages
,addMemoryToSession
, andupdateSession
The use of a destructuredsessionId
and the template literal for forming the endpoint paths match the established patterns for session-specific endpoints. The HTTP methods (POST, PATCH) correctly align with their respective actions.No inconsistency was observed relative to how endpoints are defined in similar modules. Still, please ensure these match the current API documentation for Zep as a final confirmation.
components/zep/sources/new-session/new-session.mjs (2)
3-10
: Overall source definition looks good
Providing a clear key, name, and description is beneficial for discoverability and manageability.
13-26
: Check validity of session timestamps
Date.parse(session.created_at)
can yieldNaN
ifcreated_at
is missing or malformed. Ensurecreated_at
is always present and valid.components/zep/sources/session-updated/session-updated.mjs (1)
13-19
: LGTM! Well-structured implementation.The implementation looks good:
getNewResults
correctly orders byupdated_at
for chronological processinggenerateMeta
generates unique IDs by combining session ID with timestampAlso applies to: 20-27
components/zep/actions/update-session/update-session.mjs (1)
32-43
: LGTM! Well-structured implementation.The implementation looks good:
- Correctly uses utility functions for parsing metadata and fact rating instructions
- Properly handles response and exports summary
components/zep/actions/create-session/create-session.mjs (1)
37-49
: LGTM! Well-structured implementation.The implementation looks good:
- Correctly uses utility functions for parsing metadata and fact rating instructions
- Properly handles response and exports summary
components/zep/sources/new-message/new-message.mjs (1)
22-42
: LGTM! Well-structured implementation.The implementation looks good:
- Correctly handles timestamp-based filtering
- Properly implements message slicing for max results
- Generates unique metadata for each message
Also applies to: 62-68
components/zep/actions/add-memory/add-memory.mjs (1)
8-8
: Version number is inconsistent with package.json.The version number "0.0.1" is inconsistent with the package.json version "0.1.0". Consider updating to match the package version.
components/zep/sources/common/base.mjs (2)
1-14
: LGTM!The implementation correctly uses the platform's default polling interval and properly defines the required props.
16-21
: LGTM!The timestamp management methods are well-implemented with proper persistence and default value handling.
components/zep/package.json (1)
3-17
: LGTM!The version bump and dependency addition are appropriate for the new features introduced in this PR.
Resolves #15601.
Summary by CodeRabbit
New Features
Chores