Backup #751
| ID | 751 |
| Dateipfad | /var/www/dev.campus.systemische-tools.de/src/Infrastructure/AI/VectorSearchService.php |
| Version | 1 |
| Typ |
modified |
| Größe | 1.8 KB |
| Hash | 5cef4f6b37a7b6a2da1c921fde2cfbddac199ac56c24536fe2af8c11246faba6 |
| Datum | 2025-12-23 08:00:15 |
| Geändert von | claude-code-hook |
| Grund | Claude Code Pre-Hook Backup vor Edit-Operation |
| Datei existiert |
Ja
|
Dateiinhalt
<?php
namespace Infrastructure\AI;
/**
* VectorSearchService - Unified semantic search interface
*
* Wraps OllamaService (embeddings) and QdrantService (vector search)
* for consistent vector search across the application.
*/
class VectorSearchService
{
private OllamaService $ollama;
private QdrantService $qdrant;
public function __construct(?OllamaService $ollama = null, ?QdrantService $qdrant = null)
{
$this->ollama = $ollama ?? new OllamaService();
$this->qdrant = $qdrant ?? new QdrantService();
}
/**
* Perform semantic search using embedding + vector search
*
* @param string $query Search query text
* @param string $collection Qdrant collection name
* @param int $limit Maximum results to return
* @param string $embeddingModel Ollama model for embeddings
* @return array Search results with scores and payloads
*/
public function search(
string $query,
string $collection = 'documents',
int $limit = 10,
string $embeddingModel = 'mxbai-embed-large'
): array {
// Generate embedding for query
$embedding = $this->ollama->getEmbedding($query, $embeddingModel);
if (empty($embedding)) {
return [];
}
// Search in Qdrant
return $this->qdrant->search($embedding, $collection, $limit);
}
/**
* Check if both services are available
*/
public function isAvailable(): bool
{
return $this->ollama->isAvailable() && $this->qdrant->isAvailable();
}
/**
* Get embedding for text (useful for debugging/testing)
*/
public function getEmbedding(string $text, string $model = 'mxbai-embed-large'): array
{
return $this->ollama->getEmbedding($text, $model);
}
}
Vollständig herunterladen
Aktionen
← Zurück zur Übersicht