mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-16 17:46:18 +08:00
feat(core): add get session graphql api (#12237)
Close [AI-116](https://linear.app/affine-design/issue/AI-116) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added the ability to retrieve detailed information for a specific Copilot session by its ID, including model metadata and optional models, via the user interface and API. - Session data now includes additional fields such as the model used and a list of optional models. - Enhanced GraphQL queries and UI components to support fetching and displaying these new session details. - **Improvements** - Session lists now provide richer information, including model details, for each session. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -307,9 +307,7 @@ export class ChatSessionService {
|
||||
});
|
||||
}
|
||||
|
||||
private async getSession(
|
||||
sessionId: string
|
||||
): Promise<ChatSessionState | undefined> {
|
||||
async getSession(sessionId: string): Promise<ChatSessionState | undefined> {
|
||||
return await this.db.aiSession
|
||||
.findUnique({
|
||||
where: { id: sessionId, deletedAt: null },
|
||||
@@ -414,13 +412,7 @@ export class ChatSessionService {
|
||||
workspaceId: string,
|
||||
docId?: string,
|
||||
options?: { action?: boolean }
|
||||
): Promise<
|
||||
Array<{
|
||||
id: string;
|
||||
parentSessionId: string | null;
|
||||
promptName: string;
|
||||
}>
|
||||
> {
|
||||
): Promise<Omit<ChatSessionState, 'messages'>[]> {
|
||||
return await this.db.aiSession
|
||||
.findMany({
|
||||
where: {
|
||||
@@ -434,17 +426,31 @@ export class ChatSessionService {
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
userId: true,
|
||||
workspaceId: true,
|
||||
docId: true,
|
||||
parentSessionId: true,
|
||||
promptName: true,
|
||||
},
|
||||
})
|
||||
.then(sessions =>
|
||||
sessions.map(({ id, parentSessionId, promptName }) => ({
|
||||
id,
|
||||
parentSessionId: parentSessionId || null,
|
||||
promptName,
|
||||
}))
|
||||
);
|
||||
.then(sessions => {
|
||||
return Promise.all(
|
||||
sessions.map(async session => {
|
||||
const prompt = await this.prompt.get(session.promptName);
|
||||
if (!prompt)
|
||||
throw new CopilotPromptNotFound({ name: session.promptName });
|
||||
|
||||
return {
|
||||
sessionId: session.id,
|
||||
userId: session.userId,
|
||||
workspaceId: session.workspaceId,
|
||||
docId: session.docId,
|
||||
parentSessionId: session.parentSessionId,
|
||||
prompt,
|
||||
};
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
async listHistories(
|
||||
|
||||
Reference in New Issue
Block a user