Skip to content

Conversation

@amindadgar
Copy link
Member

@amindadgar amindadgar commented Apr 28, 2025

Summary by CodeRabbit

  • New Features

    • Improved flexibility when fetching Telegram summaries by allowing use of separate platform and community identifiers instead of a combined collection name.
    • Added support for retrieving the latest summary when no date is specified.
  • Bug Fixes

    • Enhanced error handling for missing platform information during summary retrieval.
  • Chores

    • Updated input fields and internal naming to better reflect platform and community-based operations.

@coderabbitai
Copy link

coderabbitai bot commented Apr 28, 2025

Walkthrough

This update refactors the handling of collection identification within the summarization workflow and activities. Instead of passing a constructed collection name string, the code now separately manages platform_name and community_id fields, constructing collection names internally as needed. Activity and workflow functions are updated to reflect these changes, and schema models are adjusted to remove the collection_name field in favor of the new identifiers. Additionally, the logic for fetching summaries by date now supports retrieving the latest available date if none is provided, using a custom ingestion pipeline.

Changes

File(s) Change Summary
hivemind_summarizer/activities.py Renamed get_collection_name to get_platform_name, updated its return value and docstring, refactored summary-fetching functions to use platform_name and community_id instead of collection_name, and added fallback logic for latest date retrieval.
hivemind_summarizer/schema.py Modified Pydantic models: removed collection_name, added platform_name and community_id fields, and made date and start_date fields optional.
hivemind_summarizer/workflows.py Updated workflow to use get_platform_name instead of get_collection_name, and refactored activity calls to use platform_name and community_id.
registry.py Updated imports and activity registry to use get_platform_name instead of get_collection_name.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Workflow
    participant Activities
    participant Qdrant
    participant CustomPipeline

    User->>Workflow: Start summary fetch (with platform_name, community_id, [date])
    Workflow->>Activities: get_platform_name(input)
    Activities-->>Workflow: platform_name
    alt date is provided
        Workflow->>Activities: fetch_telegram_summaries_by_date(platform_name, community_id, date)
        Activities->>Qdrant: Query summaries for date
        Qdrant-->>Activities: Return summaries
    else no date provided
        Activities->>CustomPipeline: Get latest date for [platform_name]_summary
        CustomPipeline-->>Activities: latest_date
        Activities->>Qdrant: Query summaries for latest_date
        Qdrant-->>Activities: Return summaries
    end
    Activities-->>Workflow: Return summaries
    Workflow-->>User: Return result
Loading

Possibly related PRs

Poem

A hop, a skip, a field anew,
Now platform names and IDs come through.
No more strings all stitched and long—
We build them right where they belong!
Summaries fetched, the latest in tow,
This bunny’s code is set to go.
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7f39918 and ab0b4c0.

