{
"tool_response": {
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/ServiceProvider\/ChatServiceProvider.php",
"oldString": "use Infrastructure\\Persistence\\ContentConfigRepository;\nuse Infrastructure\\Persistence\\CriticsRepository;\nuse Infrastructure\\Persistence\\PromptsRepository;",
"newString": "use Infrastructure\\Persistence\\ContentConfigRepository;\nuse Infrastructure\\Persistence\\PromptsRepository;",
"originalFile": "<?php\n\ndeclare(strict_types=1);\n\n\/\/ @responsibility: Register Chat bounded context services in DI container\n\nnamespace ServiceProvider;\n\nuse Domain\\Repository\\ChatMessageRepositoryInterface;\nuse Domain\\Repository\\ChatSessionRepositoryInterface;\nuse Domain\\Repository\\ChunkRepositoryInterface;\nuse Domain\\Repository\\ContentConfigRepositoryInterface;\nuse Domain\\Repository\\PromptsRepositoryInterface;\nuse Domain\\Service\\ModelRegistryInterface;\nuse Framework\\Container;\nuse Infrastructure\\AI\\AIConfig;\nuse Infrastructure\\AI\\ChatService;\nuse Infrastructure\\AI\\ClaudeService;\nuse Infrastructure\\AI\\ContentQualityValidator;\nuse Infrastructure\\AI\\ModelRegistry;\nuse Infrastructure\\AI\\OllamaService;\nuse Infrastructure\\AI\\QdrantClient;\nuse Infrastructure\\AI\\QdrantService;\nuse Infrastructure\\AI\\ScoringService;\nuse Infrastructure\\AI\\SemanticEnrichmentService;\nuse Infrastructure\\AI\\VectorSearchService;\nuse Infrastructure\\Formatting\\ChatMessageFormatter;\nuse Infrastructure\\Logging\\KiProtokollService;\nuse Infrastructure\\Persistence\\ChatMessageRepository;\nuse Infrastructure\\Persistence\\ChatSessionRepository;\nuse Infrastructure\\Persistence\\ChunkRepository;\nuse Infrastructure\\Persistence\\ContentConfigRepository;\nuse Infrastructure\\Persistence\\CriticsRepository;\nuse Infrastructure\\Persistence\\PromptsRepository;\nuse UseCases\\Chat\\ChatPromptLoader;\nuse UseCases\\Chat\\CreateChatSessionUseCase;\nuse UseCases\\Chat\\CreateChatSessionUseCaseInterface;\nuse UseCases\\Chat\\DeleteChatSessionUseCase;\nuse UseCases\\Chat\\DeleteChatSessionUseCaseInterface;\nuse UseCases\\Chat\\GetChatSessionUseCase;\nuse UseCases\\Chat\\GetChatSessionUseCaseInterface;\nuse UseCases\\Chat\\RagContextBuilder;\nuse UseCases\\Chat\\SendChatMessageUseCase;\nuse UseCases\\Chat\\StreamingChatMessageUseCase;\nuse UseCases\\Chat\\UpdateChatSessionUseCase;\nuse UseCases\\Chat\\UpdateChatSessionUseCaseInterface;\n\n\/**\n * ChatServiceProvider registers all chat and AI-related services.\n *\/\nfinal class ChatServiceProvider implements ServiceProviderInterface\n{\n public function register(Container $container): void\n {\n \/\/ Repositories\n $container->set(ChatSessionRepository::class, fn (Container $c) => new ChatSessionRepository($c->get('pdo.content')));\n $container->set(ChatMessageRepository::class, fn (Container $c) => new ChatMessageRepository($c->get('pdo.content')));\n $container->set(PromptsRepository::class, fn (Container $c) => new PromptsRepository($c->get('pdo.content')));\n $container->set(CriticsRepository::class, fn (Container $c) => new CriticsRepository($c->get('pdo.content')));\n $container->set(ContentConfigRepository::class, fn (Container $c) => new ContentConfigRepository($c->get('pdo.content')));\n\n \/\/ Interface aliases\n $container->set(ChatSessionRepositoryInterface::class, fn (Container $c) => $c->get(ChatSessionRepository::class));\n $container->set(ChatMessageRepositoryInterface::class, fn (Container $c) => $c->get(ChatMessageRepository::class));\n $container->set(PromptsRepositoryInterface::class, fn (Container $c) => $c->get(PromptsRepository::class));\n $container->set(ContentConfigRepositoryInterface::class, fn (Container $c) => $c->get(ContentConfigRepository::class));\n\n \/\/ AI Services\n $container->set(AIConfig::class, fn () => AIConfig::fromCredentialsFile());\n $container->set(OllamaService::class, fn (Container $c) => $c->get(AIConfig::class)->createOllamaService());\n $container->set(QdrantService::class, fn (Container $c) => $c->get(AIConfig::class)->createQdrantService());\n $container->set(ClaudeService::class, fn (Container $c) => $c->get(AIConfig::class)->createClaudeService());\n $container->set(ScoringService::class, fn () => new ScoringService());\n $container->set(VectorSearchService::class, fn () => new VectorSearchService());\n $container->set(QdrantClient::class, fn () => new QdrantClient());\n\n \/\/ Chunk Repository for semantic enrichment\n $container->set(ChunkRepository::class, fn (Container $c) => new ChunkRepository($c->get('pdo.content')));\n $container->set(ChunkRepositoryInterface::class, fn (Container $c) => $c->get(ChunkRepository::class));\n\n \/\/ Semantic Enrichment Service (for Graceful Degradation)\n $container->set(SemanticEnrichmentService::class, fn (Container $c) => new SemanticEnrichmentService(\n $c->get(ChunkRepositoryInterface::class)\n ));\n\n \/\/ ChatService with Semantic Enrichment (Graceful Degradation)\n $container->set(ChatService::class, fn (Container $c) => new ChatService(\n $c->get(OllamaService::class),\n $c->get(QdrantService::class),\n $c->get(ClaudeService::class),\n $c->get(ScoringService::class),\n $c->get(SemanticEnrichmentService::class)\n ));\n\n $container->set(ContentQualityValidator::class, function (Container $c) {\n return new ContentQualityValidator($c->get(OllamaService::class));\n });\n\n $container->set(ModelRegistry::class, function (Container $c) {\n $registry = new ModelRegistry($c->get('pdo.dev'));\n ModelRegistry::setInstance($registry);\n\n return $registry;\n });\n\n $container->set(ModelRegistryInterface::class, fn (Container $c) => $c->get(ModelRegistry::class));\n\n \/\/ Formatters\n $container->set(ChatMessageFormatter::class, fn () => new ChatMessageFormatter());\n\n \/\/ Use Cases\n $container->set(UpdateChatSessionUseCase::class, function (Container $c) {\n return new UpdateChatSessionUseCase(\n $c->get(ChatSessionRepositoryInterface::class),\n $c->get(ContentConfigRepositoryInterface::class),\n $c->get(\\Domain\\Repository\\CollectionRepositoryInterface::class),\n $c->get(\\Infrastructure\\Validation\\CollectionValidator::class),\n $c->get(ModelRegistryInterface::class),\n $c->get('pdo.dev')\n );\n });\n\n $container->set(UpdateChatSessionUseCaseInterface::class, fn (Container $c) => $c->get(UpdateChatSessionUseCase::class));\n\n $container->set(CreateChatSessionUseCase::class, function (Container $c) {\n return new CreateChatSessionUseCase(\n $c->get(ChatSessionRepositoryInterface::class),\n $c->get(ModelRegistryInterface::class)\n );\n });\n\n $container->set(CreateChatSessionUseCaseInterface::class, fn (Container $c) => $c->get(CreateChatSessionUseCase::class));\n\n $container->set(GetChatSessionUseCase::class, function (Container $c) {\n return new GetChatSessionUseCase(\n $c->get(ChatSessionRepositoryInterface::class),\n $c->get(ChatMessageRepositoryInterface::class),\n $c->get(ContentConfigRepositoryInterface::class),\n $c->get(\\Domain\\Repository\\CollectionRepositoryInterface::class)\n );\n });\n\n $container->set(GetChatSessionUseCaseInterface::class, fn (Container $c) => $c->get(GetChatSessionUseCase::class));\n\n $container->set(DeleteChatSessionUseCase::class, function (Container $c) {\n return new DeleteChatSessionUseCase(\n $c->get(ChatSessionRepositoryInterface::class)\n );\n });\n\n $container->set(DeleteChatSessionUseCaseInterface::class, fn (Container $c) => $c->get(DeleteChatSessionUseCase::class));\n\n \/\/ Chat Helper Services\n $container->set(ChatPromptLoader::class, fn (Container $c) => new ChatPromptLoader(\n $c->get(ContentConfigRepositoryInterface::class)\n ));\n\n $container->set(RagContextBuilder::class, fn (Container $c) => new RagContextBuilder(\n $c->get(\\Domain\\Service\\SearchServiceInterface::class)\n ));\n\n \/\/ Streaming UseCase with extracted helpers\n $container->set(StreamingChatMessageUseCase::class, function (Container $c) {\n return new StreamingChatMessageUseCase(\n $c->get(OllamaService::class),\n $c->get(QdrantService::class),\n $c->get(ClaudeService::class),\n $c->get(ScoringService::class),\n $c->get(ChatSessionRepositoryInterface::class),\n $c->get(ChatMessageRepositoryInterface::class),\n $c->get(ChatPromptLoader::class),\n $c->get(ContentQualityValidator::class),\n $c->get(RagContextBuilder::class),\n $c->get(KiProtokollService::class)\n );\n });\n\n \/\/ Non-streaming UseCase\n $container->set(SendChatMessageUseCase::class, function (Container $c) {\n return new SendChatMessageUseCase(\n $c->get(ChatService::class),\n $c->get(ChatSessionRepositoryInterface::class),\n $c->get(ChatMessageRepositoryInterface::class),\n $c->get(ChatPromptLoader::class),\n $c->get(ContentQualityValidator::class)\n );\n });\n }\n}\n",
"structuredPatch": [
{
"oldStart": 30,
"oldLines": 7,
"newStart": 30,
"newLines": 6,
"lines": [
" use Infrastructure\\Persistence\\ChatSessionRepository;",
" use Infrastructure\\Persistence\\ChunkRepository;",
" use Infrastructure\\Persistence\\ContentConfigRepository;",
"-use Infrastructure\\Persistence\\CriticsRepository;",
" use Infrastructure\\Persistence\\PromptsRepository;",
" use UseCases\\Chat\\ChatPromptLoader;",
" use UseCases\\Chat\\CreateChatSessionUseCase;"
]
}
],
"userModified": false,
"replaceAll": false
}
}