All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Implement intent classification for natural language queries in the brain module. Features: - Hybrid classification approach: rule-based (fast, <100ms) with optional LLM fallback - 10 intent types: query_tasks, query_events, query_projects, create_task, create_event, update_task, update_event, briefing, search, unknown - Entity extraction: dates, times, priorities, statuses, people - Pattern-based matching with priority system (higher priority = checked first) - Optional LLM classification for ambiguous queries - POST /api/brain/classify endpoint Implementation: - IntentClassificationService with classify(), classifyWithRules(), classifyWithLlm(), extractEntities() - Comprehensive regex patterns for common query types - Entity extraction for dates, times, priorities, statuses, mentions - Type-safe interfaces for IntentType, IntentClassification, ExtractedEntity, IntentPattern - ClassifyIntentDto and IntentClassificationResultDto for API validation - Integrated with existing LlmService (optional dependency) Testing: - 60 comprehensive tests covering all intent types - Edge cases: empty queries, special characters, case sensitivity, multiple whitespace - Entity extraction tests with position tracking - LLM fallback tests with error handling - 100% test coverage - All tests passing (60/60) - TDD approach: tests written first Quality: - No explicit any types - Explicit return types on all functions - No TypeScript errors - Build successful - Follows existing code patterns - Quality Rails compliance: All lint checks pass Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
27 lines
588 B
TypeScript
27 lines
588 B
TypeScript
import { IsString, MinLength, IsOptional, IsBoolean } from "class-validator";
|
|
import type { IntentType, ExtractedEntity } from "../interfaces";
|
|
|
|
/**
|
|
* DTO for intent classification request
|
|
*/
|
|
export class ClassifyIntentDto {
|
|
@IsString()
|
|
@MinLength(1, { message: "query must not be empty" })
|
|
query!: string;
|
|
|
|
@IsOptional()
|
|
@IsBoolean()
|
|
useLlm?: boolean;
|
|
}
|
|
|
|
/**
|
|
* DTO for intent classification result
|
|
*/
|
|
export class IntentClassificationResultDto {
|
|
intent!: IntentType;
|
|
confidence!: number;
|
|
entities!: ExtractedEntity[];
|
|
method!: "rule" | "llm";
|
|
query!: string;
|
|
}
|