mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-21 08:17:10 +08:00
fix(server): missing embedding search (#13401)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Enhanced search functionality to include results from additional "blob" data sources, providing more comprehensive search results. * **Bug Fixes** * Improved messaging to ensure "No results found" is only shown when no relevant results exist across all data sources. * **Tests** * Updated test cases to reflect new keyword contexts, improving validation accuracy for search-related features. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -232,7 +232,7 @@ export class CopilotContextService implements OnApplicationBootstrap {
|
||||
const embedding = await this.embeddingClient.getEmbedding(content, signal);
|
||||
if (!embedding) return [];
|
||||
|
||||
const [fileChunks, workspaceChunks, scopedWorkspaceChunks] =
|
||||
const [fileChunks, blobChunks, workspaceChunks, scopedWorkspaceChunks] =
|
||||
await Promise.all([
|
||||
this.models.copilotWorkspace.matchFileEmbedding(
|
||||
workspaceId,
|
||||
@@ -240,6 +240,12 @@ export class CopilotContextService implements OnApplicationBootstrap {
|
||||
topK * 2,
|
||||
threshold
|
||||
),
|
||||
this.models.copilotWorkspace.matchBlobEmbedding(
|
||||
workspaceId,
|
||||
embedding,
|
||||
topK * 2,
|
||||
threshold
|
||||
),
|
||||
this.models.copilotContext.matchWorkspaceEmbedding(
|
||||
embedding,
|
||||
workspaceId,
|
||||
@@ -259,6 +265,7 @@ export class CopilotContextService implements OnApplicationBootstrap {
|
||||
|
||||
if (
|
||||
!fileChunks.length &&
|
||||
!blobChunks.length &&
|
||||
!workspaceChunks.length &&
|
||||
!scopedWorkspaceChunks?.length
|
||||
) {
|
||||
@@ -267,7 +274,12 @@ export class CopilotContextService implements OnApplicationBootstrap {
|
||||
|
||||
return await this.embeddingClient.reRank(
|
||||
content,
|
||||
[...fileChunks, ...workspaceChunks, ...(scopedWorkspaceChunks || [])],
|
||||
[
|
||||
...fileChunks,
|
||||
...blobChunks,
|
||||
...workspaceChunks,
|
||||
...(scopedWorkspaceChunks || []),
|
||||
],
|
||||
topK,
|
||||
signal
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user