Skip to content

fix webui#863

Open
alcholiclg wants to merge 2 commits intomodelscope:mainfrom
alcholiclg:fix/support_win
Open

fix webui#863
alcholiclg wants to merge 2 commits intomodelscope:mainfrom
alcholiclg:fix/support_win

Conversation

@alcholiclg
Copy link
Collaborator

Change Summary

  1. fix webui for windows;
  2. fix config loading in deep reseach webui

Related issue number

Checklist

  • The pull request title is a good summary of the changes - it will be used in the changelog
  • Unit tests for the changes exist
  • Run pre-commit install and pre-commit run --all-files before git commit, and passed lint check.
  • Documentation reflects the changes where applicable

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @alcholiclg, 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 usability and configurability of the application. It resolves a common console display issue for Windows users by providing a dedicated startup script, ensuring a smoother experience. Concurrently, it introduces a comprehensive system for managing deep research configurations, allowing users to customize LLM parameters for individual agents and the search summarizer through both backend logic and a new, intuitive frontend interface. This change moves away from static configurations, offering greater flexibility and control.

Highlights

  • Windows Web UI Compatibility: A new PowerShell script, webui/scripts/start-webui.ps1, has been introduced to address console encoding issues (garbled text) when running the web UI on Windows. This script forces UTF-8 encoding, and the README.md and README_ZH.md files have been updated to guide Windows users to use this script.
  • Deep Research Configuration Management: The deep research module now supports more flexible configuration loading. Hardcoded openai_base_url values in reporter.yaml, researcher.yaml, and searcher.yaml have been replaced with generic placeholders. The backend API (webui/backend/api.py) and configuration manager (webui/backend/config_manager.py) have been extended with new Pydantic models and methods to manage deep research settings, including per-agent overrides for models, API keys, and base URLs.
  • Frontend Integration for Deep Research Settings: The web UI's settings dialog (webui/frontend/src/components/SettingsDialog.tsx) now includes a dedicated 'Deep Research' tab. This tab allows users to configure specific LLM settings (model, API key, base URL) for the Researcher, Searcher, and Reporter agents, as well as the Search Summarizer, providing granular control over the deep research process directly from the interface.
  • Dependency Update: The rich library has been added to requirements/research.txt, likely to enhance console output for the research module.

🧠 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
  • README.md
    • Added a 'Windows tip' section recommending the use of start-webui.ps1 for resolving garbled text in the console.
  • README_ZH.md
    • Added a Chinese 'Windows tip' section recommending the use of start-webui.ps1 for resolving garbled text in the console.
  • projects/deep_research/v2/reporter.yaml
    • Replaced the specific openai_base_url with a generic <OPENAI_BASE_URL> placeholder.
  • projects/deep_research/v2/researcher.yaml
    • Replaced the specific openai_base_url with a generic <OPENAI_BASE_URL> placeholder.
  • projects/deep_research/v2/searcher.yaml
    • Replaced the specific openai_base_url with a generic <OPENAI_BASE_URL> placeholder.
  • requirements/research.txt
    • Added rich as a new dependency.
  • webui/backend/api.py
    • Imported Field from pydantic.
    • Defined new Pydantic models: DeepResearchAgentConfig, DeepResearchSearchConfig, and DeepResearchConfig for structured deep research settings.
    • Added new API endpoints /config/deep_research (GET and PUT) to retrieve and update deep research configurations.
  • webui/backend/config_manager.py
    • Included a deep_research section in the DEFAULT_CONFIG with default values for agent and search summarizer settings.
    • Implemented get_deep_research_config to retrieve deep research settings.
    • Implemented update_deep_research_config to save deep research settings.
  • webui/backend/deep_research_worker.py
    • Added helper functions (_load_deep_research_config, _normalize_agent_override, _resolve_agent_llm_config, _normalize_search_override) to parse and resolve deep research configurations.
    • Modified _build_config_override to accept and utilize dr_config for researcher agent settings.
    • Updated prepare_tools_with_callback to apply specific LLM and search summarizer overrides for 'searcher' and 'reporter' agents based on dr_config.
  • webui/backend/deep_research_worker_manager.py
    • Modified _build_env to accept deep_research_config and set MS_AGENT_DEEP_RESEARCH_CONFIG environment variable, along with OPENAI_API_KEY and OPENAI_BASE_URL if not already present.
    • Updated the start method signature to include deep_research_config.
  • webui/backend/websocket_handler.py
    • Passed the deep_research_config retrieved from the config manager to the deep_research_worker_manager.start method.
  • webui/frontend/src/components/SettingsDialog.tsx
    • Defined TypeScript interfaces for DeepResearchAgentConfig, DeepResearchSearchConfig, and DeepResearchConfig.
    • Added state management for deepResearchConfig and a normalizeDeepResearchConfig utility function.
    • Updated loadConfig to fetch deep research settings from the new API endpoint.
    • Modified handleSave to send updated deep research configurations to the backend.
    • Introduced a new 'Deep Research' tab in the settings dialog, providing UI fields for configuring models, API keys, and base URLs for Researcher, Searcher, Reporter agents, and the Search Summarizer.
  • webui/scripts/start-webui.ps1
    • Added a new PowerShell script to start the web UI, forcing UTF-8 encoding for Windows consoles and setting PYTHONUTF8 environment variable.
