Added personality to describe reply

This commit is contained in:
hbrain 2026-06-05 13:26:01 +02:00
parent 3ea09af486
commit 2fbb34e4c7
2 changed files with 13 additions and 2 deletions

View file

@ -151,7 +151,8 @@
var teaser = data.teaser || ''; var teaser = data.teaser || '';
var rawFirst = (Array.isArray(data.raw_json) && data.raw_json.length) ? data.raw_json[0] : data.raw_json; var rawFirst = (Array.isArray(data.raw_json) && data.raw_json.length) ? data.raw_json[0] : data.raw_json;
var quoteDa = data.quote_da || (rawFirst && rawFirst.quote_da) || ''; var quoteDa = data.quote_da || (rawFirst && rawFirst.quote_da) || '';
showModal(job, articleId, desc, teaser, quoteDa, data.raw_json || null); var personality = data.personality || (rawFirst && rawFirst.personality) || '';
showModal(job, articleId, desc, teaser, quoteDa, personality, data.raw_json || null);
} else { } else {
var msg = (data && data.message) ? data.message : 'No response'; var msg = (data && data.message) ? data.message : 'No response';
if (data && data.log) { if (data && data.log) {
@ -173,7 +174,7 @@
}); });
} }
function showModal(job, articleId, description, teaser, quoteDa, rawJson){ function showModal(job, articleId, description, teaser, quoteDa, personality, rawJson){
var existing = document.getElementById('mvlog-gemini-modal'); var existing = document.getElementById('mvlog-gemini-modal');
if (existing) existing.remove(); if (existing) existing.remove();
var overlay = document.createElement('div'); var overlay = document.createElement('div');
@ -183,6 +184,12 @@
box.style.cssText = 'background:white;color:#111;padding:20px;max-width:900px;max-height:80vh;overflow:auto;border-radius:6px;font-family:inherit;'; box.style.cssText = 'background:white;color:#111;padding:20px;max-width:900px;max-height:80vh;overflow:auto;border-radius:6px;font-family:inherit;';
var h = document.createElement('h3'); var h = document.createElement('h3');
h.textContent = 'Generated description'; h.textContent = 'Generated description';
var personalityBox = null;
if (personality) {
personalityBox = document.createElement('div');
personalityBox.style.cssText = 'font-size:0.9rem;color:#555;margin-top:6px;';
personalityBox.textContent = 'Personality: ' + personality;
}
var teaserBox = null; var teaserBox = null;
if (teaser) { if (teaser) {
teaserBox = document.createElement('div'); teaserBox = document.createElement('div');
@ -210,6 +217,7 @@
btnBar.appendChild(useBtn); btnBar.appendChild(useBtn);
btnBar.appendChild(cancelBtn); btnBar.appendChild(cancelBtn);
box.appendChild(h); box.appendChild(h);
if (personalityBox) box.appendChild(personalityBox);
if (teaserBox) box.appendChild(teaserBox); if (teaserBox) box.appendChild(teaserBox);
box.appendChild(pre); box.appendChild(pre);
if (quoteBox) box.appendChild(quoteBox); if (quoteBox) box.appendChild(quoteBox);

View file

@ -169,12 +169,14 @@ if (is_file($gfile)) {
$description = ''; $description = '';
$teaser = ''; $teaser = '';
$quote_da = ''; $quote_da = '';
$personality = '';
$tags = []; $tags = [];
if (is_array($json)) { if (is_array($json)) {
$description = isset($json['description']) ? (string)$json['description'] : ''; $description = isset($json['description']) ? (string)$json['description'] : '';
$teaser = isset($json['teaser']) ? (string)$json['teaser'] : ''; $teaser = isset($json['teaser']) ? (string)$json['teaser'] : '';
$quote_da = isset($json['quote_da']) ? (string)$json['quote_da'] : ''; $quote_da = isset($json['quote_da']) ? (string)$json['quote_da'] : '';
$quote_da = trim($quote_da, "\"“”"); $quote_da = trim($quote_da, "\"“”");
$personality = isset($json['personality']) ? (string)$json['personality'] : '';
$tags = isset($json['tags']) && is_array($json['tags']) ? $json['tags'] : []; $tags = isset($json['tags']) && is_array($json['tags']) ? $json['tags'] : [];
} }
@ -183,6 +185,7 @@ if (is_file($gfile)) {
'description' => $description, 'description' => $description,
'teaser' => $teaser, 'teaser' => $teaser,
'quote_da' => $quote_da, 'quote_da' => $quote_da,
'personality' => $personality,
'tags' => $tags, 'tags' => $tags,
'raw_json' => $json_data, // Send original raw data back for reference 'raw_json' => $json_data, // Send original raw data back for reference
'log' => $log, 'log' => $log,