Skip to content

feat: provide origin question and returning invalid sql when adjusting#1528

Merged
wwwy3y3 merged 3 commits intomainfrom
feat/adjustment-invalid-sql
Apr 17, 2025
Merged

feat: provide origin question and returning invalid sql when adjusting#1528
wwwy3y3 merged 3 commits intomainfrom
feat/adjustment-invalid-sql

Conversation

@onlyjackfrost
Copy link
Copy Markdown
Contributor

@onlyjackfrost onlyjackfrost commented Apr 7, 2025

Provide origin question and returning invalid sql when adjusting.
Relate to PR: #1526

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Enhanced the feedback submission process by capturing an additional query detail from users.
    • Expanded task responses to include new validation insights, offering clearer information on query processing.
    • Introduced a new field for handling SQL validity in adjustment tasks, improving error context.
    • Added the ability to report invalid SQL across various GraphQL operations related to adjustment tasks.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 7, 2025

Walkthrough

This update enhances the feedback and adjustment task flows by adding two key properties: question and invalidSql. The question property is now included in the data sent when asking for feedback, while invalidSql is captured from responses to indicate potential SQL issues. The changes span multiple components including API adaptors, background task trackers, data models/interfaces, resolvers, and the GraphQL schema.

Changes

Files Change Summary
wren-ui/src/apollo/server/adaptors/wrenAIAdaptor.ts, wren-ui/src/apollo/server/backgrounds/adjustmentBackgroundTracker.ts, wren-ui/src/apollo/server/models/adaptor.ts (AskFeedbackInput) Added a new question property to the request payload and relevant input interface to include the question text.
wren-ui/src/apollo/server/adaptors/wrenAIAdaptor.ts, wren-ui/src/apollo/server/models/adaptor.ts (AskFeedbackResult), wren-ui/src/apollo/server/resolvers/askingResolver.ts, wren-ui/src/apollo/server/schema.ts, wren-ui/src/apollo/client/graphql/__types__.ts, wren-ui/src/apollo/client/graphql/home.generated.ts, wren-ui/src/apollo/client/graphql/home.ts Introduced an invalidSql property to capture error details related to SQL validity in feedback responses and adjustment task representations.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Tracker
    participant AIAdaptor
    participant Server
    participant Resolver

    Client->>Tracker: Initiate adjustment task (with question)
    Tracker->>AIAdaptor: Call createAskFeedback (pass question)
    AIAdaptor->>Server: POST /v1/ask-feedbacks (payload includes question)
    Server-->>AIAdaptor: Response (returns invalid_sql field)
    AIAdaptor->>Resolver: transformAskFeedbackResult (maps invalid_sql to invalidSql)
    Resolver->>Client: Returns AdjustmentTask (includes invalidSql)
Loading

Possibly related PRs

  • feat(wren-ui): add reasoning api #1388: The changes in the main PR are related to those in the retrieved PR as both involve modifications to the handling of the question and invalidSql properties within their respective classes and interfaces, specifically in the context of feedback and task management.

Suggested reviewers

  • onlyjackfrost

Poem

I'm a coding rabbit, hopping with glee,
Adding "question" to our feedback spree,
With "invalidSql" in the mix, oh what a sight,
Fields refined and data set just right,
Leaping through code with a whiskered cheer,
Hoppy updates make our system dear!


📜 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 2a9ce73 and fdfd386.

