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

Feat/discord summarizer prompt update #47

Merged
merged 11 commits into from
Apr 16, 2024

Conversation

amindadgar
Copy link
Member

@amindadgar amindadgar commented Apr 10, 2024

Summary by CodeRabbit

  • New Features

    • Enhanced data retrieval capabilities with options for aggregating records and grouping by metadata.
    • Expanded filtering options in data retrieval functions to allow additional custom filters.
  • Tests

    • Added new test cases for data retrieval functionalities, ensuring robustness and reliability.
  • Refactor

    • Updated SQL query logic and parameter handling to support new features and filters.

Still errors on retrieve_similar_nodes.py in case of group_by. We need to fix that.
Commiting the work to be saved.
Copy link
Contributor

coderabbitai bot commented Apr 10, 2024

Warning

Rate Limit Exceeded

@amindadgar has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 23 minutes and 11 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between ce688e5 and 24fd48f.

Walkthrough

The recent updates enhance the system's ability to handle data aggregation and filtering. New functionalities allow for grouping records by metadata and adding more specific filters in queries. Adjustments in query logic and additional logging improve flexibility and traceability. A new suite of tests ensures the robustness of these enhancements.

Changes

File Path Summary of Changes
.../retrieve_similar_nodes.py Added aggregation and metadata grouping functionalities, new parameters, and SQL query adjustments.
.../forum_summary_retriever.py Enhanced filtering capabilities with additional **kwargs for and_filters.
utils/query_engine/... Updated functions to handle new filtering parameters and context adjustments.
utils/query_engine/level_based_platforms_util.py Introduced logging for node metadata processing.
tests/unit/test_retrieve_similar_nodes.py New test cases for database querying, filtering, and record aggregation based on metadata.

🐇✨
In the burrows of code, where the data nodes hide,
A rabbit hopped in with a spring in its stride.
Filters and queries, all lined in a row,
Grouped by their metadata, ready to show.
"Let's celebrate changes," it thumped with delight,
For clearer, cleaner code took flight!
🌟📊


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

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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
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

Comment on lines 98 to 111
and_filters: dict[str, str] | None = kwargs.get("and_filters", None)
filters: list[dict[str, str]] = []

for node in nodes:
# the filter made by given node
filter: dict[str, str] = {}
filter[metadata_group1_key] = node.metadata[metadata_group1_key]
filter[metadata_group2_key] = node.metadata[metadata_group2_key]
# date filter
filter[metadata_date_key] = node.metadata[metadata_date_key]

# if more and filters were given
if and_filters:
for key, value in and_filters.items():
filter[key] = value

Copy link
Contributor

Choose a reason for hiding this comment

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

The integration of and_filters from kwargs is handled correctly. However, consider adding error handling for cases where and_filters might not be a dictionary as expected.

+ if not isinstance(and_filters, dict):
+     raise ValueError("Expected 'and_filters' to be a dictionary.")

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
and_filters: dict[str, str] | None = kwargs.get("and_filters", None)
filters: list[dict[str, str]] = []
for node in nodes:
# the filter made by given node
filter: dict[str, str] = {}
filter[metadata_group1_key] = node.metadata[metadata_group1_key]
filter[metadata_group2_key] = node.metadata[metadata_group2_key]
# date filter
filter[metadata_date_key] = node.metadata[metadata_date_key]
# if more and filters were given
if and_filters:
for key, value in and_filters.items():
filter[key] = value
and_filters: dict[str, str] | None = kwargs.get("and_filters", None)
if not isinstance(and_filters, dict):
raise ValueError("Expected 'and_filters' to be a dictionary.")
filters: list[dict[str, str]] = []
for node in nodes:
filter: dict[str, str] = {}
filter[metadata_group1_key] = node.metadata[metadata_group1_key]
filter[metadata_group2_key] = node.metadata[metadata_group2_key]
filter[metadata_date_key] = node.metadata[metadata_date_key]
# if more and filters were given
if and_filters:
for key, value in and_filters.items():
filter[key] = value

Comment on lines 59 to 66
aggregate_records : bool
aggregate records and group by a given term in `group_by_metadata`
group_by_metadata : list[str]
do grouping by some property of `metadata_`
"""
ignore_sort = kwargs.get("ignore_sort", False)
aggregate_records = kwargs.get("aggregate_records", False)
group_by_metadata = kwargs.get("group_by_metadata")
Copy link
Contributor

Choose a reason for hiding this comment

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

The handling of aggregate_records and group_by_metadata is implemented correctly. Ensure that group_by_metadata is always a list to avoid type errors during iteration.

+ if not isinstance(group_by_metadata, list):
+     raise ValueError("Expected 'group_by_metadata' to be a list.")

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
aggregate_records : bool
aggregate records and group by a given term in `group_by_metadata`
group_by_metadata : list[str]
do grouping by some property of `metadata_`
"""
ignore_sort = kwargs.get("ignore_sort", False)
aggregate_records = kwargs.get("aggregate_records", False)
group_by_metadata = kwargs.get("group_by_metadata")
aggregate_records : bool
aggregate records and group by a given term in `group_by_metadata`
group_by_metadata : list[str]
do grouping by some property of `metadata_`
"""
ignore_sort = kwargs.get("ignore_sort", False)
aggregate_records = kwargs.get("aggregate_records", False)
group_by_metadata = kwargs.get("group_by_metadata")
if not isinstance(group_by_metadata, list):
raise ValueError("Expected 'group_by_metadata' to be a list.")

Comment on lines +101 to +106
summary_nodes_filters : list[dict[str, str]]
a list of filters to fetch the summary nodes
for default, not passing this would mean to use previous nodes
but if passed we would re-fetch nodes.
This could be benefitial in case we want to do some manual
processing with nodes
Copy link
Contributor

Choose a reason for hiding this comment

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

The addition of summary_nodes_filters allows for flexible filtering of summary nodes. Ensure that this parameter is properly validated to be a list of dictionaries before use.

+ if summary_nodes_filters is not None and not all(isinstance(f, dict) for f in summary_nodes_filters):
+     raise ValueError("Each filter in 'summary_nodes_filters' must be a dictionary.")

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
summary_nodes_filters : list[dict[str, str]]
a list of filters to fetch the summary nodes
for default, not passing this would mean to use previous nodes
but if passed we would re-fetch nodes.
This could be benefitial in case we want to do some manual
processing with nodes
summary_nodes_filters : list[dict[str, str]]
a list of filters to fetch the summary nodes
for default, not passing this would mean to use previous nodes
but if passed we would re-fetch nodes.
This could be benefitial in case we want to do some manual
processing with nodes
if summary_nodes_filters is not None and not all(isinstance(f, dict) for f in summary_nodes_filters):
raise ValueError("Each filter in 'summary_nodes_filters' must be a dictionary.")

Getting the metadata_ in a way no duplicate data could happen.
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: 1

bot/retrievers/retrieve_similar_nodes.py Show resolved Hide resolved
amindadgar and others added 6 commits April 11, 2024 09:40
note: this test case was just testing each module and no db conection was made, so we moved it to unit tests.
Add group_by_metadata validation

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@amindadgar amindadgar requested a review from TjitsevdM April 11, 2024 07:43
@amindadgar amindadgar linked an issue Apr 11, 2024 that may be closed by this pull request
3 tasks
@amindadgar amindadgar requested a review from cyri113 April 15, 2024 06:45
@amindadgar amindadgar merged commit 6778b7e into main Apr 16, 2024
16 checks passed
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.

feat: Update discord summarized documents flow
2 participants