Protokoll #15607
| ID | 15607 |
|---|---|
| Zeitstempel | 2025-12-25 16:55:44.478079 |
| Client | root |
| IP | Warning: Undefined array key "request_ip" in /var/www/dev.campus.systemische-tools.de/src/View/protokoll/show.php on line 13 Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/dev.campus.systemische-tools.de/src/View/protokoll/show.php on line 13 |
| Modell | claude-sonnet-4-20250514 |
| Status | completed |
| Tokens | 1,226 (Input: 0, Output: 0) |
| Dauer | 108 ms |
| Request-Zeit | Warning: Undefined array key "request_timestamp" in /var/www/dev.campus.systemische-tools.de/src/View/protokoll/show.php on line 18 |
| Response-Zeit | - |
Warning: Undefined array key "error_message" in /var/www/dev.campus.systemische-tools.de/src/View/protokoll/show.php on line 22
Request
{
"event": "PreToolUse",
"tool_name": "Read",
"tool_input": {
"file_path": "\/var\/www\/dev.campus.systemische-tools.de\/src\/UseCases\/Task\/ExecuteAITaskUseCase.php"
}
}
Response
{
"tool_response": {
"type": "text",
"file": {
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/UseCases\/Task\/ExecuteAITaskUseCase.php",
"content": "<?php\n\ndeclare(strict_types=1);\n\nnamespace UseCases\\Task;\n\n\/\/ @responsibility: Führt Tasks mit KI-Modellen aus (Ollama\/Anthropic)\n\nuse Domain\\Entity\\Task;\nuse Domain\\Entity\\TaskResult;\nuse Domain\\Repository\\TaskRepositoryInterface;\nuse Domain\\ValueObject\\AssigneeType;\nuse Domain\\ValueObject\\TaskStatus;\nuse Infrastructure\\AI\\AIClientInterface;\nuse Infrastructure\\AI\\AnthropicClient;\nuse Infrastructure\\AI\\OllamaClient;\nuse Infrastructure\\Config\\CredentialService;\n\nclass ExecuteAITaskUseCase\n{\n public function __construct(\n private TaskRepositoryInterface $taskRepository,\n private SaveTaskResultUseCase $saveResultUseCase,\n private UpdateTaskStatusUseCase $updateStatusUseCase\n ) {\n }\n\n public function execute(int $taskId, array $options = []): TaskResult\n {\n $task = $this->taskRepository->find($taskId);\n if ($task === null) {\n throw new \\InvalidArgumentException(\"Task {$taskId} not found\");\n }\n\n $executorType = AssigneeType::from($options['executor_type'] ?? 'ollama');\n $client = $this->getClient($executorType, $options);\n\n if (!$client->isAvailable()) {\n throw new \\RuntimeException(\"{$executorType->label()} is not available\");\n }\n\n if ($task->getStatus() === TaskStatus::PENDING) {\n $this->updateStatusUseCase->startTask($taskId, $client->getClientName(), 'ai');\n }\n\n $prompt = $this->buildPrompt($task, $options);\n $response = $client->execute($prompt, $options);\n\n $resultData = [\n 'executor' => $client->getClientName(),\n 'executor_type' => $executorType->value,\n 'model_name' => $response->getModel() !== '' ? $response->getModel() : $client->getModelName(),\n 'request' => $prompt,\n 'response' => $response->getContent(),\n 'tokens_input' => $response->getTokensInput(),\n 'tokens_output' => $response->getTokensOutput(),\n 'duration_ms' => $response->getDurationMs(),\n 'status' => $response->isSuccess() ? 'success' : 'error',\n ];\n\n if (!$response->isSuccess()) {\n $resultData['error_message'] = $response->getErrorMessage();\n }\n\n $metadata = $response->getMetadata();\n if (isset($metadata['cost_usd'])) {\n $resultData['cost_usd'] = $metadata['cost_usd'];\n }\n\n if (isset($options['assignment_id'])) {\n $resultData['assignment_id'] = $options['assignment_id'];\n }\n\n $result = $this->saveResultUseCase->execute($taskId, $resultData);\n\n if ($response->isSuccess() && ($options['auto_complete'] ?? false)) {\n $this->updateStatusUseCase->completeTask($taskId, $client->getClientName(), 'ai');\n }\n\n return $result;\n }\n\n private function getClient(AssigneeType $type, array $options): AIClientInterface\n {\n return match ($type) {\n AssigneeType::OLLAMA => new OllamaClient(\n CredentialService::getOllamaHost(),\n $options['model'] ?? 'mistral'\n ),\n AssigneeType::ANTHROPIC_API => new AnthropicClient(\n $options['api_key'] ?? '',\n $options['model'] ?? 'claude-sonnet-4-20250514'\n ),\n default => throw new \\InvalidArgumentException(\"Unsupported executor type: {$type->value}\")\n };\n }\n\n private function buildPrompt(Task $task, array $options): string\n {\n $prompt = $task->getTitle();\n\n if ($task->getDescription() !== null) {\n $prompt .= \"\\n\\n\" . $task->getDescription();\n }\n\n if (isset($options['additional_context'])) {\n $prompt .= \"\\n\\n\" . $options['additional_context'];\n }\n\n return $prompt;\n }\n\n public function executeWithOllama(int $taskId, string $model = 'mistral', array $options = []): TaskResult\n {\n return $this->execute($taskId, array_merge($options, [\n 'executor_type' => 'ollama',\n 'model' => $model,\n ]));\n }\n\n public function executeWithAnthropic(int $taskId, string $model = 'claude-sonnet-4-20250514', array $options = []): TaskResult\n {\n return $this->execute($taskId, array_merge($options, [\n 'executor_type' => 'anthropic_api',\n 'model' => $model,\n ]));\n }\n}\n",
"numLines": 129,
"startLine": 1,
"totalLines": 129
}
}
}