Skip to content

Conversation

@yhwang
Copy link
Collaborator

@yhwang yhwang commented Jun 24, 2025

Add RAG end-to-end support by leveraging the following features:

  • Use the RAG support from the unitxt
  • Extend the unitxt RAG to call out the MCP tool for information retrieval

related: #446

Summary by Sourcery

Add end-to-end RAG support by introducing MCP-based retrieval settings in task recipes, updating CRD schema, validation, driver logic, and tests to incorporate RAG configuration.

New Features:

  • Introduce MCP and RAG types in the API and CRD to specify retrieval server settings for end-to-end RAG.
  • Extend TaskRecipe.String and recipe generation to embed RAG session and request parameters in task recipes.
  • Enhance driver logic to replace path placeholders and include RAG configurations when generating task recipe files.

Enhancements:

  • Rename ValidateGitURL to ValidateURL and generalize URL validation logic.
  • Add ValidateMCP to enforce constraints on MCP configuration fields.
  • Generate DeepCopy methods for MCP and RAG types to integrate new fields into the codebase.

Documentation:

  • Update CRD YAML schema with RAG.MCP properties and documentation for end-to-end RAG support.

Tests:

  • Add unit tests to verify task recipe output and driver commands include RAG settings.

Add RAG end-2-end support by leveraging the following features:
- use the RAG support from the unitxt
- extend the unitxt RAG to call out the MCP tool for
  information retrieval

Signed-off-by: Yihong Wang <[email protected]>
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jun 24, 2025

Reviewer's Guide

This PR adds end-to-end RAG support by introducing MCP and RAG types in the API and CRD, extending TaskRecipe serialization, enhancing validation logic for new RAG settings, updating the driver to inject RAG configuration into unitxt commands, and adding tests to verify the full retrieval workflow.

Sequence diagram for end-to-end RAG retrieval with MCP

sequenceDiagram
    actor User
    participant LMEvalJob
    participant Unitxt
    participant MCP
    User->>LMEvalJob: Submit evaluation job (with RAG)
    LMEvalJob->>Unitxt: Start RAG evaluation
    Unitxt->>MCP: Retrieve context information
    MCP-->>Unitxt: Return context/docs
    Unitxt-->>LMEvalJob: Complete evaluation
    LMEvalJob-->>User: Return results
Loading

ER diagram for TaskRecipe and RAG/MCP relationship in CRD

erDiagram
    TASK_RECIPE ||--o| RAG : has
    RAG ||--|| MCP : uses
    MCP {
        string url
        string tool
        string payloadField
        string contextField
        string idField
        boolean verifyCertificate
    }
Loading

Class diagram for new RAG and MCP types and TaskRecipe changes

classDiagram
    class TaskRecipe {
        +int* DemosPoolSize
        +RAG* RAG
        +String() string
    }
    class RAG {
        +MCP MCP
        +String() string
    }
    class MCP {
        +string URL
        +string Tool
        +string PayloadField
        +string ContextField
        +string IdField
        +bool VerifyCertificate
        +String() string
    }
    TaskRecipe --> RAG : rag
    RAG --> MCP : mcp
Loading

Class diagram for validation logic changes (ValidateMCP and ValidateURL)

classDiagram
    class ValidateMCP {
        +ValidateMCP(mcp *MCP) error
    }
    class ValidateURL {
        +ValidateURL(url string) error
    }
    ValidateMCP ..> MCP : validates
    ValidateMCP ..> ValidateURL : uses
Loading

File-Level Changes

Change Details Files
Introduce MCP and RAG types into API model and CRD
  • Add MCP struct with URL, Tool, PayloadField, ContextField, IdField, VerifyCertificate and validation tags
  • Define RAG struct embedding MCP and add RAG field to TaskRecipe
  • Implement String() methods on MCP and RAG to format session/request and process blocks
  • Extend CRD schema to include rag.mcp properties and required fields
  • Add deepcopy functions for MCP and RAG
api/lmes/v1alpha1/lmevaljob_types.go
config/crd/bases/trustyai.opendatahub.io_lmevaljobs.yaml
api/lmes/v1alpha1/zz_generated.deepcopy.go
Enhance validation for RAG settings and general URLs
  • Rename ValidateGitURL to ValidateURL and update usages
  • Add ValidateMCP to enforce URL pattern and field character restrictions
  • Integrate RAG validation into ValidateTaskRecipes
controllers/lmes/validation.go
Update driver to inject RAG configuration into task recipes
  • Define UnitxtPath and UnitxtPattern constants
  • Replace placeholder in taskRecipe strings with actual UnitxtPath during createTaskRecipes
controllers/lmes/driver/driver.go
Add and update tests to cover RAG end-to-end workflow
  • Add Test_TaskRecipesWithRAG to driver tests
  • Update GenerateArgCmdTaskRecipes to include rag block in expected command
  • Assert correct recipe file content and driver logs for RAG
controllers/lmes/driver/driver_test.go
controllers/lmes/lmevaljob_controller_test.go

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@openshift-ci
Copy link

openshift-ci bot commented Jun 24, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@yhwang yhwang marked this pull request as draft June 24, 2025 23:58
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @yhwang - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@yhwang
Copy link
Collaborator Author

yhwang commented Jun 25, 2025

This change requires an additional change in the unitxt to support the MCP tool calling as the information retrieval mechanism for the RAG scenario. Here is the unitxt PR for that. I believe using the MCP tool for information retrieval is a good approach to support the end-to-end RAG scenario. If we have an agreement on this, we can integrate the unitxt enhancement into the downstream lm-evaluation-harness repo. Then this PR would fulfill the controller change and leverage the new feature.

@openshift-merge-robot
Copy link
Collaborator

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@yhwang
Copy link
Collaborator Author

yhwang commented Jul 8, 2025

The improvement/change in the MCP SDK moves swiftly, especially in the security aspect, because there was a lack of security at the beginning. The implementation here aims to support HTTPS at least, and it would be good to support OAuth if possible. I labeled this as Draft and would like to get feedback about the mechanism established in this PR. Then I can work on it to finalize the implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

2 participants