Backup #2078
| ID | 2078 |
| Dateipfad | /var/www/dev.campus.systemische-tools.de/src/ServiceProvider/ChatServiceProvider.php |
| Version | 13 |
| Typ |
modified |
| Größe | 7.9 KB |
| Hash | dea801c27d102923829368a39ace4572b3f9a8c6869f77991bb53499a699a1a4 |
| Datum | 2025-12-29 00:04:54 |
| Geändert von | claude-code-hook |
| Grund | Claude Code Pre-Hook Backup vor Edit-Operation |
| Datei existiert |
Ja
|
Dateiinhalt
<?php
declare(strict_types=1);
// @responsibility: Register Chat bounded context services in DI container
namespace ServiceProvider;
use Domain\Repository\ChatMessageRepositoryInterface;
use Domain\Repository\ChatSessionRepositoryInterface;
use Domain\Repository\ChunkRepositoryInterface;
use Domain\Repository\ContentConfigRepositoryInterface;
use Domain\Repository\PromptsRepositoryInterface;
use Domain\Service\ModelRegistryInterface;
use Framework\Container;
use Infrastructure\AI\AIConfig;
use Infrastructure\AI\ChatService;
use Infrastructure\AI\ClaudeService;
use Infrastructure\AI\ContentQualityValidator;
use Infrastructure\AI\ModelRegistry;
use Infrastructure\AI\OllamaService;
use Infrastructure\AI\QdrantClient;
use Infrastructure\AI\QdrantService;
use Infrastructure\AI\ScoringService;
use Infrastructure\AI\SemanticEnrichmentService;
use Infrastructure\AI\VectorSearchService;
use Infrastructure\Formatting\ChatMessageFormatter;
use Infrastructure\Persistence\ChatMessageRepository;
use Infrastructure\Persistence\ChatSessionRepository;
use Infrastructure\Persistence\ChunkRepository;
use Infrastructure\Persistence\ContentConfigRepository;
use Infrastructure\Persistence\CriticsRepository;
use Infrastructure\Persistence\PromptsRepository;
use UseCases\Chat\CreateChatSessionUseCase;
use UseCases\Chat\CreateChatSessionUseCaseInterface;
use UseCases\Chat\DeleteChatSessionUseCase;
use UseCases\Chat\DeleteChatSessionUseCaseInterface;
use UseCases\Chat\GetChatSessionUseCase;
use UseCases\Chat\GetChatSessionUseCaseInterface;
use UseCases\Chat\StreamingChatMessageUseCase;
use UseCases\Chat\UpdateChatSessionUseCase;
use UseCases\Chat\UpdateChatSessionUseCaseInterface;
/**
* ChatServiceProvider registers all chat and AI-related services.
*/
final class ChatServiceProvider implements ServiceProviderInterface
{
public function register(Container $container): void
{
// Repositories
$container->set(ChatSessionRepository::class, fn (Container $c) => new ChatSessionRepository($c->get('pdo.content')));
$container->set(ChatMessageRepository::class, fn (Container $c) => new ChatMessageRepository($c->get('pdo.content')));
$container->set(PromptsRepository::class, fn (Container $c) => new PromptsRepository($c->get('pdo.content')));
$container->set(CriticsRepository::class, fn (Container $c) => new CriticsRepository($c->get('pdo.content')));
$container->set(ContentConfigRepository::class, fn (Container $c) => new ContentConfigRepository($c->get('pdo.content')));
// Interface aliases
$container->set(ChatSessionRepositoryInterface::class, fn (Container $c) => $c->get(ChatSessionRepository::class));
$container->set(ChatMessageRepositoryInterface::class, fn (Container $c) => $c->get(ChatMessageRepository::class));
$container->set(PromptsRepositoryInterface::class, fn (Container $c) => $c->get(PromptsRepository::class));
$container->set(ContentConfigRepositoryInterface::class, fn (Container $c) => $c->get(ContentConfigRepository::class));
// AI Services
$container->set(AIConfig::class, fn () => AIConfig::fromCredentialsFile());
$container->set(OllamaService::class, fn (Container $c) => $c->get(AIConfig::class)->createOllamaService());
$container->set(QdrantService::class, fn (Container $c) => $c->get(AIConfig::class)->createQdrantService());
$container->set(ClaudeService::class, fn (Container $c) => $c->get(AIConfig::class)->createClaudeService());
$container->set(ScoringService::class, fn () => new ScoringService());
$container->set(VectorSearchService::class, fn () => new VectorSearchService());
$container->set(QdrantClient::class, fn () => new QdrantClient());
// Chunk Repository for semantic enrichment
$container->set(ChunkRepository::class, fn (Container $c) => new ChunkRepository($c->get('pdo.content')));
$container->set(ChunkRepositoryInterface::class, fn (Container $c) => $c->get(ChunkRepository::class));
// Semantic Enrichment Service (for Graceful Degradation)
$container->set(SemanticEnrichmentService::class, fn (Container $c) => new SemanticEnrichmentService(
$c->get(ChunkRepositoryInterface::class)
));
// ChatService with Semantic Enrichment (Graceful Degradation)
$container->set(ChatService::class, fn (Container $c) => new ChatService(
$c->get(OllamaService::class),
$c->get(QdrantService::class),
$c->get(ClaudeService::class),
$c->get(ScoringService::class),
$c->get(SemanticEnrichmentService::class)
));
$container->set(ContentQualityValidator::class, function (Container $c) {
return new ContentQualityValidator($c->get(OllamaService::class));
});
$container->set(ModelRegistry::class, function (Container $c) {
$registry = new ModelRegistry($c->get('pdo.dev'));
ModelRegistry::setInstance($registry);
return $registry;
});
$container->set(ModelRegistryInterface::class, fn (Container $c) => $c->get(ModelRegistry::class));
// Formatters
$container->set(ChatMessageFormatter::class, fn () => new ChatMessageFormatter());
// Use Cases
$container->set(UpdateChatSessionUseCase::class, function (Container $c) {
return new UpdateChatSessionUseCase(
$c->get(ChatSessionRepositoryInterface::class),
$c->get(ContentConfigRepositoryInterface::class),
$c->get(\Domain\Repository\CollectionRepositoryInterface::class),
$c->get(\Infrastructure\Validation\CollectionValidator::class),
$c->get(ModelRegistryInterface::class),
$c->get('pdo.dev')
);
});
$container->set(UpdateChatSessionUseCaseInterface::class, fn (Container $c) => $c->get(UpdateChatSessionUseCase::class));
$container->set(CreateChatSessionUseCase::class, function (Container $c) {
return new CreateChatSessionUseCase(
$c->get(ChatSessionRepositoryInterface::class),
$c->get(ModelRegistryInterface::class)
);
});
$container->set(CreateChatSessionUseCaseInterface::class, fn (Container $c) => $c->get(CreateChatSessionUseCase::class));
$container->set(GetChatSessionUseCase::class, function (Container $c) {
return new GetChatSessionUseCase(
$c->get(ChatSessionRepositoryInterface::class),
$c->get(ChatMessageRepositoryInterface::class),
$c->get(ContentConfigRepositoryInterface::class),
$c->get(\Domain\Repository\CollectionRepositoryInterface::class)
);
});
$container->set(GetChatSessionUseCaseInterface::class, fn (Container $c) => $c->get(GetChatSessionUseCase::class));
$container->set(DeleteChatSessionUseCase::class, function (Container $c) {
return new DeleteChatSessionUseCase(
$c->get(ChatSessionRepositoryInterface::class)
);
});
$container->set(DeleteChatSessionUseCaseInterface::class, fn (Container $c) => $c->get(DeleteChatSessionUseCase::class));
// Streaming UseCase with Semantic Search
$container->set(StreamingChatMessageUseCase::class, function (Container $c) {
return new StreamingChatMessageUseCase(
$c->get(OllamaService::class),
$c->get(QdrantService::class),
$c->get(ClaudeService::class),
$c->get(ScoringService::class),
$c->get(ChatSessionRepositoryInterface::class),
$c->get(ChatMessageRepositoryInterface::class),
$c->get(ContentConfigRepository::class),
$c->get(ContentQualityValidator::class),
$c->get(\Domain\Service\SearchServiceInterface::class)
);
});
}
}
Vollständig herunterladen
Aktionen
Andere Versionen dieser Datei
| ID |
Version |
Typ |
Größe |
Datum |
| 2148 |
20 |
modified |
8.8 KB |
2025-12-30 20:43 |
| 2147 |
19 |
modified |
8.9 KB |
2025-12-30 20:43 |
| 2110 |
18 |
modified |
8.8 KB |
2025-12-29 08:48 |
| 2109 |
17 |
modified |
8.8 KB |
2025-12-29 08:48 |
| 2086 |
16 |
modified |
8.3 KB |
2025-12-29 00:11 |
| 2085 |
15 |
modified |
8.3 KB |
2025-12-29 00:10 |
| 2079 |
14 |
modified |
7.9 KB |
2025-12-29 00:05 |
| 2078 |
13 |
modified |
7.9 KB |
2025-12-29 00:04 |
| 2030 |
12 |
modified |
7.8 KB |
2025-12-28 23:23 |
| 1593 |
11 |
modified |
7.0 KB |
2025-12-27 00:15 |
| 1592 |
10 |
modified |
6.8 KB |
2025-12-27 00:14 |
| 1562 |
9 |
modified |
6.2 KB |
2025-12-26 20:29 |
| 1561 |
8 |
modified |
6.0 KB |
2025-12-26 20:29 |
| 1560 |
7 |
modified |
5.9 KB |
2025-12-26 20:29 |
| 1489 |
6 |
modified |
5.0 KB |
2025-12-25 17:04 |
| 1481 |
5 |
modified |
4.6 KB |
2025-12-25 17:03 |
| 1480 |
4 |
modified |
4.4 KB |
2025-12-25 17:03 |
| 1479 |
3 |
modified |
4.3 KB |
2025-12-25 17:03 |
| 1478 |
2 |
modified |
4.0 KB |
2025-12-25 17:03 |
| 1477 |
1 |
modified |
3.9 KB |
2025-12-25 17:03 |
← Zurück zur Übersicht