mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
feat(core): move context docs to user prompt (#10162)
Fix issue [BS-2522](https://linear.app/affine-design/issue/BS-2522). ### Why make this change? If the user data contains illegal content, carrying the user data in the system prompt will run the risk of having the account banned. ### What Changed? - Move the `Context Documents` to the user prompt. - Add `withPrompt` in `QueryChatHistoriesInput` options. - Get chat histories without prompt messages. - Omit document context when saving messages to the `aiSessionMessage` db.
This commit is contained in:
@@ -2,6 +2,7 @@ import { AIProvider } from '@affine/core/blocksuite/presets/ai';
|
||||
import { toggleGeneralAIOnboarding } from '@affine/core/components/affine/ai-onboarding/apis';
|
||||
import type { GlobalDialogService } from '@affine/core/modules/dialogs';
|
||||
import {
|
||||
type ChatHistoryOrder,
|
||||
type getCopilotHistoriesQuery,
|
||||
type RequestOptions,
|
||||
} from '@affine/graphql';
|
||||
@@ -469,15 +470,17 @@ Could you make a new website based on these notes and send back just the html fi
|
||||
return (
|
||||
(await client.getHistories(workspaceId, docId, {
|
||||
action: true,
|
||||
withPrompt: true,
|
||||
})) ?? []
|
||||
);
|
||||
},
|
||||
chats: async (
|
||||
workspaceId: string,
|
||||
docId?: string,
|
||||
options?: RequestOptions<
|
||||
typeof getCopilotHistoriesQuery
|
||||
>['variables']['options']
|
||||
options?: {
|
||||
sessionId?: string;
|
||||
messageOrder?: ChatHistoryOrder;
|
||||
}
|
||||
): Promise<BlockSuitePresets.AIHistory[]> => {
|
||||
// @ts-expect-error - 'action' is missing in server impl
|
||||
return (await client.getHistories(workspaceId, docId, options)) ?? [];
|
||||
|
||||
Reference in New Issue
Block a user