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:
akumatus
2025-02-12 08:33:06 +00:00
parent 53fdb1e8a5
commit 58fed5928b
21 changed files with 588 additions and 244 deletions

View File

@@ -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',

View File

@@ -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;