Backup #805

ID805
Dateipfad/var/www/dev.campus.systemische-tools.de/src/Domain/Exception/DimensionMismatchException.php
Version1
Typ modified
Größe1.6 KB
Hash5de215eab4570564dcc987679b60820eb3cacb0c85663bb6989a59a4367cba64
Datum2025-12-23 08:07:54
Geändert vonclaude-code-hook
GrundClaude Code Pre-Hook Backup vor Edit-Operation
Datei existiert Ja

Dateiinhalt

<?php

declare(strict_types=1);

namespace Domain\Exception;

use RuntimeException;

/**
 * Exception thrown when vector dimensions don't match.
 *
 * This occurs when:
 * - Attempting to search collections with different embedding sizes
 * - Query embedding dimension doesn't match collection's vector_size
 *
 * @package Domain\Exception
 */
class DimensionMismatchException extends RuntimeException
{
    public function __construct(
        string $message,
        public readonly ?string $collectionId = null,
        public readonly ?int $expectedSize = null,
        public readonly ?int $actualSize = null
    ) {
        parent::__construct($message);
    }

    /**
     * Create exception for incompatible collections.
     *
     * @param array<string, int> $collectionSizes Map of collection_id => vector_size
     */
    public static function incompatibleCollections(array $collectionSizes): self
    {
        $details = [];
        foreach ($collectionSizes as $id => $size) {
            $details[] = "$id: {$size}d";
        }

        return new self(
            'Inkompatible Collections: Unterschiedliche Vektorgrößen (' . implode(', ', $details) . ')'
        );
    }

    /**
     * Create exception for embedding size mismatch.
     */
    public static function embeddingMismatch(
        string $collectionId,
        int $expectedSize,
        int $actualSize
    ): self {
        return new self(
            "Dimension Mismatch: Collection '$collectionId' erwartet {$expectedSize}d, Embedding hat {$actualSize}d",
            $collectionId,
            $expectedSize,
            $actualSize
        );
    }
}

Vollständig herunterladen

Aktionen

Herunterladen

← Zurück zur Übersicht