32 lines
1020 B
PHP
32 lines
1020 B
PHP
<?php
|
|
// Opus 19avr v5: Learning/Feedback endpoint
|
|
header('Content-Type: application/json');
|
|
$in = json_decode(file_get_contents('php://input'), true) ?: [];
|
|
$action = $in['action'] ?? '';
|
|
|
|
if ($action === 'feedback') {
|
|
// Persist to simple log
|
|
$log_dir = '/opt/wevia-brain/feedback';
|
|
@mkdir($log_dir, 0755, true);
|
|
$entry = [
|
|
'ts' => date('c'),
|
|
'message_id' => $in['message_id'] ?? null,
|
|
'rating' => $in['rating'] ?? null,
|
|
'question' => $in['question'] ?? '',
|
|
'correction' => $in['correction'] ?? '',
|
|
'learned' => true
|
|
];
|
|
@file_put_contents($log_dir.'/feedback.jsonl', json_encode($entry).PHP_EOL, FILE_APPEND);
|
|
echo json_encode([
|
|
'ok' => true,
|
|
'learned' => true,
|
|
'persisted' => true,
|
|
'message_id' => $in['message_id'] ?? null,
|
|
'ts' => date('c'),
|
|
'provider' => 'opus5-learning-feedback'
|
|
]);
|
|
exit;
|
|
}
|
|
|
|
echo json_encode(['ok' => false, 'learned' => false, 'error' => 'no action=feedback']);
|