Skip to content

chore(wren-ai-service): fix intent classification#1074

Merged
paopa merged 2 commits into
mainfrom
chore/ai-service/fix-intent-classification
Dec 30, 2024
Merged

chore(wren-ai-service): fix intent classification#1074
paopa merged 2 commits into
mainfrom
chore/ai-service/fix-intent-classification

Conversation

@cyyeh
Copy link
Copy Markdown
Member

@cyyeh cyyeh commented Dec 30, 2024

add time info to intent classification

testing result: https://cloud.langfuse.com/project/clsxfcv7i000038pix6dvd1y9/traces/e3aa58ab-b57e-4ed6-ab83-5773a5d68618?timestamp=2024-12-30T05:13:34.419Z&observation=335b3e61-9ce3-4de9-bede-8d45f227c6a9

Summary by CodeRabbit

  • New Features

    • Enhanced intent classification pipeline to incorporate current time and configuration settings.
    • Added timezone and time context considerations to query processing.
    • Improved flexibility in handling time-related queries.
  • Improvements

    • Updated method signatures to support more dynamic configuration management.
    • Expanded context handling for intent classification process.

@cyyeh cyyeh added module/ai-service ai-service related ci/ai-service ai-service related labels Dec 30, 2024
@cyyeh cyyeh requested a review from paopa December 30, 2024 05:15
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 30, 2024

Walkthrough

The pull request introduces enhancements to the intent classification pipeline's time handling and configuration management. The changes primarily focus on updating the intent_classification.py and ask.py files to incorporate current time context and configuration parameters. The modifications allow for more dynamic time-aware processing of user queries, with the ability to pass configuration settings through the pipeline's various stages.

Changes

File Change Summary
wren-ai-service/src/pipelines/generation/intent_classification.py - Added import for show_current_time
- Updated prompt method to include configuration and current time
- Modified run method to accept configuration parameter
wren-ai-service/src/web/v1/services/ask.py - Updated ask method to pass configuration to intent classification pipeline
wren-ai-service/tests/pytest/services/mocks.py - Updated run methods in IntentClassificationMock and GenerationMock to include configuration parameter

Sequence Diagram

sequenceDiagram
    participant User
    participant AskService
    participant IntentClassification
    participant TimeService

    User->>AskService: Submit query
    AskService->>TimeService: Get current time
    TimeService-->>AskService: Return current time
    AskService->>IntentClassification: Run classification with query and configuration
    IntentClassification->>IntentClassification: Process query with time context
    IntentClassification-->>AskService: Return classified intent
Loading

Possibly related PRs

Suggested reviewers

  • paopa

Poem

🕰️ A Rabbit's Time-Wise Tale 🐰

In pipelines where queries dance and sway,
Configuration whispers, time finds its way.
Intents now shimmer with temporal light,
A rabbit's code leaps with algorithmic might!

Hop, hop, hurray! 🌟


📜 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 d6d4505 and f8f18ff.

📒 Files selected for processing (1)
  • wren-ai-service/tests/pytest/services/mocks.py (1 hunks)
🔇 Additional comments (1)
wren-ai-service/tests/pytest/services/mocks.py (1)

30-34: Consider documenting or utilizing the new configuration parameter.

The newly introduced configuration parameter currently isn’t used in this mock’s body. If this is intentional, adding a docstring or comment clarifying its purpose will help future maintainers. Otherwise, consider integrating or testing logic that leverages configuration.

Would you like to generate tests that verify different scenarios based on the configuration parameter?


🪧 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. (Beta)
  • @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
Copy Markdown
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: 0

🧹 Nitpick comments (1)
wren-ai-service/src/pipelines/generation/intent_classification.py (1)

231-231: Optional configuration parameter added to prompt.

When configuration is None, show_current_time(configuration.timezone) can fail. Safeguard by providing a fallback or default timezone.

 def prompt(
     query: str,
     construct_db_schemas: list[str],
     prompt_builder: PromptBuilder,
     history: Optional[AskHistory] = None,
-    configuration: Configuration | None = None,
+    configuration: Optional[Configuration] = None,
 ) -> dict:
     ...
+    timezone = configuration.timezone if configuration and configuration.timezone else "UTC"
     return prompt_builder.run(
         ...
-        current_time=show_current_time(configuration.timezone),
+        current_time=show_current_time(timezone),
     )
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between cdc8ef2 and d6d4505.

📒 Files selected for processing (2)
  • wren-ai-service/src/pipelines/generation/intent_classification.py (7 hunks)
  • wren-ai-service/src/web/v1/services/ask.py (1 hunks)
🔇 Additional comments (7)
wren-ai-service/src/pipelines/generation/intent_classification.py (6)

16-16: New import for time-based functionality.

The addition of show_current_time expands the time-awareness capability. Good job ensuring the pipeline can handle time context.


18-18: Configuration import introduced.

Importing Configuration here aligns well with the introduction of configuration-driven features. This provides a flexible approach for timezones and other parameterization.


107-107: Template updated with Current Time placeholder.

Injecting the current time into the prompt template is a cohesive way to make the classification time-aware. Consider verifying the formatting of the displayed time if end-users will see it directly.


241-241: Potential edge case: configuration.timezone is None.

As recommended above, provide a default timezone to prevent errors when configuration.timezone is not set.


327-331: run method signature updated to integrate configuration object.

This change is beneficial for customizing time-based or other pipeline parameters. Confirm that callers now provide the correct configuration.


340-340: configuration usage in _pipe.execute.

Providing configuration ensures the pipeline’s newly introduced time logic is effective. No issues spotted.

wren-ai-service/src/web/v1/services/ask.py (1)

182-182: Passing configuration to intent_classification pipeline.

This addition is consistent with the changes in intent_classification.py. Great job ensuring the pipeline receives configuration data, including timezone settings.

Copy link
Copy Markdown
Contributor

@paopa paopa left a comment

Choose a reason for hiding this comment

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

LGTM. have a nitpick comment only, we could ignore it in this PR tho.

query=query,
db_schemas=construct_db_schemas,
query_history=previous_query_summaries,
current_time=show_current_time(configuration.timezone),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nitpick: the timezone in configuration class had a function to convert to current time, we might use it instead of this one.

@paopa paopa merged commit 82bde88 into main Dec 30, 2024
@paopa paopa deleted the chore/ai-service/fix-intent-classification branch December 30, 2024 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/ai-service ai-service related module/ai-service ai-service related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants