Added personality - Chamberlain

This commit is contained in:
hbrain 2026-06-19 18:15:40 +02:00
parent be70760320
commit 3d996db3b2
4 changed files with 75 additions and 13 deletions

View file

@ -60,7 +60,23 @@ if ($jobdir === null || !is_dir($jobdir)) {
exit;
}
function mvlog_read_personality_keys(string $script): array {
if (!is_file($script)) return [];
$src = (string)@file_get_contents($script);
if ($src === '') return [];
if (!preg_match('/PERSONALITY_KEYS=\((.*?)\)/s', $src, $m)) return [];
if (!preg_match_all('/"((?:\\\\.|[^"\\\\])*)"/', $m[1], $mm)) return [];
$out = [];
foreach ($mm[1] as $raw) {
$key = stripcslashes($raw);
if ($key === '') continue;
$out[] = ['key' => $key, 'label' => ucfirst(str_replace(['_', '-'], ' ', $key))];
}
return $out;
}
$path = $jobdir . '/.mvlog-describe-prompt.txt';
$prompt = is_file($path) ? trim((string)@file_get_contents($path)) : '';
$personalities = mvlog_read_personality_keys($MVLOG_ROOT . '/bin/generate_data.sh');
echo json_encode(['status' => 'ok', 'additional_prompt' => $prompt], JSON_UNESCAPED_UNICODE);
echo json_encode(['status' => 'ok', 'additional_prompt' => $prompt, 'personalities' => $personalities], JSON_UNESCAPED_UNICODE);