Admin-PM-Liste: KI-Pruefungs-Modal + geschaerfte KI-Prompts
- Spalten umsortiert (Aktionen, Datum, KI-Pruefung zuerst); Pruefen-Button nur noch Icon, oeffnet Detail-Modal mit Klassifikation, Begruendung, Content-Score inkl. Faktor-Breakdown und Re-Check (wire:poll bis Queue durch) - Content-Score: Bild-Punkte (10) systemseitig statt KI (nur ein Upload-Bild moeglich), Quellen 10->5, Pressestil 20->25; Breakdown wandert ins Audit-Log - Klassifikations-Prompt prueft gegen aktive Ablehnungskategorien (K1-K6, rejection_categories): klarer Verstoss => direkt rot mit Kategorie-Code Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
9cb53b1e17
commit
b26dc9057c
7 changed files with 613 additions and 89 deletions
|
|
@ -7,12 +7,16 @@ use App\Mail\PressReleasePublished;
|
|||
use App\Mail\PressReleaseRejected;
|
||||
use App\Models\KiAudit;
|
||||
use App\Models\PressRelease;
|
||||
use App\Models\RejectionCategory;
|
||||
use App\Models\User;
|
||||
use App\Services\PressRelease\Classification\ClassificationManager;
|
||||
use App\Services\PressRelease\PressReleaseService;
|
||||
use Database\Seeders\RejectionCategorySeeder;
|
||||
use Illuminate\Http\Client\Request;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use Tests\TestCase;
|
||||
|
||||
function fakeOpenAiClassification(string $classification, array $reasons = []): void
|
||||
{
|
||||
|
|
@ -66,6 +70,30 @@ test('classify job records a yellow classification with reasons', function () {
|
|||
expect($audit->reason)->toContain('Werbesprache');
|
||||
});
|
||||
|
||||
test('openai classification prompt lists the active rejection categories', function () {
|
||||
/** @var TestCase $this */
|
||||
$this->seed(RejectionCategorySeeder::class);
|
||||
RejectionCategory::query()->where('code', 'K6')->update(['active' => false]);
|
||||
|
||||
fakeOpenAiClassification('green');
|
||||
|
||||
$pressRelease = PressRelease::factory()->create(['title' => 'Sauber', 'text' => 'Inhalt']);
|
||||
|
||||
(new ClassifyPressRelease($pressRelease->id))->handle(
|
||||
app(ClassificationManager::class),
|
||||
app(PressReleaseService::class),
|
||||
);
|
||||
|
||||
Http::assertSent(function (Request $request): bool {
|
||||
$systemPrompt = (string) data_get($request->data(), 'messages.0.content');
|
||||
|
||||
return str_contains($systemPrompt, 'K1 Rechtswidrige Inhalte')
|
||||
&& str_contains($systemPrompt, 'K5 Rechte Dritter')
|
||||
&& ! str_contains($systemPrompt, 'K6 Kein Pressecharakter')
|
||||
&& str_contains($systemPrompt, 'markiere die Mitteilung dann direkt rot');
|
||||
});
|
||||
});
|
||||
|
||||
test('classify job falls back to the deterministic driver when openai fails', function () {
|
||||
config()->set('scoring.classification.provider', 'openai');
|
||||
config()->set('services.openai.api_key', 'test-key');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue