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 original params to prompt callbacks #4862

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open

Conversation

ritch
Copy link
Contributor

@ritch ritch commented Sep 27, 2024

# usage
def my_event(self, ctx):
  ctx.prompt(my_op, on_success=self.on_success)

def on_success(self, ctx):
  print(ctx.params.get("original_params", None))

Summary by CodeRabbit

  • New Features

    • Enhanced success event handling by including original parameters for improved context.
    • Updated method signatures to provide additional contextual information during operation execution.
  • Bug Fixes

    • Adjusted invocation of success handlers to pass more comprehensive data, enhancing functionality.

Copy link
Contributor

coderabbitai bot commented Sep 27, 2024

Walkthrough

The changes involve modifications to the PromptUserForOperation class and the useOperatorExecutor function. The callback function in PromptUserForOperation now accepts an additional parameter, opts, which includes an ExecutionContext. Similarly, the onSuccess handler in useOperatorExecutor has been updated to receive this new context information. These adjustments enhance the data passed during operations, allowing for richer contextual information.

Changes

File Path Change Summary
app/packages/operators/src/built-in-operators.ts Updated the callback method signature in PromptUserForOperation to include an opts parameter containing ctx.
app/packages/operators/src/state.ts Modified the invocation of onSuccess in useOperatorExecutor to pass an object with ctx alongside result.

Poem

In the meadow, where bunnies play,
New changes hop in, brightening the day.
With context in hand, we leap and bound,
Sharing more tales, where joy is found.
So let’s celebrate, with a thump and a cheer,
For every small change brings us near! 🐇✨


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between cb040ed and 600bf7b.

📒 Files selected for processing (2)
  • app/packages/operators/src/built-in-operators.ts (2 hunks)
  • app/packages/operators/src/state.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
app/packages/operators/src/built-in-operators.ts (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

app/packages/operators/src/state.ts (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

🔇 Additional comments (2)
app/packages/operators/src/state.ts (1)

927-927: LGTM! Improved context passing to onSuccess handler.

The addition of the ctx object to the onSuccess handler is a good improvement. This change allows the handler to access the execution context, which can be beneficial for post-execution operations, logging, or any other context-dependent actions. The modification enhances the flexibility and capability of the onSuccess callback.

app/packages/operators/src/built-in-operators.ts (1)

Line range hint 1045-1055: Improved context handling and callback information.

The changes to the PromptUserForOperation class enhance the callback function by:

  1. Adding an opts parameter to access the execution context.
  2. Including original_params in the success event, providing more comprehensive information.

These improvements allow for better tracking and debugging of operations.


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

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.

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.

1 participant