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 { debounce } from 'lodash-es';
|
||||||
|
|
||||||
import { AffineIcon } from '../_common/icons';
|
import { AffineIcon } from '../_common/icons';
|
||||||
|
import type {
|
||||||
|
AINetworkSearchConfig,
|
||||||
|
AIReasoningConfig,
|
||||||
|
} from '../components/ai-chat-input';
|
||||||
import {
|
import {
|
||||||
type ChatMessage,
|
type ChatMessage,
|
||||||
isChatAction,
|
isChatAction,
|
||||||
@@ -161,6 +165,12 @@ export class ChatPanelMessages extends WithDisposable(ShadowlessElement) {
|
|||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
accessor affineFeatureFlagService!: FeatureFlagService;
|
accessor affineFeatureFlagService!: FeatureFlagService;
|
||||||
|
|
||||||
|
@property({ attribute: false })
|
||||||
|
accessor networkSearchConfig!: AINetworkSearchConfig;
|
||||||
|
|
||||||
|
@property({ attribute: false })
|
||||||
|
accessor reasoningConfig!: AIReasoningConfig;
|
||||||
|
|
||||||
@query('.chat-panel-messages-container')
|
@query('.chat-panel-messages-container')
|
||||||
accessor messagesContainer: HTMLDivElement | null = null;
|
accessor messagesContainer: HTMLDivElement | null = null;
|
||||||
|
|
||||||
@@ -175,6 +185,17 @@ export class ChatPanelMessages extends WithDisposable(ShadowlessElement) {
|
|||||||
return this.messagesContainer;
|
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() {
|
private _renderAIOnboarding() {
|
||||||
return this.isLoading ||
|
return this.isLoading ||
|
||||||
!this.host?.store.get(FeatureFlagService).getFlag('enable_ai_onboarding')
|
!this.host?.store.get(FeatureFlagService).getFlag('enable_ai_onboarding')
|
||||||
@@ -380,6 +401,8 @@ export class ChatPanelMessages extends WithDisposable(ShadowlessElement) {
|
|||||||
where: 'chat-panel',
|
where: 'chat-panel',
|
||||||
control: 'chat-send',
|
control: 'chat-send',
|
||||||
isRootSession: true,
|
isRootSession: true,
|
||||||
|
reasoning: this._isReasoningActive,
|
||||||
|
webSearch: this._isNetworkActive,
|
||||||
});
|
});
|
||||||
this.updateContext({ abortController });
|
this.updateContext({ abortController });
|
||||||
for await (const text of stream) {
|
for await (const text of stream) {
|
||||||
|
|||||||
@@ -456,6 +456,8 @@ export class ChatPanel extends SignalWatcher(
|
|||||||
.isLoading=${this.isLoading}
|
.isLoading=${this.isLoading}
|
||||||
.extensions=${this.extensions}
|
.extensions=${this.extensions}
|
||||||
.affineFeatureFlagService=${this.affineFeatureFlagService}
|
.affineFeatureFlagService=${this.affineFeatureFlagService}
|
||||||
|
.networkSearchConfig=${this.networkSearchConfig}
|
||||||
|
.reasoningConfig=${this.reasoningConfig}
|
||||||
></chat-panel-messages>
|
></chat-panel-messages>
|
||||||
<ai-chat-composer
|
<ai-chat-composer
|
||||||
.host=${this.host}
|
.host=${this.host}
|
||||||
|
|||||||
@@ -387,8 +387,11 @@ export class AIChatComposer extends SignalWatcher(
|
|||||||
|
|
||||||
this._isLoading = true;
|
this._isLoading = true;
|
||||||
await this._initChips();
|
await this._initChips();
|
||||||
const isProcessing = this.chips.some(chip => chip.state === 'processing');
|
const needPoll = this.chips.some(
|
||||||
if (isProcessing) {
|
chip =>
|
||||||
|
chip.state === 'processing' || isTagChip(chip) || isCollectionChip(chip)
|
||||||
|
);
|
||||||
|
if (needPoll) {
|
||||||
await this._pollContextDocsAndFiles();
|
await this._pollContextDocsAndFiles();
|
||||||
}
|
}
|
||||||
this._isLoading = false;
|
this._isLoading = false;
|
||||||
|
|||||||
@@ -299,6 +299,8 @@ export class PlaygroundChat extends SignalWatcher(
|
|||||||
.isLoading=${this.isLoading}
|
.isLoading=${this.isLoading}
|
||||||
.extensions=${this.extensions}
|
.extensions=${this.extensions}
|
||||||
.affineFeatureFlagService=${this.affineFeatureFlagService}
|
.affineFeatureFlagService=${this.affineFeatureFlagService}
|
||||||
|
.networkSearchConfig=${this.networkSearchConfig}
|
||||||
|
.reasoningConfig=${this.reasoningConfig}
|
||||||
></chat-panel-messages>
|
></chat-panel-messages>
|
||||||
<ai-chat-composer
|
<ai-chat-composer
|
||||||
.host=${this.host}
|
.host=${this.host}
|
||||||
|
|||||||
@@ -69,6 +69,17 @@ export class AIChatBlockPeekView extends LitElement {
|
|||||||
return this.blockModel.props.rootWorkspaceId;
|
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 _textRendererOptions: TextRendererOptions = {};
|
||||||
|
|
||||||
private _forkBlockId: string | undefined = undefined;
|
private _forkBlockId: string | undefined = undefined;
|
||||||
@@ -347,6 +358,8 @@ export class AIChatBlockPeekView extends LitElement {
|
|||||||
signal: abortController.signal,
|
signal: abortController.signal,
|
||||||
where: 'ai-chat-block',
|
where: 'ai-chat-block',
|
||||||
control: 'chat-send',
|
control: 'chat-send',
|
||||||
|
reasoning: this._isReasoningActive,
|
||||||
|
webSearch: this._isNetworkActive,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.updateContext({ abortController });
|
this.updateContext({ abortController });
|
||||||
|
|||||||
Reference in New Issue
Block a user