Skip to content

feat(py): web GUI for Model Performance Tool#4455

Draft
MengqinShen wants to merge 5 commits intomainfrom
elisa/feat/auto-model-test
Draft

feat(py): web GUI for Model Performance Tool#4455
MengqinShen wants to merge 5 commits intomainfrom
elisa/feat/auto-model-test

Conversation

@MengqinShen
Copy link
Contributor

@MengqinShen MengqinShen commented Feb 5, 2026

  1. Web-based GUI for Model Performance Tool: A new web-based graphical user interface has been introduced for the Model Performance Tool, providing an interactive platform for model evaluation.
  2. Dynamic Model Performance Testing Framework: A Python-based framework for dynamic model performance testing has been implemented, capable of discovering models and generating diverse configuration variations.
  3. FastAPI Backend Implementation: A FastAPI backend was developed to power the GUI, offering API endpoints for managing test scenarios, discovering models, and executing tests.
  4. Frontend Assets for User Interface: Static frontend assets (HTML, CSS, JavaScript) were added to create a user-friendly interface for configuring and viewing model performance tests.

@github-actions github-actions bot added docs Improvements or additions to documentation feature New feature or request js python Python config test labels Feb 5, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @MengqinShen, 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 significantly enhances the Model Performance Tool by integrating a new web-based graphical user interface. This GUI, built with FastAPI for the backend and standard web technologies for the frontend, allows users to interactively select models, define test scenarios, adjust configuration parameters, and visualize test results. The underlying Python framework dynamically discovers available models and generates comprehensive test variations, streamlining the process of evaluating model performance across different settings.

Highlights

  • Web-based GUI for Model Performance Tool: A new web-based graphical user interface has been introduced for the Model Performance Tool, providing an interactive platform for model evaluation.
  • Dynamic Model Performance Testing Framework: A Python-based framework for dynamic model performance testing has been implemented, capable of discovering models and generating diverse configuration variations.
  • FastAPI Backend Implementation: A FastAPI backend was developed to power the GUI, offering API endpoints for managing test scenarios, discovering models, and executing tests.
  • Frontend Assets for User Interface: Static frontend assets (HTML, CSS, JavaScript) were added to create a user-friendly interface for configuring and viewing model performance tests.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • py/model_performance_report.md
    • Added a sample Markdown report demonstrating the output format of the model performance tests.
  • py/pyproject.toml
    • Modified the tool.uv.workspace.exclude list to include the new samples/sample-test directory, ensuring proper project structure.
  • py/samples/sample-test/README.md
    • Introduced documentation for the new Model Performance Testing Tool, detailing its setup, usage, and core features like model and config discovery.
  • py/samples/sample-test/pyproject.toml
    • Added a new pyproject.toml file for the sample-test project, defining its metadata and dependencies, including genkit, fastapi, and uvicorn.
  • py/samples/sample-test/run_single_model_test.py
    • Implemented a helper script designed to execute individual model tests in an isolated subprocess, handling Genkit initialization, prompt construction, and result serialization.
  • py/samples/sample-test/server.py
    • Created a FastAPI application that acts as the backend for the web GUI, exposing endpoints for fetching test scenarios, discovering models with their configurable parameters, and running performance tests.
  • py/samples/sample-test/static/index.html
    • Added the primary HTML file for the web GUI, providing the structural layout for the model performance testing interface.
  • py/samples/sample-test/static/script.js
    • Developed the client-side JavaScript logic for the web GUI, enabling dynamic loading of scenarios and models, configuration parameter adjustments, test execution, and real-time display of results.
  • py/samples/sample-test/static/style.css
    • Provided the CSS stylesheet for the web GUI, defining the visual design and layout of the user interface elements.
Activity
  • The pull request was opened by MengqinShen, introducing a new feature.
  • The PR description includes a checklist for conventional commits, testing, and documentation, none of which are marked as completed.
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 an excellent new model performance testing tool, complete with both a command-line interface and a web-based GUI. The overall structure is well-designed, with clear separation of concerns between the test runner, the isolated test executor, and the FastAPI backend. My review focuses on improving the robustness and correctness of the implementation. I've identified a critical issue in the asynchronous handling within the FastAPI server, a high-severity bug related to serving static files, and a medium-severity improvement for error handling consistency. Addressing these points will make the new tool more reliable and easier to debug.

Comment on lines +125 to +133
result = await asyncio.to_thread(
lambda: asyncio.run(run_wrapper(
request.model,
request.config,
request.user_prompt,
request.system_prompt,
script_path
))
)
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The use of asyncio.run inside asyncio.to_thread is an anti-pattern and unnecessarily complex. Since run_model_test is a synchronous, blocking function, you can pass it directly to asyncio.to_thread along with its arguments. This simplifies the code, improves correctness, and removes the need for the run_wrapper function.

Suggested change
result = await asyncio.to_thread(
lambda: asyncio.run(run_wrapper(
request.model,
request.config,
request.user_prompt,
request.system_prompt,
script_path
))
)
# Run test in thread pool to not block async loop (subprocess call inside)
result = await asyncio.to_thread(
run_model_test,
request.model,
request.config,
request.user_prompt,
request.system_prompt,
script_path,
)



# Mount static files (Frontend)
app.mount("/", StaticFiles(directory="samples/sample-test/static", html=True), name="static")
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 path directory="samples/sample-test/static" for StaticFiles is not robust and will likely fail depending on the current working directory from which the server is launched. To ensure the path is always correct, it should be constructed relative to the server.py file's location.

Suggested change
app.mount("/", StaticFiles(directory="samples/sample-test/static", html=True), name="static")
app.mount("/", StaticFiles(directory=Path(__file__).parent / "static", html=True), name="static")

Comment on lines +51 to +63
plugins = []
# Initialize with GoogleAI plugin
try:
plugins.append(GoogleAI())
except Exception as e:
print(f"Warning: Failed to initialize GoogleAI plugin: {e}")

# Initialize with VertexAI plugin
try:
plugins.append(VertexAI())
except Exception as e:
# print(f"Warning: Failed to initialize VertexAI plugin: {e}")
pass
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 error handling for plugin initialization is inconsistent and could hide issues. The GoogleAI plugin failure prints a warning, while the VertexAI failure is silently ignored with pass. This can make debugging difficult if a plugin fails to load due to configuration errors (e.g., missing API keys or permissions). It's better to consistently log or print a warning for any plugin initialization failure.

Suggested change
plugins = []
# Initialize with GoogleAI plugin
try:
plugins.append(GoogleAI())
except Exception as e:
print(f"Warning: Failed to initialize GoogleAI plugin: {e}")
# Initialize with VertexAI plugin
try:
plugins.append(VertexAI())
except Exception as e:
# print(f"Warning: Failed to initialize VertexAI plugin: {e}")
pass
plugins = []
# Initialize with GoogleAI plugin
try:
plugins.append(GoogleAI())
except Exception as e:
print(f"Warning: Failed to initialize GoogleAI plugin: {e}")
# Initialize with VertexAI plugin
try:
plugins.append(VertexAI())
except Exception as e:
print(f"Warning: Failed to initialize VertexAI plugin: {e}")

Comment on lines +146 to +159
# Wrapper to run async run_model_test inside the thread
async def run_wrapper(model, config, user_prompt, system_prompt, script_path):
# run_model_test in test_model_performance is synchronous (uses subprocess.run)
# We need to call it directly. Wait, run_model_test in test_model_performance IS synchronous wrapper around subprocess.
# So we don't need asyncio.run inside the lambda unless run_model_test was async.
# Checking test_model_performance.py... run_model_test is synchronous.

return run_model_test(
model,
config,
user_prompt,
system_prompt,
script_path
)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Following the recommended change to the /api/run endpoint, this run_wrapper function and its surrounding comments become redundant. Removing it will simplify the codebase. The comments here also highlight some confusion about the synchronous nature of the underlying test function, which the refactoring clarifies.

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

Labels

config docs Improvements or additions to documentation feature New feature or request js python Python test

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants