ClinicianFOCUS / FreeScribe

A medical scribe capable of creating SOAP notes running Whisper and Kobold based on conversation with a patient
GNU General Public License v3.0
0 stars 0 forks source link

[Refactor] Refactored the settings window code #19

Closed ItsSimko closed 1 week ago

ItsSimko commented 2 weeks ago

Changes Made

Summary by Sourcery

Refactor the settings window by separating logic from UI code and introduce new features including dynamic model loading and presets. Enhance the main window UI with a Docker status bar and update the build and CI configurations to support these changes.

New Features:

Enhancements:

Build:

CI:

socket-security[bot] commented 2 weeks ago

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
pypi/docker@7.1.0 environment, filesystem, network, shell 0 511 kB aiordache, ccrone, dev-tooling-team, ...4 more

🚮 Removed packages: pypi/docker@2.0.0

View full report↗︎

sourcery-ai[bot] commented 1 week ago

Reviewer's Guide by Sourcery

This pull request refactors the settings window code, separating the UI and logic components, and introduces new features such as preset configurations and Docker container management. The changes aim to improve code organization, enhance user experience, and provide better control over the application's Docker-based services.

User journey diagram for updated settings window

journey
    title User Journey for Updated Settings Window
    section Open Settings
      User -> SettingsWindowUI: Open settings window
    section Configure Settings
      User -> SettingsWindowUI: Select preset
      User -> SettingsWindowUI: Modify basic settings
      User -> SettingsWindowUI: Modify advanced settings
      User -> SettingsWindowUI: Modify Docker settings
    section Save and Apply
      User -> SettingsWindowUI: Save settings
      User -> SettingsWindowUI: Close settings window
    section Docker Management
      User -> MainWindowUI: Start/Stop LLM container
      User -> MainWindowUI: Start/Stop Whisper container
    section Exit Application
      User -> Application: Exit application
      Application -> ContainerManager: Auto shutdown containers

Class diagram for refactored settings window

classDiagram
    class SettingsWindow {
        +String KOBOLDCPP_IP
        +String WHISPERAUDIO_IP
        +String KOBOLDCPP_PORT
        +String WHISPERAUDIO_PORT
        +String OPENAI_API_KEY
        +String API_STYLE
        +Map editable_settings
        +Map advanced_settings
        +Map docker_settings
        +Map editable_settings_entries
        +void load_settings_from_file(String filename)
        +void save_settings(String koboldcpp_ip, String whisperaudio_ip, String openai_api_key, String aiscribe_text, String aiscribe2_text, String settings_window, String koboldcpp_port, String whisperaudio_port, Boolean ssl_enable, Boolean ssl_selfcert, String api_style, String preset)
        +void get_available_models()
        +void update_models_dropdown(ComboBox dropdown)
        +void load_settings_preset(String preset_name, SettingsWindowUI settings_class)
        +void set_main_window(MainWindow window)
    }

    class SettingsWindowUI {
        +SettingsWindow settings
        +MainWindow main_window
        +void open_settings_window()
        +void create_basic_settings()
        +void create_advanced_settings()
        +void create_docker_settings()
        +void create_editable_settings(Frame frame, List settings_set, int start_row)
        +void create_buttons()
        +void save_settings(Boolean close_window)
        +void reset_to_default()
    }

    class MainWindow {
        +ContainerManager container_manager
        +void start_LLM_container(String widget_name, SettingsWindow app_settings)
        +void stop_LLM_container(String widget_name, SettingsWindow app_settings)
        +void start_whisper_container(String widget_name, SettingsWindow app_settings)
        +void stop_whisper_container(String widget_name, SettingsWindow app_settings)
    }

    class ContainerManager {
        +DockerClient client
        +Boolean start_container(String container_name)
        +Boolean stop_container(String container_name)
        +Boolean check_container_status(String container_name)
        +void set_status_icon_color(Widget widget, Boolean status)
        +void check_docker_status_thread(Widget llm_dot, Widget whisper_dot, SettingsWindow app_settings)
    }

    SettingsWindow --> SettingsWindowUI
    SettingsWindowUI --> MainWindow
    MainWindow --> ContainerManager

File-Level Changes

Change Details Files
Refactored settings window code into separate UI and logic components
  • Created new classes SettingsWindow and SettingsWindowUI
  • Moved settings-related logic to SettingsWindow class
  • Implemented UI-specific code in SettingsWindowUI class
src/FreeScribe.client/UI/SettingsWindow.py
src/FreeScribe.client/UI/SettingsWindowUI.py
Added preset configurations feature
  • Implemented loading of preset configurations
  • Added preset JSON files for JanAI, GPT, and ClinicianFOCUS Toolbox
  • Created a dropdown menu for selecting presets in the settings window
src/FreeScribe.client/UI/SettingsWindowUI.py
src/FreeScribe.client/presets/JanAI.json
src/FreeScribe.client/presets/ChatGPT.json
src/FreeScribe.client/presets/ClinicianFOCUS Toolbox.json
Implemented Docker container management
  • Created ContainerManager class for Docker operations
  • Added UI elements for starting and stopping Docker containers
  • Implemented status indicators for Docker containers
src/FreeScribe.client/ContainerManager.py
src/FreeScribe.client/UI/MainWindowUI.py
Enhanced main window functionality
  • Created MainWindow and MainWindowUI classes
  • Implemented Docker status bar in the main window
  • Added tooltips for better user guidance
src/FreeScribe.client/UI/MainWindow.py
src/FreeScribe.client/UI/MainWindowUI.py
src/FreeScribe.client/Tooltip.py
Updated client.py to use new class structure
  • Replaced old settings initialization with new class instances
  • Integrated Docker status bar creation based on settings
  • Added container shutdown logic on application exit
src/FreeScribe.client/client.py
Modified installation and build process
  • Updated NSIS installer script to include preset files
  • Modified GitHub Actions workflow to use the updated NSIS script
scripts/install.nsi
.github/workflows/release.yml

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. - **Generate a pull request title:** Write `@sourcery-ai` anywhere in the pull request title to generate a 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. You can also use this command to specify where the summary should be inserted. #### Customizing Your Experience Access your [dashboard](https://app.sourcery.ai) 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 - [Contact our support team](mailto:support@sourcery.ai) for questions or feedback. - Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information. - Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).
ItsSimko commented 1 week ago

Note removed leftover API key with BFG repo cleaner, security risk resolved!