mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-17 06:16:59 +08:00
feat: add doc copilot context api (#10103)
### What Changed? - Add graphql APIs. - Provide context and session service in `AIProvider`. - Rename the state from `embedding` to `processing`. - Reafctor front-end session create, update and save logic. Persist the document selected by the user: [录屏2025-02-08 11.04.40.mov <span class="graphite__hidden">(uploaded via Graphite)</span> <img class="graphite__hidden" src="https://app.graphite.dev/api/v1/graphite/video/thumbnail/sJGviKxfE3Ap685cl5bj/195a85f2-43c4-4e49-88d9-6b5fc4f235ca.mov" />](https://app.graphite.dev/media/video/sJGviKxfE3Ap685cl5bj/195a85f2-43c4-4e49-88d9-6b5fc4f235ca.mov)
This commit is contained in:
@@ -193,11 +193,31 @@ export const removeContextDocMutation = {
|
||||
definitionName: 'removeContextDoc',
|
||||
containsFile: false,
|
||||
query: `
|
||||
mutation removeContextDoc($options: RemoveContextFileInput!) {
|
||||
mutation removeContextDoc($options: RemoveContextDocInput!) {
|
||||
removeContextDoc(options: $options)
|
||||
}`,
|
||||
};
|
||||
|
||||
export const listContextDocsAndFilesQuery = {
|
||||
id: 'listContextDocsAndFilesQuery' as const,
|
||||
operationName: 'listContextDocsAndFiles',
|
||||
definitionName: 'currentUser',
|
||||
containsFile: false,
|
||||
query: `
|
||||
query listContextDocsAndFiles($workspaceId: String!, $sessionId: String!, $contextId: String!) {
|
||||
currentUser {
|
||||
copilot(workspaceId: $workspaceId) {
|
||||
contexts(sessionId: $sessionId, contextId: $contextId) {
|
||||
docs {
|
||||
id
|
||||
createdAt
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}`,
|
||||
};
|
||||
|
||||
export const listContextQuery = {
|
||||
id: 'listContextQuery' as const,
|
||||
operationName: 'listContext',
|
||||
|
||||
@@ -42,6 +42,11 @@ export interface AddContextDocInput {
|
||||
docId: Scalars['String']['input'];
|
||||
}
|
||||
|
||||
export interface RemoveContextDocInput {
|
||||
contextId: Scalars['String']['input'];
|
||||
docId: Scalars['String']['input'];
|
||||
}
|
||||
|
||||
export interface AlreadyInSpaceDataType {
|
||||
__typename?: 'AlreadyInSpaceDataType';
|
||||
spaceId: Scalars['String']['output'];
|
||||
@@ -1013,7 +1018,7 @@ export interface MutationReleaseDeletedBlobsArgs {
|
||||
}
|
||||
|
||||
export interface MutationRemoveContextDocArgs {
|
||||
options: RemoveContextFileInput;
|
||||
options: RemoveContextDocInput;
|
||||
}
|
||||
|
||||
export interface MutationRemoveWorkspaceFeatureArgs {
|
||||
@@ -1310,11 +1315,6 @@ export interface RemoveAvatar {
|
||||
success: Scalars['Boolean']['output'];
|
||||
}
|
||||
|
||||
export interface RemoveContextFileInput {
|
||||
contextId: Scalars['String']['input'];
|
||||
fileId: Scalars['String']['input'];
|
||||
}
|
||||
|
||||
export interface RevokeDocUserRoleInput {
|
||||
docId: Scalars['String']['input'];
|
||||
userId: Scalars['String']['input'];
|
||||
@@ -1952,28 +1952,56 @@ export type AddContextDocMutationVariables = Exact<{
|
||||
options: AddContextDocInput;
|
||||
}>;
|
||||
|
||||
export type RemoveContextDocMutationVariables = Exact<{
|
||||
options: RemoveContextDocInput;
|
||||
}>;
|
||||
|
||||
export type AddContextDocMutation = {
|
||||
__typename?: 'Mutation';
|
||||
addContextDoc: Array<{
|
||||
__typename?: 'CopilotContextListItem';
|
||||
id: string;
|
||||
createdAt: number;
|
||||
name: string | null;
|
||||
chunkSize: number | null;
|
||||
status: ContextFileStatus | null;
|
||||
blobId: string | null;
|
||||
}>;
|
||||
};
|
||||
|
||||
export type RemoveContextDocMutationVariables = Exact<{
|
||||
options: RemoveContextFileInput;
|
||||
}>;
|
||||
|
||||
export type RemoveContextDocMutation = {
|
||||
__typename?: 'Mutation';
|
||||
removeContextDoc: boolean;
|
||||
};
|
||||
|
||||
export type ListContextDocsAndFilesQueryVariables = Exact<{
|
||||
workspaceId: Scalars['String']['input'];
|
||||
sessionId: Scalars['String']['input'];
|
||||
contextId: Scalars['String']['input'];
|
||||
}>;
|
||||
|
||||
export type ListContextDocsAndFilesQuery = {
|
||||
__typename?: 'Query';
|
||||
currentUser: {
|
||||
__typename?: 'UserType';
|
||||
copilot: {
|
||||
__typename?: 'Copilot';
|
||||
contexts: Array<{
|
||||
__typename?: 'CopilotContext';
|
||||
docs: Array<{
|
||||
__typename?: 'CopilotContextDoc';
|
||||
id: string;
|
||||
createdAt: number;
|
||||
}>;
|
||||
files: Array<{
|
||||
__typename?: 'CopilotContextFile';
|
||||
id: string;
|
||||
name: string;
|
||||
blobId: string;
|
||||
chunkSize: number;
|
||||
status: ContextFileStatus;
|
||||
createdAt: number;
|
||||
}>;
|
||||
}>;
|
||||
};
|
||||
} | null;
|
||||
};
|
||||
|
||||
export type ListContextQueryVariables = Exact<{
|
||||
workspaceId: Scalars['String']['input'];
|
||||
sessionId: Scalars['String']['input'];
|
||||
@@ -3372,6 +3400,11 @@ export type Queries =
|
||||
variables: ListBlobsQueryVariables;
|
||||
response: ListBlobsQuery;
|
||||
}
|
||||
| {
|
||||
name: 'listContextDocsAndFilesQuery';
|
||||
variables: ListContextDocsAndFilesQueryVariables;
|
||||
response: ListContextDocsAndFilesQuery;
|
||||
}
|
||||
| {
|
||||
name: 'listContextQuery';
|
||||
variables: ListContextQueryVariables;
|
||||
|
||||
Reference in New Issue
Block a user