690519:1631 224 to 226 AI #01
This commit is contained in:
+59
@@ -0,0 +1,59 @@
|
||||
// File: src/modules/ai/intent-classifier/interfaces/classification-result.interface.ts
|
||||
// Change Log
|
||||
// - 2026-05-19: สร้าง interfaces สำหรับ Intent Classification System (ADR-024).
|
||||
|
||||
/** วิธีที่ใช้ในการจำแนก Intent */
|
||||
export type ClassificationMethod =
|
||||
| 'pattern'
|
||||
| 'llm_fallback'
|
||||
| 'semaphore_overflow'
|
||||
| 'llm_error';
|
||||
|
||||
/**
|
||||
* ผลลัพธ์การจำแนก Intent
|
||||
* method: วิธีที่ใช้จำแนก (pattern match หรือ LLM fallback)
|
||||
*/
|
||||
export interface ClassificationResult {
|
||||
/** Intent code ที่จำแนกได้ เช่น 'SUMMARIZE_DOCUMENT', 'GET_RFA' */
|
||||
intentCode: string;
|
||||
/** ความมั่นใจ 0.0-1.0 (1.0 = pattern match, < 1.0 = LLM) */
|
||||
confidence: number;
|
||||
/** วิธีที่ใช้จำแนก */
|
||||
method: ClassificationMethod;
|
||||
/** Parameters ที่สกัดได้จาก query (optional) */
|
||||
params?: Record<string, unknown>;
|
||||
/** เวลาที่ใช้ทั้งหมด (milliseconds) */
|
||||
latencyMs: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Input สำหรับการจำแนก Intent
|
||||
*/
|
||||
export interface ClassificationInput {
|
||||
/** คำถามจาก user (trim แล้ว, max 200 chars) */
|
||||
query: string;
|
||||
/** Context project UUID (optional) */
|
||||
projectPublicId?: string;
|
||||
/** Context user UUID (optional) */
|
||||
userPublicId?: string;
|
||||
/** Document ที่เปิดอยู่ UUID (optional) */
|
||||
currentDocumentId?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* ข้อมูล Pattern ที่ใช้ใน matching (flatten จาก DB สำหรับ cache)
|
||||
*/
|
||||
export interface CachedPattern {
|
||||
/** Public UUID ของ pattern */
|
||||
publicId: string;
|
||||
/** Intent code ที่ pattern นี้เป็นของ */
|
||||
intentCode: string;
|
||||
/** ภาษา: th, en, any */
|
||||
language: 'th' | 'en' | 'any';
|
||||
/** ชนิด pattern */
|
||||
patternType: 'keyword' | 'regex';
|
||||
/** ค่า pattern (keyword string หรือ regex string) */
|
||||
patternValue: string;
|
||||
/** ลำดับการตรวจสอบ (ต่ำ = สำคัญกว่า) */
|
||||
priority: number;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// File: src/modules/ai/intent-classifier/interfaces/intent-category.enum.ts
|
||||
// Change Log
|
||||
// - 2026-05-19: สร้าง Enum สำหรับ Intent Category, Pattern Type, Pattern Language (ADR-024).
|
||||
|
||||
/** หมวดหมู่ของ Intent */
|
||||
export enum IntentCategory {
|
||||
READ = 'read', // ดึงข้อมูล: RAG_QUERY, GET_RFA, etc.
|
||||
SUGGEST = 'suggest', // แนะนำ: SUGGEST_METADATA, SUGGEST_ACTION
|
||||
UTILITY = 'utility', // อื่น ๆ: FALLBACK
|
||||
}
|
||||
|
||||
/** ชนิดของ Pattern ที่ใช้ในการ match */
|
||||
export enum PatternType {
|
||||
KEYWORD = 'keyword', // case-insensitive string includes()
|
||||
REGEX = 'regex', // RegExp.test()
|
||||
}
|
||||
|
||||
/** ภาษาที่ Pattern รองรับ */
|
||||
export enum PatternLanguage {
|
||||
TH = 'th', // ภาษาไทย
|
||||
EN = 'en', // ภาษาอังกฤษ
|
||||
ANY = 'any', // ทุกภาษา
|
||||
}
|
||||
Reference in New Issue
Block a user