Activity
  • The pull request was created by alcholiclg.
  • The author provided a summary indicating fixes for webui on Windows and config loading in deep research.
  • The author included a checklist for unit tests, pre-commit hooks, and documentation, though all items are unchecked.
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 fixes for the WebUI on Windows and adds configuration capabilities for the deep research feature. The changes include a new PowerShell script to handle text encoding issues on Windows, updates to the README files, and the removal of a hardcoded URL in the deep research configuration. New backend APIs and a corresponding frontend UI in the settings dialog have been added to allow users to configure deep research agents. My review focuses on the new configuration logic and has identified a few areas for improvement, including a potential regression where multi-provider support was inadvertently removed, some code inconsistencies, and opportunities for refactoring to improve maintainability.

Comment on lines 112 to +118
if model:
llm_override['model'] = model

if llm_override['service'] == 'modelscope':
if api_key:
llm_override['modelscope_api_key'] = api_key
if base_url:
llm_override['modelscope_base_url'] = base_url
elif llm_override['service'] == 'anthropic':
if api_key:
llm_override['anthropic_api_key'] = api_key
if base_url:
llm_override['anthropic_base_url'] = base_url
else:
if api_key:
llm_override['openai_api_key'] = api_key
if base_url:
llm_override['openai_base_url'] = base_url
if api_key:
llm_override['openai_api_key'] = api_key
if base_url:
llm_override['openai_base_url'] = base_url
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 logic for handling different LLM providers has been removed, and it now hardcodes openai_api_key and openai_base_url. This is a regression from the previous implementation and will cause issues if a provider other than OpenAI (or an OpenAI-compatible one) is configured in the global settings (e.g., 'modelscope', 'anthropic'). The provider-specific logic should be restored to ensure the correct API key and base URL parameter names are used in the configuration override.

    if model:
        llm_override['model'] = model

    provider = (llm_config.get('provider') or 'openai').strip()
    llm_override['service'] = provider

    if provider == 'modelscope':
        if api_key:
            llm_override['modelscope_api_key'] = api_key
        if base_url:
            llm_override['modelscope_base_url'] = base_url
    elif provider == 'anthropic':
        if api_key:
            llm_override['anthropic_api_key'] = api_key
        if base_url:
            llm_override['anthropic_base_url'] = base_url
    else:  # 'openai', 'dashscope', etc.
        if api_key:
            llm_override['openai_api_key'] = api_key
        if base_url:
            llm_override['openai_base_url'] = base_url

Comment on lines +89 to +98
class DeepResearchAgentConfig(BaseModel):
model: Optional[str] = ''
api_key: Optional[str] = ''
base_url: Optional[str] = ''


class DeepResearchSearchConfig(BaseModel):
summarizer_model: Optional[str] = ''
summarizer_api_key: Optional[str] = ''
summarizer_base_url: Optional[str] = ''
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For consistency with other Pydantic models in this file (e.g., LLMConfig) and to make the intent clearer, it's better to use None as the default value for optional fields instead of an empty string ''. This explicitly indicates that a value has not been set, whereas '' could be a valid (though empty) value.

Suggested change
class DeepResearchAgentConfig(BaseModel):
model: Optional[str] = ''
api_key: Optional[str] = ''
base_url: Optional[str] = ''
class DeepResearchSearchConfig(BaseModel):
summarizer_model: Optional[str] = ''
summarizer_api_key: Optional[str] = ''
summarizer_base_url: Optional[str] = ''
class DeepResearchAgentConfig(BaseModel):
model: Optional[str] = None
api_key: Optional[str] = None
base_url: Optional[str] = None
class DeepResearchSearchConfig(BaseModel):
summarizer_model: Optional[str] = None
summarizer_api_key: Optional[str] = None
summarizer_base_url: Optional[str] = None

Comment on lines +26 to +46
'deep_research': {
'researcher': {
'model': '',
'api_key': '',
'base_url': ''
},
'searcher': {
'model': '',
'api_key': '',
'base_url': ''
},
'reporter': {
'model': '',
'api_key': '',
'base_url': ''
},
'search': {
'summarizer_model': '',
'summarizer_api_key': '',
'summarizer_base_url': ''
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

To align with the suggested change in api.py to use None as the default for optional config fields, the DEFAULT_CONFIG for deep_research should also be updated to use None instead of empty strings (''). This ensures consistency across the application.

        'deep_research': {
            'researcher': {
                'model': None,
                'api_key': None,
                'base_url': None
            },
            'searcher': {
                'model': None,
                'api_key': None,
                'base_url': None
            },
            'reporter': {
                'model': None,
                'api_key': None,
                'base_url': None
            },
            'search': {
                'summarizer_model': None,
                'summarizer_api_key': None,
                'summarizer_base_url': None
            }
        },

Comment on lines +61 to +62
except Exception:
return {}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Catching a broad Exception can hide unexpected errors. It's better to catch the specific exception that can be raised here, which is json.JSONDecodeError.

Suggested change
except Exception:
return {}
except json.JSONDecodeError:
return {}

</TabPanel>

{/* Deep Research Tab */}
<TabPanel value={tabValue} index={3}>
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 onChange handlers for the TextField components in the 'Deep Research' tab are very repetitive. To improve code maintainability and reduce duplication, consider creating a helper function to handle state updates for the deepResearchConfig.

For example, you could define a handler like this:

const handleDeepResearchChange = (
  agent: keyof DeepResearchConfig,
  field: keyof DeepResearchAgentConfig | keyof DeepResearchSearchConfig,
  value: string
) => {
  setDeepResearchConfig((prev) => ({
    ...prev,
    [agent]: {
      ...(prev[agent] as any),
      [field]: value,
    },
  }));
};

Then, you can use it in your TextField components like this:

<TextField
  ...
  onChange={(e) => handleDeepResearchChange('researcher', 'model', e.target.value)}
/>

This will make the code cleaner and easier to manage.

@alcholiclg alcholiclg changed the title fix webui for windows; fix config loading in deep reseach webui fix webui Feb 6, 2026
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