📒 Files selected for processing (1)
  • hivemind_summarizer/activities.py (9 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • hivemind_summarizer/activities.py
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: ci / lint / Lint
  • GitHub Check: ci / test / Test
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

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.

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: 1

🧹 Nitpick comments (3)
hivemind_summarizer/activities.py (3)

239-241: Update error message to match the new collection name construction.

Since the collection name is now constructed internally, the error message should reference the constructed value.

     logging.info(
-        f"Fetching summaries for date range: {start_date} to {end_date} from collection: {collection_name}"
+        f"Fetching summaries for date range: {start_date} to {end_date} from collection: {community_id}_{input.platform_name}_summary"
     )

274-277: Update error message in the exception handler.

The error message still references collection_name directly, but it should use the constructed collection name for consistency.

         logging.error(
-            f"Error fetching summaries for date range {start_date} to {end_date} from collection {collection_name}: {str(e)}"
+            f"Error fetching summaries for date range {start_date} to {end_date} from collection {community_id}_{input.platform_name}_summary: {str(e)}"
         )

104-106: Update docstrings to reflect parameter changes.

The docstrings for both fetch_telegram_summaries_by_date and fetch_telegram_summaries_by_date_range still mention collection_name in the parameter descriptions, but the schema now uses separate platform_name and community_id fields.

Update the docstrings to reflect the new parameter structure:

    Parameters
    ----------
    input : TelegramSummariesActivityInput
-        Input object containing date, collection_name and extract_text_only
+        Input object containing date, platform_name, community_id and extract_text_only
    Parameters
    ----------
    input : TelegramSummariesRangeActivityInput
-        Input object containing start_date, end_date, collection_name and extract_text_only
+        Input object containing start_date, end_date, platform_name, community_id and extract_text_only

Also applies to: 218-220

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 73808cc and 7f39918.

📒 Files selected for processing (4)
  • hivemind_summarizer/activities.py (8 hunks)
  • hivemind_summarizer/schema.py (2 hunks)
  • hivemind_summarizer/workflows.py (4 hunks)
  • registry.py (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
registry.py (1)
hivemind_summarizer/activities.py (1)
  • get_platform_name (45-92)
hivemind_summarizer/workflows.py (1)
hivemind_summarizer/activities.py (1)
  • get_platform_name (45-92)
hivemind_summarizer/activities.py (1)
hivemind_summarizer/schema.py (1)
  • TelegramGetCollectionNameInput (19-21)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: ci / test / Test
  • GitHub Check: ci / lint / Lint
🔇 Additional comments (14)
registry.py (2)

15-15: Import updated to match renamed activity function.

The change correctly updates the import statement to use get_platform_name instead of the previous get_collection_name, aligning with the renamed activity function in the activities module.


45-45: Export list updated to include the renamed activity.

The ACTIVITIES list is properly updated to export the renamed get_platform_name activity, ensuring consistency with the import changes above.

hivemind_summarizer/workflows.py (4)

12-12: Import updated to reflect activity function renaming.

The import statement has been correctly updated to use the renamed activity function get_platform_name.


57-59: Variable and function name updated to reflect new functionality.

The renamed variable (platform_name instead of collection_name) and activity function call (get_platform_name) properly reflect that the function now returns only the platform name rather than constructing a collection name string.


72-75: Inputs correctly separated to match the new schema design.

The activity input has been properly updated to pass platform_name and community_id separately instead of a combined collection_name, aligning with the schema changes.


88-90: Consistent implementation of parameter changes in date range functionality.

The date range activity call has been updated with the same parameter structure as the single date function, ensuring consistency across the codebase.

hivemind_summarizer/schema.py (3)

5-8: Schema updated to support optional date and separate identifiers.

The changes to TelegramSummariesActivityInput:

  1. Make date optional with a default of None to support fetching the latest date
  2. Replace collection_name with separate platform_name and community_id fields

These changes enable the new functionality for fetching the latest summary when no date is provided.


15-16: Range activity input updated for consistency.

The TelegramSummariesRangeActivityInput class has been updated with the same pattern of separate platform_name and community_id fields, ensuring consistency across all input models.


27-27: Workflow input updated to support optional start date.

Making start_date optional with a default of None aligns with the changes in the activity input and allows the workflow to fetch the latest summary when no specific date is provided.

hivemind_summarizer/activities.py (5)

9-13: New imports added to support latest date retrieval.

The imports for CustomIngestionPipeline and models from qdrant_client.http are necessary additions to support the new functionality for retrieving the latest document date when no specific date is provided.


45-88: Activity renamed and return value simplified.

The activity has been properly renamed from get_collection_name to get_platform_name and now returns only the platform name instead of constructing a collection name. The docstring has been updated to reflect this change.


114-120: Collection name construction moved inside the activity.

The activity now correctly constructs the collection name internally using the provided community_id and platform_name, and validates that platform_name is provided. This aligns with the refactoring approach of managing these identifiers separately.


131-170: Added support for fetching latest date when none is provided.

This new logic implements a key feature of this PR - the ability to retrieve the latest available summary when no specific date is provided. It uses CustomIngestionPipeline to get the latest document date from the collection and then queries for summaries on that date.


265-267: Input parameters properly updated in date range function.

The fetch_telegram_summaries_by_date call correctly passes platform_name and community_id separately as required by the updated schema.

@amindadgar amindadgar merged commit 4d07bb1 into main Apr 28, 2025
3 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.

2 participants