Skip to content

Conversation

@hllshiro
Copy link
Collaborator

@hllshiro hllshiro commented Jun 18, 2025

你的功能请求是否与某个问题有关?请描述一下。
通用设置(commonSetting)中助手模型默认值可能错误的选择embedding模型。

请描述你希望的解决方案
修改settings中findPriorityModel逻辑,过滤chat和ImageGeneration模型
修改ModelSelect,增加基于类别过滤选项。

平台兼容性注意事项
如果此 PR 具有特定的平台兼容性考虑因素(Windows、macOS、Linux),请在此处描述。

  • 是否有任何平台特定的行为或代码调整?无
  • 你是否已在所有相关平台上进行过测试?已在windows下测试

附加背景
模型分类ModelType和模型能力functionCall、reasoning、vision是否需要做整合?例如直接通过tags标记模型能力。
另外ollama界面无法修改模型属性,对于未识别到类型的模型无法手动修改。

Summary by CodeRabbit

  • New Features
    • Added support for embedding-type models in the model selection options.
  • Improvements
    • Model selector now allows filtering by model type, enabling more flexible and relevant model choices.
    • Model selection components across the interface now restrict options to chat and image generation models where appropriate.
  • Bug Fixes
    • Enhanced logic for selecting fallback models to prioritize chat and image generation types for a more consistent user experience.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 18, 2025

Walkthrough

A new embedding model default setting was added, and the model selection UI was updated to allow filtering by model types via a new prop. Components using the model selector now restrict selectable models to "Chat" and "ImageGeneration" types. The fallback model selection logic was also updated to prefer these types.

Changes

File(s) Change Summary
src/main/presenter/configPresenter/modelDefaultSettings.ts Added a new default model setting for an embedding model to defaultModelsSettings.
src/renderer/src/components/ModelSelect.vue Introduced an optional type prop (ModelType[]) to filter models by type, replacing fixed chat-only filter.
src/renderer/src/components/NewThread.vue
src/renderer/src/components/TitleView.vue
src/renderer/src/components/mcp-config/mcpServerForm.vue
src/renderer/src/components/settings/CommonSettings.vue
Updated usage of ModelSelect to pass type prop, restricting selectable models to Chat and ImageGeneration.
src/renderer/src/stores/settings.ts Changed fallback model selection logic to prefer models of type Chat or ImageGeneration across all providers.

Sequence Diagram(s)

sequenceDiagram
    participant UI_Component as UI Component (e.g., NewThread, TitleView)
    participant ModelSelect as ModelSelect.vue
    participant ModelStore as Model Store

    UI_Component->>ModelSelect: Render with :type=[Chat, ImageGeneration]
    ModelSelect->>ModelStore: Fetch models for providers
    ModelStore-->>ModelSelect: Return all models
    ModelSelect->>ModelSelect: Filter models by type prop
    ModelSelect-->>UI_Component: Display filtered model list
Loading
sequenceDiagram
    participant Settings as settings.ts
    participant Providers as Providers List

    Settings->>Providers: Get enabled providers and their models
    Providers-->>Settings: Return providers with models
    Settings->>Settings: Flatten all enabled models
    Settings->>Settings: Find first model where type is Chat or ImageGeneration
    Settings-->>Providers: Return found model and providerId
Loading

Possibly related PRs

Poem

A model for embedding hops in with glee,
Now filtered by type, as clear as can be.
Chat and image, the choices are neat,
The UI now helps you pick models with speed.
In the warren of code, selection is right—
Every bunny gets their model tonight! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 124f0a1 and 36fa261.

📒 Files selected for processing (1)
  • src/renderer/src/components/ModelSelect.vue (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/components/ModelSelect.vue
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build-check (x64)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/renderer/src/components/ModelSelect.vue (1)

62-66: Prop lacks default & documentation

type?: ModelType[] is introduced but no default value or JSDoc comment is provided. Consumers must now remember that “undefined” ≠ “empty array”. Consider:

defineProps({
  type: {
    type: Array as PropType<ModelType[]>,
    default: undefined // ←  explicit for clarity
  }
})
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between af77553 and 124f0a1.

📒 Files selected for processing (7)
  • src/main/presenter/configPresenter/modelDefaultSettings.ts (1 hunks)
  • src/renderer/src/components/ModelSelect.vue (2 hunks)
  • src/renderer/src/components/NewThread.vue (1 hunks)
  • src/renderer/src/components/TitleView.vue (2 hunks)
  • src/renderer/src/components/mcp-config/mcpServerForm.vue (2 hunks)
  • src/renderer/src/components/settings/CommonSettings.vue (2 hunks)
  • src/renderer/src/stores/settings.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build-check (x64)
🔇 Additional comments (6)
src/main/presenter/configPresenter/modelDefaultSettings.ts (1)

1674-1690: match patterns are overly-generic – may capture unintended models

Using very broad keywords ('embedding', 'embed') makes this entry the default match for any provider/model id that merely contains those substrings.
Side-effects:

  1. Genuine provider-specific embedding models (e.g. OpenAI text-embedding-*) will also satisfy this rule, causing ambiguous or duplicate hits.
  2. If multiple entries match, whichever is iterated first “wins”, resulting in hard-to-trace behaviour.

Consider tightening the pattern or turning this into an explicit fallback entry only when no other embedding model matches, e.g.:

-  match: ['embedding', 'embed'],
+  // Only match the literal id "embedding"
+  match: ['^embedding$'],

(or move this object to the end of the list and document that it is a last-resort default).

Also double-check that the plain id embedding will not collide with any real provider id.
[ suggest_essential_refactor ]

src/renderer/src/components/TitleView.vue (1)

30-33: Hard-coded allowed types duplicated in several views

[ModelType.Chat, ModelType.ImageGeneration] is now copy-pasted across at least four components.
Extracting a small constant (e.g. ASSISTANT_MODEL_TYPES) in a shared module, or giving ModelSelect its own sensible default, removes the duplication and the risk of future divergence.

[ suggest_optional_refactor ]

src/renderer/src/components/settings/CommonSettings.vue (1)

80-83: Same concern as raised in TitleView.vue – see previous comment.
[ duplicate_comment ]

src/renderer/src/components/mcp-config/mcpServerForm.vue (1)

798-801: Duplication of the hard-coded type array – see earlier comment.
[ duplicate_comment ]

src/renderer/src/components/NewThread.vue (1)

61-64: Duplication of the hard-coded type array – see earlier comment.
[ duplicate_comment ]

src/renderer/src/stores/settings.ts (1)

85-95: Fallback now returns null when no Chat / ImageGeneration model exists—verify downstream handling

The new logic sensibly prefers Chat or ImageGeneration types, but if none are enabled findPriorityModel() returns null where the old version always returned “something”. Down-stream callers (initOrUpdateSearchAssistantModel, etc.) guard against null, yet any new caller must remember to do the same. Confirm UI code won’t break for users who only enable “Embedding” models.

@zerob13 zerob13 merged commit e6e6353 into ThinkInAIXYZ:dev Jun 18, 2025
2 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Jun 21, 2025
@hllshiro hllshiro deleted the fix-model-select branch June 26, 2025 09:29
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