Added personality - Chamberlain
This commit is contained in:
parent
be70760320
commit
3d996db3b2
4 changed files with 75 additions and 13 deletions
|
|
@ -59,6 +59,16 @@
|
|||
var p = document.createElement('div');
|
||||
p.style.cssText = 'margin:0 0 10px 0;color:#444;';
|
||||
p.textContent = 'Optional extra guidance for the description prompt.';
|
||||
var personalityLabel = document.createElement('div');
|
||||
personalityLabel.style.cssText = 'font-weight:600;margin:10px 0 6px;';
|
||||
personalityLabel.textContent = 'Personality';
|
||||
var personalitySelect = document.createElement('select');
|
||||
personalitySelect.style.cssText = 'width:100%;box-sizing:border-box;font-family:inherit;padding:10px;border:1px solid #ccc;border-radius:4px;background:white;';
|
||||
personalitySelect.disabled = true;
|
||||
var autoOption = document.createElement('option');
|
||||
autoOption.value = 'auto';
|
||||
autoOption.textContent = 'Auto / rotate';
|
||||
personalitySelect.appendChild(autoOption);
|
||||
var label = document.createElement('div');
|
||||
label.style.cssText = 'font-weight:600;margin:10px 0 6px;';
|
||||
label.textContent = 'Infos/guidelines';
|
||||
|
|
@ -81,6 +91,8 @@
|
|||
btnBar.appendChild(cancelBtn);
|
||||
box.appendChild(h);
|
||||
box.appendChild(p);
|
||||
box.appendChild(personalityLabel);
|
||||
box.appendChild(personalitySelect);
|
||||
box.appendChild(label);
|
||||
box.appendChild(textarea);
|
||||
box.appendChild(btnBar);
|
||||
|
|
@ -93,8 +105,9 @@
|
|||
}
|
||||
function submit(){
|
||||
var promptText = textarea.value || '';
|
||||
var selectedPersonality = personalitySelect.value || 'auto';
|
||||
closeModal();
|
||||
runDescribeRequest(job, articleId, promptText);
|
||||
runDescribeRequest(job, articleId, promptText, selectedPersonality);
|
||||
}
|
||||
function onKeyDown(ev){
|
||||
if (ev.key === 'Escape') {
|
||||
|
|
@ -118,9 +131,19 @@
|
|||
if (data && data.status === 'ok' && typeof data.additional_prompt === 'string') {
|
||||
textarea.value = data.additional_prompt;
|
||||
}
|
||||
if (data && data.status === 'ok' && Array.isArray(data.personalities)) {
|
||||
data.personalities.forEach(function(p){
|
||||
if (!p || !p.key) return;
|
||||
var opt = document.createElement('option');
|
||||
opt.value = String(p.key);
|
||||
opt.textContent = String(p.label || p.key);
|
||||
personalitySelect.appendChild(opt);
|
||||
});
|
||||
}
|
||||
}).catch(function(){}).finally(function(){
|
||||
if (!overlay || !overlay.parentNode) return;
|
||||
textarea.disabled = false;
|
||||
personalitySelect.disabled = false;
|
||||
submitBtn.disabled = false;
|
||||
textarea.placeholder = 'Optional details about the images/videos/trip…';
|
||||
setTimeout(function(){ textarea.focus(); }, 0);
|
||||
|
|
@ -134,9 +157,10 @@
|
|||
loadSavedPrompt();
|
||||
}
|
||||
|
||||
function runDescribeRequest(job, articleId, additionalPrompt){
|
||||
function runDescribeRequest(job, articleId, additionalPrompt, selectedPersonality){
|
||||
showDescribeBusy();
|
||||
var body = 'id=' + encodeURIComponent(articleId) + '&job=' + encodeURIComponent(job) + '&max_frames=16';
|
||||
body += '&personality=' + encodeURIComponent(selectedPersonality || 'auto');
|
||||
if (additionalPrompt && additionalPrompt.trim()) {
|
||||
body += '&additional_prompt=' + encodeURIComponent(additionalPrompt);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue