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,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enhanced LLM Service
|
|
3
|
+
*
|
|
4
|
+
* 在原有 LLMService 基础上添加:
|
|
5
|
+
* - 重试机制(指数退避)
|
|
6
|
+
* - Token 使用记录
|
|
7
|
+
* - 成本估算
|
|
8
|
+
* - 性能监控
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Chat 消息
|
|
12
|
+
*/
|
|
13
|
+
export interface ChatMessage {
|
|
14
|
+
role: 'system' | 'user' | 'assistant';
|
|
15
|
+
content: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Chat 请求参数
|
|
19
|
+
*/
|
|
20
|
+
export interface ChatRequest {
|
|
21
|
+
messages: ChatMessage[];
|
|
22
|
+
model?: string;
|
|
23
|
+
maxTokens?: number;
|
|
24
|
+
temperature?: number;
|
|
25
|
+
stream?: boolean;
|
|
26
|
+
taskId?: string;
|
|
27
|
+
stepName?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Chat 响应
|
|
31
|
+
*/
|
|
32
|
+
export interface ChatResponse {
|
|
33
|
+
id: string;
|
|
34
|
+
object: string;
|
|
35
|
+
created: number;
|
|
36
|
+
model: string;
|
|
37
|
+
choices: Array<{
|
|
38
|
+
index: number;
|
|
39
|
+
message: {
|
|
40
|
+
role: string;
|
|
41
|
+
content: string;
|
|
42
|
+
};
|
|
43
|
+
finishReason: string | null;
|
|
44
|
+
}>;
|
|
45
|
+
usage: {
|
|
46
|
+
promptTokens: number;
|
|
47
|
+
completionTokens: number;
|
|
48
|
+
totalTokens: number;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Token 使用统计
|
|
53
|
+
*/
|
|
54
|
+
export interface TokenUsage {
|
|
55
|
+
promptTokens: number;
|
|
56
|
+
completionTokens: number;
|
|
57
|
+
totalTokens: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* 重试配置
|
|
61
|
+
*/
|
|
62
|
+
export interface RetryConfig {
|
|
63
|
+
maxRetries: number;
|
|
64
|
+
initialDelay: number;
|
|
65
|
+
maxDelay: number;
|
|
66
|
+
backoffMultiplier: number;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* 增强的 LLM 服务类
|
|
70
|
+
*/
|
|
71
|
+
export declare class EnhancedLLMService {
|
|
72
|
+
private baseURL;
|
|
73
|
+
private apiKey;
|
|
74
|
+
private modelName;
|
|
75
|
+
private maxTokens;
|
|
76
|
+
private temperature;
|
|
77
|
+
private retryConfig;
|
|
78
|
+
private tokenUsageRepo;
|
|
79
|
+
constructor(retryConfig?: Partial<RetryConfig>);
|
|
80
|
+
/**
|
|
81
|
+
* 聊天对话(带重试和 Token 记录)
|
|
82
|
+
*/
|
|
83
|
+
chat(request: ChatRequest): Promise<{
|
|
84
|
+
content: string;
|
|
85
|
+
usage: TokenUsage;
|
|
86
|
+
cost: number;
|
|
87
|
+
}>;
|
|
88
|
+
/**
|
|
89
|
+
* 带重试的聊天请求
|
|
90
|
+
*/
|
|
91
|
+
private chatWithRetry;
|
|
92
|
+
/**
|
|
93
|
+
* 单次聊天请求
|
|
94
|
+
*/
|
|
95
|
+
private chatRequest;
|
|
96
|
+
/**
|
|
97
|
+
* 流式聊天请求
|
|
98
|
+
*/
|
|
99
|
+
private chatRequestStream;
|
|
100
|
+
/**
|
|
101
|
+
* 判断是否应该重试
|
|
102
|
+
*/
|
|
103
|
+
private shouldRetry;
|
|
104
|
+
/**
|
|
105
|
+
* 计算重试延迟(指数退避)
|
|
106
|
+
*/
|
|
107
|
+
private calculateRetryDelay;
|
|
108
|
+
/**
|
|
109
|
+
* 计算 Token 成本
|
|
110
|
+
*/
|
|
111
|
+
private calculateCost;
|
|
112
|
+
/**
|
|
113
|
+
* 记录 Token 使用到数据库
|
|
114
|
+
*/
|
|
115
|
+
private recordTokenUsage;
|
|
116
|
+
/**
|
|
117
|
+
* 生成 Trace ID(用于链路追踪)
|
|
118
|
+
*/
|
|
119
|
+
private generateTraceId;
|
|
120
|
+
/**
|
|
121
|
+
* 延迟函数
|
|
122
|
+
*/
|
|
123
|
+
private sleep;
|
|
124
|
+
/**
|
|
125
|
+
* 生成文本(简化接口)
|
|
126
|
+
*/
|
|
127
|
+
generateText(prompt: string, systemPrompt?: string, options?: {
|
|
128
|
+
taskId?: string;
|
|
129
|
+
stepName?: string;
|
|
130
|
+
}): Promise<string>;
|
|
131
|
+
/**
|
|
132
|
+
* 健康检查
|
|
133
|
+
*/
|
|
134
|
+
healthCheck(): Promise<boolean>;
|
|
135
|
+
/**
|
|
136
|
+
* 计算文本的 Token 数量(估算)
|
|
137
|
+
*/
|
|
138
|
+
estimateTokens(text: string): number;
|
|
139
|
+
/**
|
|
140
|
+
* 估算成本(未调用 API)
|
|
141
|
+
*/
|
|
142
|
+
estimateCost(tokensIn: number, tokensOut: number): number;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* 增强的 LLM 服务单例
|
|
146
|
+
*/
|
|
147
|
+
export declare const enhancedLLMService: EnhancedLLMService;
|
|
148
|
+
//# sourceMappingURL=EnhancedLLMService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnhancedLLMService.d.ts","sourceRoot":"","sources":["../../../src/services/llm/EnhancedLLMService.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAQH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,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
|
+
* 在原有 LLMService 基础上添加:
|
|
5
|
+
* - 重试机制(指数退避)
|
|
6
|
+
* - Token 使用记录
|
|
7
|
+
* - 成本估算
|
|
8
|
+
* - 性能监控
|
|
9
|
+
*/
|
|
10
|
+
import axios, { AxiosError } from 'axios';
|
|
11
|
+
import { config } from '../../config/index.js';
|
|
12
|
+
import { createLogger } from '../../infrastructure/logging/logger.js';
|
|
13
|
+
const logger = createLogger('LLM:Enhanced');
|
|
14
|
+
/**
|
|
15
|
+
* 默认重试配置
|
|
16
|
+
*/
|
|
17
|
+
const DEFAULT_RETRY_CONFIG = {
|
|
18
|
+
maxRetries: 3,
|
|
19
|
+
initialDelay: 1000, // 1 秒
|
|
20
|
+
maxDelay: 10000, // 10 秒
|
|
21
|
+
backoffMultiplier: 2, // 指数退避
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* 成本配置(元/1k tokens)
|
|
25
|
+
*/
|
|
26
|
+
const COST_CONFIG = {
|
|
27
|
+
deepseek: {
|
|
28
|
+
'deepseek-chat': {
|
|
29
|
+
costPer1kTokensIn: 0.001,
|
|
30
|
+
costPer1kTokensOut: 0.002,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* 增强的 LLM 服务类
|
|
36
|
+
*/
|
|
37
|
+
export class EnhancedLLMService {
|
|
38
|
+
baseURL;
|
|
39
|
+
apiKey;
|
|
40
|
+
modelName;
|
|
41
|
+
maxTokens;
|
|
42
|
+
temperature;
|
|
43
|
+
retryConfig;
|
|
44
|
+
tokenUsageRepo;
|
|
45
|
+
constructor(retryConfig) {
|
|
46
|
+
this.baseURL = config.llm.baseURL;
|
|
47
|
+
this.apiKey = config.llm.apiKey;
|
|
48
|
+
this.modelName = config.llm.modelName;
|
|
49
|
+
this.maxTokens = config.llm.maxTokens;
|
|
50
|
+
this.temperature = config.llm.temperature;
|
|
51
|
+
this.retryConfig = { ...DEFAULT_RETRY_CONFIG, ...retryConfig };
|
|
52
|
+
this.tokenUsageRepo = new TempTokenUsageRepository();
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* 聊天对话(带重试和 Token 记录)
|
|
56
|
+
*/
|
|
57
|
+
async chat(request) {
|
|
58
|
+
const startTime = Date.now();
|
|
59
|
+
try {
|
|
60
|
+
logger.debug('Sending chat request with retry', {
|
|
61
|
+
model: request.model || this.modelName,
|
|
62
|
+
messagesCount: request.messages.length,
|
|
63
|
+
maxRetries: this.retryConfig.maxRetries,
|
|
64
|
+
stream: request.stream || false,
|
|
65
|
+
});
|
|
66
|
+
// 带重试的请求
|
|
67
|
+
const response = await this.chatWithRetry(request);
|
|
68
|
+
// 提取数据
|
|
69
|
+
const choice = response.choices[0];
|
|
70
|
+
if (!choice) {
|
|
71
|
+
throw new Error('No choice in response');
|
|
72
|
+
}
|
|
73
|
+
const content = choice.message.content;
|
|
74
|
+
const usage = response.usage;
|
|
75
|
+
// 计算 Token 成本
|
|
76
|
+
const cost = this.calculateCost(usage.promptTokens, usage.completionTokens, this.modelName);
|
|
77
|
+
// 记录 Token 使用
|
|
78
|
+
if (request.taskId && request.stepName) {
|
|
79
|
+
await this.recordTokenUsage({
|
|
80
|
+
taskId: request.taskId,
|
|
81
|
+
stepName: request.stepName,
|
|
82
|
+
tokensIn: usage.promptTokens,
|
|
83
|
+
tokensOut: usage.completionTokens,
|
|
84
|
+
totalTokens: usage.totalTokens,
|
|
85
|
+
costPer1kTokensIn: COST_CONFIG.deepseek?.[this.modelName]?.costPer1kTokensIn || 0,
|
|
86
|
+
costPer1kTokensOut: COST_CONFIG.deepseek?.[this.modelName]?.costPer1kTokensOut || 0,
|
|
87
|
+
totalCost: cost,
|
|
88
|
+
duration: Date.now() - startTime,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
logger.info('Chat request completed', {
|
|
92
|
+
promptTokens: usage.promptTokens,
|
|
93
|
+
completionTokens: usage.completionTokens,
|
|
94
|
+
totalTokens: usage.totalTokens,
|
|
95
|
+
cost,
|
|
96
|
+
finishReason: choice.finishReason,
|
|
97
|
+
duration: Date.now() - startTime,
|
|
98
|
+
stream: request.stream || false,
|
|
99
|
+
});
|
|
100
|
+
return {
|
|
101
|
+
content,
|
|
102
|
+
usage: {
|
|
103
|
+
promptTokens: usage.promptTokens,
|
|
104
|
+
completionTokens: usage.completionTokens,
|
|
105
|
+
totalTokens: usage.totalTokens,
|
|
106
|
+
},
|
|
107
|
+
cost,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
logger.error('LLM API request failed after retries', {
|
|
112
|
+
error: error instanceof Error ? error.message : String(error),
|
|
113
|
+
duration: Date.now() - startTime,
|
|
114
|
+
stream: request.stream || false,
|
|
115
|
+
});
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* 带重试的聊天请求
|
|
121
|
+
*/
|
|
122
|
+
async chatWithRetry(request) {
|
|
123
|
+
let lastError = null;
|
|
124
|
+
for (let attempt = 0; attempt <= this.retryConfig.maxRetries; attempt++) {
|
|
125
|
+
try {
|
|
126
|
+
if (attempt > 0) {
|
|
127
|
+
const delay = this.calculateRetryDelay(attempt);
|
|
128
|
+
logger.info(`Retrying chat request (attempt ${attempt + 1}/${this.retryConfig.maxRetries + 1})`, {
|
|
129
|
+
delay,
|
|
130
|
+
});
|
|
131
|
+
await this.sleep(delay);
|
|
132
|
+
}
|
|
133
|
+
return await this.chatRequest(request);
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
137
|
+
// 判断是否应该重试
|
|
138
|
+
if (!this.shouldRetry(lastError, attempt)) {
|
|
139
|
+
throw lastError;
|
|
140
|
+
}
|
|
141
|
+
logger.warn('Chat request failed, will retry', {
|
|
142
|
+
attempt: attempt + 1,
|
|
143
|
+
error: lastError.message,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
throw lastError;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* 单次聊天请求
|
|
151
|
+
*/
|
|
152
|
+
async chatRequest(request) {
|
|
153
|
+
const maxTokens = typeof (request.maxTokens || this.maxTokens) === 'number'
|
|
154
|
+
? request.maxTokens || this.maxTokens
|
|
155
|
+
: parseInt(String(request.maxTokens || this.maxTokens));
|
|
156
|
+
const temperature = typeof (request.temperature ?? this.temperature) === 'number'
|
|
157
|
+
? request.temperature ?? this.temperature
|
|
158
|
+
: parseFloat(String(request.temperature ?? this.temperature));
|
|
159
|
+
const useStream = request.stream || false;
|
|
160
|
+
// 流式请求
|
|
161
|
+
if (useStream) {
|
|
162
|
+
return await this.chatRequestStream(request, maxTokens, temperature);
|
|
163
|
+
}
|
|
164
|
+
// 非流式请求
|
|
165
|
+
const response = await axios.post(`${this.baseURL}/v1/chat/completions`, {
|
|
166
|
+
model: request.model || this.modelName,
|
|
167
|
+
messages: request.messages,
|
|
168
|
+
max_tokens: maxTokens,
|
|
169
|
+
temperature: temperature,
|
|
170
|
+
stream: false,
|
|
171
|
+
}, {
|
|
172
|
+
headers: {
|
|
173
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
174
|
+
'Content-Type': 'application/json',
|
|
175
|
+
},
|
|
176
|
+
timeout: 60000, // 60 秒超时
|
|
177
|
+
});
|
|
178
|
+
return response.data;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* 流式聊天请求
|
|
182
|
+
*/
|
|
183
|
+
async chatRequestStream(request, maxTokens, temperature) {
|
|
184
|
+
logger.debug('Starting stream request', {
|
|
185
|
+
model: request.model || this.modelName,
|
|
186
|
+
});
|
|
187
|
+
const response = await axios.post(`${this.baseURL}/v1/chat/completions`, {
|
|
188
|
+
model: request.model || this.modelName,
|
|
189
|
+
messages: request.messages,
|
|
190
|
+
max_tokens: maxTokens,
|
|
191
|
+
temperature: temperature,
|
|
192
|
+
stream: true,
|
|
193
|
+
}, {
|
|
194
|
+
headers: {
|
|
195
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
196
|
+
'Content-Type': 'application/json',
|
|
197
|
+
},
|
|
198
|
+
responseType: 'stream',
|
|
199
|
+
timeout: 120000, // 流式请求超时时间更长
|
|
200
|
+
});
|
|
201
|
+
// 收集流式数据
|
|
202
|
+
let fullContent = '';
|
|
203
|
+
let finishReason = null;
|
|
204
|
+
let promptTokens = 0;
|
|
205
|
+
let completionTokens = 0;
|
|
206
|
+
let totalTokens = 0;
|
|
207
|
+
return new Promise((resolve, reject) => {
|
|
208
|
+
const chunks = [];
|
|
209
|
+
response.data.on('data', (chunk) => {
|
|
210
|
+
chunks.push(chunk);
|
|
211
|
+
// 解析 SSE 数据
|
|
212
|
+
const chunkStr = chunk.toString('utf-8');
|
|
213
|
+
const lines = chunkStr.split('\n').filter(line => line.trim() !== '');
|
|
214
|
+
for (const line of lines) {
|
|
215
|
+
if (line.startsWith('data: ')) {
|
|
216
|
+
const data = line.slice(6);
|
|
217
|
+
if (data === '[DONE]') {
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
try {
|
|
221
|
+
const parsed = JSON.parse(data);
|
|
222
|
+
const delta = parsed.choices?.[0]?.delta;
|
|
223
|
+
if (delta?.content) {
|
|
224
|
+
fullContent += delta.content;
|
|
225
|
+
}
|
|
226
|
+
if (parsed.choices?.[0]?.finish_reason) {
|
|
227
|
+
finishReason = parsed.choices[0].finish_reason;
|
|
228
|
+
}
|
|
229
|
+
// 从最后一个 chunk 获取 usage 信息
|
|
230
|
+
if (parsed.usage) {
|
|
231
|
+
promptTokens = parsed.usage.prompt_tokens || 0;
|
|
232
|
+
completionTokens = parsed.usage.completion_tokens || 0;
|
|
233
|
+
totalTokens = parsed.usage.total_tokens || 0;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
catch (error) {
|
|
237
|
+
// 忽略解析错误(可能是空行或其他格式)
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
response.data.on('end', () => {
|
|
243
|
+
logger.debug('Stream request completed', {
|
|
244
|
+
contentLength: fullContent.length,
|
|
245
|
+
finishReason,
|
|
246
|
+
});
|
|
247
|
+
// 构造标准响应格式
|
|
248
|
+
resolve({
|
|
249
|
+
id: `chatcmpl-${Date.now()}`,
|
|
250
|
+
object: 'chat.completion',
|
|
251
|
+
created: Math.floor(Date.now() / 1000),
|
|
252
|
+
model: request.model || this.modelName,
|
|
253
|
+
choices: [{
|
|
254
|
+
index: 0,
|
|
255
|
+
message: {
|
|
256
|
+
role: 'assistant',
|
|
257
|
+
content: fullContent,
|
|
258
|
+
},
|
|
259
|
+
finishReason,
|
|
260
|
+
}],
|
|
261
|
+
usage: {
|
|
262
|
+
promptTokens,
|
|
263
|
+
completionTokens,
|
|
264
|
+
totalTokens,
|
|
265
|
+
},
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
response.data.on('error', (error) => {
|
|
269
|
+
logger.error('Stream request error', { error: error.message });
|
|
270
|
+
reject(error);
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* 判断是否应该重试
|
|
276
|
+
*/
|
|
277
|
+
shouldRetry(error, attempt) {
|
|
278
|
+
// 超过最大重试次数
|
|
279
|
+
if (attempt >= this.retryConfig.maxRetries) {
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
// 网络错误或超时
|
|
283
|
+
if (axios.isAxiosError(error)) {
|
|
284
|
+
const axiosError = error;
|
|
285
|
+
const isRetryable = !axiosError.response || // 无响应(网络错误)
|
|
286
|
+
axiosError.response.status >= 500 || // 服务器错误
|
|
287
|
+
axiosError.response.status === 429; // 限流
|
|
288
|
+
return isRetryable;
|
|
289
|
+
}
|
|
290
|
+
// 其他错误不重试
|
|
291
|
+
return false;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* 计算重试延迟(指数退避)
|
|
295
|
+
*/
|
|
296
|
+
calculateRetryDelay(attempt) {
|
|
297
|
+
const delay = Math.min(this.retryConfig.initialDelay * Math.pow(this.retryConfig.backoffMultiplier, attempt), this.retryConfig.maxDelay);
|
|
298
|
+
return delay;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* 计算 Token 成本
|
|
302
|
+
*/
|
|
303
|
+
calculateCost(tokensIn, tokensOut, modelName = this.modelName) {
|
|
304
|
+
const config = COST_CONFIG.deepseek?.[modelName];
|
|
305
|
+
if (!config) {
|
|
306
|
+
logger.warn(`No cost config found for model: ${modelName}`);
|
|
307
|
+
return 0;
|
|
308
|
+
}
|
|
309
|
+
const costIn = (tokensIn / 1000) * config.costPer1kTokensIn;
|
|
310
|
+
const costOut = (tokensOut / 1000) * config.costPer1kTokensOut;
|
|
311
|
+
return Number((costIn + costOut).toFixed(6));
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* 记录 Token 使用到数据库
|
|
315
|
+
*/
|
|
316
|
+
async recordTokenUsage(params) {
|
|
317
|
+
try {
|
|
318
|
+
await this.tokenUsageRepo.create({
|
|
319
|
+
taskId: params.taskId,
|
|
320
|
+
traceId: this.generateTraceId(),
|
|
321
|
+
stepName: params.stepName,
|
|
322
|
+
apiName: 'deepseek',
|
|
323
|
+
modelName: this.modelName,
|
|
324
|
+
tokensIn: params.tokensIn,
|
|
325
|
+
tokensOut: params.tokensOut,
|
|
326
|
+
totalTokens: params.totalTokens,
|
|
327
|
+
costPer1kTokensIn: params.costPer1kTokensIn,
|
|
328
|
+
costPer1kTokensOut: params.costPer1kTokensOut,
|
|
329
|
+
totalCost: params.totalCost,
|
|
330
|
+
metadata: {
|
|
331
|
+
duration: params.duration,
|
|
332
|
+
temperature: this.temperature,
|
|
333
|
+
maxTokens: this.maxTokens,
|
|
334
|
+
},
|
|
335
|
+
});
|
|
336
|
+
logger.debug('Token usage recorded', {
|
|
337
|
+
taskId: params.taskId,
|
|
338
|
+
stepName: params.stepName,
|
|
339
|
+
totalTokens: params.totalTokens,
|
|
340
|
+
cost: params.totalCost,
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
catch (error) {
|
|
344
|
+
logger.error('Failed to record token usage', {
|
|
345
|
+
error: error instanceof Error ? error.message : String(error),
|
|
346
|
+
});
|
|
347
|
+
// 不抛出错误,避免影响主流程
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* 生成 Trace ID(用于链路追踪)
|
|
352
|
+
*/
|
|
353
|
+
generateTraceId() {
|
|
354
|
+
return `trace_${Date.now()}_${Math.random().toString(36).substring(2, 15)}`;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* 延迟函数
|
|
358
|
+
*/
|
|
359
|
+
sleep(ms) {
|
|
360
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* 生成文本(简化接口)
|
|
364
|
+
*/
|
|
365
|
+
async generateText(prompt, systemPrompt, options) {
|
|
366
|
+
const messages = [];
|
|
367
|
+
if (systemPrompt) {
|
|
368
|
+
messages.push({ role: 'system', content: systemPrompt });
|
|
369
|
+
}
|
|
370
|
+
messages.push({ role: 'user', content: prompt });
|
|
371
|
+
const result = await this.chat({
|
|
372
|
+
messages,
|
|
373
|
+
taskId: options?.taskId,
|
|
374
|
+
stepName: options?.stepName,
|
|
375
|
+
});
|
|
376
|
+
return result.content;
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* 健康检查
|
|
380
|
+
*/
|
|
381
|
+
async healthCheck() {
|
|
382
|
+
try {
|
|
383
|
+
await this.chat({
|
|
384
|
+
messages: [{ role: 'user', content: 'test' }],
|
|
385
|
+
maxTokens: 1,
|
|
386
|
+
});
|
|
387
|
+
logger.info('LLM service health check passed');
|
|
388
|
+
return true;
|
|
389
|
+
}
|
|
390
|
+
catch (error) {
|
|
391
|
+
logger.error('LLM service health check failed', error);
|
|
392
|
+
return false;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* 计算文本的 Token 数量(估算)
|
|
397
|
+
*/
|
|
398
|
+
estimateTokens(text) {
|
|
399
|
+
// 粗略估算:英文约 4 字符/token,中文约 1.5 字符/token
|
|
400
|
+
const chineseChars = (text.match(/[\u4e00-\u9fa5]/g) || []).length;
|
|
401
|
+
const englishChars = text.length - chineseChars;
|
|
402
|
+
return Math.ceil(chineseChars / 1.5 + englishChars / 4);
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* 估算成本(未调用 API)
|
|
406
|
+
*/
|
|
407
|
+
estimateCost(tokensIn, tokensOut) {
|
|
408
|
+
return this.calculateCost(tokensIn, tokensOut, this.modelName);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Token Usage Repository(临时实现,后续使用真实的 Repository)
|
|
413
|
+
*/
|
|
414
|
+
class TempTokenUsageRepository {
|
|
415
|
+
async create(params) {
|
|
416
|
+
// TODO: 实现真实的数据库保存
|
|
417
|
+
// 目前只记录日志
|
|
418
|
+
logger.debug('Token usage would be saved to database', params);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* 增强的 LLM 服务单例
|
|
423
|
+
*/
|
|
424
|
+
export const enhancedLLMService = new EnhancedLLMService();
|
|
425
|
+
//# sourceMappingURL=EnhancedLLMService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnhancedLLMService.js","sourceRoot":"","sources":["../../../src/services/llm/EnhancedLLMService.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAEtE,MAAM,MAAM,GAAG,YAAY,CAAC,cAAc,CAAC,CAAC;AA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