Skip to content
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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

New Components - zep #15616

wants to merge 4 commits into from

Conversation

michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented Feb 13, 2025

Resolves #15601.

Summary by CodeRabbit

  • New Features

    • Introduced new capabilities for managing sessions, including creating sessions, updating session details, and adding memory.
    • Launched event sources to capture real-time updates for new messages, sessions, and session changes.
    • Expanded configuration options with additional properties for session and user management, along with new API methods for fetching sessions, users, and messages.
  • Chores

    • Upgraded the component version and introduced dependency updates along with improved data parsing utilities.

@michelle0927 michelle0927 added the ai-assisted Content generated by AI, with human refinement and modification label Feb 13, 2025
Copy link

vercel bot commented Feb 13, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Ignored (Inspect) Visit Preview Feb 13, 2025 11:04pm
pipedream-docs ⬜️ Ignored (Inspect) Feb 13, 2025 11:04pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Feb 13, 2025 11:04pm

Copy link
Contributor

coderabbitai bot commented Feb 13, 2025

Walkthrough

This 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

File(s) Change Summary
components/zep/actions/add-memory/add-memory.mjs
components/zep/actions/create-session/create-session.mjs
components/zep/actions/update-session/update-session.mjs
New action modules for adding memory, creating sessions, and updating sessions. Each exports an object with metadata and an asynchronous run method that invokes the corresponding API function.
components/zep/common/utils.mjs Added utility functions parseObject and parseArray for parsing JSON inputs, with an updated default export.
components/zep/package.json Updated version from 0.0.1 to 0.1.0, added dependency on @pipedream/platform with the constraint ^3.0.3, and modified publish configuration to set the access as public.
components/zep/sources/common/base.mjs
components/zep/sources/new-message/new-message.mjs
components/zep/sources/new-session/new-session.mjs
components/zep/sources/session-updated/session-updated.mjs
New source modules for event-driven management of session data and message events. The modules extend a common base for session management and introduce methods to retrieve new events and generate metadata.
components/zep/zep.app.mjs Enhanced the Zep app by adding a new import (axios), new property definitions in propDefinitions (e.g., sessionId, userId, factRatingInstructions, metadata), and multiple new methods for handling API requests, including session creation, memory addition, user and message listing, and session updating.

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
Loading

Suggested labels

action, trigger / source

Suggested reviewers

  • jcortes

Poem

In a field of code I hop with glee,
New modules sprout as far as I see.
Memory and sessions now dance in the night,
Parsing arrays under the moonlight.
With every commit, my heart leaps free,
A joyful bunny’s digital jubilee! 🐇✨
Hop on, let’s code with delight!

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

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

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)

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

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)

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

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)

  • 6 others
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@michelle0927 michelle0927 marked this pull request as ready for review February 13, 2025 23:04
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 for sessionId
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 keep factRatingInstructions and metadata free-form, adding optional validation or default values can help handle edge cases.


53-68: Add more robust error handling
Consider wrapping the axios 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 in parseObject
If obj 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 in parseArray
If arr 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

📥 Commits

Reviewing files that changed from the base of the PR and between 55f5c24 and b7b1cf2.

⛔ 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 for userId 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, and updateSession
    The use of a destructured sessionId 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 yield NaN if created_at is missing or malformed. Ensure created_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 by updated_at for chronological processing
  • generateMeta generates unique IDs by combining session ID with timestamp

Also 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ai-assisted Content generated by AI, with human refinement and modification
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Components] zep
1 participant