feat: improve custom model OCID support for GenAI config
- Add "Personalizado (usar OCID)" option in model select dropdown - Validate OCID is required when custom model is selected - Improve Model OCID field hint text explaining portal usage - Show "OCID Personalizado" label in config table for custom models - Allows using any OCI GenAI model via OCID from the portal
This commit is contained in:
@@ -375,12 +375,12 @@ async function dOci(id){if(!confirm('Excluir credencial?'))return;await $api('/o
|
||||
|
||||
/* ── GenAI Config ── */
|
||||
function rGenAI(){const eg=S.editing?.type==='genai'?S.genaiCfg.find(g=>g.id===S.editing.id):null;
|
||||
const mOpts=Object.entries(S.models).map(([k,v])=>`<option value="${k}"${eg&&eg.model_id===k?' selected':''}>${v.name} (${v.provider})</option>`).join('');
|
||||
const mOpts='<option value="_custom"'+(eg&&eg.model_ocid?' selected':'')+'>🔗 Personalizado (usar OCID)</option>'+Object.entries(S.models).map(([k,v])=>`<option value="${k}"${eg&&eg.model_id===k&&!eg.model_ocid?' selected':''}>${v.name} (${v.provider})</option>`).join('');
|
||||
const rOpts=S.regions.map(r=>`<option value="${r}" ${eg?(r===eg.genai_region?'selected':''):(r==='us-ashburn-1'?'selected':'')}>${r}</option>`).join('');
|
||||
return`<div class="cd"><div class="ct">🧠 Modelos Configurados</div>
|
||||
<table><thead><tr><th>Config</th><th>Modelo</th><th>Região</th><th>Temp</th><th>Tokens</th><th>Ações</th></tr></thead><tbody>
|
||||
${S.genaiCfg.map(g=>{const mi=S.models[g.model_id]||{};return`<tr${eg&&eg.id===g.id?' style="background:var(--bg3)"':''}><td><strong>${g.name||'—'}</strong>${g.is_default?' ⭐':''}</td>
|
||||
<td>${mi.name||g.model_id}<br><span class="tag">${mi.provider||'?'}</span></td>
|
||||
<td>${mi.name||(g.model_ocid?'OCID Personalizado':g.model_id)}<br><span class="tag">${mi.provider||(g.model_ocid?'custom':'?')}</span></td>
|
||||
<td style="font-family:var(--fm);font-size:.7rem">${g.genai_region}</td>
|
||||
<td>${g.temperature}</td><td>${g.max_tokens}</td>
|
||||
<td><button class="btn bs bsm" onclick="editCfg('genai','${g.id}')">Editar</button> <button class="btn bs bsm" onclick="tGenai('${g.id}')">Testar</button> <button class="btn bd bsm" onclick="dGenai('${g.id}')">Excluir</button></td></tr>`}).join('')}</tbody></table>
|
||||
@@ -393,7 +393,7 @@ ${S.ociCfg.map(c=>`<option value="${c.id}"${eg&&eg.oci_config_id===c.id?' select
|
||||
<div class="ig"><label>Modelo</label><select id="gmod">${mOpts}</select></div></div>
|
||||
<div class="g3"><div class="ig"><label>Região GenAI</label><select id="greg">${rOpts}</select></div>
|
||||
<div class="ig"><label>Compartment OCID</label><input type="text" id="gcmp" placeholder="ocid1.compartment.oc1.." value="${eg?eg.compartment_id:''}"></div>
|
||||
<div class="ig"><label>Model OCID (opcional)</label><div class="ht">Somente se diferente do catálogo</div><input type="text" id="gocid" placeholder="ocid1.generativeaimodel.oc1..." value="${eg&&eg.model_ocid?eg.model_ocid:''}"></div></div>
|
||||
<div class="ig"><label>Model OCID</label><div class="ht">Cole o OCID do modelo do portal OCI. Se preenchido, será usado no lugar do modelo selecionado acima.</div><input type="text" id="gocid" placeholder="ocid1.generativeaimodel.oc1.iad.amaaaaaa..." value="${eg&&eg.model_ocid?eg.model_ocid:''}" style="${eg&&eg.model_ocid?'border-color:var(--p)':''}"></div></div>
|
||||
<div style="font-size:.76rem;font-weight:700;color:var(--t2);margin:.65rem 0 .4rem;letter-spacing:-.01em">Parâmetros</div>
|
||||
<div class="g3"><div class="ig"><label>Temperature</label><input type="number" id="gtemp" value="${eg?eg.temperature:1}" step="0.1" min="0" max="2"></div>
|
||||
<div class="ig"><label>Max Tokens</label><input type="number" id="gmt" value="${eg?eg.max_tokens:6000}" min="1" max="128000"></div>
|
||||
@@ -404,10 +404,13 @@ ${S.ociCfg.map(c=>`<option value="${c.id}"${eg&&eg.oci_config_id===c.id?' select
|
||||
<div style="display:flex;gap:8px"><button class="btn bp" id="gbtn" onclick="sGenai()">${eg?'Salvar Alterações':'Salvar Modelo'}</button>${eg?'<button class="btn bs" onclick="cancelEdit()">Cancelar</button>':''}</div></div>
|
||||
`+rConfigLogs('genai')}
|
||||
async function sGenai(){const btn=document.getElementById('gbtn');btn.disabled=true;btn.textContent='Salvando...';sm('gm','<span class="spinner" style="display:inline-block;width:14px;height:14px;vertical-align:middle"></span> Salvando modelo...','i');
|
||||
const isEdit=S.editing?.type==='genai';const body={
|
||||
const isEdit=S.editing?.type==='genai';
|
||||
const selModel=document.getElementById('gmod').value;const ocid=document.getElementById('gocid').value||null;
|
||||
if(selModel==='_custom'&&!ocid){sm('gm','Informe o Model OCID para usar modelo personalizado.','e');btn.disabled=false;btn.textContent=isEdit?'Salvar Alterações':'Salvar Modelo';return}
|
||||
const body={
|
||||
name:document.getElementById('gname').value||'default',
|
||||
oci_config_id:document.getElementById('goci').value,model_id:document.getElementById('gmod').value,
|
||||
model_ocid:document.getElementById('gocid').value||null,
|
||||
oci_config_id:document.getElementById('goci').value,model_id:selModel==='_custom'?'custom':selModel,
|
||||
model_ocid:ocid,
|
||||
compartment_id:document.getElementById('gcmp').value,genai_region:document.getElementById('greg').value,
|
||||
endpoint:null,serving_type:'ON_DEMAND',dedicated_endpoint_id:null,
|
||||
temperature:parseFloat(document.getElementById('gtemp').value),max_tokens:parseInt(document.getElementById('gmt').value),
|
||||
|
||||
Reference in New Issue
Block a user