mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
feat(core): cite source documents in the AI answer (#9863)
Support issue [BS-2424](https://linear.app/affine-design/issue/BS-2424). ### What changed? - Add relevant document prompt templates. - Add citation rules in system prompts. - Change message `params` type to `Record<string, any>` - Add unit test. <div class='graphite__hidden'> <div>🎥 Video uploaded on Graphite:</div> <a href="https://app.graphite.dev/media/video/sJGviKxfE3Ap685cl5bj/ec24e664-039e-4fab-bd26-b3312f011daf.mov"> <img src="https://app.graphite.dev/api/v1/graphite/video/thumbnail/sJGviKxfE3Ap685cl5bj/ec24e664-039e-4fab-bd26-b3312f011daf.mov"> </a> </div> <video src="https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/sJGviKxfE3Ap685cl5bj/ec24e664-039e-4fab-bd26-b3312f011daf.mov">录屏2025-01-23 10.40.38.mov</video>
This commit is contained in:
@@ -773,14 +773,17 @@ test.describe('chat with doc', () => {
|
||||
// oxlint-disable-next-line unicorn/prefer-dom-node-dataset
|
||||
expect(await chip.getAttribute('data-state')).toBe('success');
|
||||
|
||||
await makeChat(page, 'summarize');
|
||||
await typeChatSequentially(page, 'What is AFFiNE AI?');
|
||||
await page.keyboard.press('Enter');
|
||||
const history = await collectChat(page);
|
||||
expect(history[0]).toEqual({
|
||||
name: 'You',
|
||||
content:
|
||||
'AFFiNE AI is an assistant with the ability to create well-structured outlines for any given content.\nsummarize',
|
||||
content: 'What is AFFiNE AI?',
|
||||
});
|
||||
expect(history[1].name).toBe('AFFiNE AI');
|
||||
expect(
|
||||
await page.locator('chat-panel affine-footnote-node').count()
|
||||
).toBeGreaterThan(0);
|
||||
await clearChat(page);
|
||||
expect((await collectChat(page)).length).toBe(0);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user