@@ -9,6 +9,7 @@ | |||||
* @link https://www.dedebiz.com | * @link https://www.dedebiz.com | ||||
*/ | */ | ||||
require(dirname(__FILE__)."/config.php"); | require(dirname(__FILE__)."/config.php"); | ||||
CheckPurview('ai_New'); | |||||
if (empty($dopost)) $dopost = ''; | if (empty($dopost)) $dopost = ''; | ||||
if ($dopost == "add") { | if ($dopost == "add") { | ||||
$title = isset($title)? HtmlReplace($title, -1) : ''; | $title = isset($title)? HtmlReplace($title, -1) : ''; | ||||
@@ -9,22 +9,15 @@ | |||||
* @link https://www.dedebiz.com | * @link https://www.dedebiz.com | ||||
*/ | */ | ||||
require_once(dirname(__FILE__)."/config.php"); | require_once(dirname(__FILE__)."/config.php"); | ||||
$ENV_GOBACK_URL = empty($_COOKIE['ENV_GOBACK_URL']) ? 'ai_main.php' : $_COOKIE['ENV_GOBACK_URL']; | |||||
if (empty($dopost)) $dopost = ''; | if (empty($dopost)) $dopost = ''; | ||||
$id = isset($id)? intval($id) : 0; | $id = isset($id)? intval($id) : 0; | ||||
if (isset($allid)) { | |||||
$aids = explode(',', $allid); | |||||
if (count($aids) == 1) { | |||||
$id = intval($aids[0]); | |||||
$dopost = "delete"; | |||||
} | |||||
} | |||||
if ($dopost == "delete") { | if ($dopost == "delete") { | ||||
CheckPurview('ai_Del'); | |||||
$dsql->ExecuteNoneQuery("DELETE FROM `#@__ai` WHERE id='$id'"); | $dsql->ExecuteNoneQuery("DELETE FROM `#@__ai` WHERE id='$id'"); | ||||
ShowMsg("成功删除一个大模型", $ENV_GOBACK_URL); | ShowMsg("成功删除一个大模型", $ENV_GOBACK_URL); | ||||
exit(); | exit(); | ||||
} else if ($dopost == "saveedit") { | } else if ($dopost == "saveedit") { | ||||
CheckPurview('ai_Edit'); | |||||
$title = isset($title)? HtmlReplace($title, -1) : ''; | $title = isset($title)? HtmlReplace($title, -1) : ''; | ||||
$description = isset($description)? HtmlReplace($description, -1) : ''; | $description = isset($description)? HtmlReplace($description, -1) : ''; | ||||
$company = isset($company)? HtmlReplace($company, -1) : ''; | $company = isset($company)? HtmlReplace($company, -1) : ''; | ||||
@@ -36,8 +29,8 @@ if ($dopost == "delete") { | |||||
ShowMsg("成功修改一个大模型", $ENV_GOBACK_URL); | ShowMsg("成功修改一个大模型", $ENV_GOBACK_URL); | ||||
exit(); | exit(); | ||||
} | } | ||||
CheckPurview('ai_Edit'); | |||||
$myAI = $dsql->GetOne("SELECT * FROM `#@__ai` WHERE id=$id"); | $myAI = $dsql->GetOne("SELECT * FROM `#@__ai` WHERE id=$id"); | ||||
$sql = "SELECT * FROM `#@__ai_model` WHERE aiid=$id ORDER BY id DESC"; | $sql = "SELECT * FROM `#@__ai_model` WHERE aiid=$id ORDER BY id DESC"; | ||||
$dlist = new DataListCP(); | $dlist = new DataListCP(); | ||||
$dlist->SetTemplet(DEDEADMIN.'/templets/ai_edit.htm'); | $dlist->SetTemplet(DEDEADMIN.'/templets/ai_edit.htm'); | ||||
@@ -9,10 +9,11 @@ | |||||
* @link https://www.dedebiz.com | * @link https://www.dedebiz.com | ||||
*/ | */ | ||||
require_once(dirname(__FILE__)."/config.php"); | require_once(dirname(__FILE__)."/config.php"); | ||||
CheckPurview('sys_Log'); | |||||
CheckPurview('ai_LogList'); | |||||
require_once(DEDEINC."/datalistcp.class.php"); | require_once(DEDEINC."/datalistcp.class.php"); | ||||
require_once(DEDEINC."/common.func.php"); | require_once(DEDEINC."/common.func.php"); | ||||
DedeSetCookie("ENV_GOBACK_URL", $dedeNowurl, time() + 3600, "/"); | DedeSetCookie("ENV_GOBACK_URL", $dedeNowurl, time() + 3600, "/"); | ||||
CheckPurview('ai_Del'); | |||||
$sql = $where = ''; | $sql = $where = ''; | ||||
if (empty($adminid)) $adminid = 0; | if (empty($adminid)) $adminid = 0; | ||||
if (empty($cip)) $cip = ''; | if (empty($cip)) $cip = ''; | ||||
@@ -10,7 +10,7 @@ | |||||
*/ | */ | ||||
require_once(dirname(__FILE__).'/config.php'); | require_once(dirname(__FILE__).'/config.php'); | ||||
require_once(DEDEINC.'/datalistcp.class.php'); | require_once(DEDEINC.'/datalistcp.class.php'); | ||||
DedeSetCookie('ENV_GOBACK_URL', $dedeNowurl, time() + 3600, '/'); | |||||
CheckPurview('ai_List'); | |||||
$sql = "SELECT * FROM `#@__ai` ORDER BY id DESC"; | $sql = "SELECT * FROM `#@__ai` ORDER BY id DESC"; | ||||
$dlist = new DataListCP(); | $dlist = new DataListCP(); | ||||
@@ -9,6 +9,7 @@ | |||||
* @link https://www.dedebiz.com | * @link https://www.dedebiz.com | ||||
*/ | */ | ||||
require(dirname(__FILE__)."/config.php"); | require(dirname(__FILE__)."/config.php"); | ||||
CheckPurview('ai_ModelNew'); | |||||
if (empty($dopost)) $dopost = ''; | if (empty($dopost)) $dopost = ''; | ||||
$aiid = isset($aiid) ? intval($aiid) : 0; | $aiid = isset($aiid) ? intval($aiid) : 0; | ||||
if ($dopost == "add") { | if ($dopost == "add") { | ||||
@@ -9,14 +9,17 @@ | |||||
* @link https://www.dedebiz.com | * @link https://www.dedebiz.com | ||||
*/ | */ | ||||
require_once(dirname(__FILE__)."/config.php"); | require_once(dirname(__FILE__)."/config.php"); | ||||
if (empty($dopost)) $dopost = ''; | if (empty($dopost)) $dopost = ''; | ||||
$id = isset($id)? intval($id) : 0; | $id = isset($id)? intval($id) : 0; | ||||
$myModel = $dsql->GetOne("SELECT * FROM `#@__ai_model` WHERE id=$id"); | $myModel = $dsql->GetOne("SELECT * FROM `#@__ai_model` WHERE id=$id"); | ||||
if ($dopost == "delete") { | if ($dopost == "delete") { | ||||
CheckPurview('ai_ModelDel'); | |||||
$dsql->ExecuteNoneQuery("DELETE FROM `#@__ai_model` WHERE id='$id'"); | $dsql->ExecuteNoneQuery("DELETE FROM `#@__ai_model` WHERE id='$id'"); | ||||
ShowMsg("成功删除一个模型版本", "ai_model_main.php"); | ShowMsg("成功删除一个模型版本", "ai_model_main.php"); | ||||
exit(); | exit(); | ||||
} else if ($dopost == "saveedit") { | } else if ($dopost == "saveedit") { | ||||
CheckPurview('ai_ModelEdit'); | |||||
$title = isset($title)? HtmlReplace($title, -1) : ''; | $title = isset($title)? HtmlReplace($title, -1) : ''; | ||||
$description = isset($description)? HtmlReplace($description, -1) : ''; | $description = isset($description)? HtmlReplace($description, -1) : ''; | ||||
$model = isset($model)? HtmlReplace($model, -1) : ''; | $model = isset($model)? HtmlReplace($model, -1) : ''; | ||||
@@ -26,6 +29,7 @@ if ($dopost == "delete") { | |||||
ShowMsg("成功修改一个模型版本", "ai_edit.php?id={$myModel['aiid']}&dopost=getedit"); | ShowMsg("成功修改一个模型版本", "ai_edit.php?id={$myModel['aiid']}&dopost=getedit"); | ||||
exit(); | exit(); | ||||
} | } | ||||
CheckPurview('ai_ModelEdit'); | |||||
$ai = $dsql->GetOne("SELECT * FROM `#@__ai` WHERE id=".$myModel['aiid']); | $ai = $dsql->GetOne("SELECT * FROM `#@__ai` WHERE id=".$myModel['aiid']); | ||||
include DedeInclude('templets/ai_model_edit.htm'); | include DedeInclude('templets/ai_model_edit.htm'); | ||||
?> | ?> |
@@ -10,7 +10,7 @@ | |||||
*/ | */ | ||||
require_once(dirname(__FILE__).'/config.php'); | require_once(dirname(__FILE__).'/config.php'); | ||||
require_once(DEDEINC.'/datalistcp.class.php'); | require_once(DEDEINC.'/datalistcp.class.php'); | ||||
DedeSetCookie('ENV_GOBACK_URL', $dedeNowurl, time() + 3600, '/'); | |||||
CheckPurview('ai_ModelList'); | |||||
$sql = "SELECT AM.*,A.title as aititle FROM `#@__ai_model` AM LEFT JOIN `#@__ai` A ON A.id = AM.aiid WHERE 1=1 ORDER BY AM.sortrank ASC,AM.id DESC"; | $sql = "SELECT AM.*,A.title as aititle FROM `#@__ai_model` AM LEFT JOIN `#@__ai` A ON A.id = AM.aiid WHERE 1=1 ORDER BY AM.sortrank ASC,AM.id DESC"; | ||||
$dlist = new DataListCP(); | $dlist = new DataListCP(); | ||||
@@ -9,6 +9,7 @@ | |||||
* @link https://www.dedebiz.com | * @link https://www.dedebiz.com | ||||
*/ | */ | ||||
require(dirname(__FILE__)."/config.php"); | require(dirname(__FILE__)."/config.php"); | ||||
CheckPurview('ai_PromptNew'); | |||||
if (empty($dopost)) $dopost = ''; | if (empty($dopost)) $dopost = ''; | ||||
$id = isset($id) ? intval($id) : 0; | $id = isset($id) ? intval($id) : 0; | ||||
if ($dopost == "add") { | if ($dopost == "add") { | ||||
@@ -13,10 +13,12 @@ if (empty($dopost)) $dopost = ''; | |||||
$id = isset($id)? intval($id) : 0; | $id = isset($id)? intval($id) : 0; | ||||
$myPrompt = $dsql->GetOne("SELECT * FROM `#@__ai_prompt` WHERE id=$id"); | $myPrompt = $dsql->GetOne("SELECT * FROM `#@__ai_prompt` WHERE id=$id"); | ||||
if ($dopost == "delete") { | if ($dopost == "delete") { | ||||
CheckPurview('ai_PromptDel'); | |||||
$dsql->ExecuteNoneQuery("DELETE FROM `#@__ai_prompt` WHERE id='$id'"); | $dsql->ExecuteNoneQuery("DELETE FROM `#@__ai_prompt` WHERE id='$id'"); | ||||
ShowMsg("成功删除一个提示词", "ai_prompt_main.php"); | ShowMsg("成功删除一个提示词", "ai_prompt_main.php"); | ||||
exit(); | exit(); | ||||
} else if ($dopost == "saveedit") { | } else if ($dopost == "saveedit") { | ||||
CheckPurview('ai_PromptEdit'); | |||||
$title = isset($title)? HtmlReplace($title, -1) : ''; | $title = isset($title)? HtmlReplace($title, -1) : ''; | ||||
$description = isset($description)? HtmlReplace($description, -1) : ''; | $description = isset($description)? HtmlReplace($description, -1) : ''; | ||||
$prompt = isset($prompt)? $prompt : ''; | $prompt = isset($prompt)? $prompt : ''; | ||||
@@ -26,5 +28,6 @@ if ($dopost == "delete") { | |||||
ShowMsg("成功修改一个提示词", "ai_prompt_edit.php?id={$myPrompt['id']}"); | ShowMsg("成功修改一个提示词", "ai_prompt_edit.php?id={$myPrompt['id']}"); | ||||
exit(); | exit(); | ||||
} | } | ||||
CheckPurview('ai_PromptEdit'); | |||||
include DedeInclude('templets/ai_prompt_edit.htm'); | include DedeInclude('templets/ai_prompt_edit.htm'); | ||||
?> | ?> |
@@ -10,8 +10,7 @@ | |||||
*/ | */ | ||||
require_once(dirname(__FILE__).'/config.php'); | require_once(dirname(__FILE__).'/config.php'); | ||||
require_once(DEDEINC.'/datalistcp.class.php'); | require_once(DEDEINC.'/datalistcp.class.php'); | ||||
DedeSetCookie('ENV_GOBACK_URL', $dedeNowurl, time() + 3600, '/'); | |||||
CheckPurview('ai_PromptList'); | |||||
$sql = "SELECT * FROM `#@__ai_prompt` ORDER BY id DESC"; | $sql = "SELECT * FROM `#@__ai_prompt` ORDER BY id DESC"; | ||||
$dlist = new DataListCP(); | $dlist = new DataListCP(); | ||||
$dlist->SetTemplet(DEDEADMIN.'/templets/ai_prompt_main.htm'); | $dlist->SetTemplet(DEDEADMIN.'/templets/ai_prompt_main.htm'); | ||||
@@ -9,22 +9,9 @@ | |||||
* @link https://www.dedebiz.com | * @link https://www.dedebiz.com | ||||
*/ | */ | ||||
require_once(dirname(__FILE__)."/config.php"); | require_once(dirname(__FILE__)."/config.php"); | ||||
CheckPurview('ai_PromptView'); | |||||
if (empty($dopost)) $dopost = ''; | if (empty($dopost)) $dopost = ''; | ||||
$id = isset($id)? intval($id) : 0; | $id = isset($id)? intval($id) : 0; | ||||
$myPrompt = $dsql->GetOne("SELECT * FROM `#@__ai_prompt` WHERE id=$id"); | $myPrompt = $dsql->GetOne("SELECT * FROM `#@__ai_prompt` WHERE id=$id"); | ||||
if ($dopost == "delete") { | |||||
$dsql->ExecuteNoneQuery("DELETE FROM `#@__ai_prompt` WHERE id='$id'"); | |||||
ShowMsg("成功删除一个提示词", "ai_prompt_main.php"); | |||||
exit(); | |||||
} else if ($dopost == "saveedit") { | |||||
$title = isset($title)? HtmlReplace($title, -1) : ''; | |||||
$description = isset($description)? HtmlReplace($description, -1) : ''; | |||||
$prompt = isset($prompt)? $prompt : ''; | |||||
$dfprompt = isset($dfprompt)? $dfprompt : ''; | |||||
$query = "UPDATE `#@__ai_prompt` SET title='$title',description='$description',prompt='$prompt',dfprompt='$dfprompt' WHERE id='$id' "; | |||||
$dsql->ExecuteNoneQuery($query); | |||||
ShowMsg("成功修改一个提示词", "ai_prompt_edit.php?id={$myPrompt['id']}"); | |||||
exit(); | |||||
} | |||||
include DedeInclude('templets/ai_prompt_view.htm'); | include DedeInclude('templets/ai_prompt_view.htm'); | ||||
?> | ?> |
@@ -85,4 +85,21 @@ | |||||
>member_Type>会员类型管理 | >member_Type>会员类型管理 | ||||
>member_List>列出会员 | >member_List>列出会员 | ||||
>member_Edit>修改会员 | >member_Edit>修改会员 | ||||
>member_Del>删除会员 | |||||
>member_Del>删除会员 | |||||
>>智能管理 | |||||
>ai_List>模型管理 | |||||
>ai_New>新建模型 | |||||
>ai_Edit>修改模型 | |||||
>ai_Del>删除模型 | |||||
>ai_ModelList>模型版本管理 | |||||
>ai_ModelNew>新建模型版本 | |||||
>ai_ModelEdit>修改模型版本 | |||||
>ai_ModelDel>删除模型版本 | |||||
>ai_PromptList>提示词管理 | |||||
>ai_PromptNew>新建提示词 | |||||
>ai_PromptEdit>修改提示词 | |||||
>ai_PromptView>预览提示词 | |||||
>ai_PromptDel>删除提示词 | |||||
>ai_LogList>调用日志管理 |
@@ -159,6 +159,38 @@ exit; | |||||
$hash .= $chars[mt_rand(0, $max)]; | $hash .= $chars[mt_rand(0, $max)]; | ||||
} | } | ||||
echo $hash; | echo $hash; | ||||
exit(); | |||||
} else if($dopost == 'ping_ai_server'){ | |||||
$server = isset($server) ? $server : ''; | |||||
$apikey = isset($apikey) ? $apikey : ''; | |||||
if (empty($server) || empty($apikey)) { | |||||
echo 'error'; | |||||
} else { | |||||
require_once(DEDEINC.'/libraries/dedehttpdown.class.php'); | |||||
$params = $_GET; | |||||
unset($params['dopost']); | |||||
unset($params['apikey']); | |||||
unset($params['server']); | |||||
$params['timestamp'] = time(); // 加入时间戳 | |||||
$cuserLogin = new userLogin(); | |||||
$params['adminid'] = $cuserLogin->getUserID(); // 加入时间戳 | |||||
$params['ip'] = $_SERVER['REMOTE_ADDR'] ?? '127.0.0.1'; // 获取客户端IP | |||||
ksort($params); // 按字典序排序 | |||||
$queryString = http_build_query($params); // 生成查询字符串 | |||||
$params['sign'] = md5($queryString . $apikey); // 计算MD5签名 | |||||
$url = $server . '/api/ping?' . http_build_query($params); | |||||
$dhd = new DedeHttpDown(); | |||||
$dhd->OpenUrl($url); | |||||
$data = $dhd->GetJSON(); | |||||
if (isset($data->code) && $data->code == 0) { | |||||
echo 'ok'; | |||||
} else { | |||||
echo 'error'; | |||||
} | |||||
} | |||||
exit(); | exit(); | ||||
} | } | ||||
include DedeInclude('templets/sys_info.htm'); | include DedeInclude('templets/sys_info.htm'); |
@@ -3,7 +3,7 @@ | |||||
<head> | <head> | ||||
<meta charset="utf-8"> | <meta charset="utf-8"> | ||||
<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"> | <meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"> | ||||
<title>调用日志列表</title> | |||||
<title>调用日志管理</title> | |||||
<link rel="stylesheet" href="/static/web/css/font-awesome.min.css"> | <link rel="stylesheet" href="/static/web/css/font-awesome.min.css"> | ||||
<link rel="stylesheet" href="/static/web/css/bootstrap.min.css"> | <link rel="stylesheet" href="/static/web/css/bootstrap.min.css"> | ||||
<link rel="stylesheet" href="/static/web/css/admin.css"> | <link rel="stylesheet" href="/static/web/css/admin.css"> | ||||
@@ -12,7 +12,7 @@ | |||||
<div class="container-fluid"> | <div class="container-fluid"> | ||||
<ol class="breadcrumb"> | <ol class="breadcrumb"> | ||||
<li class="breadcrumb-item"><a href="index_body.php">后台面板</a></li> | <li class="breadcrumb-item"><a href="index_body.php">后台面板</a></li> | ||||
<li class="breadcrumb-item active">调用日志列表</li> | |||||
<li class="breadcrumb-item active">调用日志管理</li> | |||||
</ol> | </ol> | ||||
<div class="card shadow-sm mb-3"> | <div class="card shadow-sm mb-3"> | ||||
<div class="card-body"> | <div class="card-body"> | ||||
@@ -9,6 +9,7 @@ | |||||
<link rel="stylesheet" href="/static/web/css/admin.css"> | <link rel="stylesheet" href="/static/web/css/admin.css"> | ||||
<script src="/static/web/js/jquery.min.js"></script> | <script src="/static/web/js/jquery.min.js"></script> | ||||
<script src="/static/web/js/webajax.js"></script> | <script src="/static/web/js/webajax.js"></script> | ||||
<script src="/static/web/js/bootstrap.min.js"></script> | |||||
<script src="/static/web/js/admin.main.js"></script> | <script src="/static/web/js/admin.main.js"></script> | ||||
</head> | </head> | ||||
<body> | <body> | ||||
@@ -152,6 +153,12 @@ | |||||
if ($row['varname']=='cfg_cookie_encode') { | if ($row['varname']=='cfg_cookie_encode') { | ||||
$addstr='<a href="javascript:resetCookieEncode();" class="btn btn-success btn-sm">更新</a>'; | $addstr='<a href="javascript:resetCookieEncode();" class="btn btn-success btn-sm">更新</a>'; | ||||
} | } | ||||
if ($row['varname']=='cfg_ai_server') { | |||||
$addstr='<a href="javascript:pingAIServer();" class="btn btn-success btn-sm">检测</a>'; | |||||
} | |||||
if ($row['varname']=='cfg_ai_apikey') { | |||||
$addstr='<a href="javascript:resetAPIKey();" class="btn btn-success btn-sm">更新</a>'; | |||||
} | |||||
echo "<input type='text' name='edit___{$row['varname']}' id='edit___{$row['varname']}' value=\"".dede_htmlspecialchars($row['value'])."\" class='w-65'> {$addstr}"; | echo "<input type='text' name='edit___{$row['varname']}' id='edit___{$row['varname']}' value=\"".dede_htmlspecialchars($row['value'])."\" class='w-65'> {$addstr}"; | ||||
} | } | ||||
?> | ?> | ||||
@@ -221,6 +228,22 @@ | |||||
jQuery("#edit___cfg_cookie_encode").val(data); | jQuery("#edit___cfg_cookie_encode").val(data); | ||||
}); | }); | ||||
} | } | ||||
function resetAPIKey() { | |||||
jQuery.get("sys_info.php?dopost=make_encode", function(data) { | |||||
jQuery("#edit___cfg_ai_apikey").val(data); | |||||
}); | |||||
} | |||||
function pingAIServer() { | |||||
let server = encodeURI(jQuery("#edit___cfg_ai_server").val()); | |||||
let apikey = jQuery("#edit___cfg_ai_apikey").val(); | |||||
jQuery.get("sys_info.php?dopost=ping_ai_server&server="+server+"&apikey="+apikey, function(data) { | |||||
if (data == "ok") { | |||||
ShowMsg("DedeBIZ智能助手服务连接成功") | |||||
} else { | |||||
ShowMsg("DedeBIZ智能助手服务连接失败,请检查配置") | |||||
} | |||||
}); | |||||
} | |||||
$(document).ready(function() { | $(document).ready(function() { | ||||
$("#btnClear").click(() => { | $("#btnClear").click(() => { | ||||
location.reload(); | location.reload(); | ||||