mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 01:39:25 +08:00
update
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
<div class='plugin_version'></div>
|
<div class='plugin_version'></div>
|
||||||
<div class="bt-w-menu">
|
<div class="bt-w-menu">
|
||||||
<p class="bgw" onclick="pluginService('ollama',$('.plugin_version').attr('version'));">服务</p>
|
<p class="bgw" onclick="pluginService('ollama',$('.plugin_version').attr('version'));">服务</p>
|
||||||
|
<p onclick="ollama.ai_model_list();">模型列表</p>
|
||||||
<p onclick="pluginInitD('ollama',$('.plugin_version').attr('version'));">自启动</p>
|
<p onclick="pluginInitD('ollama',$('.plugin_version').attr('version'));">自启动</p>
|
||||||
<p onclick="ollama.readme();">说明</p>
|
<p onclick="ollama.readme();">说明</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -208,6 +208,35 @@ class App:
|
|||||||
mw.execShell('systemctl disable '+self.getPluginName())
|
mw.execShell('systemctl disable '+self.getPluginName())
|
||||||
return 'ok'
|
return 'ok'
|
||||||
|
|
||||||
|
def get_ai_model_list(self):
|
||||||
|
cmd = 'ollama list'
|
||||||
|
data = mw.execShell(cmd)
|
||||||
|
result = []
|
||||||
|
|
||||||
|
if data and data[0]:
|
||||||
|
lines = data[0].strip().split('\n')
|
||||||
|
for i, line in enumerate(lines):
|
||||||
|
if i < 2:
|
||||||
|
continue
|
||||||
|
line = line.strip()
|
||||||
|
if not line:
|
||||||
|
continue
|
||||||
|
parts = line.split()
|
||||||
|
if len(parts) >= 4:
|
||||||
|
name = parts[0]
|
||||||
|
model_id = parts[1]
|
||||||
|
size = ' '.join(parts[2:-1])
|
||||||
|
modified = parts[-1]
|
||||||
|
result.append({
|
||||||
|
'name': name,
|
||||||
|
'id': model_id,
|
||||||
|
'size': size,
|
||||||
|
'modified': modified
|
||||||
|
})
|
||||||
|
|
||||||
|
import json
|
||||||
|
return json.dumps(result)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -31,14 +31,6 @@ var ollama = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var ret_data = $.parseJSON(res.data);
|
var ret_data = $.parseJSON(res.data);
|
||||||
console.log("send:",ret_data);
|
|
||||||
// if (!ret_data.status){
|
|
||||||
// layer.msg(ret_data.msg,{icon:2,time:2000});
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// console.log("send2:",ret_data);
|
|
||||||
|
|
||||||
if(typeof(callback) == 'function'){
|
if(typeof(callback) == 'function'){
|
||||||
callback(ret_data);
|
callback(ret_data);
|
||||||
}
|
}
|
||||||
@@ -83,6 +75,36 @@ var ollama = {
|
|||||||
},'json');
|
},'json');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
ai_model_list:function(){
|
||||||
|
this.send({
|
||||||
|
"tips":"加载中...",
|
||||||
|
"method": 'get_ai_model_list',
|
||||||
|
"success": function(data){
|
||||||
|
var html = '<div class="divtable mtb15">';
|
||||||
|
html += '<table class="table table-hover">';
|
||||||
|
html += '<thead><tr><th>NAME</th><th>ID</th><th>SIZE</th><th>MODIFIED</th></tr></thead>';
|
||||||
|
html += '<tbody>';
|
||||||
|
|
||||||
|
if (data && data.length > 0) {
|
||||||
|
for (var i = 0; i < data.length; i++) {
|
||||||
|
var item = data[i];
|
||||||
|
html += '<tr>';
|
||||||
|
html += '<td>' + (item.name || '') + '</td>';
|
||||||
|
html += '<td>' + (item.id || '') + '</td>';
|
||||||
|
html += '<td>' + (item.size || '') + '</td>';
|
||||||
|
html += '<td>' + (item.modified || '') + '</td>';
|
||||||
|
html += '</tr>';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
html += '<tr><td colspan="4" class="text-center c7">暂无模型</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
html += '</tbody></table></div>';
|
||||||
|
$('.soft-man-con').html(html);
|
||||||
|
},
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
readme:function (){
|
readme:function (){
|
||||||
var readme = '<ul class="help-info-text c7">';
|
var readme = '<ul class="help-info-text c7">';
|
||||||
readme += '<li>常用命令说明:</li>';
|
readme += '<li>常用命令说明:</li>';
|
||||||
|
|||||||
Reference in New Issue
Block a user