intents icon indicating copy to clipboard operation
intents copied to clipboard

Add test-level context

Open tetele opened this issue 10 months ago • 3 comments

It should be fine to have 2 identical test sentences if their context is different (e.g. "turn off the lights" should mean "turn off all lights" without context and "turn off the lights in this area" when the satellite's area is provided as context).

Although technically you could have passed such a set of sentences to HA, it was impossible to add them to the intents repo until now due to tests not passing.

Part of the cause was the double use of intent.context, both as input context to the test and as expected outcome after the recognition. This PR splits the 2 concerns (input context and expected output context) and allows several identical sentences to be tested, as long as their input contexts differ.

Summary by CodeRabbit

  • New Features

    • Introduced an optional "context" key within test dictionaries to enhance test specificity without allowing nested dictionaries.
  • Bug Fixes

    • Removed incorrect requires_context fields in intent definitions related to binary sensors, improving accuracy.
  • Refactor

    • Restructured context field placement in YAML test files for better organization and clarity, moving it from intent to test case or scenario levels.
  • Tests

    • Enhanced contextual information for various intents by adding or restructuring context fields to specify areas such as Living Room and Bedroom.

tetele avatar Apr 18 '24 10:04 tetele

@balloob @synesthesiam i know the tests will fail, I've only fixed the EN ones for now, but before undertaking the massive task of correcting all tests in all languages, I'd like to get your feedback on the approach here.

tetele avatar Apr 18 '24 11:04 tetele

[!WARNING]

Rate limit exceeded

@tetele has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 8 minutes and 2 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 886e1f969e969ff5fa6c29d8ef97954c0a95a294 and 58e9114478f5fef6e15e5403b1b01a391a10e6f4.

Walkthrough

Walkthrough

The recent changes introduce a context management enhancement to script/intentfest/validate.py by allowing an optional "context" key within the tests dictionary. This adjustment is reflected across several YAML test files where context specifications are shifted from the intent level to the test case level, improving modularity and clarity.

Changes

File Summary
script/intentfest/validate.py Added an optional context key to the tests dictionary for validation.
sentences/en/binary_sensor_HassGetState.yaml Removed requires_context field that specified domain and device class information.
tests/en/binary_sensor_HassGetState.yaml Removed context field from intent and specified domain and device_class directly under slots.
tests/en/cover_HassTurnOff.yaml, tests/en/cover_HassTurnOn.yaml Moved context specification from the intent level to the test case level.
tests/en/fan_HassTurnOff.yaml, tests/en/fan_HassTurnOn.yaml Moved context specification from the intent level to either the scenario or top-level context field.
tests/en/light_HassLightSet.yaml Added a context field specifying area: Bedroom to each test case.
tests/en/light_HassTurnOff.yaml, tests/en/light_HassTurnOn.yaml Moved context specification from the intent level to a higher level in the hierarchy, specifying area context for tests.

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

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

coderabbitai[bot] avatar May 30 '24 14:05 coderabbitai[bot]

Bummer that this is still not being considered. IMHO a rather large limitation of Assist's capabilities.

andreasbrett avatar Sep 01 '24 06:09 andreasbrett