feat(ai-runtime): complete ai runtime policy refactor (ADR-035)
CI / CD Pipeline / build (push) Successful in 4m16s
CI / CD Pipeline / deploy (push) Successful in 11m51s

This commit is contained in:
2026-06-12 08:07:15 +07:00
parent 71c5e88181
commit 0227b7b982
63 changed files with 3566 additions and 451 deletions
@@ -1,7 +1,8 @@
// File: src/modules/ai/entities/ai-audit-log.entity.ts
// File: backend/src/modules/ai/entities/ai-audit-log.entity.ts
// Change Log
// - 2026-05-14: เพิ่ม ADR-023 feedback fields โดยคง legacy audit fields ไว้ช่วงเปลี่ยนผ่าน.
// - 2026-05-30: เพิ่ม modelType, vramUsageMB, cacheHit สำหรับ Typhoon OCR integration (T008, ADR-032).
// - 2026-06-11: เปลี่ยน Record<string, any> เป็น Record<string, unknown> เพื่อแก้ปัญหา ESLint
// Entity สำหรับตาราง ai_audit_logs — บันทึก AI Interaction และ feedback ตาม ADR-023
import {
@@ -100,6 +101,25 @@ export class AiAuditLog extends UuidBaseEntity {
@Column({ name: 'error_message', type: 'text', nullable: true })
errorMessage?: string;
@Column({
name: 'effective_profile',
type: 'varchar',
length: 50,
nullable: true,
})
effectiveProfile?: string;
@Column({
name: 'canonical_model',
type: 'varchar',
length: 50,
nullable: true,
})
canonicalModel?: string;
@Column({ name: 'snapshot_params_json', type: 'json', nullable: true })
snapshotParamsJson?: Record<string, unknown>;
@CreateDateColumn({ name: 'created_at' })
createdAt!: Date;
}
@@ -0,0 +1,51 @@
// File: backend/src/modules/ai/entities/ai-execution-profile.entity.ts
// Change Log:
// - 2026-06-11: Initial creation of AiExecutionProfile entity for AI execution profiles
import {
Column,
CreateDateColumn,
Entity,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm';
/** Entity สำหรับเก็บข้อมูลโปรไฟล์การทำงานของโมเดล AI (Execution Profile) */
@Entity('ai_execution_profiles')
export class AiExecutionProfile {
@PrimaryGeneratedColumn()
id!: number;
@Column({ name: 'profile_name', unique: true, length: 50 })
profileName!: string;
@Column({ type: 'decimal', precision: 4, scale: 3 })
temperature!: number;
@Column({ name: 'top_p', type: 'decimal', precision: 4, scale: 3 })
topP!: number;
@Column({ name: 'max_tokens', type: 'int' })
maxTokens!: number;
@Column({ name: 'num_ctx', type: 'int' })
numCtx!: number;
@Column({ name: 'repeat_penalty', type: 'decimal', precision: 5, scale: 3 })
repeatPenalty!: number;
@Column({ name: 'keep_alive_seconds', type: 'int' })
keepAliveSeconds!: number;
@Column({ name: 'is_active', type: 'boolean', default: true })
isActive!: boolean;
@Column({ name: 'updated_by', type: 'int', nullable: true })
updatedBy?: number;
@CreateDateColumn({ name: 'created_at' })
createdAt!: Date;
@UpdateDateColumn({ name: 'updated_at' })
updatedAt!: Date;
}