Files
2026-08-31 19:56:25 +02:00

54 lines
2.1 KiB
PHP

<?php
declare(strict_types=1);
require_once __DIR__ . '/ProviderInterface.php';
/**
* Für lokale Smoke-Tests ohne echten API-Key (siehe README.md) — liefert eine feste,
* valide AiPlanningResponse-JSON zurück statt einen echten LLM-Aufruf zu machen. Niemals als
* Standard-Provider in config.php eintragen, nur über eine explizite lokale Umgebungsvariable
* (siehe plan.php) für Entwicklungszwecke aktivieren.
*/
class FakeProvider implements ProviderInterface
{
public function sendMessage(string $systemPrompt, string $userContent, int $maxTokens): array
{
if (str_contains($systemPrompt, 'Placeholder-Namen')) {
$input = json_decode($userContent, true);
$classifications = array_map(static fn(array $candidate): array => [
'id' => $candidate['id'],
'blockIds' => $candidate['blockIds'] ?? [$candidate['id']],
'name' => $candidate['suggestedName'] ?? 'Feld',
'type' => $candidate['type'] ?? 'text',
'confidence' => $candidate['confidence'] ?? 'low',
], $input['candidates'] ?? []);
return [
'content' => json_encode(['classifications' => $classifications]),
'inputTokens' => 42, 'outputTokens' => 17,
'cacheCreationInputTokens' => 0, 'cacheReadInputTokens' => 0,
];
}
return [
'content' => json_encode([
'lessons' => [
[
'id' => null,
'date' => null,
'lessonNumber' => null,
'topic' => 'Fake-Vorschlag zum Testen',
'startTime' => null,
'phases' => [],
'homework' => null,
'reflection' => null,
],
],
'summary' => 'Antwort des FakeProvider (kein echter KI-Aufruf).',
]),
'inputTokens' => 42,
'outputTokens' => 17,
'cacheCreationInputTokens' => 0,
'cacheReadInputTokens' => 0,
];
}
}