📒 Files selected for processing (3)
  • wren-ui/src/apollo/client/graphql/__types__.ts (1 hunks)
  • wren-ui/src/apollo/client/graphql/home.generated.ts (7 hunks)
  • wren-ui/src/apollo/client/graphql/home.ts (2 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
wren-ui/src/apollo/client/graphql/home.generated.ts (1)
wren-ui/src/apollo/client/graphql/__types__.ts (3)
  • Scalars (8-15)
  • AdjustThreadResponseInput (26-30)
  • AdjustThreadResponseChartInput (17-24)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
🔇 Additional comments (13)
wren-ui/src/apollo/client/graphql/__types__.ts (1)

32-40: Good addition of the invalidSql field for improved error handling.

The new invalidSql field enhances the AdjustmentTask type by allowing it to store information about SQL that was determined to be invalid during processing. This is a well-structured addition that aligns with the PR's objective of returning invalid SQL when adjusting.

wren-ui/src/apollo/client/graphql/home.ts (2)

120-129: Properly included invalidSql field in the CommonResponse fragment.

The new invalidSql field has been appropriately added to the adjustmentTask object in the CommonResponse fragment, ensuring this data is included in all responses that use this fragment.


391-405: Properly included invalidSql field in the AdjustmentTask query.

The invalidSql field has been correctly added to the explicit AdjustmentTask query, ensuring consistency with the updated type definition.

wren-ui/src/apollo/client/graphql/home.generated.ts (10)

16-16: Successfully updated the CommonResponseFragment type definition.

The invalidSql field has been properly integrated into the TypeScript type definition for the CommonResponseFragment, ensuring type safety when accessing this field.


42-42: ThreadQuery type properly updated to include invalidSql.

The ThreadQuery type definition has been correctly updated to include the invalidSql field in the adjustmentTask object, maintaining consistency with the GraphQL schema changes.


49-49: ThreadResponseQuery type properly updated.

The ThreadResponseQuery type definition now correctly includes the invalidSql field, ensuring type safety when working with thread response data.


85-85: CreateThreadResponseMutation type properly updated.

The CreateThreadResponseMutation type has been correctly updated to include the invalidSql field in the response structure.


101-101: UpdateThreadResponseMutation type properly updated.

The UpdateThreadResponseMutation type definition now correctly includes the invalidSql field, maintaining consistency with the GraphQL schema changes.


109-109: AdjustThreadResponseMutation type properly updated.

The AdjustThreadResponseMutation type definition now correctly includes the invalidSql field, which is particularly relevant for this mutation as it relates directly to the adjustment process.


182-182: GenerateThreadResponseAnswerMutation type properly updated.

The GenerateThreadResponseAnswerMutation type has been correctly updated to include the invalidSql field, ensuring type safety when working with thread response generation.


189-189: GenerateThreadResponseChartMutation type properly updated.

The GenerateThreadResponseChartMutation type has been correctly updated to include the invalidSql field, maintaining consistency across all related operations.


197-197: AdjustThreadResponseChartMutation type properly updated.

The AdjustThreadResponseChartMutation type has been correctly updated to include the invalidSql field, ensuring type safety when adjusting chart responses.


204-204: AdjustmentTaskQuery type and document properly updated.

Both the AdjustmentTaskQuery type and the corresponding GraphQL document now correctly include the invalidSql field, ensuring consistency between the schema and the generated TypeScript types.

Also applies to: 240-240

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7656500 and fcd80f7.

📒 Files selected for processing (5)
  • wren-ui/src/apollo/server/adaptors/wrenAIAdaptor.ts (2 hunks)
  • wren-ui/src/apollo/server/backgrounds/adjustmentBackgroundTracker.ts (1 hunks)
  • wren-ui/src/apollo/server/models/adaptor.ts (2 hunks)
  • wren-ui/src/apollo/server/resolvers/askingResolver.ts (2 hunks)
  • wren-ui/src/apollo/server/schema.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
🔇 Additional comments (7)
wren-ui/src/apollo/server/schema.ts (1)

732-732: Addition of invalidSql field looks good

The addition of the invalidSql field to the AdjustmentTask type completes the GraphQL schema changes needed to surface invalid SQL information to clients.

wren-ui/src/apollo/server/models/adaptor.ts (2)

297-297: LGTM! Question property added to AskFeedbackInput

The addition of the question property to the AskFeedbackInput interface enables passing the original question when requesting feedback, which aligns with the PR objective of providing origin question during adjustment.


322-322: LGTM! InvalidSql property added to AskFeedbackResult

Adding the invalidSql property to the AskFeedbackResult interface provides a way to capture SQL validation issues in the feedback response. This properly implements the "returning invalid sql when adjusting" part of the PR objective.

wren-ui/src/apollo/server/backgrounds/adjustmentBackgroundTracker.ts (1)

211-211: Origin question now included when rerunning adjustment tasks

Good addition - this ensures that when re-running an adjustment task, the original question is included in the feedback request, allowing proper context to be maintained.

wren-ui/src/apollo/server/resolvers/askingResolver.ts (1)

49-49: Interface update for invalidSql in AdjustmentTask

The addition of the invalidSql optional string property to the AdjustmentTask interface correctly matches the GraphQL schema definition.

wren-ui/src/apollo/server/adaptors/wrenAIAdaptor.ts (2)

660-671: LGTM! The question property addition is appropriate.

The addition of the question property to the request body ensures that the original question is included when sending feedback to the AI service. This aligns with the PR objective of providing the origin question.


717-729: LGTM! The invalidSql property addition is appropriate.

The addition of the invalidSql property to the feedback result allows for properly capturing and propagating information about invalid SQL responses from the AI service. This implementation correctly maps from the snake_case invalid_sql in the response body to the camelCase invalidSql in the result object, maintaining consistent naming conventions.

Copy link
Copy Markdown
Contributor

@andreashimin andreashimin left a comment

Choose a reason for hiding this comment

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

lgtm, tested
image

@wwwy3y3 wwwy3y3 merged commit 749e01a into main Apr 17, 2025
9 checks passed
@wwwy3y3 wwwy3y3 deleted the feat/adjustment-invalid-sql branch April 17, 2025 02:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants