Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

835 B
Raw Blame
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 },
    });
  }
}