mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
fix(core): ai retry missing reasoning and webSearch params (#12690)
Close [AI-165](https://linear.app/affine-design/issue/AI-165) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced chat components to support advanced reasoning and network search options, providing more control over AI-powered interactions. - Improved polling for context documents and files, now also triggered by additional chip types for more comprehensive updates. - **Bug Fixes** - Ensured consistent application of configuration settings across all relevant chat components. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -13,6 +13,10 @@ import { repeat } from 'lit/directives/repeat.js';
|
||||
import { debounce } from 'lodash-es';
|
||||
|
||||
import { AffineIcon } from '../_common/icons';
|
||||
import type {
|
||||
AINetworkSearchConfig,
|
||||
AIReasoningConfig,
|
||||
} from '../components/ai-chat-input';
|
||||
import {
|
||||
type ChatMessage,
|
||||
isChatAction,
|
||||
@@ -161,6 +165,12 @@ export class ChatPanelMessages extends WithDisposable(ShadowlessElement) {
|
||||
@property({ attribute: false })
|
||||
accessor affineFeatureFlagService!: FeatureFlagService;
|
||||
|
||||
@property({ attribute: false })
|
||||
accessor networkSearchConfig!: AINetworkSearchConfig;
|
||||
|
||||
@property({ attribute: false })
|
||||
accessor reasoningConfig!: AIReasoningConfig;
|
||||
|
||||
@query('.chat-panel-messages-container')
|
||||
accessor messagesContainer: HTMLDivElement | null = null;
|
||||
|
||||
@@ -175,6 +185,17 @@ export class ChatPanelMessages extends WithDisposable(ShadowlessElement) {
|
||||
return this.messagesContainer;
|
||||
}
|
||||
|
||||
private get _isNetworkActive() {
|
||||
return (
|
||||
!!this.networkSearchConfig.visible.value &&
|
||||
!!this.networkSearchConfig.enabled.value
|
||||
);
|
||||
}
|
||||
|
||||
private get _isReasoningActive() {
|
||||
return !!this.reasoningConfig.enabled.value;
|
||||
}
|
||||
|
||||
private _renderAIOnboarding() {
|
||||
return this.isLoading ||
|
||||
!this.host?.store.get(FeatureFlagService).getFlag('enable_ai_onboarding')
|
||||
@@ -380,6 +401,8 @@ export class ChatPanelMessages extends WithDisposable(ShadowlessElement) {
|
||||
where: 'chat-panel',
|
||||
control: 'chat-send',
|
||||
isRootSession: true,
|
||||
reasoning: this._isReasoningActive,
|
||||
webSearch: this._isNetworkActive,
|
||||
});
|
||||
this.updateContext({ abortController });
|
||||
for await (const text of stream) {
|
||||
|
||||
@@ -456,6 +456,8 @@ export class ChatPanel extends SignalWatcher(
|
||||
.isLoading=${this.isLoading}
|
||||
.extensions=${this.extensions}
|
||||
.affineFeatureFlagService=${this.affineFeatureFlagService}
|
||||
.networkSearchConfig=${this.networkSearchConfig}
|
||||
.reasoningConfig=${this.reasoningConfig}
|
||||
></chat-panel-messages>
|
||||
<ai-chat-composer
|
||||
.host=${this.host}
|
||||
|
||||
@@ -387,8 +387,11 @@ export class AIChatComposer extends SignalWatcher(
|
||||
|
||||
this._isLoading = true;
|
||||
await this._initChips();
|
||||
const isProcessing = this.chips.some(chip => chip.state === 'processing');
|
||||
if (isProcessing) {
|
||||
const needPoll = this.chips.some(
|
||||
chip =>
|
||||
chip.state === 'processing' || isTagChip(chip) || isCollectionChip(chip)
|
||||
);
|
||||
if (needPoll) {
|
||||
await this._pollContextDocsAndFiles();
|
||||
}
|
||||
this._isLoading = false;
|
||||
|
||||
@@ -299,6 +299,8 @@ export class PlaygroundChat extends SignalWatcher(
|
||||
.isLoading=${this.isLoading}
|
||||
.extensions=${this.extensions}
|
||||
.affineFeatureFlagService=${this.affineFeatureFlagService}
|
||||
.networkSearchConfig=${this.networkSearchConfig}
|
||||
.reasoningConfig=${this.reasoningConfig}
|
||||
></chat-panel-messages>
|
||||
<ai-chat-composer
|
||||
.host=${this.host}
|
||||
|
||||
@@ -69,6 +69,17 @@ export class AIChatBlockPeekView extends LitElement {
|
||||
return this.blockModel.props.rootWorkspaceId;
|
||||
}
|
||||
|
||||
private get _isNetworkActive() {
|
||||
return (
|
||||
!!this.networkSearchConfig.visible.value &&
|
||||
!!this.networkSearchConfig.enabled.value
|
||||
);
|
||||
}
|
||||
|
||||
private get _isReasoningActive() {
|
||||
return !!this.reasoningConfig.enabled.value;
|
||||
}
|
||||
|
||||
private _textRendererOptions: TextRendererOptions = {};
|
||||
|
||||
private _forkBlockId: string | undefined = undefined;
|
||||
@@ -347,6 +358,8 @@ export class AIChatBlockPeekView extends LitElement {
|
||||
signal: abortController.signal,
|
||||
where: 'ai-chat-block',
|
||||
control: 'chat-send',
|
||||
reasoning: this._isReasoningActive,
|
||||
webSearch: this._isNetworkActive,
|
||||
});
|
||||
|
||||
this.updateContext({ abortController });
|
||||
|
||||
Reference in New Issue
Block a user