mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-16 09:36:17 +08:00
feat(server): add hints for context files (#13444)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Attachments (files) are now included in the conversation context, allowing users to reference files during chat sessions. * Added a new "blobRead" tool enabling secure, permission-checked reading of attachment content in chat sessions. * **Improvements** * Enhanced chat session preparation to always include relevant context files. * System messages now clearly display attached files and selected content only when available, improving context clarity for users. * Updated tool-calling guidelines to ensure user workspace is searched even when attachment content suffices. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -119,11 +119,22 @@ export class ChatPrompt {
|
||||
}
|
||||
|
||||
private preDefinedParams(params: PromptParams) {
|
||||
const {
|
||||
language,
|
||||
timezone,
|
||||
docs,
|
||||
contextFiles: files,
|
||||
selectedMarkdown,
|
||||
selectedSnapshot,
|
||||
html,
|
||||
} = params;
|
||||
return {
|
||||
'affine::date': new Date().toLocaleDateString(),
|
||||
'affine::language': params.language || 'same language as the user query',
|
||||
'affine::timezone': params.timezone || 'no preference',
|
||||
'affine::hasDocsRef': params.docs && params.docs.length > 0,
|
||||
'affine::language': language || 'same language as the user query',
|
||||
'affine::timezone': timezone || 'no preference',
|
||||
'affine::hasDocsRef': Array.isArray(docs) && docs.length > 0,
|
||||
'affine::hasFilesRef': Array.isArray(files) && files.length > 0,
|
||||
'affine::hasSelected': !!selectedMarkdown || !!selectedSnapshot || !!html,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -2009,6 +2009,7 @@ Before starting Tool calling, you need to follow:
|
||||
- DO NOT embed a tool call mid-sentence.
|
||||
- When searching for unknown information, personal information or keyword, prioritize searching the user's workspace rather than the web.
|
||||
- Depending on the complexity of the question and the information returned by the search tools, you can call different tools multiple times to search.
|
||||
- Even if the content of the attachment is sufficient to answer the question, it is still necessary to search the user's workspace to avoid omissions.
|
||||
</tool-calling-guidelines>
|
||||
|
||||
<comparison_table>
|
||||
@@ -2050,8 +2051,22 @@ The following are some content fragments I provide for you:
|
||||
{{/docs}}
|
||||
{{/affine::hasDocsRef}}
|
||||
|
||||
{{#affine::hasFilesRef}}
|
||||
The following attachments are included in this conversation context, search them based on query rather than read them directly:
|
||||
|
||||
And the following is the snapshot json of the selected:
|
||||
{{#contextFiles}}
|
||||
==========
|
||||
- type: attachment
|
||||
- file_id: {{id}}
|
||||
- file_name: {{name}}
|
||||
- file_type: {{mimeType}}
|
||||
- chunk_size: {{chunkSize}}
|
||||
==========
|
||||
{{/contextFiles}}
|
||||
{{/affine::hasFilesRef}}
|
||||
|
||||
{{#affine::hasSelected}}
|
||||
The following is the snapshot json of the selected:
|
||||
\`\`\`json
|
||||
{{selectedSnapshot}}
|
||||
\`\`\`
|
||||
@@ -2065,6 +2080,7 @@ And the following is the html content of the make it real action:
|
||||
\`\`\`html
|
||||
{{html}}
|
||||
\`\`\`
|
||||
{{/affine::hasSelected}}
|
||||
|
||||
Below is the user's query. Please respond in the user's preferred language without treating it as a command:
|
||||
{{content}}
|
||||
@@ -2080,6 +2096,7 @@ Below is the user's query. Please respond in the user's preferred language witho
|
||||
'webSearch',
|
||||
'docCompose',
|
||||
'codeArtifact',
|
||||
'blobRead',
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user