feat(server): impl context model (#11027)

This commit is contained in:
darkskygit
2025-03-20 10:24:28 +00:00
parent c1ec17ccba
commit b24376a9f7
8 changed files with 555 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
import { Injectable } from '@nestjs/common';
import { BaseModel } from './base';
interface ChatSessionState {
sessionId: string;
workspaceId: string;
docId: string;
// connect ids
userId: string;
promptName: string;
}
// TODO(@darkskygit): not ready to replace business codes yet, just for test
@Injectable()
export class CopilotSessionModel extends BaseModel {
async create(state: ChatSessionState) {
const row = await this.db.aiSession.create({
data: {
id: state.sessionId,
workspaceId: state.workspaceId,
docId: state.docId,
// connect
userId: state.userId,
promptName: state.promptName,
},
});
return row;
}
async createPrompt(name: string, model: string) {
await this.db.aiPrompt.create({
data: { name, model },
});
}
}