createChatService(); */ public static function fromCredentialsFile( string $credentialsPath = '/var/www/docs/credentials/credentials.md' ): self { $anthropicApiKey = self::loadAnthropicApiKey($credentialsPath); return new self( ollamaHost: CredentialService::getOllamaHost(), qdrantHost: CredentialService::getQdrantHost(), anthropicApiKey: $anthropicApiKey, embeddingModel: 'mxbai-embed-large', claudeModel: 'claude-opus-4-5-20251101', defaultCollection: 'documents' ); } /** * Erstellt einen konfigurierten ChatService. * * Erzeugt alle benötigten Dependencies (OllamaService, QdrantService, ClaudeService) * und liefert einen vollständig konfigurierten ChatService zurück. * * @return ChatService Konfigurierter ChatService * * @example * $config = AIConfig::fromCredentialsFile(); * $chatService = $config->createChatService(); * $result = $chatService->chat('Was ist systemisches Coaching?'); */ public function createChatService(): ChatService { return new ChatService( $this->createOllamaService(), $this->createQdrantService(), $this->createClaudeService(), new ScoringService() ); } /** * Erstellt einen konfigurierten OllamaService. * * @return OllamaService Konfigurierter OllamaService * * @example * $config = AIConfig::fromCredentialsFile(); * $ollama = $config->createOllamaService(); * $embedding = $ollama->getEmbedding('Hello World'); */ public function createOllamaService(): OllamaService { return new OllamaService($this->ollamaHost); } /** * Erstellt einen konfigurierten QdrantService. * * @return QdrantService Konfigurierter QdrantService * * @example * $config = AIConfig::fromCredentialsFile(); * $qdrant = $config->createQdrantService(); * $results = $qdrant->search($vector, 'documents'); */ public function createQdrantService(): QdrantService { return new QdrantService($this->qdrantHost); } /** * Erstellt einen konfigurierten ClaudeService. * * @return ClaudeService Konfigurierter ClaudeService * * @example * $config = AIConfig::fromCredentialsFile(); * $claude = $config->createClaudeService(); * $result = $claude->ask('Explain quantum computing'); */ public function createClaudeService(): ClaudeService { return new ClaudeService($this->anthropicApiKey); } /** * Lädt den Anthropic API Key aus der Credentials-Datei. * * @param string $credentialsPath Pfad zur credentials.md Datei (unused, kept for BC) * * @return string Der gefundene API Key * * @throws RuntimeException Wenn API Key nicht gefunden wird */ private static function loadAnthropicApiKey(string $credentialsPath): string { $apiKey = \Infrastructure\Config\CredentialService::getAnthropicApiKey(); if ($apiKey === '') { throw new RuntimeException('Anthropic API key not found in credentials file'); } return $apiKey; } }