mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-24 05:48:59 +08:00
feat(core): add ai playground feature flag and remove model switch feature flag (#12934)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added support for the "AI Playground" experimental feature, including new settings and localization entries. * **Refactor** * Renamed configuration and service references from "Model Switch" to "Playground" across the AI chat and playground interfaces. * Updated feature flag from "enable_ai_model_switch" to "enable_ai_playground" for consistency. * **Bug Fixes** * The "Model" submenu in AI chat preferences is now always visible, simplifying menu options. * **Chores** * Removed outdated Claude model options from the chat prompt. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -20,8 +20,8 @@ import type {
|
||||
SearchMenuConfig,
|
||||
} from '../components/ai-chat-chips';
|
||||
import type {
|
||||
AIModelSwitchConfig,
|
||||
AINetworkSearchConfig,
|
||||
AIPlaygroundConfig,
|
||||
AIReasoningConfig,
|
||||
} from '../components/ai-chat-input';
|
||||
import {
|
||||
@@ -224,7 +224,7 @@ export class ChatPanel extends SignalWatcher(
|
||||
accessor reasoningConfig!: AIReasoningConfig;
|
||||
|
||||
@property({ attribute: false })
|
||||
accessor modelSwitchConfig!: AIModelSwitchConfig;
|
||||
accessor playgroundConfig!: AIPlaygroundConfig;
|
||||
|
||||
@property({ attribute: false })
|
||||
accessor appSidebarConfig!: AppSidebarConfig;
|
||||
@@ -298,7 +298,7 @@ export class ChatPanel extends SignalWatcher(
|
||||
.doc=${this.doc}
|
||||
.networkSearchConfig=${this.networkSearchConfig}
|
||||
.reasoningConfig=${this.reasoningConfig}
|
||||
.modelSwitchConfig=${this.modelSwitchConfig}
|
||||
.playgroundConfig=${this.playgroundConfig}
|
||||
.appSidebarConfig=${this.appSidebarConfig}
|
||||
.searchMenuConfig=${this.searchMenuConfig}
|
||||
.docDisplayConfig=${this.docDisplayConfig}
|
||||
@@ -437,7 +437,7 @@ export class ChatPanel extends SignalWatcher(
|
||||
>`
|
||||
: 'AFFiNE AI'}
|
||||
</div>
|
||||
${this.modelSwitchConfig.visible.value
|
||||
${this.playgroundConfig.visible.value
|
||||
? html`
|
||||
<div class="chat-panel-playground" @click=${this._openPlayground}>
|
||||
${CenterPeekIcon()}
|
||||
@@ -478,7 +478,7 @@ export class ChatPanel extends SignalWatcher(
|
||||
.isVisible=${this._isSidebarOpen}
|
||||
.networkSearchConfig=${this.networkSearchConfig}
|
||||
.reasoningConfig=${this.reasoningConfig}
|
||||
.modelSwitchConfig=${this.modelSwitchConfig}
|
||||
.playgroundConfig=${this.playgroundConfig}
|
||||
.docDisplayConfig=${this.docDisplayConfig}
|
||||
.searchMenuConfig=${this.searchMenuConfig}
|
||||
.trackOptions=${{
|
||||
|
||||
-5
@@ -29,7 +29,6 @@ import type {
|
||||
import { isCollectionChip, isDocChip, isTagChip } from '../ai-chat-chips';
|
||||
import type {
|
||||
AIChatInputContext,
|
||||
AIModelSwitchConfig,
|
||||
AINetworkSearchConfig,
|
||||
AIReasoningConfig,
|
||||
} from '../ai-chat-input';
|
||||
@@ -93,9 +92,6 @@ export class AIChatComposer extends SignalWatcher(
|
||||
@property({ attribute: false })
|
||||
accessor searchMenuConfig!: SearchMenuConfig;
|
||||
|
||||
@property({ attribute: false })
|
||||
accessor modelSwitchConfig!: AIModelSwitchConfig;
|
||||
|
||||
@property({ attribute: false })
|
||||
accessor onChatSuccess: (() => void) | undefined;
|
||||
|
||||
@@ -151,7 +147,6 @@ export class AIChatComposer extends SignalWatcher(
|
||||
.updateContext=${this.updateContext}
|
||||
.networkSearchConfig=${this.networkSearchConfig}
|
||||
.reasoningConfig=${this.reasoningConfig}
|
||||
.modelSwitchConfig=${this.modelSwitchConfig}
|
||||
.docDisplayConfig=${this.docDisplayConfig}
|
||||
.onChatSuccess=${this.onChatSuccess}
|
||||
.trackOptions=${this.trackOptions}
|
||||
|
||||
@@ -27,7 +27,6 @@ import {
|
||||
import { MAX_IMAGE_COUNT } from './const';
|
||||
import type {
|
||||
AIChatInputContext,
|
||||
AIModelSwitchConfig,
|
||||
AINetworkSearchConfig,
|
||||
AIReasoningConfig,
|
||||
} from './type';
|
||||
@@ -320,9 +319,6 @@ export class AIChatInput extends SignalWatcher(
|
||||
@property({ attribute: false })
|
||||
accessor reasoningConfig!: AIReasoningConfig;
|
||||
|
||||
@property({ attribute: false })
|
||||
accessor modelSwitchConfig: AIModelSwitchConfig | undefined = undefined;
|
||||
|
||||
@property({ attribute: false })
|
||||
accessor docDisplayConfig!: DocDisplayConfig;
|
||||
|
||||
@@ -442,7 +438,6 @@ export class AIChatInput extends SignalWatcher(
|
||||
</div>
|
||||
<div class="chat-input-footer-spacer"></div>
|
||||
<chat-input-preference
|
||||
.modelSwitchConfig=${this.modelSwitchConfig}
|
||||
.session=${this.session}
|
||||
.onModelChange=${this._handleModelChange}
|
||||
.modelId=${this.modelId}
|
||||
|
||||
+14
-22
@@ -15,8 +15,6 @@ import { ShadowlessElement } from '@blocksuite/std';
|
||||
import { css, html } from 'lit';
|
||||
import { property } from 'lit/decorators.js';
|
||||
|
||||
import type { AIModelSwitchConfig } from './type';
|
||||
|
||||
export class ChatInputPreference extends SignalWatcher(
|
||||
WithDisposable(ShadowlessElement)
|
||||
) {
|
||||
@@ -51,10 +49,6 @@ export class ChatInputPreference extends SignalWatcher(
|
||||
@property({ attribute: false })
|
||||
accessor session!: CopilotSessionType | undefined;
|
||||
|
||||
// --------- model props start ---------
|
||||
@property({ attribute: false })
|
||||
accessor modelSwitchConfig: AIModelSwitchConfig | undefined = undefined;
|
||||
|
||||
@property({ attribute: false })
|
||||
accessor onModelChange: ((modelId: string) => void) | undefined;
|
||||
|
||||
@@ -96,22 +90,20 @@ export class ChatInputPreference extends SignalWatcher(
|
||||
const searchItems = [];
|
||||
|
||||
// model switch
|
||||
if (this.modelSwitchConfig?.visible.value) {
|
||||
modelItems.push(
|
||||
menu.subMenu({
|
||||
name: 'Model',
|
||||
prefix: AiOutlineIcon(),
|
||||
options: {
|
||||
items: (this.session?.optionalModels ?? []).map(modelId => {
|
||||
return menu.action({
|
||||
name: modelId,
|
||||
select: () => this._onModelChange(modelId),
|
||||
});
|
||||
}),
|
||||
},
|
||||
})
|
||||
);
|
||||
}
|
||||
modelItems.push(
|
||||
menu.subMenu({
|
||||
name: 'Model',
|
||||
prefix: AiOutlineIcon(),
|
||||
options: {
|
||||
items: (this.session?.optionalModels ?? []).map(modelId => {
|
||||
return menu.action({
|
||||
name: modelId,
|
||||
select: () => this._onModelChange(modelId),
|
||||
});
|
||||
}),
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
modelItems.push(
|
||||
menu.toggleSwitch({
|
||||
|
||||
@@ -14,7 +14,7 @@ export interface AIReasoningConfig {
|
||||
setEnabled: (state: boolean) => void;
|
||||
}
|
||||
|
||||
export interface AIModelSwitchConfig {
|
||||
export interface AIPlaygroundConfig {
|
||||
visible: Signal<boolean | undefined>;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ import type { ChatPanelMessages } from '../../chat-panel/chat-panel-messages';
|
||||
import { AIProvider } from '../../provider';
|
||||
import type { DocDisplayConfig, SearchMenuConfig } from '../ai-chat-chips';
|
||||
import type {
|
||||
AIModelSwitchConfig,
|
||||
AINetworkSearchConfig,
|
||||
AIPlaygroundConfig,
|
||||
AIReasoningConfig,
|
||||
} from '../ai-chat-input';
|
||||
import {
|
||||
@@ -136,7 +136,7 @@ export class PlaygroundChat extends SignalWatcher(
|
||||
accessor reasoningConfig!: AIReasoningConfig;
|
||||
|
||||
@property({ attribute: false })
|
||||
accessor modelSwitchConfig!: AIModelSwitchConfig;
|
||||
accessor playgroundConfig!: AIPlaygroundConfig;
|
||||
|
||||
@property({ attribute: false })
|
||||
accessor appSidebarConfig!: AppSidebarConfig;
|
||||
@@ -320,7 +320,7 @@ export class PlaygroundChat extends SignalWatcher(
|
||||
.isVisible=${this._isVisible}
|
||||
.networkSearchConfig=${this.networkSearchConfig}
|
||||
.reasoningConfig=${this.reasoningConfig}
|
||||
.modelSwitchConfig=${this.modelSwitchConfig}
|
||||
.playgroundConfig=${this.playgroundConfig}
|
||||
.docDisplayConfig=${this.docDisplayConfig}
|
||||
.searchMenuConfig=${this.searchMenuConfig}
|
||||
></ai-chat-composer>
|
||||
|
||||
@@ -12,8 +12,8 @@ import type { AppSidebarConfig } from '../../chat-panel/chat-config';
|
||||
import { AIProvider } from '../../provider';
|
||||
import type { DocDisplayConfig, SearchMenuConfig } from '../ai-chat-chips';
|
||||
import type {
|
||||
AIModelSwitchConfig,
|
||||
AINetworkSearchConfig,
|
||||
AIPlaygroundConfig,
|
||||
AIReasoningConfig,
|
||||
} from '../ai-chat-input';
|
||||
|
||||
@@ -66,7 +66,7 @@ export class PlaygroundContent extends SignalWatcher(
|
||||
accessor reasoningConfig!: AIReasoningConfig;
|
||||
|
||||
@property({ attribute: false })
|
||||
accessor modelSwitchConfig!: AIModelSwitchConfig;
|
||||
accessor playgroundConfig!: AIPlaygroundConfig;
|
||||
|
||||
@property({ attribute: false })
|
||||
accessor appSidebarConfig!: AppSidebarConfig;
|
||||
@@ -329,7 +329,7 @@ export class PlaygroundContent extends SignalWatcher(
|
||||
.doc=${this.doc}
|
||||
.networkSearchConfig=${this.networkSearchConfig}
|
||||
.reasoningConfig=${this.reasoningConfig}
|
||||
.modelSwitchConfig=${this.modelSwitchConfig}
|
||||
.playgroundConfig=${this.playgroundConfig}
|
||||
.appSidebarConfig=${this.appSidebarConfig}
|
||||
.searchMenuConfig=${this.searchMenuConfig}
|
||||
.docDisplayConfig=${this.docDisplayConfig}
|
||||
|
||||
Reference in New Issue
Block a user