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

Add support for externalUserId for chats. #25

Merged
merged 3 commits into from
Jul 9, 2024
Merged

Add support for externalUserId for chats. #25

merged 3 commits into from
Jul 9, 2024

Conversation

jmoseley
Copy link
Contributor

@jmoseley jmoseley commented Jul 9, 2024

Summary by CodeRabbit

  • New Features
    • Added support for externalUserId in various chat functionalities including chat creation, listing, and responses.
  • Bug Fixes
    • Ensured consistent id property format by converting item.id to a string in Shopify indexer.

Copy link

coderabbitai bot commented Jul 9, 2024

Walkthrough

The updates enhance chat functionality by integrating an externalUserId field across various interfaces and classes, ensuring compatibility with user-specific identifiers. An additional minor update involves converting the item.id to a string in the Shopify indexer to maintain consistency when storing document IDs.

Changes

Files Change Summaries
chat.test.ts Added externalUserId: "123" parameter to various chat-related function calls and objects.
chat.ts Introduced externalUserId field in interfaces and classes related to chat functionalities.
client.ts Added externalUserId field to ClientListChatOpts interface.
cortex.ts Included externalUserId in CortexCreateChatOptsBase interface and Cortex class methods.
indexers/shopify-indexer.ts Converted item.id to a string for consistency in the ShopifyIndexer class.

Poem

In chats, a new field we bestow,
externalUserId to follow and flow.
With IDs now clear, both here and there,
Our system aligns, with precision and care.
Shopify's IDs now stringy delights,
Ensuring all documents remain in sight. 🌟


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

Copy link

@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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b7e06f7 and 0d64c05.

Files selected for processing (4)
  • chat.test.ts (3 hunks)
  • chat.ts (9 hunks)
  • client.ts (1 hunks)
  • cortex.ts (3 hunks)
Files skipped from review due to trivial changes (1)
  • client.ts
Additional comments not posted (12)
chat.test.ts (4)

70-70: LGTM! Verify externalUserId handling in cortex.chat.

The addition of externalUserId to the cortex.chat method call looks good.

Ensure that the externalUserId field is properly handled in the cortex.chat method.


77-77: LGTM!

The check for externalUserId in the getChatRes object ensures that the field is correctly returned from the getChat method.


165-165: LGTM! Verify externalUserId handling in cortex.chat.

The addition of externalUserId to the statusStream object in the streaming chat test looks good.

Ensure that the externalUserId field is properly handled in the cortex.chat method.


193-193: LGTM!

The check for externalUserId in the chatResult object ensures that the field is correctly returned from the chat method.

cortex.ts (2)

93-93: LGTM!

The addition of externalUserId to the CortexCreateChatOptsBase interface aligns with the objective of associating external user identifiers with chat operations.


196-196: LGTM! Verify externalUserId handling in Chat.create.

The addition of externalUserId to the chat method in both the streaming and non-streaming cases looks good.

Ensure that the externalUserId field is properly handled in the Chat.create method.

Also applies to: 205-205

chat.ts (6)

12-12: LGTM!

The addition of externalUserId to the CreateChatOptsBase interface aligns with the objective of associating external user identifiers with chat operations.


50-50: LGTM!

The addition of externalUserId to the ChatListItem interface aligns with the objective of associating external user identifiers with chat operations.


61-61: LGTM!

The addition of externalUserId to the ChatListOpts interface aligns with the objective of associating external user identifiers with chat operations.


78-78: LGTM!

The addition of externalUserId to the Chat class constructor aligns with the objective of associating external user identifiers with chat operations.


118-118: LGTM! Verify externalUserId handling in createContentSync and createContentStreaming.

The addition of externalUserId to the createContentSync and createContentStreaming methods looks good.

Ensure that the externalUserId field is properly handled in the createContentSync and createContentStreaming methods.

Also applies to: 125-125


209-211: LGTM! Verify externalUserId handling in the list method and ChatListItem object.

The addition of externalUserId to the query parameters in the list method and to the ChatListItem object looks good.

Ensure that the externalUserId field is properly handled in the list method and the ChatListItem object.

Also applies to: 226-226

Copy link

@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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0d64c05 and 941f21f.

Files selected for processing (4)
  • chat.test.ts (3 hunks)
  • chat.ts (9 hunks)
  • client.ts (1 hunks)
  • cortex.ts (3 hunks)
Files skipped from review as they are similar to previous changes (4)
  • chat.test.ts
  • chat.ts
  • client.ts
  • cortex.ts

Copy link

@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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 941f21f and 1115d5b.

Files selected for processing (4)
  • chat.test.ts (3 hunks)
  • chat.ts (10 hunks)
  • client.ts (1 hunks)
  • cortex.ts (3 hunks)
Files skipped from review as they are similar to previous changes (3)
  • chat.test.ts
  • client.ts
  • cortex.ts
Additional comments not posted (6)
chat.ts (6)

12-12: Addition of externalUserId to CreateChatOptsBase looks good.

The externalUserId field is correctly added as an optional string.


50-50: Addition of externalUserId to ChatListItem looks good.

The externalUserId field is correctly added as an optional string.


61-61: Addition of externalUserId to ChatListOpts looks good.

The externalUserId field is correctly added as an optional string or null.


78-78: Addition of externalUserId to Chat constructor looks good.

The externalUserId field is correctly added as an optional string.


98-103: Inclusion of externalUserId in createContentSync looks good.

The externalUserId field is correctly destructured from the opts object and included in the POST request payload.


Line range hint 129-172:
Inclusion of externalUserId in createContentStreaming looks good.

The externalUserId field is correctly destructured from the opts object, included in the POST request payload, and used in the Chat constructor.

Copy link
Member

@EvanBoyle EvanBoyle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need any updates to respond?

chat.ts Outdated Show resolved Hide resolved
@jmoseley
Copy link
Contributor Author

jmoseley commented Jul 9, 2024

Do we need any updates to respond?

I thought not, since we don't currently support changing users in the middle of a chat. At some point we should consider implementing forking for chats, but we don't have that right now.

@EvanBoyle
Copy link
Member

That sounds right. Thanks for refreshing my memory.

Copy link

@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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1115d5b and 73b23c2.

Files selected for processing (2)
  • chat.ts (10 hunks)
  • client.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • client.ts
Additional comments not posted (9)
chat.ts (9)

12-12: Addition of externalUserId in CreateChatOptsBase is correct.

The addition aligns with the PR's objective and is appropriately marked as optional.


50-50: Addition of externalUserId in ChatListItem is correct.

The addition aligns with the PR's objective and is appropriately marked as optional.


61-61: Verify the necessity of | null in externalUserId type definition.

The addition aligns with the PR's objective and is appropriately marked as optional. However, consider if | null is necessary, as undefined might suffice.


78-78: Addition of externalUserId in Chat class constructor is correct.

The addition aligns with the PR's objective and is appropriately marked as optional.


98-103: Addition of externalUserId in createContentSync method is correct.

The addition aligns with the PR's objective and is appropriately included in the request body.


129-134: Addition of externalUserId in createContentStreaming method is correct.

The addition aligns with the PR's objective and is appropriately included in the request body.


164-172: Addition of externalUserId in Chat instantiation within createContentStreaming is correct.

The addition aligns with the PR's objective and is appropriately included in the Chat object instantiation.


191-191: Addition of externalUserId in Chat instantiation within get method is correct.

The addition aligns with the PR's objective and is appropriately included in the Chat object instantiation.


213-215: Addition of externalUserId in list method is correct.

The addition aligns with the PR's objective and is appropriately included in the query parameters and the ChatListItem instantiation.

Also applies to: 230-230

Copy link

@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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 73b23c2 and f262b39.

Files selected for processing (1)
  • indexers/shopify-indexer.ts (1 hunks)
Additional comments not posted (1)
indexers/shopify-indexer.ts (1)

84-84: Approve the conversion of id to string.

The conversion of the id property to a string ensures consistent data types within the documents array. This change is straightforward and should not have any adverse side effects. However, verify if this conversion is necessary for all use cases and ensure that all parts of the codebase that interact with this data are compatible with this change.

@jmoseley jmoseley merged commit c172c76 into main Jul 9, 2024
3 checks passed
@jmoseley jmoseley deleted the jeremy/35 branch July 9, 2024 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants