Backup #1220
| ID | 1220 |
| Dateipfad | /var/www/dev.campus.systemische-tools.de/src/Domain/DTO/QdrantSearchResultDTO.php |
| Version | 1 |
| Typ |
modified |
| Größe | 2.3 KB |
| Hash | a310299db0ceae162c84b142e8ea10072e4e7caa962258cc4ddbca0b20f84d95 |
| Datum | 2025-12-25 10:49:54 |
| Geändert von | claude-code-hook |
| Grund | Claude Code Pre-Hook Backup vor Write-Operation |
| Datei existiert |
Ja
|
Dateiinhalt
<?php
declare(strict_types=1);
namespace Domain\DTO;
// @responsibility: DTO für Qdrant-Suchergebnisse
final readonly class QdrantSearchResultDTO
{
/**
* @param array<string, mixed> $metadata
*/
public function __construct(
public string $id,
public float $score,
public string $content,
public string $documentTitle,
public string $collection,
public int $chunkIndex,
public array $metadata = [],
) {}
/**
* Create from Qdrant API response.
*
* @param array<string, mixed> $point
*/
public static function fromQdrantPoint(array $point): self
{
$payload = $point['payload'] ?? [];
return new self(
id: (string) ($point['id'] ?? ''),
score: (float) ($point['score'] ?? 0.0),
content: (string) ($payload['content'] ?? $payload['content_preview'] ?? ''),
documentTitle: (string) ($payload['document_title'] ?? $payload['title'] ?? 'Unbekannt'),
collection: (string) ($payload['collection'] ?? 'documents'),
chunkIndex: (int) ($payload['chunk_index'] ?? 0),
metadata: self::extractMetadata($payload),
);
}
/**
* Extract additional metadata from payload.
*
* @param array<string, mixed> $payload
* @return array<string, mixed>
*/
private static function extractMetadata(array $payload): array
{
$excludeKeys = ['content', 'content_preview', 'document_title', 'title', 'collection', 'chunk_index'];
return array_filter(
$payload,
fn(string $key): bool => !in_array($key, $excludeKeys, true),
ARRAY_FILTER_USE_KEY
);
}
/**
* Check if result is highly relevant (score > threshold).
*/
public function isHighlyRelevant(float $threshold = 0.8): bool
{
return $this->score >= $threshold;
}
/**
* Get content preview.
*/
public function contentPreview(int $length = 200): string
{
if (mb_strlen($this->content) <= $length) {
return $this->content;
}
return mb_substr($this->content, 0, $length) . '...';
}
/**
* Get score as percentage.
*/
public function scorePercentage(): int
{
return (int) round($this->score * 100);
}
}
Vollständig herunterladen
Aktionen
Andere Versionen dieser Datei
| ID |
Version |
Typ |
Größe |
Datum |
| 1889 |
3 |
modified |
3.0 KB |
2025-12-28 01:01 |
| 1885 |
2 |
modified |
3.0 KB |
2025-12-28 01:00 |
| 1220 |
1 |
modified |
2.3 KB |
2025-12-25 10:49 |
← Zurück zur Übersicht