Backup #738
| ID | 738 |
| Dateipfad | /var/www/dev.campus.systemische-tools.de/src/UseCases/Command/SendChatMessageCommand.php |
| Version | 1 |
| Typ |
modified |
| Größe | 2.3 KB |
| Hash | 74efb3a9745a3614589f215ac6af2b0d57699964b96a82d71b0185262b51b498 |
| Datum | 2025-12-23 07:57:57 |
| Geändert von | claude-code-hook |
| Grund | Claude Code Pre-Hook Backup vor Edit-Operation |
| Datei existiert |
Ja
|
Dateiinhalt
<?php
namespace UseCases\Command;
/**
* Command for sending a chat message.
*/
final class SendChatMessageCommand
{
/**
* @param array<string> $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<string, mixed> $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<string>
*/
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() === [];
}
}
Vollständig herunterladen
Aktionen
Andere Versionen dieser Datei
| ID |
Version |
Typ |
Größe |
Datum |
| 1837 |
3 |
modified |
2.3 KB |
2025-12-27 23:19 |
| 1836 |
2 |
modified |
2.3 KB |
2025-12-27 23:19 |
| 738 |
1 |
modified |
2.3 KB |
2025-12-23 07:57 |
← Zurück zur Übersicht