feat(core): display doc title with display-config for semantic result (#13194)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Improved document title display in AI chat semantic search results by fetching titles from a dedicated service for more accurate and consistent information. * **Enhancements** * Enhanced integration between chat and document display features, ensuring configuration and services are consistently passed through chat components for better user experience. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Co-authored-by: Wu Yue <akumatus@gmail.com>
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
|||||||
EdgelessEditorActions,
|
EdgelessEditorActions,
|
||||||
PageEditorActions,
|
PageEditorActions,
|
||||||
} from '../../_common/chat-actions-handle';
|
} from '../../_common/chat-actions-handle';
|
||||||
|
import type { DocDisplayConfig } from '../../components/ai-chat-chips';
|
||||||
import {
|
import {
|
||||||
type ChatMessage,
|
type ChatMessage,
|
||||||
type ChatStatus,
|
type ChatStatus,
|
||||||
@@ -82,6 +83,9 @@ export class ChatMessageAssistant extends WithDisposable(ShadowlessElement) {
|
|||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
accessor independentMode: boolean | undefined;
|
accessor independentMode: boolean | undefined;
|
||||||
|
|
||||||
|
@property({ attribute: false })
|
||||||
|
accessor docDisplayService!: DocDisplayConfig;
|
||||||
|
|
||||||
get state() {
|
get state() {
|
||||||
const { isLast, status } = this;
|
const { isLast, status } = this;
|
||||||
return isLast
|
return isLast
|
||||||
@@ -141,6 +145,7 @@ export class ChatMessageAssistant extends WithDisposable(ShadowlessElement) {
|
|||||||
.affineFeatureFlagService=${this.affineFeatureFlagService}
|
.affineFeatureFlagService=${this.affineFeatureFlagService}
|
||||||
.notificationService=${this.notificationService}
|
.notificationService=${this.notificationService}
|
||||||
.theme=${this.affineThemeService.appTheme.themeSignal}
|
.theme=${this.affineThemeService.appTheme.themeSignal}
|
||||||
|
.docDisplayService=${this.docDisplayService}
|
||||||
></chat-content-stream-objects>`;
|
></chat-content-stream-objects>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -417,6 +417,7 @@ export class AIChatContent extends SignalWatcher(
|
|||||||
.width=${this.width}
|
.width=${this.width}
|
||||||
.independentMode=${this.independentMode}
|
.independentMode=${this.independentMode}
|
||||||
.messages=${this.messages}
|
.messages=${this.messages}
|
||||||
|
.docDisplayService=${this.docDisplayConfig}
|
||||||
></ai-chat-messages>
|
></ai-chat-messages>
|
||||||
<ai-chat-composer
|
<ai-chat-composer
|
||||||
style=${styleMap({
|
style=${styleMap({
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import { AffineIcon } from '../../_common/icons';
|
|||||||
import { AIPreloadConfig } from '../../chat-panel/preload-config';
|
import { AIPreloadConfig } from '../../chat-panel/preload-config';
|
||||||
import { type AIError, AIProvider, UnauthorizedError } from '../../provider';
|
import { type AIError, AIProvider, UnauthorizedError } from '../../provider';
|
||||||
import { mergeStreamObjects } from '../../utils/stream-objects';
|
import { mergeStreamObjects } from '../../utils/stream-objects';
|
||||||
|
import type { DocDisplayConfig } from '../ai-chat-chips';
|
||||||
import { type ChatContextValue } from '../ai-chat-content/type';
|
import { type ChatContextValue } from '../ai-chat-content/type';
|
||||||
import type {
|
import type {
|
||||||
AINetworkSearchConfig,
|
AINetworkSearchConfig,
|
||||||
@@ -202,6 +203,9 @@ export class AIChatMessages extends WithDisposable(ShadowlessElement) {
|
|||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
accessor width: Signal<number | undefined> | undefined;
|
accessor width: Signal<number | undefined> | undefined;
|
||||||
|
|
||||||
|
@property({ attribute: false })
|
||||||
|
accessor docDisplayService!: DocDisplayConfig;
|
||||||
|
|
||||||
@query('.chat-panel-messages-container')
|
@query('.chat-panel-messages-container')
|
||||||
accessor messagesContainer: HTMLDivElement | null = null;
|
accessor messagesContainer: HTMLDivElement | null = null;
|
||||||
|
|
||||||
@@ -328,6 +332,7 @@ export class AIChatMessages extends WithDisposable(ShadowlessElement) {
|
|||||||
.retry=${() => this.retry()}
|
.retry=${() => this.retry()}
|
||||||
.width=${this.width}
|
.width=${this.width}
|
||||||
.independentMode=${this.independentMode}
|
.independentMode=${this.independentMode}
|
||||||
|
.docDisplayService=${this.docDisplayService}
|
||||||
></chat-message-assistant>`;
|
></chat-message-assistant>`;
|
||||||
} else if (isChatAction(item) && this.host) {
|
} else if (isChatAction(item) && this.host) {
|
||||||
return html`<chat-message-action
|
return html`<chat-message-action
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import { css, html, nothing } from 'lit';
|
|||||||
import { property } from 'lit/decorators.js';
|
import { property } from 'lit/decorators.js';
|
||||||
|
|
||||||
import type { AffineAIPanelState } from '../../widgets/ai-panel/type';
|
import type { AffineAIPanelState } from '../../widgets/ai-panel/type';
|
||||||
|
import type { DocDisplayConfig } from '../ai-chat-chips';
|
||||||
import type { StreamObject } from '../ai-chat-messages';
|
import type { StreamObject } from '../ai-chat-messages';
|
||||||
|
|
||||||
export class ChatContentStreamObjects extends WithDisposable(
|
export class ChatContentStreamObjects extends WithDisposable(
|
||||||
@@ -54,6 +55,9 @@ export class ChatContentStreamObjects extends WithDisposable(
|
|||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
accessor notificationService!: NotificationService;
|
accessor notificationService!: NotificationService;
|
||||||
|
|
||||||
|
@property({ attribute: false })
|
||||||
|
accessor docDisplayService!: DocDisplayConfig;
|
||||||
|
|
||||||
private renderToolCall(streamObject: StreamObject) {
|
private renderToolCall(streamObject: StreamObject) {
|
||||||
if (streamObject.type !== 'tool-call') {
|
if (streamObject.type !== 'tool-call') {
|
||||||
return nothing;
|
return nothing;
|
||||||
@@ -178,6 +182,7 @@ export class ChatContentStreamObjects extends WithDisposable(
|
|||||||
return html`<doc-semantic-search-result
|
return html`<doc-semantic-search-result
|
||||||
.data=${streamObject}
|
.data=${streamObject}
|
||||||
.width=${this.width}
|
.width=${this.width}
|
||||||
|
.docDisplayService=${this.docDisplayService}
|
||||||
></doc-semantic-search-result>`;
|
></doc-semantic-search-result>`;
|
||||||
case 'doc_keyword_search':
|
case 'doc_keyword_search':
|
||||||
return html`<doc-keyword-search-result
|
return html`<doc-keyword-search-result
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import type { Signal } from '@preact/signals-core';
|
|||||||
import { html, nothing } from 'lit';
|
import { html, nothing } from 'lit';
|
||||||
import { property } from 'lit/decorators.js';
|
import { property } from 'lit/decorators.js';
|
||||||
|
|
||||||
|
import type { DocDisplayConfig } from '../ai-chat-chips';
|
||||||
|
|
||||||
interface DocSemanticSearchToolCall {
|
interface DocSemanticSearchToolCall {
|
||||||
type: 'tool-call';
|
type: 'tool-call';
|
||||||
toolCallId: string;
|
toolCallId: string;
|
||||||
@@ -58,6 +60,9 @@ export class DocSemanticSearchResult extends WithDisposable(ShadowlessElement) {
|
|||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
accessor width: Signal<number | undefined> | undefined;
|
accessor width: Signal<number | undefined> | undefined;
|
||||||
|
|
||||||
|
@property({ attribute: false })
|
||||||
|
accessor docDisplayService!: DocDisplayConfig;
|
||||||
|
|
||||||
renderToolCall() {
|
renderToolCall() {
|
||||||
return html`<tool-call-card
|
return html`<tool-call-card
|
||||||
.name=${`Finding semantically related pages for "${this.data.args.query}"`}
|
.name=${`Finding semantically related pages for "${this.data.args.query}"`}
|
||||||
@@ -75,7 +80,10 @@ export class DocSemanticSearchResult extends WithDisposable(ShadowlessElement) {
|
|||||||
.icon=${AiEmbeddingIcon()}
|
.icon=${AiEmbeddingIcon()}
|
||||||
.width=${this.width}
|
.width=${this.width}
|
||||||
.results=${this.data.result
|
.results=${this.data.result
|
||||||
.map(result => parseResultContent(result.content))
|
.map(result => ({
|
||||||
|
...parseResultContent(result.content),
|
||||||
|
title: this.docDisplayService.getTitle(result.docId),
|
||||||
|
}))
|
||||||
.filter(Boolean)}
|
.filter(Boolean)}
|
||||||
></tool-result-card>`;
|
></tool-result-card>`;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user