Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(wren-ui): use intent reasoning instead of hard code string for misleading query #1217

Merged
merged 1 commit into from
Jan 24, 2025

Conversation

fredalai
Copy link
Contributor

@fredalai fredalai commented Jan 23, 2025

Description

  • Change templated response “Could you please provide more details or specify the information you're seeking?” to the text AI service provided.

image

AI API

    // GET /v1/asks/{query_id}/result
    {
     "status": "understanding|searching|generating|finished|failed|stopped",
     "response": [Result],
     "intent_reasoning": <string|optional>
     "error": <Error|optional>
    }

↓ example response

    {
       "status": "finished",
       "rephrased_question": "What is the current number of people sleeping at 2025-01-23 15:07:29?",
       "intent_reasoning": "The question about 'people sleeping' is unrelated to the database schema.",
       "type": "MISLEADING_QUERY",
       "response": null,
       "error": null
    }

UI screenshots

截圖 2025-01-23 下午6 43 35

Summary by CodeRabbit

  • New Features

    • Added intentReasoning field to provide additional context about task intent across multiple system components
    • Enhanced error handling with more detailed reasoning information
  • Improvements

    • Expanded GraphQL schema and query responses to include intent reasoning
    • Updated data models to support new intent reasoning property

Copy link
Contributor

coderabbitai bot commented Jan 23, 2025

Walkthrough

This pull request introduces an intentReasoning field across multiple components of the Wren UI system, enabling the capture and transmission of reasoning behind an asking task's intent. The changes span from GraphQL type definitions to server-side adaptors and client-side components, ensuring consistent integration of this new contextual information. The modification allows for more detailed error handling and provides additional context about AI-generated tasks and queries.

Changes

File Change Summary
wren-ui/src/apollo/client/graphql/__types__.ts Added optional intentReasoning field to AskingTask type
wren-ui/src/apollo/client/graphql/home.generated.ts Updated AskingTaskQuery type to include intentReasoning
wren-ui/src/apollo/client/graphql/home.ts Modified ASKING_TASK query to include intentReasoning
wren-ui/src/apollo/server/adaptors/wrenAIAdaptor.ts Updated transformAskResult method to include intent_reasoning
wren-ui/src/apollo/server/models/adaptor.ts Extended AskResult type with optional intentReasoning
wren-ui/src/apollo/server/resolvers/askingResolver.ts Added intentReasoning to AskingTask interface
wren-ui/src/apollo/server/schema.ts Added intentReasoning field to GraphQL AskingTask type
wren-ui/src/components/pages/home/prompt/Result.tsx Added intentReasoning to Props interface
wren-ui/src/components/pages/home/prompt/index.tsx Integrated intentReasoning into result object

Possibly related PRs

Suggested reviewers

  • wwwy3y3

Poem

🐰 A Rabbit's Reasoning Tale 🔍

In GraphQL's realm, a field takes flight,
intentReasoning shines so bright
From server to client, context unfurled
A whisper of meaning in our data world
Hop, hop, knowledge grows with delight! 🌟

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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>, 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
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-ui/src/apollo/server/resolvers/askingResolver.ts (1)

Line range hint 1-228: Architecture implementation is clean and well-structured.

The implementation of intent reasoning follows a clean architecture pattern:

  1. GraphQL schema defines the contract
  2. Server-side adaptor handles the transformation from snake_case to camelCase
  3. Resolver properly propagates the field
  4. Client-side types ensure type safety

The changes are minimal, focused, and maintain consistency across all layers of the application.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8422f5b and 99b5cdd.

📒 Files selected for processing (9)
  • wren-ui/src/apollo/client/graphql/__types__.ts (1 hunks)
  • wren-ui/src/apollo/client/graphql/home.generated.ts (2 hunks)
  • wren-ui/src/apollo/client/graphql/home.ts (1 hunks)
  • wren-ui/src/apollo/server/adaptors/wrenAIAdaptor.ts (2 hunks)
  • wren-ui/src/apollo/server/models/adaptor.ts (1 hunks)
  • wren-ui/src/apollo/server/resolvers/askingResolver.ts (2 hunks)
  • wren-ui/src/apollo/server/schema.ts (1 hunks)
  • wren-ui/src/components/pages/home/prompt/Result.tsx (2 hunks)
  • wren-ui/src/components/pages/home/prompt/index.tsx (1 hunks)
⏰ 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/server/models/adaptor.ts (1)

122-124: LGTM! The type extension is well-defined.

The optional intentReasoning field is properly typed and maintains backward compatibility.

wren-ui/src/components/pages/home/prompt/index.tsx (1)

108-108: LGTM! The memoized result is properly handled.

Good use of optional chaining and fallback to empty string for the intentReasoning field.

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

131-131: LGTM! The GraphQL query is properly extended.

The intentReasoning field is correctly added to the ASKING_TASK query structure.

wren-ui/src/components/pages/home/prompt/Result.tsx (2)

43-43: LGTM! The Props interface is properly extended.

The intentReasoning field is correctly typed as string in the Props interface.


121-123: LGTM! The error description fallback chain is well-implemented.

Good implementation of the fallback chain:

  1. First tries config.description
  2. Then falls back to data.intentReasoning
  3. Finally falls back to error message
wren-ui/src/apollo/server/resolvers/askingResolver.ts (2)

47-47: LGTM! The interface change is well-structured.

The optional intentReasoning field is appropriately typed and aligns with the PR's objective of supporting AI-generated intent reasoning.


228-228: LGTM! Clean implementation of intent reasoning.

The field is correctly mapped from the AI service response to the resolver's return object.

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

510-510: LGTM! Proper extraction of the intent reasoning field.

The snake_case intent_reasoning field is correctly destructured from the AI service response.


523-523: LGTM! Consistent field transformation.

The snake_case intent_reasoning is properly transformed to camelCase intentReasoning in the return object, maintaining consistency with the codebase's naming conventions.

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

586-586: LGTM! GraphQL schema properly extended.

The intentReasoning field is correctly defined as a nullable String type in the AskingTask type, matching the TypeScript interface.

wren-ui/src/apollo/client/graphql/__types__.ts (1)

30-30: LGTM! Client-side type definition is consistent.

The intentReasoning field is properly typed as Maybe<Scalars['String']>, maintaining type safety and consistency with the GraphQL schema.

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

28-28: LGTM! Type definition properly extended.

The intentReasoning field is correctly added to the AskingTaskQuery type with proper TypeScript optional and nullable type modifiers.


321-321: LGTM! GraphQL query field properly added.

The intentReasoning field is correctly added to the askingTask query selection set, aligning with the type definition.

@wwwy3y3 wwwy3y3 merged commit bce25a8 into main Jan 24, 2025
5 checks passed
@wwwy3y3 wwwy3y3 deleted the feature/ask-intent-reasoning-ui branch January 24, 2025 01:41
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