| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- import {
- Entity,
- PrimaryGeneratedColumn,
- Column,
- CreateDateColumn,
- ManyToOne,
- JoinColumn,
- } from 'typeorm';
- import { SearchHistory } from './search-history.entity';
- import { Tenant } from '../tenant/tenant.entity';
- @Entity('chat_messages')
- export class ChatMessage {
- @PrimaryGeneratedColumn('uuid')
- id: string;
- @Column({ name: 'search_history_id' })
- searchHistoryId: string;
- @Column({ name: 'tenant_id', nullable: true, type: 'text' })
- tenantId: string;
- @Column()
- role: 'user' | 'assistant';
- @Column('text')
- content: string;
- @Column({ nullable: true })
- sources?: string; // JSON string
- @CreateDateColumn({ name: 'created_at' })
- createdAt: Date;
- @ManyToOne(() => SearchHistory, (history) => history.messages)
- @JoinColumn({ name: 'search_history_id' })
- searchHistory: SearchHistory;
- @ManyToOne(() => Tenant)
- @JoinColumn({ name: 'tenant_id' })
- tenant: Tenant;
- }
|