Skip to content

Conversation

@shijinpjlab
Copy link
Collaborator

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @shijinpjlab, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the system's data input handling by introducing a standardized mechanism for declaring required fields for LLM models and evaluation rules. This change centralizes field definitions and improves the user experience in the Gradio application by dynamically suggesting necessary input fields based on selected components, making the data mapping process more intuitive and less error-prone.

Highlights

  • Standardized Required Fields: Introduced a new RequiredField enum to explicitly define standard input data fields (e.g., CONTENT, PROMPT, CONTEXT, IMAGE) required by LLM models and evaluation rules.
  • Model/Rule Required Field Declaration: Added a _required_fields class attribute to numerous LLM and Rule classes, allowing each to declare its specific input data dependencies using the new RequiredField enum.
  • Dynamic Field Suggestion in Gradio App: Refactored the suggest_fields_dataframe function in the Gradio application to dynamically retrieve and display required fields based on the selected evaluators, improving user guidance for data mapping.
  • Gradio UI Update: Updated the Gradio UI for field mapping, changing column headers from 'Field Key' to 'Required Field' and initializing the dataframe with an empty state, aligning with the new dynamic suggestion logic.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a _required_fields attribute to models, which is a great improvement for dynamically configuring the UI. The implementation in the Gradio app correctly uses this new attribute. My review includes suggestions to refactor some duplicated code in the Gradio app, correct an improperly assigned required field for a search tool, and improve consistency in how required fields are declared for vision models to avoid confusion.

description = "Search the web for factual information using Tavily AI"
config: TavilyConfig = TavilyConfig()

_required_fields = [RequiredField.IMAGE]
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The _required_fields is set to [RequiredField.IMAGE], which is incorrect. The TavilySearch tool performs a web search based on a text query, not an image. This is misleading and could cause issues if this attribute is used for tools in the future. It should likely be [RequiredField.CONTENT] to reflect that the query often originates from text content.

Suggested change
_required_fields = [RequiredField.IMAGE]
_required_fields = [RequiredField.CONTENT]


def suggest_fields_dataframe(rule_list, llm_list):
"""Suggest required field mappings based on selected evaluators"""
from dingo.io.input import RequiredField
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The import from dingo.io.input import RequiredField is located inside the suggest_fields_dataframe function. According to PEP 8, imports should be at the top of the file. This also avoids the overhead of re-importing the module on every function call.

Comment on lines 259 to +274
for rule in rule_list:
# Find which type this rule belongs to
for rule_type, rules in rule_type_mapping.items():
if rule in rules:
if rule_type in data_column_mapping:
suggested_fields.update(data_column_mapping[rule_type])
break
if rule in rule_name_map:
rule_class = rule_name_map[rule]
if hasattr(rule_class, '_required_fields'):
for field in rule_class._required_fields:
if isinstance(field, RequiredField):
suggested_fields.add(field.value)

# Fields required by LLM evaluators
llm_column_mapping = get_llm_column_mapping()
for llm in llm_list:
if llm in llm_column_mapping:
suggested_fields.update(llm_column_mapping[llm])

# Generate suggested fields rows
if llm in llm_name_map:
llm_class = llm_name_map[llm]
if hasattr(llm_class, '_required_fields'):
for field in llm_class._required_fields:
if isinstance(field, RequiredField):
suggested_fields.add(field.value)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The logic for iterating through rule_list and llm_list to collect _required_fields is duplicated. This can be refactored into a helper function to avoid code repetition and improve maintainability. For example, you could create a helper that takes a list of model names and a map of names to classes, and returns the set of required fields.

"evaluation_results": ""
}

_required_fields = [RequiredField.CONTENT]
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This model classifies images, but _required_fields is set to [RequiredField.CONTENT]. This is confusing because content usually implies text. For consistency with other vision models and to make the UI mapping more intuitive, this should be [RequiredField.IMAGE]. The build_messages method would also need to be updated to use input_data.image instead of input_data.content to align with this change.

Suggested change
_required_fields = [RequiredField.CONTENT]
_required_fields = [RequiredField.IMAGE]

"evaluation_results": "通过对比VLM输出与OCR ground truth,识别文字遗漏、错误、幻觉等问题"
}

_required_fields = [RequiredField.CONTENT]
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This is a Vision-Language Model for OCR understanding, which implies it needs an image. However, _required_fields is set to [RequiredField.CONTENT]. This is confusing and inconsistent with other VLM models in this PR. It should be [RequiredField.IMAGE] to make it clear that an image input is expected. The inherited build_messages method would also need to be overridden to handle input_data.image.

Suggested change
_required_fields = [RequiredField.CONTENT]
_required_fields = [RequiredField.IMAGE]

@shijinpjlab shijinpjlab merged commit 1b01708 into MigoXLab:dev Dec 31, 2025
2 checks passed
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.

1 participant