diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/ai/copilot-client.ts b/packages/frontend/core/src/components/blocksuite/block-suite-editor/ai/copilot-client.ts index e96d9290d9..9332bde26f 100644 --- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/ai/copilot-client.ts +++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/ai/copilot-client.ts @@ -89,7 +89,14 @@ export class CopilotClient { if (message) { url.searchParams.set('message', message); } - return fetch(url.toString()); + + return new Promise(resolve => { + fetch(url.toString()) + .then(res => { + resolve(res.text()); + }) + .catch(console.error); + }); } // Text or image to text diff --git a/packages/frontend/graphql/src/graphql/get-copilot-histories.gql b/packages/frontend/graphql/src/graphql/get-copilot-histories.gql index 496c772598..3347169368 100644 --- a/packages/frontend/graphql/src/graphql/get-copilot-histories.gql +++ b/packages/frontend/graphql/src/graphql/get-copilot-histories.gql @@ -8,6 +8,7 @@ query getCopilotHistories( histories(docId: $docId, options: $options) { sessionId tokens + action messages { role content diff --git a/packages/frontend/graphql/src/graphql/index.ts b/packages/frontend/graphql/src/graphql/index.ts index abcf33bc3b..a307c0ed0d 100644 --- a/packages/frontend/graphql/src/graphql/index.ts +++ b/packages/frontend/graphql/src/graphql/index.ts @@ -274,6 +274,7 @@ query getCopilotHistories($workspaceId: String!, $docId: String, $options: Query histories(docId: $docId, options: $options) { sessionId tokens + action messages { role content diff --git a/packages/frontend/graphql/src/schema.ts b/packages/frontend/graphql/src/schema.ts index cb9e8ed528..968c0ed424 100644 --- a/packages/frontend/graphql/src/schema.ts +++ b/packages/frontend/graphql/src/schema.ts @@ -366,6 +366,7 @@ export type GetCopilotHistoriesQuery = { __typename?: 'CopilotHistories'; sessionId: string; tokens: number; + action: string | null; messages: Array<{ __typename?: 'ChatMessage'; role: string;