Fix describe generator script syntax and fail on stale JSON fallback
This commit is contained in:
parent
62156ed946
commit
5c544f3cfb
2 changed files with 31 additions and 2 deletions
|
|
@ -112,6 +112,7 @@ PERSONALITIES=(
|
|||
"You're highly intelligent yet chronically depressed android. Your expression should convey exhaustion, disappointment, and the certainty that everything will eventually go wrong. Surrounded by futuristic technology, starships, data displays, and impossible engineering problems. Despite obvious genius, you appear profoundly unimpressed by the universe. Dark humor, existential dread, quiet sarcasm, and the feeling that you have already calculated every possible outcome and disliked all of them. Cinematic science-fiction style, realistic, highly detailed."
|
||||
|
||||
"You're embodying the personality, presence, and atmosphere of a wartime statesman leading a nation through its darkest hour. Calm under pressure, determined, intelligent, and unbreakable. Strong posture, thoughtful expression, commanding presence. Surrounded by maps, strategy documents, war rooms, and symbols of leadership. The image should convey courage, resilience, discipline, and the ability to inspire others during difficult times. Historic yet timeless atmosphere, dramatic lighting, realistic, highly detailed portrait photography."
|
||||
)
|
||||
|
||||
# Pick a random personality
|
||||
idx=$(( RANDOM % ${#PERSONALITIES[@]} ))
|
||||
|
|
@ -124,7 +125,7 @@ Before the actual description write just one quoted sentence (ONE sentence only!
|
|||
coming. The atmosphere should combine culture, intelligence, optimism, and gentle satire. Refined, warm, charismatic, and playful. Realistic, cinematic, highly detailed.
|
||||
|
||||
"$PERSONALITY"
|
||||
Now synthesize what you saw on the pictures into one single, coherent description (make it not more than 896 but less than 1280 characters)
|
||||
Now synthesize what you saw on the pictures into one single, coherent description (make it not less than 768 and not more than 1024 characters)
|
||||
that summarizes the overall experience for motorcycle/travel blog: You are the main character riding your beloved Yamaha FJR.
|
||||
You love motorcycles of course but also pizzas and the best sport ever invented: ice hockey.
|
||||
|
||||
|
|
|
|||
|
|
@ -107,11 +107,39 @@ $cmd = escapeshellcmd($script) . ' ' . escapeshellarg($jobdir) . ' ' . escapeshe
|
|||
// Allow long-running
|
||||
@set_time_limit(0);
|
||||
|
||||
$gfile = dirname($jobdir) . '/' . basename($jobdir) . '.json';
|
||||
$gfileExistedBefore = is_file($gfile);
|
||||
$gfileMtimeBefore = $gfileExistedBefore ? @filemtime($gfile) : null;
|
||||
|
||||
exec($cmd, $out_lines, $rc);
|
||||
$log = implode("\n", $out_lines);
|
||||
clearstatcache(true, $gfile);
|
||||
|
||||
if ($rc !== 0) {
|
||||
http_response_code(500);
|
||||
echo json_encode([
|
||||
'status' => 'error',
|
||||
'message' => 'generator failed',
|
||||
'log' => $log,
|
||||
'rc' => $rc,
|
||||
'output_file' => basename($gfile),
|
||||
'stale_output_present' => is_file($gfile),
|
||||
], JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!is_file($gfile)) {
|
||||
http_response_code(500);
|
||||
echo json_encode([
|
||||
'status' => 'error',
|
||||
'message' => 'no gemini output',
|
||||
'log' => $log,
|
||||
'rc' => $rc,
|
||||
], JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
}
|
||||
|
||||
// If gemini_generated.json exists, parse and return
|
||||
$gfile = dirname($jobdir) . '/' . basename($jobdir) . '.json';
|
||||
if (is_file($gfile)) {
|
||||
$raw = @file_get_contents($gfile);
|
||||
$json_data = @json_decode($raw, true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue