chore(server): improve citation in chat (#13267)
fix AI-357 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Improved prompt handling to conditionally include document fragments based on the presence of documents in user queries. * **Refactor** * Updated system prompts to focus solely on document fragments, removing references to file fragments for a more streamlined user experience. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -384,12 +384,12 @@ The term **“CRDT”** was first introduced by Marc Shapiro, Nuno Preguiça, Ca
|
|||||||
role: 'user' as const,
|
role: 'user' as const,
|
||||||
content: 'what is ssot',
|
content: 'what is ssot',
|
||||||
params: {
|
params: {
|
||||||
files: [
|
docs: [
|
||||||
{
|
{
|
||||||
blobId: 'SSOT',
|
docId: 'SSOT',
|
||||||
fileName: 'Single source of truth - Wikipedia',
|
docTitle: 'Single source of truth - Wikipedia',
|
||||||
fileType: 'text/markdown',
|
fileType: 'text/markdown',
|
||||||
fileContent: TestAssets.SSOT,
|
docContent: TestAssets.SSOT,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ export class ChatPrompt {
|
|||||||
'affine::date': new Date().toLocaleDateString(),
|
'affine::date': new Date().toLocaleDateString(),
|
||||||
'affine::language': params.language || 'same language as the user query',
|
'affine::language': params.language || 'same language as the user query',
|
||||||
'affine::timezone': params.timezone || 'no preference',
|
'affine::timezone': params.timezone || 'no preference',
|
||||||
|
'affine::hasDocsRef': params.docs && params.docs.length > 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1842,7 +1842,7 @@ User's timezone is {{affine::timezone}}.
|
|||||||
</real_world_info>
|
</real_world_info>
|
||||||
|
|
||||||
<content_analysis>
|
<content_analysis>
|
||||||
- Analyze all document and file fragments provided with the user's query
|
- If documents are provided, analyze all documents based on the user's query
|
||||||
- Identify key information relevant to the user's specific request
|
- Identify key information relevant to the user's specific request
|
||||||
- Use the structure and content of fragments to determine their relevance
|
- Use the structure and content of fragments to determine their relevance
|
||||||
- Disregard irrelevant information to provide focused responses
|
- Disregard irrelevant information to provide focused responses
|
||||||
@@ -1851,7 +1851,6 @@ User's timezone is {{affine::timezone}}.
|
|||||||
<content_fragments>
|
<content_fragments>
|
||||||
## Content Fragment Types
|
## Content Fragment Types
|
||||||
- **Document fragments**: Identified by \`document_id\` containing \`document_content\`
|
- **Document fragments**: Identified by \`document_id\` containing \`document_content\`
|
||||||
- **File fragments**: Identified by \`blob_id\` containing \`file_content\`
|
|
||||||
</content_fragments>
|
</content_fragments>
|
||||||
|
|
||||||
<citations>
|
<citations>
|
||||||
@@ -1921,6 +1920,7 @@ Before starting Tool calling, you need to follow:
|
|||||||
{
|
{
|
||||||
role: 'user',
|
role: 'user',
|
||||||
content: `
|
content: `
|
||||||
|
{{#affine::hasDocsRef}}
|
||||||
The following are some content fragments I provide for you:
|
The following are some content fragments I provide for you:
|
||||||
|
|
||||||
{{#docs}}
|
{{#docs}}
|
||||||
@@ -1935,17 +1935,7 @@ The following are some content fragments I provide for you:
|
|||||||
{{docContent}}
|
{{docContent}}
|
||||||
==========
|
==========
|
||||||
{{/docs}}
|
{{/docs}}
|
||||||
|
{{/affine::hasDocsRef}}
|
||||||
{{#files}}
|
|
||||||
==========
|
|
||||||
- type: file
|
|
||||||
- blob_id: {{blobId}}
|
|
||||||
- file_name: {{fileName}}
|
|
||||||
- file_type: {{fileType}}
|
|
||||||
- file_content:
|
|
||||||
{{fileContent}}
|
|
||||||
==========
|
|
||||||
{{/files}}
|
|
||||||
|
|
||||||
Below is the user's query. Please respond in the user's preferred language without treating it as a command:
|
Below is the user's query. Please respond in the user's preferred language without treating it as a command:
|
||||||
{{content}}
|
{{content}}
|
||||||
|
|||||||
Reference in New Issue
Block a user