mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-21 08:17:10 +08:00
feat(server): scenario mapping (#13404)
fix AI-404 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Introduced scenario-based configuration for copilot, allowing default model assignments for various AI use cases. * Added a new image generation model to the available options. * **Improvements** * Refined copilot provider settings by removing deprecated fallback options and standardizing base URL configuration. * Enhanced prompt management to support scenario-driven updates and improved configuration handling. * Updated admin and settings interfaces to support new scenario configurations. * **Bug Fixes** * Removed deprecated or unused prompts and related references across platforms for consistency. * **Other** * Improved test coverage and updated test assets to reflect prompt and scenario changes. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -104,22 +104,12 @@ export abstract class CopilotProvider<C = any> {
|
||||
|
||||
if (modelId) {
|
||||
const hasOnlineModel = this.onlineModelList.includes(modelId);
|
||||
const hasFallbackModel = cond.fallbackModel
|
||||
? this.onlineModelList.includes(cond.fallbackModel)
|
||||
: undefined;
|
||||
|
||||
const model = this.models.find(
|
||||
m => m.id === modelId && m.capabilities.some(matcher)
|
||||
);
|
||||
|
||||
if (model) {
|
||||
// return fallback model if current model is not alive
|
||||
if (!hasOnlineModel && hasFallbackModel) {
|
||||
// oxlint-disable-next-line typescript-eslint(no-non-null-assertion)
|
||||
return { id: cond.fallbackModel!, capabilities: [] };
|
||||
}
|
||||
return model;
|
||||
}
|
||||
if (model) return model;
|
||||
// allow online model without capabilities check
|
||||
if (hasOnlineModel) return { id: modelId, capabilities: [] };
|
||||
return undefined;
|
||||
|
||||
Reference in New Issue
Block a user