Upload 3 files
Browse files- Dockerfile +7 -1
- preset_creator.html +286 -0
- tool_server.py +60 -0
Dockerfile
CHANGED
|
@@ -24,6 +24,7 @@ COPY coding_priority_pipe.py /app/coding_priority_pipe.py
|
|
| 24 |
COPY smart_matcher.py /app/smart_matcher.py
|
| 25 |
COPY api_router.py /app/api_router.py
|
| 26 |
COPY system_prompt.txt /app/system_prompt.txt
|
|
|
|
| 27 |
|
| 28 |
# JSON funkcije
|
| 29 |
COPY token_saver.json /app/token_saver.json
|
|
@@ -36,8 +37,13 @@ COPY __mermaid_doctor_-_heals_broken_mermaid_diagrams_generated_by_small_or_hall
|
|
| 36 |
COPY github_simple.json /app/github_simple.json
|
| 37 |
COPY pdf_tools_-_rich_ui_for_in_context_basic_editing_.json /app/pdf_tools_-_rich_ui_for_in_context_basic_editing_.json
|
| 38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
RUN chmod +x /app/setup_endpoints.sh /app/backup_restore.sh
|
| 40 |
|
| 41 |
EXPOSE 8080
|
|
|
|
| 42 |
|
| 43 |
-
CMD bash -lc "bash /app/backup_restore.sh restore; bash /app/backup_restore.sh loop & sleep 10 && bash /app/setup_endpoints.sh & bash start.sh"
|
|
|
|
| 24 |
COPY smart_matcher.py /app/smart_matcher.py
|
| 25 |
COPY api_router.py /app/api_router.py
|
| 26 |
COPY system_prompt.txt /app/system_prompt.txt
|
| 27 |
+
COPY tool_server.py /app/tool_server.py
|
| 28 |
|
| 29 |
# JSON funkcije
|
| 30 |
COPY token_saver.json /app/token_saver.json
|
|
|
|
| 37 |
COPY github_simple.json /app/github_simple.json
|
| 38 |
COPY pdf_tools_-_rich_ui_for_in_context_basic_editing_.json /app/pdf_tools_-_rich_ui_for_in_context_basic_editing_.json
|
| 39 |
|
| 40 |
+
# Tools HTML folder
|
| 41 |
+
RUN mkdir -p /app/tools
|
| 42 |
+
COPY preset_creator.html /app/tools/preset_creator.html
|
| 43 |
+
|
| 44 |
RUN chmod +x /app/setup_endpoints.sh /app/backup_restore.sh
|
| 45 |
|
| 46 |
EXPOSE 8080
|
| 47 |
+
EXPOSE 8081
|
| 48 |
|
| 49 |
+
CMD bash -lc "bash /app/backup_restore.sh restore; bash /app/backup_restore.sh loop & sleep 10 && bash /app/setup_endpoints.sh & python3 /app/tool_server.py & bash start.sh"
|
preset_creator.html
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="bs">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>WebUI Preset Creator</title>
|
| 7 |
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@3.19.0/dist/tabler-icons.min.css">
|
| 8 |
+
<style>
|
| 9 |
+
*{box-sizing:border-box;margin:0;padding:0}
|
| 10 |
+
body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;background:#0f0f0f;color:#e0e0e0;padding:1rem;max-width:480px;margin:0 auto}
|
| 11 |
+
h1{font-size:16px;font-weight:500;margin-bottom:1rem;color:#fff}
|
| 12 |
+
.sec{font-size:11px;font-weight:500;color:#888;text-transform:uppercase;letter-spacing:.06em;margin:1.2rem 0 .4rem}
|
| 13 |
+
.card{background:#1a1a1a;border:0.5px solid #333;border-radius:12px;padding:1rem 1.25rem;margin-bottom:10px}
|
| 14 |
+
.row{display:flex;align-items:flex-start;gap:8px;margin-bottom:8px}
|
| 15 |
+
.row label{font-size:13px;color:#888;width:100px;flex-shrink:0;padding-top:8px}
|
| 16 |
+
.row input,.row select,.row textarea{flex:1;font-size:13px;background:#111;border:0.5px solid #444;border-radius:8px;padding:7px 10px;color:#e0e0e0;outline:none}
|
| 17 |
+
.row input:focus,.row textarea:focus{border-color:#555}
|
| 18 |
+
.grid2{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;margin-bottom:8px}
|
| 19 |
+
.prov-btn{background:#222;border:0.5px solid #444;border-radius:8px;padding:10px 6px;text-align:center;cursor:pointer;font-size:12px;color:#ccc;transition:all .15s}
|
| 20 |
+
.prov-btn:hover{background:#2a2a2a;border-color:#555}
|
| 21 |
+
.prov-btn.active{border:1.5px solid #3b82f6;background:#1e3a5f;color:#93c5fd}
|
| 22 |
+
.prov-btn i{font-size:18px;display:block;margin-bottom:3px}
|
| 23 |
+
.model-list{max-height:200px;overflow-y:auto;border:0.5px solid #333;border-radius:8px;margin-top:6px;display:none}
|
| 24 |
+
.model-item{padding:8px 12px;font-size:13px;cursor:pointer;border-bottom:0.5px solid #2a2a2a;color:#ccc}
|
| 25 |
+
.model-item:last-child{border-bottom:none}
|
| 26 |
+
.model-item:hover{background:#222}
|
| 27 |
+
.model-item.selected{background:#1e3a5f;color:#93c5fd}
|
| 28 |
+
.sel-badge{font-size:12px;font-family:monospace;color:#666;margin-top:4px;min-height:16px;word-break:break-all}
|
| 29 |
+
.check-grid{display:flex;flex-direction:column;gap:4px}
|
| 30 |
+
.check-item{display:flex;align-items:center;gap:8px;padding:7px 10px;background:#222;border-radius:8px;border:0.5px solid #333;cursor:pointer}
|
| 31 |
+
.check-item input{width:16px;height:16px;cursor:pointer;flex-shrink:0;accent-color:#3b82f6}
|
| 32 |
+
.check-item .lbl{font-size:13px;flex:1;color:#ccc;cursor:pointer}
|
| 33 |
+
.check-item .tag{font-size:10px;padding:2px 6px;border-radius:4px;background:#1e3a5f;color:#93c5fd}
|
| 34 |
+
.check-item .tag.tool{background:#14532d;color:#86efac}
|
| 35 |
+
.empty{font-size:13px;color:#666;padding:8px}
|
| 36 |
+
button{background:#222;border:0.5px solid #444;border-radius:8px;padding:8px 16px;color:#ccc;font-size:13px;cursor:pointer;width:auto;transition:all .15s}
|
| 37 |
+
button:hover{background:#2a2a2a;border-color:#555}
|
| 38 |
+
button.primary{background:#1e3a5f;border-color:#3b82f6;color:#93c5fd}
|
| 39 |
+
button.danger{color:#f87171;border-color:#7f1d1d}
|
| 40 |
+
.status{font-size:13px;padding:8px 12px;border-radius:8px;margin-top:8px;display:none}
|
| 41 |
+
.status.ok{display:block;background:#14532d;color:#86efac}
|
| 42 |
+
.status.err{display:block;background:#450a0a;color:#f87171}
|
| 43 |
+
.status.info{display:block;background:#1e3a5f;color:#93c5fd}
|
| 44 |
+
.prog{font-size:12px;color:#666;margin-top:4px;min-height:14px}
|
| 45 |
+
.spin{display:inline-block;animation:spin 1s linear infinite}
|
| 46 |
+
@keyframes spin{to{transform:rotate(360deg)}}
|
| 47 |
+
.refresh-row{display:flex;align-items:center;justify-content:space-between;margin-bottom:8px}
|
| 48 |
+
.refresh-row span{font-size:13px;color:#888}
|
| 49 |
+
.refresh-row button{width:auto;font-size:12px;padding:3px 10px}
|
| 50 |
+
</style>
|
| 51 |
+
</head>
|
| 52 |
+
<body>
|
| 53 |
+
<h1><i class="ti ti-sparkles"></i> WebUI Preset Creator</h1>
|
| 54 |
+
|
| 55 |
+
<div class="sec">Prijava na WebUI</div>
|
| 56 |
+
<div class="card">
|
| 57 |
+
<div class="row"><label>URL</label><input type="text" id="url" value="https://nerdur-webui.hf.space"></div>
|
| 58 |
+
<div class="row"><label>Email</label><input type="email" id="email" placeholder="admin@email.com"></div>
|
| 59 |
+
<div class="row"><label>Lozinka</label><input type="password" id="pass" placeholder="••••••••"></div>
|
| 60 |
+
<button class="primary" onclick="doLogin()" style="width:100%"><i class="ti ti-login"></i> Prijavi se</button>
|
| 61 |
+
<div class="status" id="ls"></div>
|
| 62 |
+
</div>
|
| 63 |
+
|
| 64 |
+
<div id="main" style="display:none">
|
| 65 |
+
|
| 66 |
+
<div class="sec">Odaberi provajdera i model</div>
|
| 67 |
+
<div class="card">
|
| 68 |
+
<div class="grid2" id="pgrid">
|
| 69 |
+
<div class="prov-btn" onclick="loadModels(this,'groq')"><i class="ti ti-bolt"></i>Groq</div>
|
| 70 |
+
<div class="prov-btn" onclick="loadModels(this,'gemini')"><i class="ti ti-sparkles"></i>Gemini</div>
|
| 71 |
+
<div class="prov-btn" onclick="loadModels(this,'mistral')"><i class="ti ti-circle"></i>Mistral</div>
|
| 72 |
+
<div class="prov-btn" onclick="loadModels(this,'sambanova')"><i class="ti ti-bolt"></i>SambaNova</div>
|
| 73 |
+
<div class="prov-btn" onclick="loadModels(this,'nvidia')"><i class="ti ti-cpu"></i>NVIDIA</div>
|
| 74 |
+
<div class="prov-btn" onclick="loadModels(this,'hf')"><i class="ti ti-mood-wink"></i>HuggingFace</div>
|
| 75 |
+
<div class="prov-btn" onclick="loadModels(this,'pollinations')"><i class="ti ti-flower"></i>Pollinations</div>
|
| 76 |
+
<div class="prov-btn" onclick="loadModels(this,'cerebras')"><i class="ti ti-brain"></i>Cerebras</div>
|
| 77 |
+
</div>
|
| 78 |
+
<div id="model-loading" style="display:none;font-size:13px;color:#888;padding:6px 0">
|
| 79 |
+
<i class="ti ti-refresh spin"></i> Učitavam modele...
|
| 80 |
+
</div>
|
| 81 |
+
<div id="model-list" class="model-list"></div>
|
| 82 |
+
<div class="sel-badge" id="sel-model">← Odaberi provajdera pa model</div>
|
| 83 |
+
</div>
|
| 84 |
+
|
| 85 |
+
<div class="sec">Detalji preseta</div>
|
| 86 |
+
<div class="card">
|
| 87 |
+
<div class="row"><label>Preset ID</label><input type="text" id="pid" placeholder="npr. moj_groq_llama"></div>
|
| 88 |
+
<div class="row"><label>Naziv</label><input type="text" id="pname" placeholder="npr. ⚡ Groq Llama"></div>
|
| 89 |
+
<div class="row">
|
| 90 |
+
<label>Temperatura</label>
|
| 91 |
+
<input type="number" id="temp" value="0.2" min="0" max="2" step="0.1" style="width:70px;flex:none">
|
| 92 |
+
<span style="font-size:13px;color:#888;padding-top:8px;margin-left:10px">Max tokena</span>
|
| 93 |
+
<input type="number" id="maxtok" value="8192" step="256" style="width:85px;flex:none;margin-left:6px">
|
| 94 |
+
</div>
|
| 95 |
+
<div class="row"><label>System Prompt</label><textarea id="sysp" rows="3" style="flex:1;font-size:13px;resize:vertical" placeholder="Ostavi prazno za default..."></textarea></div>
|
| 96 |
+
</div>
|
| 97 |
+
|
| 98 |
+
<div class="sec">Funkcije i toolovi</div>
|
| 99 |
+
<div class="card">
|
| 100 |
+
<div class="refresh-row">
|
| 101 |
+
<span>Odaberi šta prikaći na preset</span>
|
| 102 |
+
<button onclick="refreshFunctions()"><i class="ti ti-refresh"></i> Osvježi</button>
|
| 103 |
+
</div>
|
| 104 |
+
<div id="fn-loading" style="font-size:13px;color:#888;display:none"><i class="ti ti-refresh spin"></i> Učitavam...</div>
|
| 105 |
+
<div id="fn-list" class="check-grid"><div class="empty">Prijavi se da učitam funkcije i toolove.</div></div>
|
| 106 |
+
</div>
|
| 107 |
+
|
| 108 |
+
<button class="primary" onclick="createPreset()" style="width:100%;margin-bottom:6px">
|
| 109 |
+
<i class="ti ti-sparkles"></i> Kreiraj / Ažuriraj Preset
|
| 110 |
+
</button>
|
| 111 |
+
<div class="status" id="ps"></div>
|
| 112 |
+
<div class="prog" id="prog"></div>
|
| 113 |
+
|
| 114 |
+
<div class="sec">Obriši preset</div>
|
| 115 |
+
<div class="card">
|
| 116 |
+
<div class="row"><label>Preset ID</label><input type="text" id="did" placeholder="npr. nerdur_claude"></div>
|
| 117 |
+
<button class="danger" onclick="deletePreset()" style="width:100%">
|
| 118 |
+
<i class="ti ti-trash"></i> Obriši
|
| 119 |
+
</button>
|
| 120 |
+
</div>
|
| 121 |
+
|
| 122 |
+
</div>
|
| 123 |
+
|
| 124 |
+
<script>
|
| 125 |
+
let TOKEN='', BASE='';
|
| 126 |
+
|
| 127 |
+
function setS(id,msg,t){const e=document.getElementById(id);e.className='status '+t;e.textContent=msg}
|
| 128 |
+
|
| 129 |
+
async function doLogin(){
|
| 130 |
+
BASE=document.getElementById('url').value.trim().replace(/\/$/,'');
|
| 131 |
+
const email=document.getElementById('email').value.trim();
|
| 132 |
+
const pass=document.getElementById('pass').value;
|
| 133 |
+
setS('ls','Prijavljivanje...','info');
|
| 134 |
+
try{
|
| 135 |
+
const r=await fetch(BASE+'/api/v1/auths/signin',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({email,password:pass})});
|
| 136 |
+
const d=await r.json();
|
| 137 |
+
if(d.token){
|
| 138 |
+
TOKEN=d.token;
|
| 139 |
+
setS('ls','✅ Ulogovan kao '+(d.name||email),'ok');
|
| 140 |
+
document.getElementById('main').style.display='block';
|
| 141 |
+
refreshFunctions();
|
| 142 |
+
} else {
|
| 143 |
+
setS('ls','❌ '+(d.detail||'Pogrešni podaci'),'err');
|
| 144 |
+
}
|
| 145 |
+
}catch(e){setS('ls','❌ '+e.message,'err')}
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
const PROVIDER_KEYWORDS={
|
| 149 |
+
groq:['groq','llama','gemma','whisper','moonshotai'],
|
| 150 |
+
gemini:['gemini','google','models/'],
|
| 151 |
+
mistral:['mistral','codestral','mixtral'],
|
| 152 |
+
sambanova:['sambanova','meta-llama'],
|
| 153 |
+
nvidia:['nvidia','integrate.api.nvidia','mistral-ai/','deepseek-ai/','qwen/','zhipuai/','stepfun','baidu','canopy','bytedance'],
|
| 154 |
+
hf:['huggingface','hf-inference','qwen2','falcon','bloom','phi'],
|
| 155 |
+
pollinations:['pollinations','openai','gpt','dall'],
|
| 156 |
+
cerebras:['cerebras','llama-4','scout']
|
| 157 |
+
};
|
| 158 |
+
|
| 159 |
+
async function loadModels(btn,provider){
|
| 160 |
+
document.querySelectorAll('.prov-btn').forEach(b=>b.classList.remove('active'));
|
| 161 |
+
btn.classList.add('active');
|
| 162 |
+
const ml=document.getElementById('model-list');
|
| 163 |
+
const loading=document.getElementById('model-loading');
|
| 164 |
+
ml.style.display='none'; ml.innerHTML='';
|
| 165 |
+
loading.style.display='block';
|
| 166 |
+
document.getElementById('sel-model').textContent='Učitavam modele...';
|
| 167 |
+
try{
|
| 168 |
+
const r=await fetch(BASE+'/api/models',{headers:{'Authorization':'Bearer '+TOKEN}});
|
| 169 |
+
const d=await r.json();
|
| 170 |
+
const keys=PROVIDER_KEYWORDS[provider]||[];
|
| 171 |
+
const models=(d.data||[]).filter(m=>{
|
| 172 |
+
const id=(m.id||'').toLowerCase();
|
| 173 |
+
const owned=(m.owned_by||'').toLowerCase();
|
| 174 |
+
const name=(m.name||'').toLowerCase();
|
| 175 |
+
return keys.some(k=>id.includes(k)||owned.includes(k)||name.includes(k));
|
| 176 |
+
});
|
| 177 |
+
loading.style.display='none';
|
| 178 |
+
if(models.length===0){
|
| 179 |
+
ml.innerHTML='<div class="empty">Nema modela za ovog provajdera.</div>';
|
| 180 |
+
ml.style.display='block'; return;
|
| 181 |
+
}
|
| 182 |
+
models.forEach(m=>{
|
| 183 |
+
const div=document.createElement('div');
|
| 184 |
+
div.className='model-item';
|
| 185 |
+
div.textContent=m.name||m.id;
|
| 186 |
+
div.title=m.id;
|
| 187 |
+
div.onclick=()=>{
|
| 188 |
+
document.querySelectorAll('.model-item').forEach(x=>x.classList.remove('selected'));
|
| 189 |
+
div.classList.add('selected');
|
| 190 |
+
document.getElementById('sel-model').textContent=m.id;
|
| 191 |
+
if(!document.getElementById('pid').value) document.getElementById('pid').value='nerdur_'+provider;
|
| 192 |
+
if(!document.getElementById('pname').value) document.getElementById('pname').value=m.name||m.id;
|
| 193 |
+
};
|
| 194 |
+
ml.appendChild(div);
|
| 195 |
+
});
|
| 196 |
+
ml.style.display='block';
|
| 197 |
+
}catch(e){
|
| 198 |
+
loading.style.display='none';
|
| 199 |
+
ml.innerHTML='<div class="empty">Greška: '+e.message+'</div>';
|
| 200 |
+
ml.style.display='block';
|
| 201 |
+
}
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
async function refreshFunctions(){
|
| 205 |
+
if(!TOKEN) return;
|
| 206 |
+
const h={'Authorization':'Bearer '+TOKEN};
|
| 207 |
+
const fl=document.getElementById('fn-list');
|
| 208 |
+
const fload=document.getElementById('fn-loading');
|
| 209 |
+
fl.innerHTML=''; fload.style.display='block';
|
| 210 |
+
try{
|
| 211 |
+
const [fr,tr]=await Promise.all([
|
| 212 |
+
fetch(BASE+'/api/v1/functions/',{headers:h}).then(r=>r.json()),
|
| 213 |
+
fetch(BASE+'/api/v1/tools/',{headers:h}).then(r=>r.json())
|
| 214 |
+
]);
|
| 215 |
+
fload.style.display='none';
|
| 216 |
+
const items=[];
|
| 217 |
+
(Array.isArray(fr)?fr:[]).forEach(f=>items.push({id:f.id,name:f.name,type:'filter'}));
|
| 218 |
+
(Array.isArray(tr)?tr:[]).forEach(t=>items.push({id:t.id,name:t.name,type:'tool'}));
|
| 219 |
+
if(items.length===0){fl.innerHTML='<div class="empty">Nema instaliranih funkcija/toolova.</div>';return;}
|
| 220 |
+
items.forEach(item=>{
|
| 221 |
+
const div=document.createElement('div');
|
| 222 |
+
div.className='check-item';
|
| 223 |
+
div.innerHTML=`<input type="checkbox" id="fn_${item.id}" value="${item.id}" data-type="${item.type}">
|
| 224 |
+
<label class="lbl" for="fn_${item.id}">${item.name}</label>
|
| 225 |
+
<span class="tag ${item.type==='tool'?'tool':''}">${item.type}</span>`;
|
| 226 |
+
fl.appendChild(div);
|
| 227 |
+
});
|
| 228 |
+
}catch(e){
|
| 229 |
+
fload.style.display='none';
|
| 230 |
+
fl.innerHTML='<div class="empty">Greška: '+e.message+'</div>';
|
| 231 |
+
}
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
async function createPreset(){
|
| 235 |
+
const modelId=document.getElementById('sel-model').textContent.trim();
|
| 236 |
+
const presetId=document.getElementById('pid').value.trim();
|
| 237 |
+
const name=document.getElementById('pname').value.trim();
|
| 238 |
+
if(!TOKEN){setS('ps','❌ Prvo se prijavi!','err');return}
|
| 239 |
+
if(!modelId||modelId.startsWith('←')){setS('ps','❌ Odaberi model!','err');return}
|
| 240 |
+
if(!presetId||!name){setS('ps','❌ Popuni Preset ID i Naziv!','err');return}
|
| 241 |
+
const filterIds=[],toolIds=[];
|
| 242 |
+
document.querySelectorAll('#fn-list input[type=checkbox]:checked').forEach(cb=>{
|
| 243 |
+
if(cb.dataset.type==='tool') toolIds.push(cb.value);
|
| 244 |
+
else filterIds.push(cb.value);
|
| 245 |
+
});
|
| 246 |
+
const prog=document.getElementById('prog');
|
| 247 |
+
prog.textContent='Provjera...';
|
| 248 |
+
setS('ps','Kreiram...','info');
|
| 249 |
+
const payload={
|
| 250 |
+
id:presetId,name,
|
| 251 |
+
base_model_id:modelId,
|
| 252 |
+
meta:{description:name+' — preset',profile_image_url:'/static/favicon.png',tags:[{name:'custom'}],capabilities:{vision:false,citations:true,usage:true}},
|
| 253 |
+
params:{system:document.getElementById('sysp').value.trim()||'',temperature:parseFloat(document.getElementById('temp').value),max_tokens:parseInt(document.getElementById('maxtok').value)},
|
| 254 |
+
filter_ids:filterIds,
|
| 255 |
+
tool_ids:toolIds
|
| 256 |
+
};
|
| 257 |
+
const h={'Content-Type':'application/json','Authorization':'Bearer '+TOKEN};
|
| 258 |
+
try{
|
| 259 |
+
const chk=await fetch(BASE+'/api/v1/models/model?id='+encodeURIComponent(presetId),{headers:h});
|
| 260 |
+
const ep=chk.status===200?'/api/v1/models/model/update?id='+encodeURIComponent(presetId):'/api/v1/models/create';
|
| 261 |
+
prog.textContent=chk.status===200?'Ažuriram...':'Kreiram novi...';
|
| 262 |
+
const r=await fetch(BASE+ep,{method:'POST',headers:h,body:JSON.stringify(payload)});
|
| 263 |
+
const d=await r.json();
|
| 264 |
+
if(r.ok){
|
| 265 |
+
setS('ps','✅ "'+name+'" '+(chk.status===200?'ažuriran':'kreiran')+'!','ok');
|
| 266 |
+
prog.textContent='Filtri: '+filterIds.length+' | Toolovi: '+toolIds.length+' | Model: '+modelId;
|
| 267 |
+
} else {
|
| 268 |
+
setS('ps','❌ '+(d.detail||JSON.stringify(d).slice(0,120)),'err');
|
| 269 |
+
prog.textContent='';
|
| 270 |
+
}
|
| 271 |
+
}catch(e){setS('ps','❌ '+e.message,'err');prog.textContent=''}
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
async function deletePreset(){
|
| 275 |
+
if(!TOKEN){alert('Prvo se prijavi!');return}
|
| 276 |
+
const id=document.getElementById('did').value.trim();
|
| 277 |
+
if(!id){alert('Unesi Preset ID');return}
|
| 278 |
+
try{
|
| 279 |
+
const r=await fetch(BASE+'/api/v1/models/model/delete?id='+encodeURIComponent(id),{method:'DELETE',headers:{'Authorization':'Bearer '+TOKEN}});
|
| 280 |
+
if(r.ok) alert('✅ Preset "'+id+'" obrisan!');
|
| 281 |
+
else alert('❌ Greška ili preset ne postoji.');
|
| 282 |
+
}catch(e){alert('❌ '+e.message)}
|
| 283 |
+
}
|
| 284 |
+
</script>
|
| 285 |
+
</body>
|
| 286 |
+
</html>
|
tool_server.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
tool_server.py — Mini HTTP server za WebUI toolove
|
| 3 |
+
Servira /preset-creator i ostale admin alate na portu 8081
|
| 4 |
+
Radi kao sidecar uz Open WebUI (port 8080)
|
| 5 |
+
"""
|
| 6 |
+
from http.server import HTTPServer, BaseHTTPRequestHandler
|
| 7 |
+
import os
|
| 8 |
+
|
| 9 |
+
HTML_DIR = "/app/tools"
|
| 10 |
+
|
| 11 |
+
class ToolHandler(BaseHTTPRequestHandler):
|
| 12 |
+
def log_message(self, format, *args):
|
| 13 |
+
# Tiši logovi
|
| 14 |
+
pass
|
| 15 |
+
|
| 16 |
+
def do_GET(self):
|
| 17 |
+
path = self.path.split("?")[0].rstrip("/")
|
| 18 |
+
|
| 19 |
+
if path == "" or path == "/":
|
| 20 |
+
self.redirect("/preset-creator")
|
| 21 |
+
return
|
| 22 |
+
|
| 23 |
+
if path == "/preset-creator":
|
| 24 |
+
self.serve_file("preset_creator.html", "text/html; charset=utf-8")
|
| 25 |
+
return
|
| 26 |
+
|
| 27 |
+
# 404
|
| 28 |
+
self.send_response(404)
|
| 29 |
+
self.send_header("Content-Type", "text/plain; charset=utf-8")
|
| 30 |
+
self.end_headers()
|
| 31 |
+
self.wfile.write(b"404 Not Found")
|
| 32 |
+
|
| 33 |
+
def redirect(self, location):
|
| 34 |
+
self.send_response(302)
|
| 35 |
+
self.send_header("Location", location)
|
| 36 |
+
self.end_headers()
|
| 37 |
+
|
| 38 |
+
def serve_file(self, filename, content_type):
|
| 39 |
+
filepath = os.path.join(HTML_DIR, filename)
|
| 40 |
+
if not os.path.exists(filepath):
|
| 41 |
+
self.send_response(404)
|
| 42 |
+
self.send_header("Content-Type", "text/plain")
|
| 43 |
+
self.end_headers()
|
| 44 |
+
self.wfile.write(f"File not found: {filename}".encode())
|
| 45 |
+
return
|
| 46 |
+
with open(filepath, "rb") as f:
|
| 47 |
+
data = f.read()
|
| 48 |
+
self.send_response(200)
|
| 49 |
+
self.send_header("Content-Type", content_type)
|
| 50 |
+
self.send_header("Content-Length", str(len(data)))
|
| 51 |
+
self.end_headers()
|
| 52 |
+
self.wfile.write(data)
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
if __name__ == "__main__":
|
| 56 |
+
port = int(os.environ.get("TOOLS_PORT", 8081))
|
| 57 |
+
server = HTTPServer(("0.0.0.0", port), ToolHandler)
|
| 58 |
+
print(f"✅ Tool server pokrenut na portu {port}")
|
| 59 |
+
print(f" → http://localhost:{port}/preset-creator")
|
| 60 |
+
server.serve_forever()
|