Backup #1490
| ID | 1490 |
| Dateipfad | /var/www/dev.campus.systemische-tools.de/src/Domain/ValueObject/SessionMetadata.php |
| Version | 1 |
| Typ |
modified |
| Größe | 4.6 KB |
| Hash | 4ad92d848e697a51e41240f4851289c915b33dc2ba0e09e71a25f31773c6f808 |
| Datum | 2025-12-25 17:21:12 |
| Geändert von | claude-code-hook |
| Grund | Claude Code Pre-Hook Backup vor Edit-Operation |
| Datei existiert |
Ja
|
Dateiinhalt
<?php
declare(strict_types=1);
namespace Domain\ValueObject;
// @responsibility: Immutable Value Object für Chat-Session-Metadaten (Model, Collections, Context, etc.)
use InvalidArgumentException;
final class SessionMetadata
{
/**
* @param array<string> $collections
*/
private function __construct(
private string $model,
private array $collections,
private int $contextLimit,
private float $temperature,
private int $maxTokens
) {
}
/**
* @param array<string> $collections
*/
public static function create(
string $model = 'claude-opus-4-5-20251101',
array $collections = ['documents'],
int $contextLimit = 5,
float $temperature = 0.7,
int $maxTokens = 4096
): self {
self::validateModel($model);
self::validateCollections($collections);
self::validateContextLimit($contextLimit);
self::validateTemperature($temperature);
self::validateMaxTokens($maxTokens);
return new self($model, $collections, $contextLimit, $temperature, $maxTokens);
}
public function getModel(): string
{
return $this->model;
}
/**
* @return array<string>
*/
public function getCollections(): array
{
return $this->collections;
}
public function getContextLimit(): int
{
return $this->contextLimit;
}
public function getTemperature(): float
{
return $this->temperature;
}
public function getMaxTokens(): int
{
return $this->maxTokens;
}
/**
* @param array<string> $collections
*/
public function withModel(string $model): self
{
self::validateModel($model);
return new self($model, $this->collections, $this->contextLimit, $this->temperature, $this->maxTokens);
}
/**
* @param array<string> $collections
*/
public function withCollections(array $collections): self
{
self::validateCollections($collections);
return new self($this->model, $collections, $this->contextLimit, $this->temperature, $this->maxTokens);
}
public function withContextLimit(int $contextLimit): self
{
self::validateContextLimit($contextLimit);
return new self($this->model, $this->collections, $contextLimit, $this->temperature, $this->maxTokens);
}
public function withTemperature(float $temperature): self
{
self::validateTemperature($temperature);
return new self($this->model, $this->collections, $this->contextLimit, $temperature, $this->maxTokens);
}
public function withMaxTokens(int $maxTokens): self
{
self::validateMaxTokens($maxTokens);
return new self($this->model, $this->collections, $this->contextLimit, $this->temperature, $maxTokens);
}
private static function validateModel(string $model): void
{
if (trim($model) === '') {
throw new InvalidArgumentException('Model cannot be empty');
}
}
/**
* @param array<string> $collections
*/
private static function validateCollections(array $collections): void
{
if (empty($collections)) {
throw new InvalidArgumentException('Collections cannot be empty');
}
foreach ($collections as $collection) {
if (!is_string($collection) || trim($collection) === '') {
throw new InvalidArgumentException('Each collection must be a non-empty string');
}
}
}
private static function validateContextLimit(int $contextLimit): void
{
if ($contextLimit < 1 || $contextLimit > 20) {
throw new InvalidArgumentException('Context limit must be between 1 and 20');
}
}
private static function validateTemperature(float $temperature): void
{
if ($temperature < 0.0 || $temperature > 1.0) {
throw new InvalidArgumentException('Temperature must be between 0.0 and 1.0');
}
}
private static function validateMaxTokens(int $maxTokens): void
{
if ($maxTokens < 1 || $maxTokens > 100000) {
throw new InvalidArgumentException('Max tokens must be between 1 and 100000');
}
}
public function equals(self $other): bool
{
return $this->model === $other->model
&& $this->collections === $other->collections
&& $this->contextLimit === $other->contextLimit
&& abs($this->temperature - $other->temperature) < 0.0001
&& $this->maxTokens === $other->maxTokens;
}
}
Vollständig herunterladen
Aktionen
Andere Versionen dieser Datei
| ID |
Version |
Typ |
Größe |
Datum |
| 1580 |
3 |
modified |
4.5 KB |
2025-12-26 20:57 |
| 1491 |
2 |
modified |
4.5 KB |
2025-12-25 17:26 |
| 1490 |
1 |
modified |
4.6 KB |
2025-12-25 17:21 |
← Zurück zur Übersicht