Skip to content

Conversation

@amindadgar
Copy link
Member

@amindadgar amindadgar commented May 12, 2025

  • Added RealTimeSummaryWorkflow to fetch and summarize recent data.
  • Introduced fetch_and_summarize_realtime_data activity for real-time data processing.
  • Updated schema to include RealTimeSummaryWorkflowInput for input parameters.
  • Refactored existing activities to use platform_id instead of platform_name.
  • Enhanced logging and error handling for better traceability.

Summary by CodeRabbit

  • New Features

    • Introduced real-time summarization to generate fresh summaries from recent data using flexible time and collection filters.
    • Added a new workflow for fetching and summarizing recent data with retry and timeout policies.
  • Improvements

    • Replaced platform name usage with platform ID across workflows and inputs for more consistent and direct platform identification.
    • Updated documentation with examples and guidance for using the new real-time summary feature.
  • Bug Fixes

    • Enhanced validation by standardizing on platform IDs, minimizing errors related to platform data retrieval.

- Added RealTimeSummaryWorkflow to fetch and summarize recent data.
- Introduced fetch_and_summarize_realtime_data activity for real-time data processing.
- Updated schema to include RealTimeSummaryWorkflowInput for input parameters.
- Refactored existing activities to use platform_id instead of platform_name.
- Enhanced logging and error handling for better traceability.
@coderabbitai
Copy link

coderabbitai bot commented May 12, 2025

Warning

Rate limit exceeded

@amindadgar has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 16 minutes and 21 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

Reviewing files that changed from the base of the PR and between 6eb3917 and a025f68.

📒 Files selected for processing (1)
  • hivemind_summarizer/activities.py (7 hunks)

"""

Walkthrough

The changes remove the use of platform names in favor of platform IDs across activities, schemas, and workflows. A new real-time summarization workflow and activity are introduced, enabling the retrieval and summarization of recent data from Qdrant using OpenAI. Registry and import statements are updated to reflect these modifications and new components.

Changes

File(s) Change Summary
hivemind_summarizer/activities.py Removed get_platform_name activity; added fetch_and_summarize_realtime_data activity; updated references from platform_name to platform_id.
hivemind_summarizer/real_time_summary_workflow.py Introduced RealTimeSummaryWorkflow class with a run method that executes the new real-time summarization activity with retry policy.
hivemind_summarizer/schema.py Replaced platform_name with platform_id in relevant models; removed PlatformGetCollectionNameInput; added RealTimeSummaryWorkflowInput with fields for period, platform/community IDs, collection name.
hivemind_summarizer/summarizer_workflow.py Removed calls to get_platform_name and its input; switched summary activities to use platform_id directly; removed related imports and logging.
registry.py Replaced get_platform_name with fetch_and_summarize_realtime_data in activities; registered RealTimeSummaryWorkflow in workflows and activities lists.
workflows.py Updated import for PlatformSummariesWorkflow to use summarizer_workflow; added import for RealTimeSummaryWorkflow.
README.md Added documentation for the new Real-Time Summaries feature with example usage; clarified Platform Summaries example and noted differences in summary generation.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant TemporalWorkflow
    participant Activity
    participant Qdrant
    participant OpenAI

    Client->>TemporalWorkflow: Start RealTimeSummaryWorkflow(input)
    TemporalWorkflow->>Activity: fetch_and_summarize_realtime_data(input)
    Activity->>Qdrant: Query recent data points (by period/date/collection)
    Qdrant-->>Activity: Return data points
    Activity->>OpenAI: Request summary (chat completion)
    OpenAI-->>Activity: Return summary text
    Activity-->>TemporalWorkflow: Return summary
    TemporalWorkflow-->>Client: Return summary
Loading

Possibly related PRs

  • feat: updated to get latest summary docs! #31: Prior changes modified and renamed get_collection_name to get_platform_name and adjusted its usage, which is directly related to the current PR’s removal of get_platform_name and replacement with platform ID usage.

Poem

In the warren of code, a new path we tread,
Platform names retire, platform IDs instead.
Real-time summaries now hop into view,
With Qdrant and OpenAI, insights anew!
Activities shuffled, workflows align—
A bunny’s delight in every new line.
🐇✨
"""

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

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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

🧹 Nitpick comments (6)
workflows.py (1)

16-17: Address unused imports flagged by Ruff.

The imports for PlatformSummariesWorkflow and RealTimeSummaryWorkflow are flagged as unused by the static analyzer, but they appear to be re-exported for use in registry.py.

Either use these imports directly within this module or add a comment to explicitly indicate they are re-exported:

-from hivemind_summarizer.summarizer_workflow import PlatformSummariesWorkflow
-from hivemind_summarizer.real_time_summary_workflow import RealTimeSummaryWorkflow
+# These imports are re-exported for use in registry.py
+from hivemind_summarizer.summarizer_workflow import PlatformSummariesWorkflow
+from hivemind_summarizer.real_time_summary_workflow import RealTimeSummaryWorkflow

Alternatively, consider using __all__ to explicitly declare the exported names:

+__all__ = [
+    "PlatformSummariesWorkflow",
+    "RealTimeSummaryWorkflow",
+    "CommunityWebsiteWorkflow",
+    "WebsiteIngestionSchedulerWorkflow",
+    "MediaWikiETLWorkflow",
+    "IngestionWorkflow",
+]
🧰 Tools
🪛 Ruff (0.8.2)

16-16: hivemind_summarizer.summarizer_workflow.PlatformSummariesWorkflow imported but unused

Remove unused import: hivemind_summarizer.summarizer_workflow.PlatformSummariesWorkflow

(F401)


17-17: hivemind_summarizer.real_time_summary_workflow.RealTimeSummaryWorkflow imported but unused

Remove unused import: hivemind_summarizer.real_time_summary_workflow.RealTimeSummaryWorkflow

(F401)

hivemind_summarizer/real_time_summary_workflow.py (1)

36-41: Consider configuring more robust retry policies.

The current retry policy is good, but for interactions with external services (OpenAI), you might want to add handling for specific exceptions.

Consider enhancing the retry policy with exception filtering:

 retry_policy=RetryPolicy(
     maximum_attempts=3,
     initial_interval=timedelta(seconds=1),
     maximum_interval=timedelta(minutes=1),
     backoff_coefficient=2.0,
+    non_retryable_error_types=["ValueError", "TypeError"],
 ),
hivemind_summarizer/summarizer_workflow.py (1)

36-36: Update docstring to reflect removed parameter.

The docstring still mentions platform_name which has been removed from the input model.

-            Input containing platform_id, community_id, start_date, end_date, extract_text_only and platform_name
+            Input containing platform_id, community_id, start_date, end_date, and extract_text_only
hivemind_summarizer/activities.py (3)

185-189: Error message mentions “Platform name” instead of platform_id.

The parameter was renamed, but the message was not:

-    raise ValueError("Platform name is required but was not provided")
+    raise ValueError("platform_id is required but was not provided")

Keeping wording consistent prevents confusion during debugging.


333-343: Risk of exceeding model context length; consider chunked summarisation.

combined_text concatenates up to 500 payloads and feeds them directly to GPT-4o. Large communities can easily breach the model’s context window and generate “context length exceeded” errors.

Recommended pattern:

  1. Summarise in batches (e.g., 2-3 k token chunks) locally.
  2. Feed the intermediate summaries into a final “summary of summaries” call.

This keeps calls deterministic, reduces cost, and avoids runtime failures.


