mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-30 00:29:46 +08:00
feat(server): context awareness for copilot (#9611)
fix PD-2167 fix PD-2169 fix PD-2190
This commit is contained in:
@@ -250,7 +250,7 @@ declare global {
|
||||
addContextDoc: (options: {
|
||||
contextId: string;
|
||||
docId: string;
|
||||
}) => Promise<Array<{ id: string }>>;
|
||||
}) => Promise<{ id: string; createdAt: number }>;
|
||||
removeContextDoc: (options: {
|
||||
contextId: string;
|
||||
docId: string;
|
||||
@@ -268,7 +268,11 @@ declare global {
|
||||
sessionId: string,
|
||||
contextId: string
|
||||
) => Promise<
|
||||
{ docs: CopilotContextDoc[]; files: CopilotContextFile[] } | undefined
|
||||
| {
|
||||
docs: Array<CopilotContextDoc>;
|
||||
files: Array<CopilotContextFile>;
|
||||
}
|
||||
| undefined
|
||||
>;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
type GraphQLQuery,
|
||||
listContextDocsAndFilesQuery,
|
||||
listContextQuery,
|
||||
matchContextQuery,
|
||||
type QueryOptions,
|
||||
type QueryResponse,
|
||||
removeContextDocMutation,
|
||||
@@ -284,6 +285,18 @@ export class CopilotClient {
|
||||
return res.currentUser?.copilot?.contexts?.[0];
|
||||
}
|
||||
|
||||
async matchContext(contextId: string, content: string, limit?: number) {
|
||||
const res = await this.gql({
|
||||
query: matchContextQuery,
|
||||
variables: {
|
||||
contextId,
|
||||
content,
|
||||
limit,
|
||||
},
|
||||
});
|
||||
return res.currentUser?.copilot?.contexts?.[0]?.matchContext;
|
||||
}
|
||||
|
||||
async chatText({
|
||||
sessionId,
|
||||
messageId,
|
||||
|
||||
Reference in New Issue
Block a user