mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-29 08:09:52 +08:00
feat(server): improve context metadata & matching (#12064)
fix AI-20 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced file metadata with MIME type, blob ID, and file name across context and workspace, now visible in UI and API. - Added workspace-level matching for files and documents with configurable thresholds and workspace scoping in search queries. - Introduced a new error type and user-friendly messaging for global workspace context matching failures. - **Bug Fixes** - Improved consistent handling of file MIME types and nullable context IDs for accurate metadata. - **Documentation** - Updated GraphQL schema, queries, and mutations to include new metadata fields, optional parameters, and error types. - **Style** - Added new localization strings for global context matching error messages. - **Tests** - Extended test coverage with new and updated snapshot tests for metadata and matching logic. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -6,6 +6,17 @@ Generated by [AVA](https://avajs.dev).
|
||||
|
||||
## should insert embedding by doc id
|
||||
|
||||
> should match file embedding
|
||||
|
||||
[
|
||||
{
|
||||
chunk: 0,
|
||||
content: 'content',
|
||||
distance: 0,
|
||||
fileId: 'file-id',
|
||||
},
|
||||
]
|
||||
|
||||
> should return empty array when embedding deleted
|
||||
|
||||
[]
|
||||
|
||||
BIN
Binary file not shown.
+15
@@ -54,3 +54,18 @@ Generated by [AVA](https://avajs.dev).
|
||||
docId: 'new_doc',
|
||||
},
|
||||
]
|
||||
|
||||
## should insert and search embedding
|
||||
|
||||
> should match workspace file embedding
|
||||
|
||||
[
|
||||
{
|
||||
blobId: 'blob1',
|
||||
chunk: 0,
|
||||
content: 'content',
|
||||
distance: 0,
|
||||
mimeType: 'text/plain',
|
||||
name: 'file1',
|
||||
},
|
||||
]
|
||||
|
||||
BIN
Binary file not shown.
@@ -111,8 +111,7 @@ test('should insert embedding by doc id', async t => {
|
||||
1,
|
||||
1
|
||||
);
|
||||
t.is(ret.length, 1);
|
||||
t.is(ret[0].content, 'content');
|
||||
t.snapshot(ret, 'should match file embedding');
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@@ -107,6 +107,7 @@ test('should insert and search embedding', async t => {
|
||||
{
|
||||
const { fileId } = await t.context.copilotWorkspace.addFile(workspace.id, {
|
||||
fileName: 'file1',
|
||||
blobId: 'blob1',
|
||||
mimeType: 'text/plain',
|
||||
size: 1,
|
||||
});
|
||||
@@ -129,8 +130,10 @@ test('should insert and search embedding', async t => {
|
||||
1,
|
||||
1
|
||||
);
|
||||
t.is(ret.length, 1);
|
||||
t.is(ret[0].content, 'content');
|
||||
t.snapshot(
|
||||
cleanObject(ret, ['fileId']),
|
||||
'should match workspace file embedding'
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user