303-306: ```diff

  •            try:
    
  •                content = json.loads(content)
    
  •            except json.JSONDecodeError:
    
  •                pass
    
  •            from contextlib import suppress
    
  •            with suppress(json.JSONDecodeError):
    
  •                content = json.loads(content)
    

Adopting `contextlib.suppress` both shortens the code and follows Ruff’s SIM105 recommendation.

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 Ruff (0.8.2)</summary>

303-306: Use `contextlib.suppress(json.JSONDecodeError)` instead of `try`-`except`-`pass`

Replace with `contextlib.suppress(json.JSONDecodeError)`

(SIM105)

</details>

</details>

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

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

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 525bae07317f570e1402f05bdb13a736a1da69f2 and 40ac8ffcaa4233f3a26ffea7ed7a438f4d272029.

</details>

<details>
<summary>📒 Files selected for processing (6)</summary>

* `hivemind_summarizer/activities.py` (7 hunks)
* `hivemind_summarizer/real_time_summary_workflow.py` (1 hunks)
* `hivemind_summarizer/schema.py` (1 hunks)
* `hivemind_summarizer/summarizer_workflow.py` (2 hunks)
* `registry.py` (3 hunks)
* `workflows.py` (1 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧬 Code Graph Analysis (3)</summary>

<details>
<summary>workflows.py (2)</summary><blockquote>

<details>
<summary>hivemind_summarizer/summarizer_workflow.py (1)</summary>

* `PlatformSummariesWorkflow` (21-82)

</details>
<details>
<summary>hivemind_summarizer/real_time_summary_workflow.py (1)</summary>

* `RealTimeSummaryWorkflow` (11-44)

</details>

</blockquote></details>
<details>
<summary>hivemind_summarizer/real_time_summary_workflow.py (2)</summary><blockquote>

<details>
<summary>hivemind_summarizer/activities.py (1)</summary>

* `fetch_and_summarize_realtime_data` (228-349)

</details>
<details>
<summary>hivemind_summarizer/schema.py (1)</summary>

* `RealTimeSummaryWorkflowInput` (27-34)

</details>

</blockquote></details>
<details>
<summary>hivemind_summarizer/activities.py (1)</summary><blockquote>

<details>
<summary>hivemind_summarizer/schema.py (3)</summary>

* `PlatformSummariesActivityInput` (4-8)
* `PlatformSummariesRangeActivityInput` (11-16)
* `RealTimeSummaryWorkflowInput` (27-34)

</details>

</blockquote></details>

</details><details>
<summary>🪛 Ruff (0.8.2)</summary>

<details>
<summary>workflows.py</summary>

16-16: `hivemind_summarizer.summarizer_workflow.PlatformSummariesWorkflow` imported but unused

Remove unused import: `hivemind_summarizer.summarizer_workflow.PlatformSummariesWorkflow`

(F401)

---

17-17: `hivemind_summarizer.real_time_summary_workflow.RealTimeSummaryWorkflow` imported but unused

Remove unused import: `hivemind_summarizer.real_time_summary_workflow.RealTimeSummaryWorkflow`

(F401)

</details>
<details>
<summary>hivemind_summarizer/activities.py</summary>

303-306: Use `contextlib.suppress(json.JSONDecodeError)` instead of `try`-`except`-`pass`

Replace with `contextlib.suppress(json.JSONDecodeError)`

(SIM105)

</details>

</details>

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms (1)</summary>

* GitHub Check: ci / test / Test

</details>

<details>
<summary>🔇 Additional comments (7)</summary><blockquote>

<details>
<summary>hivemind_summarizer/real_time_summary_workflow.py (1)</summary>

`1-44`: **LGTM! Well-structured workflow implementation.**

This new workflow is well-implemented with proper documentation, error handling, and retry policies. The code follows the established workflow patterns in the codebase.

</details>
<details>
<summary>registry.py (4)</summary>

`16-16`: **LGTM! New activity registration.**

The new activity `fetch_and_summarize_realtime_data` is properly registered.

---

`24-24`: **LGTM! New workflow registration.**

The new `RealTimeSummaryWorkflow` is properly registered.

---

`33-33`: **LGTM! Added workflow to registry list.**

The `RealTimeSummaryWorkflow` is correctly added to the `WORKFLOWS` list.

---

`49-49`: **LGTM! Added activity to registry list.**

The `fetch_and_summarize_realtime_data` activity is correctly added to the `ACTIVITIES` list.

</details>
<details>
<summary>hivemind_summarizer/summarizer_workflow.py (2)</summary>

`60-60`: **LGTM! Successfully migrated from platform_name to platform_id.**

The parameter has been correctly updated to use `platform_id` directly instead of resolving the platform name.

---

`75-75`: **LGTM! Successfully migrated from platform_name to platform_id.**

The parameter has been correctly updated to use `platform_id` directly instead of resolving the platform name.

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

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

🧹 Nitpick comments (2)
README.md (2)

15-15: New Real-Time Summaries bullet
The addition of the Real-Time Summaries bullet aligns well with the new feature. Consider adding a hyperlink to the RealTimeSummaryWorkflow (e.g., [RealTimeSummaryWorkflow](src/hivemind_summarizer/workflows/real_time_summary.py)) for quick navigation.


88-121: Refine Real-Time Summary example
The new example for Real-Time Summaries is comprehensive. A few nitpicks for clarity and grammar:

  • Fix typo in Note 2: change “tha raw data” to “the raw data”.
  • Rephrase the note to:

    Note: Provide either a collection_name filter or both platform_id and community_id.

  • To avoid repeating “Use this when,” consider varying the phrasing (e.g., “Use this workflow if you want to …”).
🧰 Tools
🪛 LanguageTool

[style] ~120-~120: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...ries for recent data. Use this when you want to create fresh summaries for the specifie...

(REP_WANT_TO_VB)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 40ac8ff and cf5b0ad.

📒 Files selected for processing (2)
  • README.md (3 hunks)
  • hivemind_summarizer/schema.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • hivemind_summarizer/schema.py
🧰 Additional context used
🪛 LanguageTool
README.md

[style] ~120-~120: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...ries for recent data. Use this when you want to create fresh summaries for the specifie...

(REP_WANT_TO_VB)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: ci / lint / Lint
  • GitHub Check: ci / test / Test
🔇 Additional comments (1)
README.md (1)

55-87: Platform Summaries example updated
The code snippet correctly replaces platform_name/community_name with platform_id/community_id and clarifies that it fetches existing summaries from Qdrant. The formatting and parameter descriptions are clear and consistent.

@amindadgar amindadgar merged commit c9d0bcc into main May 12, 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.

BUG: fetch summaries are using platform_name for qdrant collection names! feat: Define real time summarizer based on Qdrant data!

2 participants