$collections */ public function __construct( public readonly string $sessionUuid, public readonly string $message, public readonly string $model, public readonly array $collections, public readonly int $contextLimit, public readonly int $authorProfileId, public readonly int $systemPromptId, public readonly float $temperature, public readonly int $maxTokens, ) { } /** * @param array $data */ public static function fromRequest(string $sessionUuid, array $data): self { $collections = $data['collections'] ?? ['documents']; if (!is_array($collections)) { $collections = [$collections]; } return new self( sessionUuid: $sessionUuid, message: trim((string) ($data['message'] ?? '')), model: (string) ($data['model'] ?? 'mistral'), collections: $collections, contextLimit: (int) ($data['context_limit'] ?? 5), authorProfileId: (int) ($data['author_profile_id'] ?? 0), systemPromptId: (int) ($data['system_prompt_id'] ?? 1), temperature: (float) ($data['temperature'] ?? 0.7), maxTokens: (int) ($data['max_tokens'] ?? 4096), ); } /** * @return array */ public function validate(): array { $errors = []; if ($this->sessionUuid === '') { $errors[] = 'Session-ID ist erforderlich.'; } if ($this->message === '') { $errors[] = 'Nachricht ist erforderlich.'; } if ($this->model === '') { $errors[] = 'Modell ist erforderlich.'; } if ($this->temperature < 0.0 || $this->temperature > 2.0) { $errors[] = 'Temperature muss zwischen 0 und 2 liegen.'; } if ($this->maxTokens < 100 || $this->maxTokens > 16000) { $errors[] = 'Max-Tokens muss zwischen 100 und 16000 liegen.'; } return $errors; } public function isValid(): bool { return $this->validate() === []; } }