llm-content-creator 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +309 -0
- package/dist/application/workflow/SyncExecutor.d.ts +75 -0
- package/dist/application/workflow/SyncExecutor.d.ts.map +1 -0
- package/dist/application/workflow/SyncExecutor.js +370 -0
- package/dist/application/workflow/SyncExecutor.js.map +1 -0
- package/dist/application/workflow/types.d.ts +46 -0
- package/dist/application/workflow/types.d.ts.map +1 -0
- package/dist/application/workflow/types.js +7 -0
- package/dist/application/workflow/types.js.map +1 -0
- package/dist/config/index.d.ts +173 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +288 -0
- package/dist/config/index.js.map +1 -0
- package/dist/domain/entities/QualityCheck.d.ts +181 -0
- package/dist/domain/entities/QualityCheck.d.ts.map +1 -0
- package/dist/domain/entities/QualityCheck.js +39 -0
- package/dist/domain/entities/QualityCheck.js.map +1 -0
- package/dist/domain/entities/Result.d.ts +103 -0
- package/dist/domain/entities/Result.d.ts.map +1 -0
- package/dist/domain/entities/Result.js +15 -0
- package/dist/domain/entities/Result.js.map +1 -0
- package/dist/domain/entities/Task.d.ts +130 -0
- package/dist/domain/entities/Task.d.ts.map +1 -0
- package/dist/domain/entities/Task.js +64 -0
- package/dist/domain/entities/Task.js.map +1 -0
- package/dist/domain/entities/TaskStep.d.ts +160 -0
- package/dist/domain/entities/TaskStep.d.ts.map +1 -0
- package/dist/domain/entities/TaskStep.js +30 -0
- package/dist/domain/entities/TaskStep.js.map +1 -0
- package/dist/domain/entities/TokenUsage.d.ts +70 -0
- package/dist/domain/entities/TokenUsage.d.ts.map +1 -0
- package/dist/domain/entities/TokenUsage.js +42 -0
- package/dist/domain/entities/TokenUsage.js.map +1 -0
- package/dist/domain/entities/index.d.ts +11 -0
- package/dist/domain/entities/index.d.ts.map +1 -0
- package/dist/domain/entities/index.js +16 -0
- package/dist/domain/entities/index.js.map +1 -0
- package/dist/domain/repositories/QualityCheckRepository.d.ts +49 -0
- package/dist/domain/repositories/QualityCheckRepository.d.ts.map +1 -0
- package/dist/domain/repositories/QualityCheckRepository.js +5 -0
- package/dist/domain/repositories/QualityCheckRepository.js.map +1 -0
- package/dist/domain/repositories/ResultRepository.d.ts +43 -0
- package/dist/domain/repositories/ResultRepository.d.ts.map +1 -0
- package/dist/domain/repositories/ResultRepository.js +5 -0
- package/dist/domain/repositories/ResultRepository.js.map +1 -0
- package/dist/domain/repositories/TaskRepository.d.ts +240 -0
- package/dist/domain/repositories/TaskRepository.d.ts.map +1 -0
- package/dist/domain/repositories/TaskRepository.js +7 -0
- package/dist/domain/repositories/TaskRepository.js.map +1 -0
- package/dist/domain/workflow/CheckpointManager.d.ts +94 -0
- package/dist/domain/workflow/CheckpointManager.d.ts.map +1 -0
- package/dist/domain/workflow/CheckpointManager.js +224 -0
- package/dist/domain/workflow/CheckpointManager.js.map +1 -0
- package/dist/domain/workflow/ContentCreatorGraph.d.ts +17 -0
- package/dist/domain/workflow/ContentCreatorGraph.d.ts.map +1 -0
- package/dist/domain/workflow/ContentCreatorGraph.js +381 -0
- package/dist/domain/workflow/ContentCreatorGraph.js.map +1 -0
- package/dist/domain/workflow/State.d.ts +172 -0
- package/dist/domain/workflow/State.d.ts.map +1 -0
- package/dist/domain/workflow/State.js +184 -0
- package/dist/domain/workflow/State.js.map +1 -0
- package/dist/domain/workflow/index.d.ts +11 -0
- package/dist/domain/workflow/index.d.ts.map +1 -0
- package/dist/domain/workflow/index.js +15 -0
- package/dist/domain/workflow/index.js.map +1 -0
- package/dist/domain/workflow/nodes/BaseNode.d.ts +134 -0
- package/dist/domain/workflow/nodes/BaseNode.d.ts.map +1 -0
- package/dist/domain/workflow/nodes/BaseNode.js +253 -0
- package/dist/domain/workflow/nodes/BaseNode.js.map +1 -0
- package/dist/domain/workflow/nodes/CheckImageNode.d.ts +43 -0
- package/dist/domain/workflow/nodes/CheckImageNode.d.ts.map +1 -0
- package/dist/domain/workflow/nodes/CheckImageNode.js +254 -0
- package/dist/domain/workflow/nodes/CheckImageNode.js.map +1 -0
- package/dist/domain/workflow/nodes/CheckTextNode.d.ts +66 -0
- package/dist/domain/workflow/nodes/CheckTextNode.d.ts.map +1 -0
- package/dist/domain/workflow/nodes/CheckTextNode.js +530 -0
- package/dist/domain/workflow/nodes/CheckTextNode.js.map +1 -0
- package/dist/domain/workflow/nodes/GenerateImageNode.d.ts +44 -0
- package/dist/domain/workflow/nodes/GenerateImageNode.d.ts.map +1 -0
- package/dist/domain/workflow/nodes/GenerateImageNode.js +272 -0
- package/dist/domain/workflow/nodes/GenerateImageNode.js.map +1 -0
- package/dist/domain/workflow/nodes/OrganizeNode.d.ts +49 -0
- package/dist/domain/workflow/nodes/OrganizeNode.d.ts.map +1 -0
- package/dist/domain/workflow/nodes/OrganizeNode.js +241 -0
- package/dist/domain/workflow/nodes/OrganizeNode.js.map +1 -0
- package/dist/domain/workflow/nodes/SearchNode.d.ts +48 -0
- package/dist/domain/workflow/nodes/SearchNode.d.ts.map +1 -0
- package/dist/domain/workflow/nodes/SearchNode.js +151 -0
- package/dist/domain/workflow/nodes/SearchNode.js.map +1 -0
- package/dist/domain/workflow/nodes/WriteNode.d.ts +68 -0
- package/dist/domain/workflow/nodes/WriteNode.d.ts.map +1 -0
- package/dist/domain/workflow/nodes/WriteNode.js +431 -0
- package/dist/domain/workflow/nodes/WriteNode.js.map +1 -0
- package/dist/domain/workflow/nodes/config/index.js +287 -0
- package/dist/domain/workflow/nodes/domain/entities/Task.js +68 -0
- package/dist/domain/workflow/nodes/domain/workflow/State.js +200 -0
- package/dist/domain/workflow/nodes/domain/workflow/nodes/BaseNode.js +328 -0
- package/dist/domain/workflow/nodes/domain/workflow/nodes/CheckTextNode.js +500 -0
- package/dist/domain/workflow/nodes/index.d.ts +13 -0
- package/dist/domain/workflow/nodes/index.d.ts.map +1 -0
- package/dist/domain/workflow/nodes/index.js +13 -0
- package/dist/domain/workflow/nodes/index.js.map +1 -0
- package/dist/domain/workflow/nodes/infrastructure/logging/logger.js +275 -0
- package/dist/domain/workflow/nodes/services/llm/EnhancedLLMService.js +559 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/infrastructure/cache/CacheService.d.ts +139 -0
- package/dist/infrastructure/cache/CacheService.d.ts.map +1 -0
- package/dist/infrastructure/cache/CacheService.js +419 -0
- package/dist/infrastructure/cache/CacheService.js.map +1 -0
- package/dist/infrastructure/cache/index.d.ts +5 -0
- package/dist/infrastructure/cache/index.d.ts.map +1 -0
- package/dist/infrastructure/cache/index.js +6 -0
- package/dist/infrastructure/cache/index.js.map +1 -0
- package/dist/infrastructure/database/BaseRepository.d.ts +98 -0
- package/dist/infrastructure/database/BaseRepository.d.ts.map +1 -0
- package/dist/infrastructure/database/BaseRepository.js +178 -0
- package/dist/infrastructure/database/BaseRepository.js.map +1 -0
- package/dist/infrastructure/database/MemoryTaskRepository.d.ts +77 -0
- package/dist/infrastructure/database/MemoryTaskRepository.d.ts.map +1 -0
- package/dist/infrastructure/database/MemoryTaskRepository.js +309 -0
- package/dist/infrastructure/database/MemoryTaskRepository.js.map +1 -0
- package/dist/infrastructure/database/PostgresQualityCheckRepository.d.ts +36 -0
- package/dist/infrastructure/database/PostgresQualityCheckRepository.d.ts.map +1 -0
- package/dist/infrastructure/database/PostgresQualityCheckRepository.js +89 -0
- package/dist/infrastructure/database/PostgresQualityCheckRepository.js.map +1 -0
- package/dist/infrastructure/database/PostgresTaskRepository.d.ts +94 -0
- package/dist/infrastructure/database/PostgresTaskRepository.d.ts.map +1 -0
- package/dist/infrastructure/database/PostgresTaskRepository.js +364 -0
- package/dist/infrastructure/database/PostgresTaskRepository.js.map +1 -0
- package/dist/infrastructure/database/ResultRepository.d.ts +41 -0
- package/dist/infrastructure/database/ResultRepository.d.ts.map +1 -0
- package/dist/infrastructure/database/ResultRepository.js +86 -0
- package/dist/infrastructure/database/ResultRepository.js.map +1 -0
- package/dist/infrastructure/database/SQLiteTaskRepository.d.ts +101 -0
- package/dist/infrastructure/database/SQLiteTaskRepository.d.ts.map +1 -0
- package/dist/infrastructure/database/SQLiteTaskRepository.js +548 -0
- package/dist/infrastructure/database/SQLiteTaskRepository.js.map +1 -0
- package/dist/infrastructure/database/index.d.ts +32 -0
- package/dist/infrastructure/database/index.d.ts.map +1 -0
- package/dist/infrastructure/database/index.js +72 -0
- package/dist/infrastructure/database/index.js.map +1 -0
- package/dist/infrastructure/logging/logger.d.ts +69 -0
- package/dist/infrastructure/logging/logger.d.ts.map +1 -0
- package/dist/infrastructure/logging/logger.js +169 -0
- package/dist/infrastructure/logging/logger.js.map +1 -0
- package/dist/infrastructure/monitoring/LoggingService.d.ts +109 -0
- package/dist/infrastructure/monitoring/LoggingService.d.ts.map +1 -0
- package/dist/infrastructure/monitoring/LoggingService.js +198 -0
- package/dist/infrastructure/monitoring/LoggingService.js.map +1 -0
- package/dist/infrastructure/monitoring/MetricsService.d.ts +112 -0
- package/dist/infrastructure/monitoring/MetricsService.d.ts.map +1 -0
- package/dist/infrastructure/monitoring/MetricsService.js +362 -0
- package/dist/infrastructure/monitoring/MetricsService.js.map +1 -0
- package/dist/infrastructure/monitoring/SentryService.d.ts +108 -0
- package/dist/infrastructure/monitoring/SentryService.d.ts.map +1 -0
- package/dist/infrastructure/monitoring/SentryService.js +282 -0
- package/dist/infrastructure/monitoring/SentryService.js.map +1 -0
- package/dist/infrastructure/monitoring/index.d.ts +7 -0
- package/dist/infrastructure/monitoring/index.d.ts.map +1 -0
- package/dist/infrastructure/monitoring/index.js +10 -0
- package/dist/infrastructure/monitoring/index.js.map +1 -0
- package/dist/infrastructure/queue/TaskQueue.d.ts +110 -0
- package/dist/infrastructure/queue/TaskQueue.d.ts.map +1 -0
- package/dist/infrastructure/queue/TaskQueue.js +363 -0
- package/dist/infrastructure/queue/TaskQueue.js.map +1 -0
- package/dist/infrastructure/queue/index.d.ts +5 -0
- package/dist/infrastructure/queue/index.d.ts.map +1 -0
- package/dist/infrastructure/queue/index.js +5 -0
- package/dist/infrastructure/queue/index.js.map +1 -0
- package/dist/infrastructure/redis/connection.d.ts +61 -0
- package/dist/infrastructure/redis/connection.d.ts.map +1 -0
- package/dist/infrastructure/redis/connection.js +184 -0
- package/dist/infrastructure/redis/connection.js.map +1 -0
- package/dist/infrastructure/redis/index.d.ts +5 -0
- package/dist/infrastructure/redis/index.d.ts.map +1 -0
- package/dist/infrastructure/redis/index.js +5 -0
- package/dist/infrastructure/redis/index.js.map +1 -0
- package/dist/infrastructure/security/ApiKeyService.d.ts +103 -0
- package/dist/infrastructure/security/ApiKeyService.d.ts.map +1 -0
- package/dist/infrastructure/security/ApiKeyService.js +250 -0
- package/dist/infrastructure/security/ApiKeyService.js.map +1 -0
- package/dist/infrastructure/security/QuotaService.d.ts +87 -0
- package/dist/infrastructure/security/QuotaService.d.ts.map +1 -0
- package/dist/infrastructure/security/QuotaService.js +303 -0
- package/dist/infrastructure/security/QuotaService.js.map +1 -0
- package/dist/infrastructure/security/RateLimiter.d.ts +104 -0
- package/dist/infrastructure/security/RateLimiter.d.ts.map +1 -0
- package/dist/infrastructure/security/RateLimiter.js +331 -0
- package/dist/infrastructure/security/RateLimiter.js.map +1 -0
- package/dist/infrastructure/security/index.d.ts +7 -0
- package/dist/infrastructure/security/index.d.ts.map +1 -0
- package/dist/infrastructure/security/index.js +10 -0
- package/dist/infrastructure/security/index.js.map +1 -0
- package/dist/monitoring/index.d.ts +5 -0
- package/dist/monitoring/index.d.ts.map +1 -0
- package/dist/monitoring/index.js +5 -0
- package/dist/monitoring/index.js.map +1 -0
- package/dist/monitoring/server.d.ts +14 -0
- package/dist/monitoring/server.d.ts.map +1 -0
- package/dist/monitoring/server.js +99 -0
- package/dist/monitoring/server.js.map +1 -0
- package/dist/presentation/cli/commands/cancel.d.ts +8 -0
- package/dist/presentation/cli/commands/cancel.d.ts.map +1 -0
- package/dist/presentation/cli/commands/cancel.js +57 -0
- package/dist/presentation/cli/commands/cancel.js.map +1 -0
- package/dist/presentation/cli/commands/create.d.ts +8 -0
- package/dist/presentation/cli/commands/create.d.ts.map +1 -0
- package/dist/presentation/cli/commands/create.js +368 -0
- package/dist/presentation/cli/commands/create.js.map +1 -0
- package/dist/presentation/cli/commands/result.d.ts +8 -0
- package/dist/presentation/cli/commands/result.d.ts.map +1 -0
- package/dist/presentation/cli/commands/result.js +121 -0
- package/dist/presentation/cli/commands/result.js.map +1 -0
- package/dist/presentation/cli/commands/status.d.ts +8 -0
- package/dist/presentation/cli/commands/status.d.ts.map +1 -0
- package/dist/presentation/cli/commands/status.js +92 -0
- package/dist/presentation/cli/commands/status.js.map +1 -0
- package/dist/presentation/cli/index.d.ts +8 -0
- package/dist/presentation/cli/index.d.ts.map +1 -0
- package/dist/presentation/cli/index.js +32 -0
- package/dist/presentation/cli/index.js.map +1 -0
- package/dist/presentation/cli/utils/cleanup.d.ts +14 -0
- package/dist/presentation/cli/utils/cleanup.d.ts.map +1 -0
- package/dist/presentation/cli/utils/cleanup.js +62 -0
- package/dist/presentation/cli/utils/cleanup.js.map +1 -0
- package/dist/presentation/cli/utils/formatter.d.ts +28 -0
- package/dist/presentation/cli/utils/formatter.d.ts.map +1 -0
- package/dist/presentation/cli/utils/formatter.js +68 -0
- package/dist/presentation/cli/utils/formatter.js.map +1 -0
- package/dist/presentation/cli.d.ts +7 -0
- package/dist/presentation/cli.d.ts.map +1 -0
- package/dist/presentation/cli.js +8 -0
- package/dist/presentation/cli.js.map +1 -0
- package/dist/presentation/monitor-cli.d.ts +8 -0
- package/dist/presentation/monitor-cli.d.ts.map +1 -0
- package/dist/presentation/monitor-cli.js +44 -0
- package/dist/presentation/monitor-cli.js.map +1 -0
- package/dist/presentation/worker-cli.d.ts +8 -0
- package/dist/presentation/worker-cli.d.ts.map +1 -0
- package/dist/presentation/worker-cli.js +51 -0
- package/dist/presentation/worker-cli.js.map +1 -0
- package/dist/schedulers/TaskScheduler.d.ts +99 -0
- package/dist/schedulers/TaskScheduler.d.ts.map +1 -0
- package/dist/schedulers/TaskScheduler.js +233 -0
- package/dist/schedulers/TaskScheduler.js.map +1 -0
- package/dist/schedulers/index.d.ts +5 -0
- package/dist/schedulers/index.d.ts.map +1 -0
- package/dist/schedulers/index.js +5 -0
- package/dist/schedulers/index.js.map +1 -0
- package/dist/services/image/ImageService.d.ts +68 -0
- package/dist/services/image/ImageService.d.ts.map +1 -0
- package/dist/services/image/ImageService.js +166 -0
- package/dist/services/image/ImageService.js.map +1 -0
- package/dist/services/index.d.ts +8 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +12 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/llm/EnhancedLLMService.d.ts +148 -0
- package/dist/services/llm/EnhancedLLMService.d.ts.map +1 -0
- package/dist/services/llm/EnhancedLLMService.js +425 -0
- package/dist/services/llm/EnhancedLLMService.js.map +1 -0
- package/dist/services/llm/LLMService.d.ts +103 -0
- package/dist/services/llm/LLMService.d.ts.map +1 -0
- package/dist/services/llm/LLMService.js +212 -0
- package/dist/services/llm/LLMService.js.map +1 -0
- package/dist/services/quality/HardRuleChecker.d.ts +143 -0
- package/dist/services/quality/HardRuleChecker.d.ts.map +1 -0
- package/dist/services/quality/HardRuleChecker.js +353 -0
- package/dist/services/quality/HardRuleChecker.js.map +1 -0
- package/dist/services/quality/LLMEvaluator.d.ts +105 -0
- package/dist/services/quality/LLMEvaluator.d.ts.map +1 -0
- package/dist/services/quality/LLMEvaluator.js +312 -0
- package/dist/services/quality/LLMEvaluator.js.map +1 -0
- package/dist/services/quality/QualityCheckService.d.ts +112 -0
- package/dist/services/quality/QualityCheckService.d.ts.map +1 -0
- package/dist/services/quality/QualityCheckService.js +342 -0
- package/dist/services/quality/QualityCheckService.js.map +1 -0
- package/dist/services/quality/QualityService.d.ts +75 -0
- package/dist/services/quality/QualityService.d.ts.map +1 -0
- package/dist/services/quality/QualityService.js +360 -0
- package/dist/services/quality/QualityService.js.map +1 -0
- package/dist/services/quality/index.d.ts +7 -0
- package/dist/services/quality/index.d.ts.map +1 -0
- package/dist/services/quality/index.js +10 -0
- package/dist/services/quality/index.js.map +1 -0
- package/dist/services/search/SearchService.d.ts +79 -0
- package/dist/services/search/SearchService.d.ts.map +1 -0
- package/dist/services/search/SearchService.js +193 -0
- package/dist/services/search/SearchService.js.map +1 -0
- package/dist/workers/TaskWorker.d.ts +61 -0
- package/dist/workers/TaskWorker.d.ts.map +1 -0
- package/dist/workers/TaskWorker.js +256 -0
- package/dist/workers/TaskWorker.js.map +1 -0
- package/dist/workers/index.d.ts +5 -0
- package/dist/workers/index.d.ts.map +1 -0
- package/dist/workers/index.js +5 -0
- package/dist/workers/index.js.map +1 -0
- package/docs/DOCUMENTATION-ANALYSIS.md +190 -0
- package/docs/README.md +145 -0
- package/docs/SOURCE-CODE-ANALYSIS.md +1107 -0
- package/docs/architecture-complete.md +5524 -0
- package/docs/archive/implementation/implementation-analysis/README.md +244 -0
- package/docs/archive/implementation/implementation-analysis/implementation-analysis-context.md +483 -0
- package/docs/archive/implementation/implementation-analysis/implementation-analysis-plan.md +1242 -0
- package/docs/archive/implementation/implementation-analysis/implementation-analysis-tasks.md +777 -0
- package/docs/archive/phases/phase-1/phase-1-completion-summary.md +284 -0
- package/docs/archive/phases/phase-1/phase-1-implementation-guide.md +1380 -0
- package/docs/archive/phases/phase-2/phase-2a/phase-2a-completion-summary.md +443 -0
- package/docs/archive/phases/phase-2/phase-2b/phase-2b-completion-report.md +430 -0
- package/docs/archive/phases/phase-2/phase-2b/phase-2b-completion-summary.md +592 -0
- package/docs/archive/phases/phase-2/phase-2b/phase-2b-final-summary.md +371 -0
- package/docs/archive/phases/phase-2/phase-2b/phase-2b-preparation-complete.md +343 -0
- package/docs/archive/phases/phase-2/phase-2b/phase-2b-preparation.md +945 -0
- package/docs/archive/phases/phase-2/phase-2b/phase-2b-progress-update.md +366 -0
- package/docs/archive/phases/phase-3/phase-3-completion-summary.md +354 -0
- package/docs/archive/phases/phase-3/phase-3-development-plan.md +878 -0
- package/docs/archive/phases/phase-3/phase-3-quick-start.md +324 -0
- package/docs/archive/phases/phase-4/phase-4-completion-summary.md +708 -0
- package/docs/archive/phases/phase-4/phase-4-development-plan.md +740 -0
- package/docs/archive/phases/phase-4/phase-4-quick-start.md +632 -0
- package/docs/archive/phases/phase-4/phase-4-session-3-security-testing.md +484 -0
- package/docs/archive/phases/phase-4/phase-4-session-4-unit-tests.md +550 -0
- package/docs/archive/phases/phase-4/phase-4-session-5-security-tests.md +564 -0
- package/docs/archive/phases/phase-4/phase-4-session-6-cache-integration.md +456 -0
- package/docs/archive/phases/phase-4/phase-4-session-7-test-fixes.md +348 -0
- package/docs/archive/phases/phase-4/phase-4-session-8-taskqueue-fixes.md +323 -0
- package/docs/archive/phases/phase-4/phase-4-session-summary-continued.md +373 -0
- package/docs/archive/phases/phase-4/phase-4-session-summary.md +595 -0
- package/docs/archive/reports/progress-reports/PHASE_0_PROGRESS.md +242 -0
- package/docs/archive/reports/progress-reports/PHASE_0_SUMMARY.md +262 -0
- package/docs/archive/reports/progress-reports/PHASE_1_2_ISSUES.md +399 -0
- package/docs/archive/reports/progress-reports/PHASE_1_PROGRESS.md +388 -0
- package/docs/archive/reports/progress-reports/PHASE_3_PREPARATION.md +574 -0
- package/docs/archive/reports/progress-reports/current-progress-update.md +294 -0
- package/docs/archive/reports/progress-reports/final-summary.md +215 -0
- package/docs/archive/reports/progress-reports/implementation-summary.md +287 -0
- package/docs/archive/reports/progress-reports/project-progress-report.md +440 -0
- package/docs/archive/reports/progress-reports/project-progress.md +386 -0
- package/docs/archive/reports/test-reports/TEST-COVERAGE-REPORT.md +441 -0
- package/docs/archive/reports/test-reports/e2e-test-report.md +293 -0
- package/docs/archive/reports/test-reports/final-test-report.md +367 -0
- package/docs/archive/reports/test-reports/real-env-test-report.md +391 -0
- package/docs/archive/reports/test-reports/test-completion-summary.md +356 -0
- package/docs/archive/reports/test-reports/test-report.md +371 -0
- package/docs/archive/sessions/session-2-summary.md +429 -0
- package/docs/archive/sessions/session-3-summary.md +395 -0
- package/docs/archive/sessions/session-summary.md +370 -0
- package/docs/config-system-update.md +239 -0
- package/docs/database-refactoring-PLAN.md +199 -0
- package/docs/database-refactoring-SUMMARY.md +384 -0
- package/docs/quality-check-architecture.md +1030 -0
- package/docs/quick-start.md +388 -0
- package/docs/references/bullmq-quick-reference.md +525 -0
- package/docs/references/monitoring-optimization-guide.md +871 -0
- package/docs/references/performance-optimization-guide.md +933 -0
- package/docs/storage-guide.md +612 -0
- package/docs/test-implementation-PLAN.md +223 -0
- package/docs/test-implementation-SUMMARY.md +194 -0
- package/docs/user-guide.md +719 -0
- package/docs/workflow-architecture.md +549 -0
- package/package.json +126 -0
- package/src/application/workflow/SyncExecutor.ts +444 -0
- package/src/application/workflow/types.ts +57 -0
- package/src/config/index.ts +352 -0
- package/src/domain/entities/QualityCheck.ts +202 -0
- package/src/domain/entities/Result.ts +130 -0
- package/src/domain/entities/Task.ts +178 -0
- package/src/domain/entities/TaskStep.ts +188 -0
- package/src/domain/entities/TokenUsage.ts +119 -0
- package/src/domain/entities/index.ts +20 -0
- package/src/domain/repositories/QualityCheckRepository.ts +52 -0
- package/src/domain/repositories/ResultRepository.ts +47 -0
- package/src/domain/repositories/TaskRepository.ts +271 -0
- package/src/domain/workflow/CheckpointManager.ts +283 -0
- package/src/domain/workflow/ContentCreatorGraph.ts +446 -0
- package/src/domain/workflow/State.ts +321 -0
- package/src/domain/workflow/index.ts +18 -0
- package/src/domain/workflow/nodes/BaseNode.ts +325 -0
- package/src/domain/workflow/nodes/CheckImageNode.ts +325 -0
- package/src/domain/workflow/nodes/CheckTextNode.ts +709 -0
- package/src/domain/workflow/nodes/GenerateImageNode.ts +342 -0
- package/src/domain/workflow/nodes/OrganizeNode.ts +304 -0
- package/src/domain/workflow/nodes/SearchNode.ts +192 -0
- package/src/domain/workflow/nodes/WriteNode.ts +505 -0
- package/src/domain/workflow/nodes/index.ts +13 -0
- package/src/index.ts +43 -0
- package/src/infrastructure/cache/CacheService.ts +483 -0
- package/src/infrastructure/cache/index.ts +6 -0
- package/src/infrastructure/database/BaseRepository.ts +214 -0
- package/src/infrastructure/database/MemoryTaskRepository.ts +377 -0
- package/src/infrastructure/database/PostgresQualityCheckRepository.ts +115 -0
- package/src/infrastructure/database/PostgresTaskRepository.ts +424 -0
- package/src/infrastructure/database/ResultRepository.ts +113 -0
- package/src/infrastructure/database/SQLiteTaskRepository.ts +651 -0
- package/src/infrastructure/database/index.ts +83 -0
- package/src/infrastructure/logging/logger.ts +231 -0
- package/src/infrastructure/monitoring/LoggingService.ts +292 -0
- package/src/infrastructure/monitoring/MetricsService.ts +468 -0
- package/src/infrastructure/monitoring/SentryService.ts +345 -0
- package/src/infrastructure/monitoring/index.ts +12 -0
- package/src/infrastructure/queue/TaskQueue.ts +429 -0
- package/src/infrastructure/queue/index.ts +5 -0
- package/src/infrastructure/redis/connection.ts +215 -0
- package/src/infrastructure/redis/index.ts +5 -0
- package/src/infrastructure/security/ApiKeyService.ts +340 -0
- package/src/infrastructure/security/QuotaService.ts +411 -0
- package/src/infrastructure/security/RateLimiter.ts +417 -0
- package/src/infrastructure/security/index.ts +12 -0
- package/src/monitoring/index.ts +5 -0
- package/src/monitoring/server.ts +109 -0
- package/src/presentation/cli/commands/cancel.ts +64 -0
- package/src/presentation/cli/commands/create.ts +400 -0
- package/src/presentation/cli/commands/result.ts +136 -0
- package/src/presentation/cli/commands/status.ts +102 -0
- package/src/presentation/cli/index.ts +39 -0
- package/src/presentation/cli/utils/cleanup.ts +65 -0
- package/src/presentation/cli/utils/formatter.ts +74 -0
- package/src/presentation/cli.ts +8 -0
- package/src/presentation/monitor-cli.ts +52 -0
- package/src/presentation/worker-cli.ts +62 -0
- package/src/schedulers/TaskScheduler.ts +314 -0
- package/src/schedulers/index.ts +11 -0
- package/src/services/image/ImageService.ts +221 -0
- package/src/services/index.ts +15 -0
- package/src/services/llm/EnhancedLLMService.ts +596 -0
- package/src/services/llm/LLMService.ts +310 -0
- package/src/services/quality/HardRuleChecker.ts +509 -0
- package/src/services/quality/LLMEvaluator.ts +400 -0
- package/src/services/quality/QualityCheckService.ts +473 -0
- package/src/services/quality/QualityService.ts +445 -0
- package/src/services/quality/index.ts +12 -0
- package/src/services/search/SearchService.ts +266 -0
- package/src/types/global.d.ts +17 -0
- package/src/workers/TaskWorker.ts +320 -0
- package/src/workers/index.ts +5 -0
|
@@ -0,0 +1,1030 @@
|
|
|
1
|
+
# 质量检查服务架构文档
|
|
2
|
+
|
|
3
|
+
**版本**: 1.0
|
|
4
|
+
**日期**: 2026-01-19
|
|
5
|
+
**所属阶段**: 阶段 4
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 📋 目录
|
|
10
|
+
|
|
11
|
+
- [概述](#概述)
|
|
12
|
+
- [架构设计](#架构设计)
|
|
13
|
+
- [硬规则检查](#硬规则检查)
|
|
14
|
+
- [LLM 软评分](#llm-软评分)
|
|
15
|
+
- [智能反馈](#智能反馈)
|
|
16
|
+
- [配置管理](#配置管理)
|
|
17
|
+
- [实施指南](#实施指南)
|
|
18
|
+
- [测试策略](#测试策略)
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 概述
|
|
23
|
+
|
|
24
|
+
### 目标
|
|
25
|
+
|
|
26
|
+
构建两层质量检查系统:
|
|
27
|
+
1. **硬规则检查** - 确定性规则,快速验证
|
|
28
|
+
2. **LLM 软评分** - AI 评估内容质量
|
|
29
|
+
|
|
30
|
+
### 设计原则
|
|
31
|
+
|
|
32
|
+
- ✅ **快速失败** - 先检查硬规则,快速发现问题
|
|
33
|
+
- ✅ **可配置** - 规则和阈值可灵活配置
|
|
34
|
+
- ✅ **可扩展** - 易于添加新的检查规则
|
|
35
|
+
- ✅ **可观测** - 详细的检查日志和指标
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 架构设计
|
|
40
|
+
|
|
41
|
+
### 整体架构
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
┌─────────────────────────────────────────────────┐
|
|
45
|
+
│ QualityCheckService │
|
|
46
|
+
│ ┌─────────────────────────────────────────┐ │
|
|
47
|
+
│ │ 1. 硬规则检查器 (HardRuleChecker) │ │
|
|
48
|
+
│ │ - 字数检查 │ │
|
|
49
|
+
│ │ - 关键词检查 │ │
|
|
50
|
+
│ │ - 结构检查 │ │
|
|
51
|
+
│ │ - 禁用词检查 │ │
|
|
52
|
+
│ └──────────────┬──────────────────────────┘ │
|
|
53
|
+
│ ↓ (通过?) │
|
|
54
|
+
│ ┌──────┴──────┐ │
|
|
55
|
+
│ │ │ │
|
|
56
|
+
│ ❌ ✅ │
|
|
57
|
+
│ ↓ ↓ │
|
|
58
|
+
│ 失败返回 ┌─────────────────────────┐ │
|
|
59
|
+
│ │ 2. LLM 评估器 (LLMEvaluator)│ │
|
|
60
|
+
│ │ - 相关性评估 │ │
|
|
61
|
+
│ │ - 连贯性评估 │ │
|
|
62
|
+
│ │ - 完整性评估 │ │
|
|
63
|
+
│ │ - 可读性评估 │ │
|
|
64
|
+
│ └──────────┬──────────────┘ │
|
|
65
|
+
│ ↓ │
|
|
66
|
+
│ ┌──────┴──────┐ │
|
|
67
|
+
│ │ 分数 >= 7? │ │
|
|
68
|
+
│ └──────┬──────┘ │
|
|
69
|
+
│ │ │
|
|
70
|
+
│ ┌────┴────┐ │
|
|
71
|
+
│ │ │ │
|
|
72
|
+
│ ❌ ✅ │
|
|
73
|
+
│ ↓ ↓ │
|
|
74
|
+
│ 生成反馈 通过返回 │
|
|
75
|
+
└─────────────────────────────────────────────────┘
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### 数据流
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
// 输入
|
|
82
|
+
{
|
|
83
|
+
content: string,
|
|
84
|
+
requirements: string,
|
|
85
|
+
hardConstraints: {
|
|
86
|
+
minWords?: number,
|
|
87
|
+
maxWords?: number,
|
|
88
|
+
keywords?: string[],
|
|
89
|
+
// ...
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// 输出
|
|
94
|
+
{
|
|
95
|
+
passed: boolean,
|
|
96
|
+
score: number,
|
|
97
|
+
hardConstraintsPassed: boolean,
|
|
98
|
+
details: {
|
|
99
|
+
wordCount?: number,
|
|
100
|
+
keywordsFound?: string[],
|
|
101
|
+
structureValid?: boolean,
|
|
102
|
+
relevance?: number,
|
|
103
|
+
coherence?: number,
|
|
104
|
+
completeness?: number,
|
|
105
|
+
readability?: number
|
|
106
|
+
},
|
|
107
|
+
fixSuggestions?: string[],
|
|
108
|
+
checkedAt: number
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## 硬规则检查
|
|
115
|
+
|
|
116
|
+
### 1. 字数检查
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
// 文件: src/services/quality/checkers/WordCountChecker.ts
|
|
120
|
+
|
|
121
|
+
export class WordCountChecker {
|
|
122
|
+
check(content: string, constraints: WordCountConstraints): CheckResult {
|
|
123
|
+
// 移除空白字符后计算字数
|
|
124
|
+
const text = content.trim();
|
|
125
|
+
const wordCount = text.length; // 中文按字符计算
|
|
126
|
+
|
|
127
|
+
// 英文按单词计算
|
|
128
|
+
const englishWords = text.match(/\b\w+\b/g);
|
|
129
|
+
const englishWordCount = englishWords ? englishWords.length : 0;
|
|
130
|
+
|
|
131
|
+
const totalCount = wordCount + englishWordCount;
|
|
132
|
+
|
|
133
|
+
const passed = totalCount >= constraints.min &&
|
|
134
|
+
totalCount <= constraints.max;
|
|
135
|
+
|
|
136
|
+
return {
|
|
137
|
+
passed,
|
|
138
|
+
details: {
|
|
139
|
+
wordCount: totalCount,
|
|
140
|
+
minWords: constraints.min,
|
|
141
|
+
maxWords: constraints.max,
|
|
142
|
+
deficit: Math.max(0, constraints.min - totalCount),
|
|
143
|
+
excess: Math.max(0, totalCount - constraints.max)
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
getFixSuggestions(result: CheckResult): string[] {
|
|
149
|
+
const suggestions: string[] = [];
|
|
150
|
+
const details = result.details;
|
|
151
|
+
|
|
152
|
+
if (details.deficit > 0) {
|
|
153
|
+
suggestions.push(
|
|
154
|
+
`字数不足:当前 ${details.wordCount} 字,` +
|
|
155
|
+
`最少需要 ${details.minWords} 字,` +
|
|
156
|
+
`还需补充 ${details.deficit} 字`
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (details.excess > 0) {
|
|
161
|
+
suggestions.push(
|
|
162
|
+
`字数超出:当前 ${details.wordCount} 字,` +
|
|
163
|
+
`最多允许 ${details.maxWords} 字,` +
|
|
164
|
+
`需要精简 ${details.excess} 字`
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return suggestions;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### 2. 关键词检查
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
// 文件: src/services/quality/checkers/KeywordChecker.ts
|
|
177
|
+
|
|
178
|
+
export class KeywordChecker {
|
|
179
|
+
check(content: string, keywords: string[], options: KeywordOptions): CheckResult {
|
|
180
|
+
const found: string[] = [];
|
|
181
|
+
const missing: string[] = [];
|
|
182
|
+
|
|
183
|
+
for (const keyword of keywords) {
|
|
184
|
+
// 支持中英文关键词匹配
|
|
185
|
+
const regex = new RegExp(keyword, 'i');
|
|
186
|
+
if (regex.test(content)) {
|
|
187
|
+
found.push(keyword);
|
|
188
|
+
} else {
|
|
189
|
+
missing.push(keyword);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// 根据配置决定是否需要全部匹配
|
|
194
|
+
const passed = options.matchAll
|
|
195
|
+
? missing.length === 0
|
|
196
|
+
: found.length > 0;
|
|
197
|
+
|
|
198
|
+
return {
|
|
199
|
+
passed,
|
|
200
|
+
details: {
|
|
201
|
+
keywords,
|
|
202
|
+
found,
|
|
203
|
+
missing,
|
|
204
|
+
foundCount: found.length,
|
|
205
|
+
missingCount: missing.length,
|
|
206
|
+
matchRate: found.length / keywords.length
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
getFixSuggestions(result: CheckResult): string[] {
|
|
212
|
+
const suggestions: string[] = [];
|
|
213
|
+
const details = result.details;
|
|
214
|
+
|
|
215
|
+
if (details.missing.length > 0) {
|
|
216
|
+
suggestions.push(
|
|
217
|
+
`缺少关键词:${details.missing.join('、')}。` +
|
|
218
|
+
`请在文章中自然地融入这些关键词。`
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return suggestions;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### 3. 结构检查
|
|
228
|
+
|
|
229
|
+
```typescript
|
|
230
|
+
// 文件: src/services/quality/checkers/StructureChecker.ts
|
|
231
|
+
|
|
232
|
+
export class StructureChecker {
|
|
233
|
+
check(content: string, requirements: StructureRequirements): CheckResult {
|
|
234
|
+
const issues: string[] = [];
|
|
235
|
+
|
|
236
|
+
// 检查标题
|
|
237
|
+
if (requirements.requireTitle) {
|
|
238
|
+
const hasTitle = /^#\s+.+/m.test(content);
|
|
239
|
+
if (!hasTitle) {
|
|
240
|
+
issues.push('缺少标题(# 标题)');
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// 检查导语
|
|
245
|
+
if (requirements.requireIntro) {
|
|
246
|
+
const hasIntro = /导语|引言|概述|简介/.test(content);
|
|
247
|
+
if (!hasIntro) {
|
|
248
|
+
issues.push('缺少导语段落');
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// 检查正文
|
|
253
|
+
const paragraphs = content.split('\n\n').filter(p => p.trim().length > 0);
|
|
254
|
+
if (paragraphs.length < 3) {
|
|
255
|
+
issues.push('正文段落数量过少,建议至少 3 段');
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// 检查结尾
|
|
259
|
+
if (requirements.requireConclusion) {
|
|
260
|
+
const hasConclusion = /总结|结语|结论|结尾/.test(content);
|
|
261
|
+
if (!hasConclusion) {
|
|
262
|
+
issues.push('缺少结尾段落');
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const passed = issues.length === 0;
|
|
267
|
+
|
|
268
|
+
return {
|
|
269
|
+
passed,
|
|
270
|
+
details: {
|
|
271
|
+
structureValid: passed,
|
|
272
|
+
issues,
|
|
273
|
+
paragraphCount: paragraphs.length
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
getFixSuggestions(result: CheckResult): string[] {
|
|
279
|
+
return result.details.issues.map(issue => {
|
|
280
|
+
switch (issue) {
|
|
281
|
+
case '缺少标题(# 标题)':
|
|
282
|
+
return '请在文章开头添加标题,格式:# 文章标题';
|
|
283
|
+
case '缺少导语段落':
|
|
284
|
+
return '请添加导语段落,简要介绍文章内容';
|
|
285
|
+
case '正文段落数量过少,建议至少 3 段':
|
|
286
|
+
return '请丰富正文内容,增加段落数量';
|
|
287
|
+
case '缺少结尾段落':
|
|
288
|
+
return '请添加结尾段落,总结文章要点';
|
|
289
|
+
default:
|
|
290
|
+
return `结构问题:${issue}`;
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### 4. 禁用词检查
|
|
298
|
+
|
|
299
|
+
```typescript
|
|
300
|
+
// 文件: src/services/quality/checkers/ForbiddenWordsChecker.ts
|
|
301
|
+
|
|
302
|
+
export class ForbiddenWordsChecker {
|
|
303
|
+
constructor(private forbiddenWords: Set<string>) {}
|
|
304
|
+
|
|
305
|
+
check(content: string): CheckResult {
|
|
306
|
+
const found: string[] = [];
|
|
307
|
+
|
|
308
|
+
for (const word of this.forbiddenWords) {
|
|
309
|
+
const regex = new RegExp(word, 'gi');
|
|
310
|
+
const matches = content.match(regex);
|
|
311
|
+
if (matches) {
|
|
312
|
+
found.push(...matches);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
const passed = found.length === 0;
|
|
317
|
+
|
|
318
|
+
return {
|
|
319
|
+
passed,
|
|
320
|
+
details: {
|
|
321
|
+
forbiddenWordsFound: found,
|
|
322
|
+
count: found.length
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
getFixSuggestions(result: CheckResult): string[] {
|
|
328
|
+
if (result.details.count > 0) {
|
|
329
|
+
return [
|
|
330
|
+
`文章包含禁用词:${result.details.forbiddenWordsFound.join('、')}。` +
|
|
331
|
+
`请移除或替换这些词汇。`
|
|
332
|
+
];
|
|
333
|
+
}
|
|
334
|
+
return [];
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
---
|
|
340
|
+
|
|
341
|
+
## LLM 软评分
|
|
342
|
+
|
|
343
|
+
### 评估维度
|
|
344
|
+
|
|
345
|
+
```typescript
|
|
346
|
+
// 文件: src/services/quality/evaluators/LLMEvaluator.ts
|
|
347
|
+
|
|
348
|
+
export interface EvaluationDimensions {
|
|
349
|
+
relevance: number; // 相关性 (30%)
|
|
350
|
+
coherence: number; // 连贯性 (30%)
|
|
351
|
+
completeness: number; // 完整性 (20%)
|
|
352
|
+
readability: number; // 可读性 (20%)
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
export class LLMEvaluator {
|
|
356
|
+
async evaluate(
|
|
357
|
+
content: string,
|
|
358
|
+
requirements: string,
|
|
359
|
+
options: EvaluationOptions
|
|
360
|
+
): Promise<EvaluationResult> {
|
|
361
|
+
|
|
362
|
+
// 1. 构建评估 Prompt
|
|
363
|
+
const prompt = this.buildEvaluationPrompt(content, requirements);
|
|
364
|
+
|
|
365
|
+
// 2. 调用 LLM
|
|
366
|
+
const response = await this.llmService.generate(prompt, {
|
|
367
|
+
temperature: 0.3,
|
|
368
|
+
maxTokens: 500,
|
|
369
|
+
responseFormat: 'json_object'
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
// 3. 解析响应
|
|
373
|
+
const evaluation = this.parseEvaluationResponse(response);
|
|
374
|
+
|
|
375
|
+
// 4. 计算加权总分
|
|
376
|
+
const score = this.calculateScore(evaluation);
|
|
377
|
+
|
|
378
|
+
return {
|
|
379
|
+
score,
|
|
380
|
+
passed: score >= options.passThreshold,
|
|
381
|
+
dimensions: evaluation.dimensions,
|
|
382
|
+
reasoning: evaluation.reasoning
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
private buildEvaluationPrompt(content: string, requirements: string): string {
|
|
387
|
+
return `
|
|
388
|
+
你是一位专业的文章质量评估专家。请根据以下要求评估文章:
|
|
389
|
+
|
|
390
|
+
## 文章内容
|
|
391
|
+
${content}
|
|
392
|
+
|
|
393
|
+
## 写作要求
|
|
394
|
+
${requirements}
|
|
395
|
+
|
|
396
|
+
## 评估维度
|
|
397
|
+
请从以下四个维度评估文章质量(0-10分):
|
|
398
|
+
|
|
399
|
+
1. **相关性 (30%)**
|
|
400
|
+
- 内容是否紧扣主题
|
|
401
|
+
- 是否回应了所有写作要求
|
|
402
|
+
- 是否有偏离主题的内容
|
|
403
|
+
|
|
404
|
+
2. **连贯性 (30%)**
|
|
405
|
+
- 逻辑是否清晰
|
|
406
|
+
- 段落衔接是否自然
|
|
407
|
+
- 论证是否有条理
|
|
408
|
+
|
|
409
|
+
3. **完整性 (20%)**
|
|
410
|
+
- 内容是否完整
|
|
411
|
+
- 要点是否覆盖
|
|
412
|
+
- 是否有明显遗漏
|
|
413
|
+
|
|
414
|
+
4. **可读性 (20%)**
|
|
415
|
+
- 语言是否通顺
|
|
416
|
+
- 用词是否准确
|
|
417
|
+
- 是否易于理解
|
|
418
|
+
|
|
419
|
+
## 输出格式
|
|
420
|
+
请以 JSON 格式输出:
|
|
421
|
+
{
|
|
422
|
+
"relevance": 分数,
|
|
423
|
+
"coherence": 分数,
|
|
424
|
+
"completeness": 分数,
|
|
425
|
+
"readability": 分数,
|
|
426
|
+
"reasoning": "评估理由(100字以内)"
|
|
427
|
+
}
|
|
428
|
+
`;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
private calculateScore(evaluation: EvaluationData): number {
|
|
432
|
+
return (
|
|
433
|
+
evaluation.dimensions.relevance * 0.3 +
|
|
434
|
+
evaluation.dimensions.coherence * 0.3 +
|
|
435
|
+
evaluation.dimensions.completeness * 0.2 +
|
|
436
|
+
evaluation.dimensions.readability * 0.2
|
|
437
|
+
) * 10; // 转换为 0-10 分制
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
private parseEvaluationResponse(response: string): EvaluationData {
|
|
441
|
+
try {
|
|
442
|
+
const parsed = JSON.parse(response);
|
|
443
|
+
return {
|
|
444
|
+
dimensions: {
|
|
445
|
+
relevance: parsed.relevance,
|
|
446
|
+
coherence: parsed.coherence,
|
|
447
|
+
completeness: parsed.completeness,
|
|
448
|
+
readability: parsed.readability
|
|
449
|
+
},
|
|
450
|
+
reasoning: parsed.reasoning
|
|
451
|
+
};
|
|
452
|
+
} catch (error) {
|
|
453
|
+
// Fallback: 如果解析失败,返回默认分数
|
|
454
|
+
return {
|
|
455
|
+
dimensions: {
|
|
456
|
+
relevance: 7,
|
|
457
|
+
coherence: 7,
|
|
458
|
+
completeness: 7,
|
|
459
|
+
readability: 7
|
|
460
|
+
},
|
|
461
|
+
reasoning: '无法解析评估结果'
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
### 智能重试机制
|
|
469
|
+
|
|
470
|
+
```typescript
|
|
471
|
+
// 文件: src/services/quality/RetryManager.ts
|
|
472
|
+
|
|
473
|
+
export class RetryManager {
|
|
474
|
+
async shouldRetry(
|
|
475
|
+
content: string,
|
|
476
|
+
evaluation: EvaluationResult,
|
|
477
|
+
attemptNumber: number,
|
|
478
|
+
maxAttempts: number
|
|
479
|
+
): Promise<boolean> {
|
|
480
|
+
// 达到最大重试次数
|
|
481
|
+
if (attemptNumber >= maxAttempts) {
|
|
482
|
+
return false;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
// 分数足够高
|
|
486
|
+
if (evaluation.score >= 7.0) {
|
|
487
|
+
return false;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
return true;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
getNextRetryPrompt(
|
|
494
|
+
content: string,
|
|
495
|
+
evaluation: EvaluationResult,
|
|
496
|
+
previousContent?: string
|
|
497
|
+
): string {
|
|
498
|
+
const suggestions = this.generateFixSuggestions(evaluation);
|
|
499
|
+
|
|
500
|
+
if (previousContent) {
|
|
501
|
+
// 重写模式
|
|
502
|
+
return `
|
|
503
|
+
根据以下质检反馈,修改上一版文章:
|
|
504
|
+
|
|
505
|
+
## 质检反馈
|
|
506
|
+
${suggestions.map(s => `- ${s}`).join('\n')}
|
|
507
|
+
|
|
508
|
+
## 要求
|
|
509
|
+
1. 只修改有问题的部分
|
|
510
|
+
2. 保持已经合格的内容不变
|
|
511
|
+
3. 确保修改后不引入新问题
|
|
512
|
+
|
|
513
|
+
## 上一版文章
|
|
514
|
+
${previousContent}
|
|
515
|
+
|
|
516
|
+
请输出修改后的完整文章。
|
|
517
|
+
`;
|
|
518
|
+
} else {
|
|
519
|
+
// 首次重试
|
|
520
|
+
return `
|
|
521
|
+
请根据以下质检反馈,重新生成文章:
|
|
522
|
+
|
|
523
|
+
## 质检反馈
|
|
524
|
+
${suggestions.map(s => `- ${s}`).join('\n')}
|
|
525
|
+
|
|
526
|
+
## 原要求
|
|
527
|
+
${this.requirements}
|
|
528
|
+
|
|
529
|
+
请输出改进后的完整文章。
|
|
530
|
+
`;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
private generateFixSuggestions(evaluation: EvaluationResult): string[] {
|
|
535
|
+
const suggestions: string[] = [];
|
|
536
|
+
|
|
537
|
+
const { dimensions, reasoning } = evaluation;
|
|
538
|
+
|
|
539
|
+
if (dimensions.relevance < 7) {
|
|
540
|
+
suggestions.push('相关性不足:请更紧密地围绕主题展开内容');
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
if (dimensions.coherence < 7) {
|
|
544
|
+
suggestions.push('连贯性欠佳:请加强段落间的逻辑衔接');
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
if (dimensions.completeness < 7) {
|
|
548
|
+
suggestions.push('完整性不够:请补充遗漏的关键要点');
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
if (dimensions.readability < 7) {
|
|
552
|
+
suggestions.push('可读性待提升:请优化语言表达,使其更通顺易懂');
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
if (suggestions.length === 0) {
|
|
556
|
+
suggestions.push(reasoning || '整体质量需要提升');
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
return suggestions;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
---
|
|
565
|
+
|
|
566
|
+
## 智能反馈
|
|
567
|
+
|
|
568
|
+
### 反馈生成器
|
|
569
|
+
|
|
570
|
+
```typescript
|
|
571
|
+
// 文件: src/services/quality/FeedbackGenerator.ts
|
|
572
|
+
|
|
573
|
+
export class FeedbackGenerator {
|
|
574
|
+
generate(
|
|
575
|
+
hardRuleResult: CheckResult,
|
|
576
|
+
llmEvaluation?: EvaluationResult
|
|
577
|
+
): QualityFeedback {
|
|
578
|
+
const feedback: QualityFeedback = {
|
|
579
|
+
hardConstraints: {
|
|
580
|
+
passed: hardRuleResult.passed,
|
|
581
|
+
issues: [],
|
|
582
|
+
fixSuggestions: []
|
|
583
|
+
},
|
|
584
|
+
softScoring: llmEvaluation ? {
|
|
585
|
+
passed: llmEvaluation.passed,
|
|
586
|
+
score: llmEvaluation.score,
|
|
587
|
+
dimensions: llmEvaluation.dimensions,
|
|
588
|
+
reasoning: llmEvaluation.reasoning
|
|
589
|
+
} : null,
|
|
590
|
+
overall: {
|
|
591
|
+
passed: false,
|
|
592
|
+
score: 0
|
|
593
|
+
}
|
|
594
|
+
};
|
|
595
|
+
|
|
596
|
+
// 硬规则反馈
|
|
597
|
+
if (!hardRuleResult.passed) {
|
|
598
|
+
feedback.hardConstraints.fixSuggestions =
|
|
599
|
+
this.getHardRuleFixSuggestions(hardRuleResult);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
// 软评分反馈
|
|
603
|
+
if (llmEvaluation && !llmEvaluation.passed) {
|
|
604
|
+
feedback.softScoring!.fixSuggestions =
|
|
605
|
+
this.getLLMFixSuggestions(llmEvaluation);
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
// 整体评估
|
|
609
|
+
feedback.overall = this.calculateOverallFeedback(feedback);
|
|
610
|
+
|
|
611
|
+
return feedback;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
private getHardRuleFixSuggestions(result: CheckResult): string[] {
|
|
615
|
+
const suggestions: string[] = [];
|
|
616
|
+
|
|
617
|
+
// 字数问题
|
|
618
|
+
if (result.details.wordCount !== undefined) {
|
|
619
|
+
if (result.details.deficit > 0) {
|
|
620
|
+
suggestions.push(`字数不足:还需补充 ${result.details.deficit} 字`);
|
|
621
|
+
}
|
|
622
|
+
if (result.details.excess > 0) {
|
|
623
|
+
suggestions.push(`字数超出:需要精简 ${result.details.excess} 字`);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
// 关键词问题
|
|
628
|
+
if (result.details.missing?.length > 0) {
|
|
629
|
+
suggestions.push(`缺少关键词:${result.details.missing.join('、')}`);
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
// 结构问题
|
|
633
|
+
if (result.details.issues?.length > 0) {
|
|
634
|
+
suggestions.push(...result.details.issues);
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
return suggestions;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
private getLLMFixSuggestions(evaluation: EvaluationResult): string[] {
|
|
641
|
+
const suggestions: string[] = [];
|
|
642
|
+
const { dimensions } = evaluation;
|
|
643
|
+
|
|
644
|
+
if (dimensions.relevance < 7) {
|
|
645
|
+
suggestions.push('加强内容与主题的相关性');
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
if (dimensions.coherence < 7) {
|
|
649
|
+
suggestions.push('优化段落间的逻辑衔接');
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
if (dimensions.completeness < 7) {
|
|
653
|
+
suggestions.push('补充遗漏的关键要点');
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
if (dimensions.readability < 7) {
|
|
657
|
+
suggestions.push('提升语言表达的通顺度');
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
return suggestions;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
private calculateOverallFeedback(feedback: QualityFeedback): OverallFeedback {
|
|
664
|
+
// 必须通过硬规则
|
|
665
|
+
if (!feedback.hardConstraints.passed) {
|
|
666
|
+
return {
|
|
667
|
+
passed: false,
|
|
668
|
+
score: 0,
|
|
669
|
+
reason: '硬性约束未通过'
|
|
670
|
+
};
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
// 如果没有软评分,硬规则通过即整体通过
|
|
674
|
+
if (!feedback.softScoring) {
|
|
675
|
+
return {
|
|
676
|
+
passed: true,
|
|
677
|
+
score: 8,
|
|
678
|
+
reason: '硬规则检查通过'
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
// 综合评估
|
|
683
|
+
return {
|
|
684
|
+
passed: feedback.softScoring.passed,
|
|
685
|
+
score: feedback.softScoring.score,
|
|
686
|
+
reason: feedback.softScoring.reasoning
|
|
687
|
+
};
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
```
|
|
691
|
+
|
|
692
|
+
---
|
|
693
|
+
|
|
694
|
+
## 配置管理
|
|
695
|
+
|
|
696
|
+
### 配置文件
|
|
697
|
+
|
|
698
|
+
```yaml
|
|
699
|
+
# config/quality-check.yaml
|
|
700
|
+
quality_check:
|
|
701
|
+
version: "1.0"
|
|
702
|
+
|
|
703
|
+
# 硬规则配置
|
|
704
|
+
hard_rules:
|
|
705
|
+
word_count:
|
|
706
|
+
enabled: true
|
|
707
|
+
min: 500
|
|
708
|
+
max: 5000
|
|
709
|
+
|
|
710
|
+
keywords:
|
|
711
|
+
enabled: true
|
|
712
|
+
required: true
|
|
713
|
+
match_all: false # false: 至少匹配一个
|
|
714
|
+
|
|
715
|
+
structure:
|
|
716
|
+
enabled: true
|
|
717
|
+
require_title: true
|
|
718
|
+
require_intro: true
|
|
719
|
+
require_body: true
|
|
720
|
+
require_conclusion: false
|
|
721
|
+
|
|
722
|
+
forbidden_words:
|
|
723
|
+
enabled: true
|
|
724
|
+
words: []
|
|
725
|
+
# - "违规词1"
|
|
726
|
+
# - "违规词2"
|
|
727
|
+
|
|
728
|
+
# 软评分配置
|
|
729
|
+
soft_scoring:
|
|
730
|
+
enabled: true
|
|
731
|
+
provider: llm
|
|
732
|
+
|
|
733
|
+
llm_config:
|
|
734
|
+
model: deepseek-chat
|
|
735
|
+
temperature: 0.3
|
|
736
|
+
max_tokens: 500
|
|
737
|
+
timeout: 30000
|
|
738
|
+
|
|
739
|
+
dimensions:
|
|
740
|
+
relevance:
|
|
741
|
+
weight: 0.3
|
|
742
|
+
description: "内容与主题的相关性"
|
|
743
|
+
|
|
744
|
+
coherence:
|
|
745
|
+
weight: 0.3
|
|
746
|
+
description: "逻辑连贯性"
|
|
747
|
+
|
|
748
|
+
completeness:
|
|
749
|
+
weight: 0.2
|
|
750
|
+
description: "内容完整性"
|
|
751
|
+
|
|
752
|
+
readability:
|
|
753
|
+
weight: 0.2
|
|
754
|
+
description: "可读性"
|
|
755
|
+
|
|
756
|
+
pass_threshold: 7.0
|
|
757
|
+
|
|
758
|
+
retry:
|
|
759
|
+
max_attempts: 3
|
|
760
|
+
temperature_schedule: [0.3, 0.5, 0.7]
|
|
761
|
+
|
|
762
|
+
# 缓存配置
|
|
763
|
+
cache:
|
|
764
|
+
enabled: true
|
|
765
|
+
ttl: 259200 # 3天(秒)
|
|
766
|
+
```
|
|
767
|
+
|
|
768
|
+
### 配置加载
|
|
769
|
+
|
|
770
|
+
```typescript
|
|
771
|
+
// 文件: src/services/quality/config/QualityCheckConfig.ts
|
|
772
|
+
|
|
773
|
+
import yaml from 'js-yaml';
|
|
774
|
+
import fs from 'fs';
|
|
775
|
+
|
|
776
|
+
export interface QualityCheckConfig {
|
|
777
|
+
version: string;
|
|
778
|
+
hard_rules: any;
|
|
779
|
+
soft_scoring: any;
|
|
780
|
+
cache: any;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
export class QualityCheckConfigLoader {
|
|
784
|
+
private config: QualityCheckConfig;
|
|
785
|
+
|
|
786
|
+
load(configPath: string): QualityCheckConfig {
|
|
787
|
+
const fileContent = fs.readFileSync(configPath, 'utf8');
|
|
788
|
+
this.config = yaml.load(fileContent);
|
|
789
|
+
return this.config;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
getHardRuleConfig(ruleName: string): any {
|
|
793
|
+
return this.config.hard_rules[ruleName];
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
getSoftScoringConfig(): any {
|
|
797
|
+
return this.config.soft_scoring;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
isHardRuleEnabled(ruleName: string): boolean {
|
|
801
|
+
const rule = this.config.hard_rules[ruleName];
|
|
802
|
+
return rule && rule.enabled;
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
isSoftScoringEnabled(): boolean {
|
|
806
|
+
return this.config.soft_scoring.enabled;
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
```
|
|
810
|
+
|
|
811
|
+
---
|
|
812
|
+
|
|
813
|
+
## 实施指南
|
|
814
|
+
|
|
815
|
+
### Step 1: 创建基础结构
|
|
816
|
+
|
|
817
|
+
```bash
|
|
818
|
+
# 创建目录
|
|
819
|
+
mkdir -p src/services/quality/{checkers,evaluators,config}
|
|
820
|
+
|
|
821
|
+
# 创建文件
|
|
822
|
+
touch src/services/quality/QualityCheckService.ts
|
|
823
|
+
touch src/services/quality/checkers/WordCountChecker.ts
|
|
824
|
+
touch src/services/quality/checkers/KeywordChecker.ts
|
|
825
|
+
touch src/services/quality/checkers/StructureChecker.ts
|
|
826
|
+
touch src/services/quality/evaluators/LLMEvaluator.ts
|
|
827
|
+
touch src/services/quality/FeedbackGenerator.ts
|
|
828
|
+
```
|
|
829
|
+
|
|
830
|
+
### Step 2: 实现硬规则检查器
|
|
831
|
+
|
|
832
|
+
```bash
|
|
833
|
+
# 按顺序实现
|
|
834
|
+
1. WordCountChecker
|
|
835
|
+
2. KeywordChecker
|
|
836
|
+
3. StructureChecker
|
|
837
|
+
4. ForbiddenWordsChecker
|
|
838
|
+
|
|
839
|
+
# 每个检查器实现后编写测试
|
|
840
|
+
pnpm test -- WordCountChecker
|
|
841
|
+
```
|
|
842
|
+
|
|
843
|
+
### Step 3: 实现 LLM 评估器
|
|
844
|
+
|
|
845
|
+
```bash
|
|
846
|
+
1. 创建 LLMEvaluator
|
|
847
|
+
2. 实现 Prompt 模板
|
|
848
|
+
3. 实现响应解析
|
|
849
|
+
4. 编写测试
|
|
850
|
+
```
|
|
851
|
+
|
|
852
|
+
### Step 4: 集成到工作流
|
|
853
|
+
|
|
854
|
+
```typescript
|
|
855
|
+
// 更新 CheckTextNode
|
|
856
|
+
import { QualityCheckService } from '../../services/quality/index.js';
|
|
857
|
+
|
|
858
|
+
export class CheckTextNode extends BaseNode {
|
|
859
|
+
private qualityService = new QualityCheckService();
|
|
860
|
+
|
|
861
|
+
async executeLogic(state: State): Promise<Partial<State>> {
|
|
862
|
+
const result = await this.qualityService.check(
|
|
863
|
+
state.articleContent!,
|
|
864
|
+
state.requirements!,
|
|
865
|
+
state.hardConstraints!
|
|
866
|
+
);
|
|
867
|
+
|
|
868
|
+
return {
|
|
869
|
+
textQualityReport: result,
|
|
870
|
+
textRetryCount: state.textRetryCount + (result.passed ? 0 : 1)
|
|
871
|
+
};
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
```
|
|
875
|
+
|
|
876
|
+
---
|
|
877
|
+
|
|
878
|
+
## 测试策略
|
|
879
|
+
|
|
880
|
+
### 单元测试
|
|
881
|
+
|
|
882
|
+
```typescript
|
|
883
|
+
// WordCountChecker 测试
|
|
884
|
+
describe('WordCountChecker', () => {
|
|
885
|
+
it('should pass when word count in range', () => {
|
|
886
|
+
const checker = new WordCountChecker();
|
|
887
|
+
const result = checker.check('测试内容', { min: 2, max: 100 });
|
|
888
|
+
expect(result.passed).toBe(true);
|
|
889
|
+
});
|
|
890
|
+
|
|
891
|
+
it('should fail when word count below min', () => {
|
|
892
|
+
const checker = new WordCountChecker();
|
|
893
|
+
const result = checker.check('测', { min: 10, max: 100 });
|
|
894
|
+
expect(result.passed).toBe(false);
|
|
895
|
+
expect(result.details.deficit).toBe(7);
|
|
896
|
+
});
|
|
897
|
+
});
|
|
898
|
+
|
|
899
|
+
// KeywordChecker 测试
|
|
900
|
+
describe('KeywordChecker', () => {
|
|
901
|
+
it('should pass when all keywords found', () => {
|
|
902
|
+
const checker = new KeywordChecker();
|
|
903
|
+
const result = checker.check(
|
|
904
|
+
'人工智能和机器学习',
|
|
905
|
+
['人工智能', '机器学习'],
|
|
906
|
+
{ matchAll: true }
|
|
907
|
+
);
|
|
908
|
+
expect(result.passed).toBe(true);
|
|
909
|
+
});
|
|
910
|
+
|
|
911
|
+
it('should pass with matchAll: false', () => {
|
|
912
|
+
const checker = new KeywordChecker();
|
|
913
|
+
const result = checker.check(
|
|
914
|
+
'人工智能很棒',
|
|
915
|
+
['人工智能', '机器学习'],
|
|
916
|
+
{ matchAll: false }
|
|
917
|
+
);
|
|
918
|
+
expect(result.passed).toBe(true);
|
|
919
|
+
});
|
|
920
|
+
});
|
|
921
|
+
```
|
|
922
|
+
|
|
923
|
+
### 集成测试
|
|
924
|
+
|
|
925
|
+
```typescript
|
|
926
|
+
describe('QualityCheckService Integration', () => {
|
|
927
|
+
it('should pass both checks', async () => {
|
|
928
|
+
const service = new QualityCheckService();
|
|
929
|
+
const result = await service.check(
|
|
930
|
+
'这是一篇关于人工智能的文章...',
|
|
931
|
+
'写一篇关于AI的文章',
|
|
932
|
+
{
|
|
933
|
+
minWords: 10,
|
|
934
|
+
maxWords: 1000,
|
|
935
|
+
keywords: ['AI']
|
|
936
|
+
}
|
|
937
|
+
);
|
|
938
|
+
expect(result.passed).toBe(true);
|
|
939
|
+
});
|
|
940
|
+
|
|
941
|
+
it('should fail hard rule and skip LLM', async () => {
|
|
942
|
+
const service = new QualityCheckService();
|
|
943
|
+
const result = await service.check(
|
|
944
|
+
'短文',
|
|
945
|
+
'写一篇文章',
|
|
946
|
+
{ minWords: 100, maxWords: 1000 }
|
|
947
|
+
);
|
|
948
|
+
expect(result.hardConstraintsPassed).toBe(false);
|
|
949
|
+
expect(result.softScoring).toBeNull();
|
|
950
|
+
});
|
|
951
|
+
});
|
|
952
|
+
```
|
|
953
|
+
|
|
954
|
+
---
|
|
955
|
+
|
|
956
|
+
## 性能优化
|
|
957
|
+
|
|
958
|
+
### 缓存策略
|
|
959
|
+
|
|
960
|
+
```typescript
|
|
961
|
+
// 缓存质量检查结果
|
|
962
|
+
async check(content: string, requirements: string, constraints: any) {
|
|
963
|
+
const cacheKey = this.hashContent(content, requirements);
|
|
964
|
+
|
|
965
|
+
// 检查缓存
|
|
966
|
+
const cached = await this.cache.get(cacheKey);
|
|
967
|
+
if (cached) {
|
|
968
|
+
return cached;
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
// 执行检查
|
|
972
|
+
const result = await this.performCheck(content, requirements, constraints);
|
|
973
|
+
|
|
974
|
+
// 缓存结果(3天)
|
|
975
|
+
await this.cache.set(cacheKey, result, 259200);
|
|
976
|
+
|
|
977
|
+
return result;
|
|
978
|
+
}
|
|
979
|
+
```
|
|
980
|
+
|
|
981
|
+
### 并行检查
|
|
982
|
+
|
|
983
|
+
```typescript
|
|
984
|
+
// 并行执行多个硬规则检查
|
|
985
|
+
async checkHardRules(content: string, constraints: any): Promise<CheckResult[]> {
|
|
986
|
+
const checkers = [
|
|
987
|
+
new WordCountChecker(),
|
|
988
|
+
new KeywordChecker(),
|
|
989
|
+
new StructureChecker(),
|
|
990
|
+
new ForbiddenWordsChecker()
|
|
991
|
+
];
|
|
992
|
+
|
|
993
|
+
const results = await Promise.all(
|
|
994
|
+
checkers.map(checker => checker.check(content, constraints))
|
|
995
|
+
);
|
|
996
|
+
|
|
997
|
+
return results;
|
|
998
|
+
}
|
|
999
|
+
```
|
|
1000
|
+
|
|
1001
|
+
---
|
|
1002
|
+
|
|
1003
|
+
## 监控指标
|
|
1004
|
+
|
|
1005
|
+
### Prometheus 指标
|
|
1006
|
+
|
|
1007
|
+
```typescript
|
|
1008
|
+
// 质量检查指标
|
|
1009
|
+
const qualityCheckDuration = new Histogram({
|
|
1010
|
+
name: 'quality_check_duration_seconds',
|
|
1011
|
+
help: 'Quality check execution duration',
|
|
1012
|
+
buckets: [0.1, 0.5, 1, 5, 10, 30]
|
|
1013
|
+
});
|
|
1014
|
+
|
|
1015
|
+
const qualityCheckPassRate = new Gauge({
|
|
1016
|
+
name: 'quality_check_pass_rate',
|
|
1017
|
+
help: 'Quality check pass rate'
|
|
1018
|
+
});
|
|
1019
|
+
|
|
1020
|
+
const qualityCheckScore = new Histogram({
|
|
1021
|
+
name: 'quality_check_score',
|
|
1022
|
+
help: 'Quality check score distribution',
|
|
1023
|
+
buckets: [0, 3, 5, 7, 8, 9, 10]
|
|
1024
|
+
});
|
|
1025
|
+
```
|
|
1026
|
+
|
|
1027
|
+
---
|
|
1028
|
+
|
|
1029
|
+
**文档生成时间**: 2026-01-19
|
|
1030
|
+
**版本**: 1.0
|