Backup #754
| ID | 754 |
| Dateipfad | /var/www/dev.campus.systemische-tools.de/src/Infrastructure/AI/AIResponse.php |
| Version | 1 |
| Typ |
modified |
| Größe | 3.0 KB |
| Hash | 178ab495d4a9dde29b7ad01a411c9da556138381d11f5bae85d685f4597cb08f |
| Datum | 2025-12-23 08:00:16 |
| Geändert von | claude-code-hook |
| Grund | Claude Code Pre-Hook Backup vor Edit-Operation |
| Datei existiert |
Ja
|
Dateiinhalt
<?php
namespace Infrastructure\AI;
class AIResponse
{
private bool $success;
private ?string $content;
private ?string $errorMessage;
private ?int $tokensInput;
private ?int $tokensOutput;
private ?int $durationMs;
private string $model;
private array $metadata;
public function __construct(
bool $success,
?string $content = null,
?string $errorMessage = null,
?int $tokensInput = null,
?int $tokensOutput = null,
?int $durationMs = null,
string $model = '',
array $metadata = []
) {
$this->success = $success;
$this->content = $content;
$this->errorMessage = $errorMessage;
$this->tokensInput = $tokensInput;
$this->tokensOutput = $tokensOutput;
$this->durationMs = $durationMs;
$this->model = $model;
$this->metadata = $metadata;
}
public static function success(
string $content,
?int $tokensInput = null,
?int $tokensOutput = null,
?int $durationMs = null,
string $model = '',
array $metadata = []
): self {
return new self(
true,
$content,
null,
$tokensInput,
$tokensOutput,
$durationMs,
$model,
$metadata
);
}
public static function error(string $errorMessage, string $model = '', array $metadata = []): self
{
return new self(
false,
null,
$errorMessage,
null,
null,
null,
$model,
$metadata
);
}
public function isSuccess(): bool
{
return $this->success;
}
public function getContent(): ?string
{
return $this->content;
}
public function getErrorMessage(): ?string
{
return $this->errorMessage;
}
public function getTokensInput(): ?int
{
return $this->tokensInput;
}
public function getTokensOutput(): ?int
{
return $this->tokensOutput;
}
public function getTokensTotal(): ?int
{
if ($this->tokensInput !== null && $this->tokensOutput !== null) {
return $this->tokensInput + $this->tokensOutput;
}
return null;
}
public function getDurationMs(): ?int
{
return $this->durationMs;
}
public function getModel(): string
{
return $this->model;
}
public function getMetadata(): array
{
return $this->metadata;
}
public function toArray(): array
{
return [
'success' => $this->success,
'content' => $this->content,
'error_message' => $this->errorMessage,
'tokens_input' => $this->tokensInput,
'tokens_output' => $this->tokensOutput,
'tokens_total' => $this->getTokensTotal(),
'duration_ms' => $this->durationMs,
'model' => $this->model,
'metadata' => $this->metadata,
];
}
}
Vollständig herunterladen
Aktionen
← Zurück zur Übersicht