Skip to content

chore: adjust default model name#7634

Merged
richardshiue merged 1 commit intoAppFlowy-IO:mainfrom
richardshiue:chore/adjust-default-model-name
Mar 27, 2025
Merged

chore: adjust default model name#7634
richardshiue merged 1 commit intoAppFlowy-IO:mainfrom
richardshiue:chore/adjust-default-model-name

Conversation

@richardshiue
Copy link
Copy Markdown
Collaborator

@richardshiue richardshiue commented Mar 27, 2025

Feature Preview


PR Checklist

  • My code adheres to AppFlowy's Conventions
  • I've listed at least one issue that this PR fixes in the description above.
  • I've added a test(s) to validate changes in this PR, or this PR only contains semantic changes.
  • All existing tests are passing.

Summary by Sourcery

Adjust the display of the default AI model name in the user interface

Enhancements:

  • Add localized display for the default AI model
  • Modify model selection UI to show a more user-friendly model name

Chores:

  • Update model display logic across multiple UI components

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Mar 27, 2025

Reviewer's Guide by Sourcery

This pull request adjusts the default model name and introduces internationalization (i18n) support for AI model names throughout the application. It also refactors the way the default model is displayed, using a spark icon in some places and the translated 'Auto Model' text in others. The changes affect the AI model selection menus and the AI writer prompt.

Sequence diagram for selecting an AI model

sequenceDiagram
    participant User
    participant _SelectModelMenuState
    participant _CurrentModelButton
    participant _ModelItem

    User->>_CurrentModelButton: Clicks on the current model button
    activate _CurrentModelButton
    _CurrentModelButton->>_SelectModelMenuState: Shows the popover menu
    deactivate _CurrentModelButton
    _SelectModelMenuState->>_ModelItem: Renders model items
    User->>_ModelItem: Selects a model
    activate _ModelItem
    _ModelItem->>_SelectModelMenuState: Calls onTap
    deactivate _ModelItem
    _SelectModelMenuState->>_CurrentModelButton: Updates the selected model
    activate _CurrentModelButton
    _CurrentModelButton->>_CurrentModelButton: Displays i18n or spark icon if default
    deactivate _CurrentModelButton
Loading

File-Level Changes

Change Details Files
Adjusted the display of the selected AI model in the SelectModelMenu widget to use the i18n property for internationalization and added a spark icon for the default model.
  • Replaced modelName with model in _CurrentModelButton to access the AI model's properties.
  • Used model.i18n to display the model name, supporting internationalization.
  • Added a spark icon to visually represent the default model.
  • Modified _CurrentModelButton to display either the i18n model name or a spark icon if the model is default.
frontend/appflowy_flutter/lib/ai/widgets/prompt_input/select_model_menu.dart
Added an extension to the AIModelPB class to determine if a model is the default and to retrieve its internationalized name.
  • Introduced an isDefault getter to check if the model's name is 'Default'.
  • Added an i18n getter to return the internationalized name of the model, defaulting to a translation key for the default model.
  • Added AiModelExtension on AIModelPB to encapsulate isDefault and i18n properties.
frontend/appflowy_flutter/lib/ai/service/ai_model_state_notifier.dart
Removed the spark icon from the AiWriterPromptMoreButton widget.
  • Removed the FlowySvg widget displaying the spark icon.
  • Removed the horizontal space after the spark icon.
frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/ai/widgets/ai_writer_prompt_input_more_button.dart
Updated the AIModelSelection widget to use the i18n property of the AI model for the dropdown menu label.
  • Replaced model.name with model.i18n in the buildDropdownMenuEntry function to display the internationalized model name.
  • Imported appflowy/ai/ai.dart to use the extension methods.
frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/setting_ai_view/model_selection.dart
Added a translation key for the 'Auto Model' option in the English translation file.
  • Added chat_switchModel_autoModel translation key with the value 'Auto Model'.
frontend/resources/translations/en.json

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!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

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

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 27, 2025

🥷 Ninja i18n – 🛎️ Translations need to be updated

Project /project.inlang

lint rule new reports level link
Missing translation 29 warning contribute (via Fink 🐦)

Copy link
Copy Markdown
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 @richardshiue - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding a comment explaining the purpose of the AiModelExtension and its isDefault and i18n properties.
  • The _content method in _CurrentModelButton could be simplified using a ternary operator.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

@richardshiue richardshiue force-pushed the chore/adjust-default-model-name branch from 49d445c to 9a71ce5 Compare March 27, 2025 06:15
@richardshiue richardshiue merged commit 07a78b4 into AppFlowy-IO:main Mar 27, 2025
7 checks passed
@richardshiue richardshiue deleted the chore/adjust-default-model-name branch March 27, 2025 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant