@@ -1,6 +1,6 @@ | |||||
<?php | <?php | ||||
/** | /** | ||||
* 添加大模型 | |||||
* 添加AI模型 | |||||
* | * | ||||
* @version $id:ai_add.php 2025 tianya $ | * @version $id:ai_add.php 2025 tianya $ | ||||
* @package DedeBIZ.Administrator | * @package DedeBIZ.Administrator | ||||
@@ -22,10 +22,10 @@ if ($dopost == "add") { | |||||
$rs = $dsql->ExecuteNoneQuery($query); | $rs = $dsql->ExecuteNoneQuery($query); | ||||
$burl = empty($_COOKIE['ENV_GOBACK_URL']) ? "ai_main.php" : $_COOKIE['ENV_GOBACK_URL']; | $burl = empty($_COOKIE['ENV_GOBACK_URL']) ? "ai_main.php" : $_COOKIE['ENV_GOBACK_URL']; | ||||
if ($rs) { | if ($rs) { | ||||
ShowMsg("成功添加一个大模型", $burl); | |||||
ShowMsg("成功添加一个AI模型", $burl); | |||||
exit(); | exit(); | ||||
} else { | } else { | ||||
ShowMsg("添加大模型时出错,原因:".$dsql->GetError(), "javascript:;"); | |||||
ShowMsg("添加AI模型时出错,原因:".$dsql->GetError(), "javascript:;"); | |||||
exit(); | exit(); | ||||
} | } | ||||
} | } | ||||
@@ -1,6 +1,6 @@ | |||||
<?php | <?php | ||||
/** | /** | ||||
* 修改大模型 | |||||
* 修改AI模型 | |||||
* | * | ||||
* @version $id:ai_edit.php 2025 tianya $ | * @version $id:ai_edit.php 2025 tianya $ | ||||
* @package DedeBIZ.Administrator | * @package DedeBIZ.Administrator | ||||
@@ -14,7 +14,7 @@ $id = isset($id)? intval($id) : 0; | |||||
if ($dopost == "delete") { | if ($dopost == "delete") { | ||||
CheckPurview('ai_Del'); | CheckPurview('ai_Del'); | ||||
$dsql->ExecuteNoneQuery("DELETE FROM `#@__ai` WHERE id='$id'"); | $dsql->ExecuteNoneQuery("DELETE FROM `#@__ai` WHERE id='$id'"); | ||||
ShowMsg("成功删除一个大模型", $ENV_GOBACK_URL); | |||||
ShowMsg("成功删除一个AI模型", $ENV_GOBACK_URL); | |||||
exit(); | exit(); | ||||
} else if ($dopost == "saveedit") { | } else if ($dopost == "saveedit") { | ||||
CheckPurview('ai_Edit'); | CheckPurview('ai_Edit'); | ||||
@@ -26,7 +26,7 @@ if ($dopost == "delete") { | |||||
$baseurl = isset($baseurl)? HtmlReplace($baseurl, -1) : ''; | $baseurl = isset($baseurl)? HtmlReplace($baseurl, -1) : ''; | ||||
$query = "UPDATE `#@__ai` SET title='$title',description='$description',company='$company',website='$website',apikey='$apikey', baseurl='$baseurl' WHERE id='$id' "; | $query = "UPDATE `#@__ai` SET title='$title',description='$description',company='$company',website='$website',apikey='$apikey', baseurl='$baseurl' WHERE id='$id' "; | ||||
$dsql->ExecuteNoneQuery($query); | $dsql->ExecuteNoneQuery($query); | ||||
ShowMsg("成功修改一个大模型", $ENV_GOBACK_URL); | |||||
ShowMsg("成功修改一个AI模型", $ENV_GOBACK_URL); | |||||
exit(); | exit(); | ||||
} | } | ||||
CheckPurview('ai_Edit'); | CheckPurview('ai_Edit'); | ||||
@@ -1,6 +1,6 @@ | |||||
<?php | <?php | ||||
/** | /** | ||||
* 大模型管理 | |||||
* AI模型管理 | |||||
* | * | ||||
* @version $id:ai_main.php 2025 tianya $ | * @version $id:ai_main.php 2025 tianya $ | ||||
* @package DedeBIZ.Administrator | * @package DedeBIZ.Administrator | ||||
@@ -11,7 +11,6 @@ | |||||
require_once(dirname(__FILE__).'/config.php'); | require_once(dirname(__FILE__).'/config.php'); | ||||
require_once(DEDEINC.'/datalistcp.class.php'); | require_once(DEDEINC.'/datalistcp.class.php'); | ||||
CheckPurview('ai_List'); | 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(); | ||||
$dlist->SetTemplet(DEDEADMIN.'/templets/ai_main.htm'); | $dlist->SetTemplet(DEDEADMIN.'/templets/ai_main.htm'); | ||||
@@ -9,7 +9,6 @@ | |||||
* @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"); | ||||
@@ -11,7 +11,6 @@ | |||||
require_once(dirname(__FILE__).'/config.php'); | require_once(dirname(__FILE__).'/config.php'); | ||||
require_once(DEDEINC.'/datalistcp.class.php'); | require_once(DEDEINC.'/datalistcp.class.php'); | ||||
CheckPurview('ai_ModelList'); | 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(); | ||||
$dlist->SetTemplet(DEDEADMIN.'/templets/ai_model_main.htm'); | $dlist->SetTemplet(DEDEADMIN.'/templets/ai_model_main.htm'); | ||||
@@ -1,8 +1,8 @@ | |||||
1,站点设置 | 1,站点设置 | ||||
2,核心设置 | 2,核心设置 | ||||
3,附件设置 | |||||
3,文件设置 | |||||
4,会员设置 | 4,会员设置 | ||||
5,互动设置 | 5,互动设置 | ||||
6,性能选项 | 6,性能选项 | ||||
8,智能设置 | |||||
7,其它选项 | |||||
7,附加选项 | |||||
8,AI设置 |
@@ -87,7 +87,7 @@ | |||||
>member_Edit>修改会员 | >member_Edit>修改会员 | ||||
>member_Del>删除会员 | >member_Del>删除会员 | ||||
>>智能管理 | |||||
>>AI管理 | |||||
>ai_List>模型管理 | >ai_List>模型管理 | ||||
>ai_New>新建模型 | >ai_New>新建模型 | ||||
@@ -54,8 +54,8 @@ if ($cuserLogin->getUserType() >= 10) { | |||||
<m:item name='积分产品分类' link='cards_type.php' rank='sys_Data' target='main' /> | <m:item name='积分产品分类' link='cards_type.php' rank='sys_Data' target='main' /> | ||||
<m:item name='支付接口设置' link='sys_payment.php' .php' rank='sys_Data' target='main' /> | <m:item name='支付接口设置' link='sys_payment.php' .php' rank='sys_Data' target='main' /> | ||||
</m:top> | </m:top> | ||||
<m:top item='10_' name='智能管理' rank='sys_Data' icon='fa fa-gg'> | |||||
<m:item name='大模型管理' link='ai_main.php' rank='sys_Data' target='main' /> | |||||
<m:top item='10_' name='AI管理' rank='sys_Data' icon='fa fa-gg'> | |||||
<m:item name='AI模型管理' link='ai_main.php' rank='sys_Data' target='main' /> | |||||
<m:item name='提示词管理' link='ai_prompt_main.php' rank='sys_Data' target='main' /> | <m:item name='提示词管理' link='ai_prompt_main.php' rank='sys_Data' target='main' /> | ||||
<m:item name='调用日志管理' link='ai_log_main.php' rank='sys_Data' target='main' /> | <m:item name='调用日志管理' link='ai_log_main.php' rank='sys_Data' target='main' /> | ||||
</m:top> | </m:top> | ||||
@@ -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>添加AI模型</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"> | ||||
@@ -15,11 +15,11 @@ | |||||
<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"><a href="ai_main.php">大模型管理</a></li> | |||||
<li class="breadcrumb-item active">添加大模型</li> | |||||
<li class="breadcrumb-item"><a href="ai_main.php">AI模型管理</a></li> | |||||
<li class="breadcrumb-item active">添加AI模型</li> | |||||
</ol> | </ol> | ||||
<div class="card shadow-sm"> | <div class="card shadow-sm"> | ||||
<div class="card-header">添加大模型</div> | |||||
<div class="card-header">添加AI模型</div> | |||||
<div class="card-body"> | <div class="card-body"> | ||||
<form name="form1" action="ai_add.php" method="post" enctype="multipart/form-data"> | <form name="form1" action="ai_add.php" method="post" enctype="multipart/form-data"> | ||||
<input type="hidden" name="dopost" value="add"> | <input type="hidden" name="dopost" value="add"> | ||||
@@ -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>修改AI模型</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,11 +12,11 @@ | |||||
<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"><a href="ai_main.php">大模型管理</a></li> | |||||
<li class="breadcrumb-item active">修改大模型</li> | |||||
<li class="breadcrumb-item"><a href="ai_main.php">AI模型管理</a></li> | |||||
<li class="breadcrumb-item active">修改AI模型</li> | |||||
</ol> | </ol> | ||||
<div class="card shadow-sm"> | <div class="card shadow-sm"> | ||||
<div class="card-header">修改大模型</div> | |||||
<div class="card-header">修改AI模型</div> | |||||
<div class="card-body"> | <div class="card-body"> | ||||
<form action="ai_edit.php" method="post" enctype="multipart/form-data" name="form1"> | <form action="ai_edit.php" method="post" enctype="multipart/form-data" name="form1"> | ||||
<input type="hidden" name="id" value="<?php echo $myAI['id']?>"> | <input type="hidden" name="id" value="<?php echo $myAI['id']?>"> | ||||
@@ -26,7 +26,10 @@ | |||||
<tbody> | <tbody> | ||||
<tr> | <tr> | ||||
<td width="260">名称</td> | <td width="260">名称</td> | ||||
<td><input type="text" name="title" id="title" value="<?php echo $myAI['title']?>" class="admin-input-lg" required></td> | |||||
<td> | |||||
<input type="text" name="title" id="title" value="<?php echo $myAI['title']?>" class="admin-input-lg" required> | |||||
<a href="ai_model_add.php?aiid=<?php echo $myAI['id']?>" class="btn btn-success btn-sm">添加模型版本</a> | |||||
</td> | |||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
<td>描述</td> | <td>描述</td> | ||||
@@ -51,9 +54,6 @@ | |||||
<tr> | <tr> | ||||
<td colspan="2"> | <td colspan="2"> | ||||
<div class="table-responsive"> | <div class="table-responsive"> | ||||
<p> | |||||
模型版本 <a href="ai_model_add.php?aiid=<?php echo $myAI['id']?>" class="btn btn-success btn-sm">添加模型版本</a> | |||||
</p><hr> | |||||
<table class="table table-borderless table-hover"> | <table class="table table-borderless table-hover"> | ||||
<thead> | <thead> | ||||
<tr> | <tr> | ||||
@@ -107,7 +107,7 @@ | |||||
function DelSel() { | function DelSel() { | ||||
var nid = getCheckboxItem(); | var nid = getCheckboxItem(); | ||||
if (nid == "") { | if (nid == "") { | ||||
alert("请选择项目"); | |||||
alert("请选择日志"); | |||||
return; | return; | ||||
} | } | ||||
location.href = "log_edit.php?dopost=del&ids=" + nid; | location.href = "log_edit.php?dopost=del&ids=" + nid; | ||||
@@ -1,73 +1,67 @@ | |||||
{dede:config.pagesize value='15'/} | |||||
{dede:config.pagesize value='30'/} | |||||
<!DOCTYPE html> | <!DOCTYPE html> | ||||
<html> | <html> | ||||
<head> | |||||
<meta charset="utf-8"> | |||||
<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"> | |||||
<title>大模型管理</title> | |||||
<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/admin.css"> | |||||
<script src="/static/web/js/jquery.min.js"></script> | |||||
<script src="/static/web/js/bootstrap.min.js"></script> | |||||
<script src="/static/web/js/admin.main.js"></script> | |||||
</head> | |||||
<body> | |||||
<div class="container-fluid"> | |||||
<ol class="breadcrumb"> | |||||
<li class="breadcrumb-item"><a href="index_body.php">后台面板</a></li> | |||||
<li class="breadcrumb-item active">大模型管理</li> | |||||
</ol> | |||||
<div class="card shadow-sm mb-3"> | |||||
<div class="card-body"> | |||||
<a href="ai_add.php" class="btn btn-success btn-sm">添加大模型</a> | |||||
<a href="ai_model_main.php" class="btn btn-outline-success btn-sm">模型版本</a> | |||||
<a target="_blank" href="https://www.dedebiz.com/ai?from=dedebiz#models" class="btn btn-outline-danger btn-sm">模型优选</a> | |||||
<head> | |||||
<meta charset="utf-8"> | |||||
<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"> | |||||
<title>AI模型管理</title> | |||||
<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/admin.css"> | |||||
<script src="/static/web/js/jquery.min.js"></script> | |||||
<script src="/static/web/js/bootstrap.min.js"></script> | |||||
<script src="/static/web/js/admin.main.js"></script> | |||||
</head> | |||||
<body> | |||||
<div class="container-fluid"> | |||||
<ol class="breadcrumb"> | |||||
<li class="breadcrumb-item"><a href="index_body.php">后台面板</a></li> | |||||
<li class="breadcrumb-item active">AI模型管理</li> | |||||
</ol> | |||||
<div class="card shadow-sm mb-3"> | |||||
<div class="card-body"> | |||||
<a href="ai_add.php" class="btn btn-success btn-sm">添加AI模型</a> | |||||
<a href="ai_model_main.php" class="btn btn-outline-success btn-sm">模型版本</a> | |||||
<a target="_blank" href="https://www.dedebiz.com/ai?from=dedebiz#models" class="btn btn-outline-danger btn-sm">模型优选</a> | |||||
</div> | |||||
</div> | </div> | ||||
</div> | |||||
<div class="card shadow-sm"> | |||||
<div class="card-header">大模型管理</div> | |||||
<div class="card-body"> | |||||
<form name="form1" method="post" action="ai_edit.php"> | |||||
<input type="hidden" name="dopost" value="delall"> | |||||
<input type="hidden" name="allid"> | |||||
<div class="table-responsive"> | |||||
<table class="table table-borderless table-hover"> | |||||
<thead> | |||||
<tr> | |||||
<td scope="col">名称</td> | |||||
<td width="30%">描述</td> | |||||
<td scope="col">隶属公司</td> | |||||
<td scope="col">官网</td> | |||||
<td scope="col">操作</td> | |||||
</tr> | |||||
</thead> | |||||
<tbody> | |||||
{dede:datalist} | |||||
<tr> | |||||
<td>{dede:field.title function='dede_htmlspecialchars(@me)'/}</td> | |||||
<td>{dede:field.description function='dede_htmlspecialchars(@me)'/}</td> | |||||
<td>{dede:field.company/}</td> | |||||
<td>{dede:field.website/}</td> | |||||
<td> | |||||
<a href="ai_edit.php?id={dede:field.id/}&dopost=getedit" | |||||
class="btn btn-light btn-sm"><i class="fa fa-pencil-square" | |||||
title="修改"></i></a> | |||||
<a href="ai_edit.php?id={dede:field.id/}&dopost=delete" | |||||
class="btn btn-danger btn-sm"><i class="fa fa-trash" title="删除"></i></a> | |||||
</td> | |||||
</tr> | |||||
{/dede:datalist} | |||||
</tbody> | |||||
</table> | |||||
</div> | |||||
</form> | |||||
{dede:pagelist listsize='6'/} | |||||
<div class="card shadow-sm"> | |||||
<div class="card-header">AI模型管理</div> | |||||
<div class="card-body"> | |||||
<form name="form1" method="post" action="ai_edit.php"> | |||||
<input type="hidden" name="dopost" value="delall"> | |||||
<input type="hidden" name="allid"> | |||||
<div class="table-responsive"> | |||||
<table class="table table-borderless table-hover"> | |||||
<thead> | |||||
<tr> | |||||
<td scope="col">名称</td> | |||||
<td width="30%">描述</td> | |||||
<td scope="col">隶属公司</td> | |||||
<td scope="col">官网</td> | |||||
<td scope="col">操作</td> | |||||
</tr> | |||||
</thead> | |||||
<tbody> | |||||
{dede:datalist} | |||||
<tr> | |||||
<td>{dede:field.title function='dede_htmlspecialchars(@me)'/}</td> | |||||
<td>{dede:field.description function='dede_htmlspecialchars(@me)'/}</td> | |||||
<td>{dede:field.company/}</td> | |||||
<td>{dede:field.website/}</td> | |||||
<td> | |||||
<a href="ai_edit.php?id={dede:field.id/}&dopost=getedit" class="btn btn-light btn-sm"><i class="fa fa-pencil-square" title="修改"></i></a> | |||||
<a href="ai_edit.php?id={dede:field.id/}&dopost=delete" class="btn btn-danger btn-sm"><i class="fa fa-trash" title="删除"></i></a> | |||||
</td> | |||||
</tr> | |||||
{/dede:datalist} | |||||
</tbody> | |||||
</table> | |||||
</div> | |||||
</form> | |||||
{dede:pagelist listsize='6'/} | |||||
</div> | |||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | |||||
</body> | |||||
</body> | |||||
</html> | </html> |
@@ -15,7 +15,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"><a href="ai_main.php">大模型管理</a></li> | |||||
<li class="breadcrumb-item"><a href="ai_main.php">AI模型管理</a></li> | |||||
<?php if($aiid > 0) { ;?><li class="breadcrumb-item"><a href="ai_edit.php?id=<?php echo $ai['id'];?>"><?php echo $ai['title'];?></a></li><?php }?> | <?php if($aiid > 0) { ;?><li class="breadcrumb-item"><a href="ai_edit.php?id=<?php echo $ai['id'];?>"><?php echo $ai['title'];?></a></li><?php }?> | ||||
<li class="breadcrumb-item active">添加模型版本</li> | <li class="breadcrumb-item active">添加模型版本</li> | ||||
</ol> | </ol> | ||||
@@ -29,11 +29,11 @@ | |||||
<table class="table table-borderless"> | <table class="table table-borderless"> | ||||
<tbody> | <tbody> | ||||
<tr> | <tr> | ||||
<td width="260">隶属模型</td> | |||||
<td width="260">所属模型</td> | |||||
<td> | <td> | ||||
<?php if($aiid > 0) { ;?> | |||||
<?php if($aiid > 0) {;?> | |||||
id:<?php echo $ai['id'];?> <?php echo $ai['title'];?> | id:<?php echo $ai['id'];?> <?php echo $ai['title'];?> | ||||
<?php } else { ?> | |||||
<?php } else {?> | |||||
<select id="modelid" class="admin-input-sm"> | <select id="modelid" class="admin-input-sm"> | ||||
<?php | <?php | ||||
$dsql->SetQuery("SELECT * FROM `#@__ai` ORDER BY id"); | $dsql->SetQuery("SELECT * FROM `#@__ai` ORDER BY id"); | ||||
@@ -41,11 +41,9 @@ | |||||
while ($row = $dsql->GetObject()) { | while ($row = $dsql->GetObject()) { | ||||
?> | ?> | ||||
<option value="<?php echo $row->id;?>"><?php echo $row->title;?></option> | <option value="<?php echo $row->id;?>"><?php echo $row->title;?></option> | ||||
<?php | |||||
} | |||||
?> | |||||
<?php }?> | |||||
</select> | </select> | ||||
<?php } ?> | |||||
<?php }?> | |||||
</td> | </td> | ||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
@@ -15,7 +15,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"><a href="ai_main.php">大模型管理</a></li> | |||||
<li class="breadcrumb-item"><a href="ai_main.php">AI模型管理</a></li> | |||||
<li class="breadcrumb-item"><a href="ai_edit.php?id=<?php echo $ai['id'];?>"><?php echo $ai['title'];?></a></li> | <li class="breadcrumb-item"><a href="ai_edit.php?id=<?php echo $ai['id'];?>"><?php echo $ai['title'];?></a></li> | ||||
<li class="breadcrumb-item active">修改模型版本</li> | <li class="breadcrumb-item active">修改模型版本</li> | ||||
</ol> | </ol> | ||||
@@ -30,7 +30,7 @@ | |||||
<table class="table table-borderless"> | <table class="table table-borderless"> | ||||
<tbody> | <tbody> | ||||
<tr> | <tr> | ||||
<td width="260">隶属模型</td> | |||||
<td width="260">所属模型</td> | |||||
<td>id:<?php echo $ai['id'];?> <?php echo $ai['title'];?></td> | <td>id:<?php echo $ai['id'];?> <?php echo $ai['title'];?></td> | ||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
@@ -1,68 +1,65 @@ | |||||
{dede:config.pagesize value='30'/} | {dede:config.pagesize value='30'/} | ||||
<!DOCTYPE html> | <!DOCTYPE html> | ||||
<html> | <html> | ||||
<head> | |||||
<meta charset="utf-8"> | |||||
<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"> | |||||
<title>模型版本管理</title> | |||||
<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/admin.css"> | |||||
<script src="/static/web/js/jquery.min.js"></script> | |||||
<script src="/static/web/js/bootstrap.min.js"></script> | |||||
<script src="/static/web/js/admin.main.js"></script> | |||||
</head> | |||||
<body> | |||||
<div class="container-fluid"> | |||||
<ol class="breadcrumb"> | |||||
<li class="breadcrumb-item"><a href="index_body.php">后台面板</a></li> | |||||
<li class="breadcrumb-item"><a href="ai_main.php">大模型管理</a></li> | |||||
<li class="breadcrumb-item active">模型版本管理</li> | |||||
</ol> | |||||
<div class="card shadow-sm"> | |||||
<div class="card-header d-flex justify-content-between align-items-center">模型版本管理 <a href="ai_model_add.php" class="btn btn-success btn-sm">添加模型版本</a></div> | |||||
<div class="card-body"> | |||||
<form name="form1" method="post" action="ai_model_edit.php"> | |||||
<input type="hidden" name="dopost" value="delall"> | |||||
<input type="hidden" name="allid"> | |||||
<div class="table-responsive"> | |||||
<table class="table table-borderless table-hover"> | |||||
<thead> | |||||
<tr> | |||||
<td scope="col">ID</td> | |||||
<td scope="col">Model</td> | |||||
<td scope="col">名称</td> | |||||
<td scope="col">大模型</td> | |||||
<td scope="col" width="30%">描述</td> | |||||
<td scope="col">排序</td> | |||||
<td scope="col">操作</td> | |||||
</tr> | |||||
</thead> | |||||
<tbody> | |||||
{dede:datalist} | |||||
<tr> | |||||
<td>{dede:field.id/}</td> | |||||
<td>{dede:field.model function='dede_htmlspecialchars(@me)'/}</td> | |||||
<td>{dede:field.title function='dede_htmlspecialchars(@me)'/}</td> | |||||
<td>{dede:field.aititle/}</td> | |||||
<td>{dede:field.description/}</td> | |||||
<td>{dede:field.sortrank/}</td> | |||||
<td> | |||||
<a href="ai_model_edit.php?id={dede:field.id/}" class="btn btn-light btn-sm"><i class="fa fa-pencil-square" title="修改"></i></a> | |||||
<a href="ai_model_edit.php?id={dede:field.id/}&dopost=delete" class="btn btn-danger btn-sm"><i class="fa fa-trash" title="删除"></i></a> | |||||
</td> | |||||
</tr> | |||||
{/dede:datalist} | |||||
</tbody> | |||||
</table> | |||||
</div> | |||||
</form> | |||||
{dede:pagelist listsize='6'/} | |||||
<head> | |||||
<meta charset="utf-8"> | |||||
<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"> | |||||
<title>模型版本管理</title> | |||||
<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/admin.css"> | |||||
<script src="/static/web/js/jquery.min.js"></script> | |||||
<script src="/static/web/js/bootstrap.min.js"></script> | |||||
<script src="/static/web/js/admin.main.js"></script> | |||||
</head> | |||||
<body> | |||||
<div class="container-fluid"> | |||||
<ol class="breadcrumb"> | |||||
<li class="breadcrumb-item"><a href="index_body.php">后台面板</a></li> | |||||
<li class="breadcrumb-item"><a href="ai_main.php">AI模型管理</a></li> | |||||
<li class="breadcrumb-item active">模型版本管理</li> | |||||
</ol> | |||||
<div class="card shadow-sm"> | |||||
<div class="card-header d-flex justify-content-between align-items-center">模型版本管理 <a href="ai_model_add.php" class="btn btn-success btn-sm">添加模型版本</a></div> | |||||
<div class="card-body"> | |||||
<form name="form1" method="post" action="ai_model_edit.php"> | |||||
<input type="hidden" name="dopost" value="delall"> | |||||
<input type="hidden" name="allid"> | |||||
<div class="table-responsive"> | |||||
<table class="table table-borderless table-hover"> | |||||
<thead> | |||||
<tr> | |||||
<td scope="col">ID</td> | |||||
<td scope="col">Model</td> | |||||
<td scope="col">名称</td> | |||||
<td scope="col">AI模型</td> | |||||
<td scope="col" width="30%">描述</td> | |||||
<td scope="col">排序</td> | |||||
<td scope="col">操作</td> | |||||
</tr> | |||||
</thead> | |||||
<tbody> | |||||
{dede:datalist} | |||||
<tr> | |||||
<td>{dede:field.id/}</td> | |||||
<td>{dede:field.model function='dede_htmlspecialchars(@me)'/}</td> | |||||
<td>{dede:field.title function='dede_htmlspecialchars(@me)'/}</td> | |||||
<td>{dede:field.aititle/}</td> | |||||
<td>{dede:field.description/}</td> | |||||
<td>{dede:field.sortrank/}</td> | |||||
<td> | |||||
<a href="ai_model_edit.php?id={dede:field.id/}" class="btn btn-light btn-sm"><i class="fa fa-pencil-square" title="修改"></i></a> | |||||
<a href="ai_model_edit.php?id={dede:field.id/}&dopost=delete" class="btn btn-danger btn-sm"><i class="fa fa-trash" title="删除"></i></a> | |||||
</td> | |||||
</tr> | |||||
{/dede:datalist} | |||||
</tbody> | |||||
</table> | |||||
</div> | |||||
</form> | |||||
{dede:pagelist listsize='6'/} | |||||
</div> | |||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | |||||
</body> | |||||
</body> | |||||
</html> | </html> |
@@ -1,75 +1,70 @@ | |||||
<!DOCTYPE html> | <!DOCTYPE html> | ||||
<html> | <html> | ||||
<head> | |||||
<meta charset="utf-8"> | |||||
<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"> | |||||
<title>添加提示词</title> | |||||
<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/admin.css"> | |||||
<script src="/static/web/js/jquery.min.js"></script> | |||||
<script src="/static/web/js/bootstrap.min.js"></script> | |||||
<script src="/static/web/js/admin.main.js"></script> | |||||
</head> | |||||
<body> | |||||
<div class="container-fluid"> | |||||
<ol class="breadcrumb"> | |||||
<li class="breadcrumb-item"><a href="index_body.php">后台面板</a></li> | |||||
<li class="breadcrumb-item"><a href="ai_prompt_main.php">提示词管理</a></li> | |||||
<li class="breadcrumb-item active">添加提示词</li> | |||||
</ol> | |||||
<div class="card shadow-sm"> | |||||
<div class="card-header">添加提示词</div> | |||||
<div class="card-body"> | |||||
<form name="form1" action="ai_prompt_add.php" method="post" enctype="multipart/form-data"> | |||||
<input type="hidden" name="dopost" value="add"> | |||||
<div class="table-responsive"> | |||||
<table class="table table-borderless"> | |||||
<tbody> | |||||
<tr> | |||||
<td width="260">标识</td> | |||||
<td> | |||||
<input name="pname" id="pname" class="admin-input-lg" | |||||
required>(英文数字组成) | |||||
</td> | |||||
</tr> | |||||
<tr> | |||||
<td width="260">名称</td> | |||||
<td> | |||||
<input name="title" id="title" class="admin-input-lg" | |||||
required> | |||||
</td> | |||||
</tr> | |||||
<tr> | |||||
<td>描述</td> | |||||
<td><textarea name="description" id="description" | |||||
class="admin-textarea-sm"></textarea></td> | |||||
</tr> | |||||
<tr> | |||||
<td>系统提示词</td> | |||||
<td> | |||||
<textarea name="prompt" id="prompt" class="admin-textarea-sm" style="height: 200px;"></textarea>(AI系统提示词) | |||||
</td> | |||||
</tr> | |||||
<tr> | |||||
<td>默认提示词</td> | |||||
<td><textarea name="dfprompt" id="dfprompt" class="admin-textarea-sm"></textarea>(用户不提交内容,默认采用的提示词)</td> | |||||
</tr> | |||||
<tr> | |||||
<td colspan="2" align="center"> | |||||
<button type="submit" class="btn btn-success btn-sm">保存</button> | |||||
<button type="reset" class="btn btn-outline-success btn-sm">重置</button> | |||||
<a href="ai_prompt_main.php" class="btn btn-outline-success btn-sm">返回</a> | |||||
</td> | |||||
</tr> | |||||
</tbody> | |||||
</table> | |||||
</div> | |||||
</form> | |||||
<head> | |||||
<meta charset="utf-8"> | |||||
<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"> | |||||
<title>添加提示词</title> | |||||
<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/admin.css"> | |||||
<script src="/static/web/js/jquery.min.js"></script> | |||||
<script src="/static/web/js/bootstrap.min.js"></script> | |||||
<script src="/static/web/js/admin.main.js"></script> | |||||
</head> | |||||
<body> | |||||
<div class="container-fluid"> | |||||
<ol class="breadcrumb"> | |||||
<li class="breadcrumb-item"><a href="index_body.php">后台面板</a></li> | |||||
<li class="breadcrumb-item"><a href="ai_prompt_main.php">提示词管理</a></li> | |||||
<li class="breadcrumb-item active">添加提示词</li> | |||||
</ol> | |||||
<div class="card shadow-sm"> | |||||
<div class="card-header">添加提示词</div> | |||||
<div class="card-body"> | |||||
<form name="form1" action="ai_prompt_add.php" method="post" enctype="multipart/form-data"> | |||||
<input type="hidden" name="dopost" value="add"> | |||||
<div class="table-responsive"> | |||||
<table class="table table-borderless"> | |||||
<tbody> | |||||
<tr> | |||||
<td width="260">标识</td> | |||||
<td><input name="pname" id="pname" class="admin-input-lg" required>(英文数字组成)</td> | |||||
</tr> | |||||
<tr> | |||||
<td>名称</td> | |||||
<td><input name="title" id="title" class="admin-input-lg" required></td> | |||||
</tr> | |||||
<tr> | |||||
<td>描述</td> | |||||
<td><textarea name="description" id="description" class="admin-textarea-sm"></textarea></td> | |||||
</tr> | |||||
<tr> | |||||
<td>系统提示词</td> | |||||
<td> | |||||
<textarea name="prompt" id="prompt" class="admin-textarea-sm" style="height:160px"></textarea> | |||||
<span>(AI系统提示词)</span> | |||||
</td> | |||||
</tr> | |||||
<tr> | |||||
<td>默认提示词</td> | |||||
<td> | |||||
<textarea name="dfprompt" id="dfprompt" class="admin-textarea-sm"></textarea> | |||||
<span>(用户不提交内容,默认采用的提示词)</span> | |||||
</td> | |||||
</tr> | |||||
<tr> | |||||
<td colspan="2" align="center"> | |||||
<button type="submit" class="btn btn-success btn-sm">保存</button> | |||||
<button type="reset" class="btn btn-outline-success btn-sm">重置</button> | |||||
<a href="ai_prompt_main.php" class="btn btn-outline-success btn-sm">返回</a> | |||||
</td> | |||||
</tr> | |||||
</tbody> | |||||
</table> | |||||
</div> | |||||
</form> | |||||
</div> | |||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | |||||
</body> | |||||
</body> | |||||
</html> | </html> |
@@ -25,40 +25,28 @@ | |||||
<input type="hidden" name="dopost" value="saveedit"> | <input type="hidden" name="dopost" value="saveedit"> | ||||
<input type="hidden" name="id" value="<?php echo $myPrompt['id']?>"> | <input type="hidden" name="id" value="<?php echo $myPrompt['id']?>"> | ||||
<div class="table-responsive"> | <div class="table-responsive"> | ||||
<?php | |||||
if(!empty($myPrompt['info'])){ | |||||
?> | |||||
<?php if (!empty($myPrompt['info'])){?> | |||||
<div class="alert alert-warning"> | <div class="alert alert-warning"> | ||||
<?php echo $myPrompt['info']?> | <?php echo $myPrompt['info']?> | ||||
</div> | </div> | ||||
<?php | |||||
} | |||||
?> | |||||
<?php }?> | |||||
<table class="table table-borderless"> | <table class="table table-borderless"> | ||||
<tbody> | <tbody> | ||||
<tr> | <tr> | ||||
<td width="260">标识</td> | <td width="260">标识</td> | ||||
<td> | |||||
<?php echo $myPrompt['pname']?> | |||||
</td> | |||||
<td><?php echo $myPrompt['pname']?></td> | |||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
<td width="260">名称</td> | |||||
<td> | |||||
<input name="title" id="title" value="<?php echo $myPrompt['title']?>" class="admin-input-lg" | |||||
required> | |||||
</td> | |||||
<td>名称</td> | |||||
<td><input name="title" id="title" value="<?php echo $myPrompt['title']?>" class="admin-input-lg" required></td> | |||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
<td>描述</td> | <td>描述</td> | ||||
<td><textarea name="description" id="description" | |||||
class="admin-textarea-sm"><?php echo $myPrompt['description']?></textarea></td> | |||||
<td><textarea name="description" id="description" class="admin-textarea-sm"><?php echo $myPrompt['description']?></textarea></td> | |||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
<td>系统提示词</td> | <td>系统提示词</td> | ||||
<td> | |||||
<textarea name="prompt" id="prompt" class="admin-textarea-sm" style="height: 200px;"><?php echo $myPrompt['prompt']?></textarea> | |||||
</td> | |||||
<td><textarea name="prompt" id="prompt" class="admin-textarea-sm" style="height:160px"><?php echo $myPrompt['prompt']?></textarea></td> | |||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
<td>默认提示词</td> | <td>默认提示词</td> | ||||
@@ -1,77 +1,70 @@ | |||||
{dede:config.pagesize value='30'/} | {dede:config.pagesize value='30'/} | ||||
<!DOCTYPE html> | <!DOCTYPE html> | ||||
<html> | <html> | ||||
<head> | |||||
<meta charset="utf-8"> | |||||
<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"> | |||||
<title>提示词管理</title> | |||||
<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/admin.css"> | |||||
<script src="/static/web/js/jquery.min.js"></script> | |||||
<script src="/static/web/js/bootstrap.min.js"></script> | |||||
<script src="/static/web/js/admin.main.js"></script> | |||||
</head> | |||||
<body> | |||||
<div class="container-fluid"> | |||||
<ol class="breadcrumb"> | |||||
<li class="breadcrumb-item"><a href="index_body.php">后台面板</a></li> | |||||
<li class="breadcrumb-item active">提示词管理</li> | |||||
</ol> | |||||
<div class="card shadow-sm mb-3"> | |||||
<div class="card-body"> | |||||
<a href="ai_prompt_add.php" class="btn btn-success btn-sm">添加提示词</a> | |||||
<head> | |||||
<meta charset="utf-8"> | |||||
<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"> | |||||
<title>提示词管理</title> | |||||
<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/admin.css"> | |||||
<script src="/static/web/js/jquery.min.js"></script> | |||||
<script src="/static/web/js/bootstrap.min.js"></script> | |||||
<script src="/static/web/js/admin.main.js"></script> | |||||
</head> | |||||
<body> | |||||
<div class="container-fluid"> | |||||
<ol class="breadcrumb"> | |||||
<li class="breadcrumb-item"><a href="index_body.php">后台面板</a></li> | |||||
<li class="breadcrumb-item active">提示词管理</li> | |||||
</ol> | |||||
<div class="card shadow-sm mb-3"> | |||||
<div class="card-body"> | |||||
<a href="ai_prompt_add.php" class="btn btn-success btn-sm">添加提示词</a> | |||||
</div> | |||||
</div> | </div> | ||||
</div> | |||||
<div class="card shadow-sm"> | |||||
<div class="card-header">提示词管理</div> | |||||
<div class="card-body"> | |||||
<form name="form1" method="post" action="ai_edit.php"> | |||||
<input type="hidden" name="dopost" value="delall"> | |||||
<input type="hidden" name="allid"> | |||||
<div class="table-responsive"> | |||||
<table class="table table-borderless table-hover"> | |||||
<thead> | |||||
<tr> | |||||
<td scope="col">ID</td> | |||||
<td scope="col">标识</td> | |||||
<td scope="col">名称</td> | |||||
<td scope="col">系统</td> | |||||
<td scope="col">描述</td> | |||||
<td scope="col">操作</td> | |||||
</tr> | |||||
</thead> | |||||
<tbody> | |||||
{dede:datalist} | |||||
<tr> | |||||
<td>{dede:field.id/}</td> | |||||
<td>{dede:field.pname/}</td> | |||||
<td>{dede:field.title function='dede_htmlspecialchars(@me)'/}</td> | |||||
<td><?php echo $fields['issystem']==0?'否' : '是';?></td> | |||||
<td>{dede:field.description function='dede_htmlspecialchars(@me)'/}</td> | |||||
<td> | |||||
<a href="ai_prompt_edit.php?id={dede:field.id/}&dopost=getedit" | |||||
class="btn btn-light btn-sm"><i class="fa fa-pencil-square" | |||||
title="修改"></i></a> | |||||
<?php if($fields['issystem']==0) {?> | |||||
<a href="ai_prompt_view.php?id={dede:field.id/}" | |||||
class="btn btn-success btn-sm"><i class="fa fa-eye" title="预览"></i></a> | |||||
<a href="ai_prompt_edit.php?id={dede:field.id/}&dopost=delete" | |||||
class="btn btn-danger btn-sm"><i class="fa fa-trash" title="删除"></i></a> | |||||
<?php }?> | |||||
</td> | |||||
</tr> | |||||
{/dede:datalist} | |||||
</tbody> | |||||
</table> | |||||
</div> | |||||
</form> | |||||
{dede:pagelist listsize='6'/} | |||||
<div class="card shadow-sm"> | |||||
<div class="card-header">提示词管理</div> | |||||
<div class="card-body"> | |||||
<form name="form1" method="post" action="ai_edit.php"> | |||||
<input type="hidden" name="dopost" value="delall"> | |||||
<input type="hidden" name="allid"> | |||||
<div class="table-responsive"> | |||||
<table class="table table-borderless table-hover"> | |||||
<thead> | |||||
<tr> | |||||
<td scope="col">ID</td> | |||||
<td scope="col">标识</td> | |||||
<td scope="col">名称</td> | |||||
<td scope="col">系统</td> | |||||
<td scope="col">描述</td> | |||||
<td scope="col">操作</td> | |||||
</tr> | |||||
</thead> | |||||
<tbody> | |||||
{dede:datalist} | |||||
<tr> | |||||
<td>{dede:field.id/}</td> | |||||
<td>{dede:field.pname/}</td> | |||||
<td>{dede:field.title function='dede_htmlspecialchars(@me)'/}</td> | |||||
<td><?php echo $fields['issystem']==0?'否' : '是';?></td> | |||||
<td>{dede:field.description function='dede_htmlspecialchars(@me)'/}</td> | |||||
<td> | |||||
<a href="ai_prompt_edit.php?id={dede:field.id/}&dopost=getedit" class="btn btn-light btn-sm"><i class="fa fa-pencil-square" title="修改"></i></a> | |||||
<?php if($fields['issystem']==0) {?> | |||||
<a href="ai_prompt_view.php?id={dede:field.id/}" class="btn btn-success btn-sm"><i class="fa fa-eye" title="预览"></i></a> | |||||
<a href="ai_prompt_edit.php?id={dede:field.id/}&dopost=delete" class="btn btn-danger btn-sm"><i class="fa fa-trash" title="删除"></i></a> | |||||
<?php }?> | |||||
</td> | |||||
</tr> | |||||
{/dede:datalist} | |||||
</tbody> | |||||
</table> | |||||
</div> | |||||
</form> | |||||
{dede:pagelist listsize='6'/} | |||||
</div> | |||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | |||||
</body> | |||||
</body> | |||||
</html> | </html> |
@@ -21,65 +21,52 @@ | |||||
<div class="card shadow-sm"> | <div class="card shadow-sm"> | ||||
<div class="card-header">预览提示词</div> | <div class="card-header">预览提示词</div> | ||||
<div class="card-body"> | <div class="card-body"> | ||||
<div class="table-responsive"> | |||||
<?php | |||||
if(!empty($myPrompt['info'])){ | |||||
?> | |||||
<div class="alert alert-warning"> | |||||
<?php echo $myPrompt['info']?> | |||||
</div> | |||||
<?php | |||||
} | |||||
?> | |||||
<table class="table table-borderless"> | |||||
<tbody> | |||||
<tr> | |||||
<td width="260">名称</td> | |||||
<td> | |||||
[<?php echo $myPrompt['pname']?>]<?php echo $myPrompt['title']?> | |||||
</td> | |||||
</tr> | |||||
<tr> | |||||
<td>提示词</td> | |||||
<td> | |||||
<textarea name="prompt" id="prompt" class="admin-textarea-sm" style="height: 100px;" placeholder="填写您的要求,默认:<?php echo $myPrompt['dfprompt']?>"></textarea> | |||||
</td> | |||||
</tr> | |||||
<tr> | |||||
<td>选择模型</td> | |||||
<td> | |||||
<select id="modelid" class="admin-input-sm"> | |||||
<?php | |||||
$dsql->SetQuery("SELECT AM.*,A.title as aititle FROM `#@__ai_model` AM LEFT JOIN `#@__ai` A ON A.id = AM.aiid ORDER BY id"); | |||||
$dsql->Execute(); | |||||
while ($row = $dsql->GetObject()) { | |||||
?> | |||||
<option value="<?php echo $row->id;?>"<?php echo $row->isdefault==1?' selected' : '';?>><?php echo $row->model;?>(<?php echo $row->aititle;?>)</option> | |||||
<?php | |||||
} | |||||
?> | |||||
</select> | |||||
</td> | |||||
</tr> | |||||
<tr> | |||||
<td></td> | |||||
<td> | |||||
<button type="button" id="btnAIAction" class="btn btn-success btn-sm">AI生成</button> | |||||
<a href="ai_prompt_main.php" class="btn btn-outline-success btn-sm">返回</a> | |||||
</td> | |||||
</tr> | |||||
<tr> | |||||
<td>结果</td> | |||||
<td><textarea name="result" id="result" class="admin-textarea-sm" style="height: 200px;"></textarea></td> | |||||
</tr> | |||||
</tbody> | |||||
</table> | |||||
<div class="table-responsive"> | |||||
<?php if(!empty($myPrompt['info'])){?> | |||||
<div class="alert alert-warning"> | |||||
<?php echo $myPrompt['info']?> | |||||
</div> | </div> | ||||
<?php }?> | |||||
<table class="table table-borderless"> | |||||
<tbody> | |||||
<tr> | |||||
<td width="260">名称</td> | |||||
<td><?php echo $myPrompt['pname']?><?php echo $myPrompt['title']?></td> | |||||
</tr> | |||||
<tr> | |||||
<td>提示词</td> | |||||
<td><textarea name="prompt" id="prompt" class="admin-textarea-sm" style="height:160px" placeholder="填写您的要求,默认:<?php echo $myPrompt['dfprompt']?>"></textarea></td> | |||||
</tr> | |||||
<tr> | |||||
<td>选择模型</td> | |||||
<td> | |||||
<select id="modelid" class="admin-input-sm"> | |||||
<?php | |||||
$dsql->SetQuery("SELECT AM.*,A.title as aititle FROM `#@__ai_model` AM LEFT JOIN `#@__ai` A ON A.id = AM.aiid ORDER BY id"); | |||||
$dsql->Execute(); | |||||
while ($row = $dsql->GetObject()) { | |||||
?> | |||||
<option value="<?php echo $row->id;?>"<?php echo $row->isdefault==1?' selected' : '';?>><?php echo $row->model;?>(<?php echo $row->aititle;?>)</option> | |||||
<?php }?> | |||||
</select> | |||||
<button type="button" id="btnAIAction" class="btn btn-success btn-sm">AI生成</button> | |||||
</td> | |||||
</tr> | |||||
<tr> | |||||
<td>结果</td> | |||||
<td><textarea name="result" id="result" class="admin-textarea-sm" style="height:160px"></textarea></td> | |||||
</tr> | |||||
<tr> | |||||
<td colspan="2" align="center"><a href="ai_prompt_main.php" class="btn btn-outline-success btn-sm">返回</a></td> | |||||
</tr> | |||||
</tbody> | |||||
</table> | |||||
</div> | |||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<script> | <script> | ||||
let eventSource; // 保存 EventSource 实例 | |||||
let eventSource; //保存EventSource实例 | |||||
let modelid = 0; | let modelid = 0; | ||||
$("#btnAIAction").click(async function() { | $("#btnAIAction").click(async function() { | ||||
let prompt = document.getElementById("prompt").value; | let prompt = document.getElementById("prompt").value; | ||||
@@ -91,12 +78,10 @@ | |||||
return | return | ||||
} | } | ||||
let eventSource = new EventSource(resp.data); | let eventSource = new EventSource(resp.data); | ||||
// 新增状态跟踪变量 | |||||
//新增状态跟踪变量 | |||||
let currentKey = null; | let currentKey = null; | ||||
let tagBuffer = ""; | let tagBuffer = ""; | ||||
let isClosingTag = false; | let isClosingTag = false; | ||||
$("#btnAI").attr("disabled", "disabled"); | $("#btnAI").attr("disabled", "disabled"); | ||||
prompt = ""; | prompt = ""; | ||||
let lastChar = ""; | let lastChar = ""; | ||||
@@ -107,23 +92,21 @@ | |||||
const msg = event.data; | const msg = event.data; | ||||
input.value += msg; | input.value += msg; | ||||
}; | }; | ||||
eventSource.onerror = (error) => { | eventSource.onerror = (error) => { | ||||
if (error.target.readyState === EventSource.CONNECTING) { | if (error.target.readyState === EventSource.CONNECTING) { | ||||
ShowMsg("连接失败,请确保您已开启并正确配置了DedeBIZ智能助手服务器。 <a class='text-success' href='https://www.dedebiz.com/ai?from=dedebiz' target='_blank'>如何配置?</a>"); | |||||
ShowMsg("连接失败,请确保您已开启并正确配置了DedeBIZ小德AI助手。 <a class='text-success' href='https://www.dedebiz.com/ai?from=dedebiz' target='_blank'>如何配置?</a>"); | |||||
} else if (typeof error.data!=="undefined" && error.data !== "" && error.target.readyState !== EventSource.CLOSED) { | } else if (typeof error.data!=="undefined" && error.data !== "" && error.target.readyState !== EventSource.CLOSED) { | ||||
ShowMsg(error.data); | ShowMsg(error.data); | ||||
} | } | ||||
$("#btnAI").prop("disabled", false); | $("#btnAI").prop("disabled", false); | ||||
eventSource.close(); | eventSource.close(); | ||||
}; | }; | ||||
// 监听特定事件 "close" | |||||
//监听特定事件"close" | |||||
eventSource.addEventListener('close', (event) => { | eventSource.addEventListener('close', (event) => { | ||||
console.log('SSE connection closed:', event.data); | console.log('SSE connection closed:', event.data); | ||||
$("#btnAI").prop("disabled", false); | $("#btnAI").prop("disabled", false); | ||||
$(input).prop("disabled", false); | $(input).prop("disabled", false); | ||||
eventSource.close(); // 关闭连接 | |||||
eventSource.close(); //关闭连接 | |||||
}); | }); | ||||
}); | }); | ||||
</script> | </script> | ||||
@@ -26,7 +26,7 @@ | |||||
<li class="breadcrumb-item active">发布文档</li> | <li class="breadcrumb-item active">发布文档</li> | ||||
</ol> | </ol> | ||||
<div class="card shadow-sm"> | <div class="card shadow-sm"> | ||||
<div class="card-header d-flex justify-content-between align-items-center">发布文档 <?php if($cfg_ai_enabled == 'Y'){ ;?><button type="button" id="btnAI" onclick="showAI();" class="btn btn-success btn-sm">智能助手</button><?php } ;?></div> | |||||
<div class="card-header d-flex justify-content-between align-items-center">发布文档<?php if($cfg_ai_enabled == 'Y'){;?><button type="button" id="btnAI" onclick="showAI();" class="btn btn-success btn-sm">小德AI助手</button><?php };?></div> | |||||
<div class="card-body"> | <div class="card-body"> | ||||
<form name="form1" action="article_add.php" method="post" enctype="multipart/form-data"> | <form name="form1" action="article_add.php" method="post" enctype="multipart/form-data"> | ||||
<input type="hidden" name="channelid" value="<?php echo $channelid?>"> | <input type="hidden" name="channelid" value="<?php echo $channelid?>"> | ||||
@@ -227,37 +227,39 @@ | |||||
<div class="modal-dialog modal-xl"> | <div class="modal-dialog modal-xl"> | ||||
<div class="modal-content"> | <div class="modal-content"> | ||||
<div class="modal-header"> | <div class="modal-header"> | ||||
<h5 class="modal-title">智能助手-发布文档</h5> | |||||
<h5 class="modal-title">小德AI助手:发布文档</h5> | |||||
<button type="button" class="update-close" data-dismiss="modal" aria-label="Close"><i class="fa fa-times"></i></button> | <button type="button" class="update-close" data-dismiss="modal" aria-label="Close"><i class="fa fa-times"></i></button> | ||||
</div> | </div> | ||||
<div class="modal-body"> | <div class="modal-body"> | ||||
<form> | <form> | ||||
<div class="form-group"> | <div class="form-group"> | ||||
<textarea class="admin-input-sm" style="width: 100%;height: 100px;" id="prompt" placeholder="我需要写一篇介绍穆云智能科技公司的文章"></textarea><br/> | |||||
选择模型:<select id="modelid" class="admin-input-sm" style="width: 100%;"> | |||||
<textarea id="prompt" class="form-control" style="height:160px" placeholder="请输入生成文档要求,例如:我需要写一篇介绍穆云智能科技公司的文章"></textarea> | |||||
</div> | |||||
<div class="form-group"> | |||||
<label for="modelid" class="form-label">选择模型</label> | |||||
<select id="modelid" class="form-control"> | |||||
<?php | <?php | ||||
$dsql->SetQuery("SELECT AM.*,A.title as aititle FROM `#@__ai_model` AM LEFT JOIN `#@__ai` A ON A.id = AM.aiid ORDER BY AM.sortrank ASC,AM.id DESC"); | $dsql->SetQuery("SELECT AM.*,A.title as aititle FROM `#@__ai_model` AM LEFT JOIN `#@__ai` A ON A.id = AM.aiid ORDER BY AM.sortrank ASC,AM.id DESC"); | ||||
$dsql->Execute(); | $dsql->Execute(); | ||||
while ($row = $dsql->GetObject()) { | while ($row = $dsql->GetObject()) { | ||||
?> | ?> | ||||
<option value="<?php echo $row->id;?>"<?php echo $row->isdefault==1?' selected' : '';?>><?php echo $row->model;?>(<?php echo $row->aititle;?>)</option> | |||||
<option value="<?php echo $row->id;?>"<?php echo $row->isdefault==1?' selected' : '';?>><?php echo $row->model;?><?php echo $row->aititle;?></option> | |||||
<?php | <?php | ||||
} | } | ||||
?> | ?> | ||||
</select><br/> | |||||
</select> | |||||
</div> | </div> | ||||
</form> | </form> | ||||
</div> | </div> | ||||
<div class="modal-footer"> | <div class="modal-footer"> | ||||
<button id="btnAIAction" class="btn btn-success">AI生成</button> | |||||
<button id="btnAIAction" class="btn btn-success btn-sm">确定</button> | |||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<script>InitPage();</script> | <script>InitPage();</script> | ||||
<script> | <script> | ||||
let eventSource; // 保存 EventSource 实例 | |||||
let eventSource; //保存EventSource实例 | |||||
let modelid = 0; | let modelid = 0; | ||||
function showAI() { | function showAI() { | ||||
$("#mdlAI").modal('show'); | $("#mdlAI").modal('show'); | ||||
@@ -272,12 +274,10 @@ | |||||
return | return | ||||
} | } | ||||
let eventSource = new EventSource(resp.data); | let eventSource = new EventSource(resp.data); | ||||
// 新增状态跟踪变量 | |||||
//新增状态跟踪变量 | |||||
let currentKey = null; | let currentKey = null; | ||||
let tagBuffer = ""; | let tagBuffer = ""; | ||||
let isClosingTag = false; | let isClosingTag = false; | ||||
$("#mdlAI").modal('hide'); | $("#mdlAI").modal('hide'); | ||||
$("#btnAI").attr("disabled", "disabled"); | $("#btnAI").attr("disabled", "disabled"); | ||||
prompt = ""; | prompt = ""; | ||||
@@ -285,17 +285,16 @@ | |||||
let bodyHtml = ""; | let bodyHtml = ""; | ||||
let typeid = ""; | let typeid = ""; | ||||
eventSource.onmessage = (event) => { | eventSource.onmessage = (event) => { | ||||
const chars = event.data.split(''); | const chars = event.data.split(''); | ||||
chars.forEach(char => { | chars.forEach(char => { | ||||
if (lastChar === '\\' && char === 'r') { | if (lastChar === '\\' && char === 'r') { | ||||
char = '<br>'; // 替换为 <br> 标签 | |||||
lastChar = ""; // 清空追踪字符 | |||||
char = '<br>'; //替换为br标签 | |||||
lastChar = ""; //清空追踪字符 | |||||
} else { | } else { | ||||
lastChar = char; // 记录当前字符 | |||||
lastChar = char; //记录当前字符 | |||||
} | } | ||||
if (char === '\\') { | if (char === '\\') { | ||||
return; // 如果是反斜杠,跳过处理 | |||||
return; //如果是反斜杠,跳过处理 | |||||
} | } | ||||
if (currentKey) { | if (currentKey) { | ||||
if (char === '{') { | if (char === '{') { | ||||
@@ -303,35 +302,32 @@ | |||||
tagBuffer = '{'; | tagBuffer = '{'; | ||||
return; | return; | ||||
} | } | ||||
if (isClosingTag) { | if (isClosingTag) { | ||||
tagBuffer += char; | tagBuffer += char; | ||||
if (tagBuffer === `{/${currentKey}}`) { | if (tagBuffer === `{/${currentKey}}`) { | ||||
if (currentKey == "body") { | if (currentKey == "body") { | ||||
CKEDITOR.instances["body"].setReadOnly(false); | CKEDITOR.instances["body"].setReadOnly(false); | ||||
bodyHtml = ""; | bodyHtml = ""; | ||||
} else if(currentKey == "typeid"){ | |||||
} else if (currentKey == "typeid") { | |||||
const input = document.querySelector(`[name="${currentKey}"]`); | const input = document.querySelector(`[name="${currentKey}"]`); | ||||
if (input) { | if (input) { | ||||
$(input).val(typeid); | $(input).val(typeid); | ||||
$(input).prop("disabled", false).removeClass("disabled"); // 恢复输入状态 | |||||
$(input).prop("disabled", false).removeClass("disabled"); //恢复输入状态 | |||||
} | } | ||||
} else { | } else { | ||||
const input = document.querySelector(`[name="${currentKey}"]`); | const input = document.querySelector(`[name="${currentKey}"]`); | ||||
if (input) $(input).prop("disabled", false).removeClass("disabled"); // 恢复输入状态 | |||||
if (input) $(input).prop("disabled", false).removeClass("disabled"); //恢复输入状态 | |||||
} | } | ||||
currentKey = null; | currentKey = null; | ||||
isClosingTag = false; | isClosingTag = false; | ||||
tagBuffer = ""; | tagBuffer = ""; | ||||
return; | return; | ||||
} | } | ||||
if (!`{/${currentKey}}`.startsWith(tagBuffer)) { | if (!`{/${currentKey}}`.startsWith(tagBuffer)) { | ||||
if (currentKey == "body") { | if (currentKey == "body") { | ||||
bodyHtml += tagBuffer; | bodyHtml += tagBuffer; | ||||
CKEDITOR.instances["body"].setData(bodyHtml) | CKEDITOR.instances["body"].setData(bodyHtml) | ||||
} else if(currentKey == "typeid"){ | |||||
} else if (currentKey == "typeid") { | |||||
typeid += tagBuffer; | typeid += tagBuffer; | ||||
} else { | } else { | ||||
const input = document.querySelector(`[name="${currentKey}"]`); | const input = document.querySelector(`[name="${currentKey}"]`); | ||||
@@ -343,16 +339,16 @@ | |||||
} | } | ||||
} else { | } else { | ||||
if (currentKey == "body") { | if (currentKey == "body") { | ||||
// CKEDITOR.instances["body"].insertHtml(char); | |||||
//CKEDITOR.instances["body"].insertHtml(char); | |||||
bodyHtml += char; | bodyHtml += char; | ||||
CKEDITOR.instances["body"].setData(bodyHtml) | CKEDITOR.instances["body"].setData(bodyHtml) | ||||
} else if(currentKey == "typeid"){ | |||||
} else if (currentKey == "typeid") { | |||||
typeid += char; | typeid += char; | ||||
} else { | } else { | ||||
const input = document.querySelector(`[name="${currentKey}"]`); | const input = document.querySelector(`[name="${currentKey}"]`); | ||||
if (input) { | if (input) { | ||||
input.value += char; | input.value += char; | ||||
input.scrollTop = input.scrollHeight; // 滚动到底部 | |||||
input.scrollTop = input.scrollHeight; //滚动到底部 | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -370,7 +366,7 @@ | |||||
} else { | } else { | ||||
const input = document.querySelector(`[name="${currentKey}"]`); | const input = document.querySelector(`[name="${currentKey}"]`); | ||||
if (input) { | if (input) { | ||||
$(input).prop("disabled", true).addClass("disabled"); // 仅禁用当前输入框 | |||||
$(input).prop("disabled", true).addClass("disabled"); //仅禁用当前输入框 | |||||
input.value = ""; | input.value = ""; | ||||
} | } | ||||
} | } | ||||
@@ -381,22 +377,20 @@ | |||||
} | } | ||||
}); | }); | ||||
}; | }; | ||||
eventSource.onerror = (error) => { | eventSource.onerror = (error) => { | ||||
if (error.target.readyState === EventSource.CONNECTING) { | if (error.target.readyState === EventSource.CONNECTING) { | ||||
ShowMsg("连接失败,请确保您已开启并正确配置了DedeBIZ智能助手服务器。 <a class='text-success' href='https://www.dedebiz.com/ai?from=dedebiz' target='_blank'>如何配置?</a>"); | |||||
ShowMsg("连接失败,请确保您已开启并正确配置了DedeBIZ小德AI助手。 <a class='text-success' href='https://www.dedebiz.com/ai?from=dedebiz' target='_blank'>如何配置?</a>"); | |||||
} else if (typeof error.data!=="undefined" && error.data !== "" && error.target.readyState !== EventSource.CLOSED) { | } else if (typeof error.data!=="undefined" && error.data !== "" && error.target.readyState !== EventSource.CLOSED) { | ||||
ShowMsg(error.data); | ShowMsg(error.data); | ||||
} | } | ||||
$("#btnAI").prop("disabled", false); | $("#btnAI").prop("disabled", false); | ||||
eventSource.close(); | eventSource.close(); | ||||
}; | }; | ||||
// 监听特定事件 "close" | |||||
//监听特定事件"close" | |||||
eventSource.addEventListener('close', (event) => { | eventSource.addEventListener('close', (event) => { | ||||
console.log('SSE connection closed:', event.data); | console.log('SSE connection closed:', event.data); | ||||
$("#btnAI").prop("disabled", false); | $("#btnAI").prop("disabled", false); | ||||
eventSource.close(); // 关闭连接 | |||||
eventSource.close(); //关闭连接 | |||||
}); | }); | ||||
}); | }); | ||||
</script> | </script> | ||||
@@ -26,7 +26,7 @@ | |||||
<li class="breadcrumb-item active">修改文档</li> | <li class="breadcrumb-item active">修改文档</li> | ||||
</ol> | </ol> | ||||
<div class="card shadow-sm"> | <div class="card shadow-sm"> | ||||
<div class="card-header d-flex justify-content-between align-items-center">修改<?php echo $arcRow['title'];?>文档 <?php if($cfg_ai_enabled == 'Y'){ ;?><button type="button" id="btnAI" onclick="showAI();" class="btn btn-success btn-sm">智能助手</button><?php } ;?></div> | |||||
<div class="card-header d-flex justify-content-between align-items-center">修改<?php echo $arcRow['title'];?>文档<?php if($cfg_ai_enabled == 'Y'){;?><button type="button" id="btnAI" onclick="showAI();" class="btn btn-success btn-sm">小德AI助手</button><?php };?></div> | |||||
<div class="card-body"> | <div class="card-body"> | ||||
<form name="form1" action="article_edit.php" method="post" enctype="multipart/form-data"> | <form name="form1" action="article_edit.php" method="post" enctype="multipart/form-data"> | ||||
<input type="hidden" name="dopost" value="save"> | <input type="hidden" name="dopost" value="save"> | ||||
@@ -231,14 +231,17 @@ | |||||
<div class="modal-dialog modal-xl"> | <div class="modal-dialog modal-xl"> | ||||
<div class="modal-content"> | <div class="modal-content"> | ||||
<div class="modal-header"> | <div class="modal-header"> | ||||
<h5 class="modal-title">智能助手-修改文档</h5> | |||||
<h5 class="modal-title">小德AI助手:修改文档</h5> | |||||
<button type="button" class="update-close" data-dismiss="modal" aria-label="Close"><i class="fa fa-times"></i></button> | <button type="button" class="update-close" data-dismiss="modal" aria-label="Close"><i class="fa fa-times"></i></button> | ||||
</div> | </div> | ||||
<div class="modal-body"> | <div class="modal-body"> | ||||
<form> | <form> | ||||
<div class="form-group"> | <div class="form-group"> | ||||
<textarea class="admin-input-sm" style="width: 100%;height: 100px;" id="prompt" placeholder="填写您需要对当前的内容进行怎样的优化,例如:我需要对当前文章就行润色,内容轻松活泼些,不要出现错别字"></textarea><br/> | |||||
选择模型:<select id="modelid" class="admin-input-sm" style="width: 100%;"> | |||||
<textarea id="prompt" class="form-control" style="height:160px" placeholder="请输入修改文档要求,例如:我需要对当前文章就行润色,内容轻松活泼些,不要出现错别字。"></textarea> | |||||
</div> | |||||
<div class="form-group"> | |||||
<label for="modelid" class="form-label">选择模型</label> | |||||
<select id="modelid" class="form-control"> | |||||
<?php | <?php | ||||
$dsql->SetQuery("SELECT AM.*,A.title as aititle FROM `#@__ai_model` AM LEFT JOIN `#@__ai` A ON A.id = AM.aiid ORDER BY AM.sortrank ASC,AM.id DESC"); | $dsql->SetQuery("SELECT AM.*,A.title as aititle FROM `#@__ai_model` AM LEFT JOIN `#@__ai` A ON A.id = AM.aiid ORDER BY AM.sortrank ASC,AM.id DESC"); | ||||
$dsql->Execute(); | $dsql->Execute(); | ||||
@@ -248,20 +251,19 @@ | |||||
<?php | <?php | ||||
} | } | ||||
?> | ?> | ||||
</select><br/> | |||||
</select> | |||||
</div> | </div> | ||||
</form> | </form> | ||||
</div> | </div> | ||||
<div class="modal-footer"> | <div class="modal-footer"> | ||||
<button id="btnAIAction" class="btn btn-success">AI生成</button> | |||||
<button id="btnAIAction" class="btn btn-success btn-sm">确定</button> | |||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<script>InitPage();</script> | <script>InitPage();</script> | ||||
<script> | <script> | ||||
let eventSource; // 保存 EventSource 实例 | |||||
let eventSource; //保存EventSource实例 | |||||
let modelid = 0; | let modelid = 0; | ||||
function showAI() { | function showAI() { | ||||
$("#mdlAI").modal('show'); | $("#mdlAI").modal('show'); | ||||
@@ -276,12 +278,10 @@ | |||||
return | return | ||||
} | } | ||||
let eventSource = new EventSource(resp.data); | let eventSource = new EventSource(resp.data); | ||||
// 新增状态跟踪变量 | |||||
//新增状态跟踪变量 | |||||
let currentKey = null; | let currentKey = null; | ||||
let tagBuffer = ""; | let tagBuffer = ""; | ||||
let isClosingTag = false; | let isClosingTag = false; | ||||
$("#mdlAI").modal('hide'); | $("#mdlAI").modal('hide'); | ||||
$("#btnAI").attr("disabled", "disabled"); | $("#btnAI").attr("disabled", "disabled"); | ||||
prompt = ""; | prompt = ""; | ||||
@@ -292,13 +292,13 @@ | |||||
const chars = event.data.split(''); | const chars = event.data.split(''); | ||||
chars.forEach(char => { | chars.forEach(char => { | ||||
if (lastChar === '\\' && char === 'r') { | if (lastChar === '\\' && char === 'r') { | ||||
char = '<br>'; // 替换为 <br> 标签 | |||||
lastChar = ""; // 清空追踪字符 | |||||
char = '<br>'; //替换为br标签 | |||||
lastChar = ""; //清空追踪字符 | |||||
} else { | } else { | ||||
lastChar = char; // 记录当前字符 | |||||
lastChar = char; //记录当前字符 | |||||
} | } | ||||
if (char === '\\') { | if (char === '\\') { | ||||
return; // 如果是反斜杠,跳过处理 | |||||
return; //如果是反斜杠,跳过处理 | |||||
} | } | ||||
if (currentKey) { | if (currentKey) { | ||||
if (char === '{') { | if (char === '{') { | ||||
@@ -306,58 +306,54 @@ | |||||
tagBuffer = '{'; | tagBuffer = '{'; | ||||
return; | return; | ||||
} | } | ||||
if (isClosingTag) { | if (isClosingTag) { | ||||
tagBuffer += char; | tagBuffer += char; | ||||
if (tagBuffer === `{/${currentKey}}`) { | if (tagBuffer === `{/${currentKey}}`) { | ||||
if (currentKey == "body") { | if (currentKey == "body") { | ||||
CKEDITOR.instances["body"].setReadOnly(false); | CKEDITOR.instances["body"].setReadOnly(false); | ||||
bodyHtml = ""; | bodyHtml = ""; | ||||
} else if(currentKey == "typeid"){ | |||||
} else if (currentKey == "typeid") { | |||||
const input = document.querySelector(`[name="${currentKey}"]`); | const input = document.querySelector(`[name="${currentKey}"]`); | ||||
if (input) { | if (input) { | ||||
$(input).val(typeid); | $(input).val(typeid); | ||||
$(input).prop("disabled", false).removeClass("disabled"); // 恢复输入状态 | |||||
$(input).prop("disabled", false).removeClass("disabled"); //恢复输入状态 | |||||
} | } | ||||
} else { | } else { | ||||
const input = document.querySelector(`[name="${currentKey}"]`); | const input = document.querySelector(`[name="${currentKey}"]`); | ||||
if (input) $(input).prop("disabled", false).removeClass("disabled"); // 恢复输入状态 | |||||
if (input) $(input).prop("disabled", false).removeClass("disabled"); //恢复输入状态 | |||||
} | } | ||||
currentKey = null; | currentKey = null; | ||||
isClosingTag = false; | isClosingTag = false; | ||||
tagBuffer = ""; | tagBuffer = ""; | ||||
return; | return; | ||||
} | } | ||||
if (!`{/${currentKey}}`.startsWith(tagBuffer)) { | if (!`{/${currentKey}}`.startsWith(tagBuffer)) { | ||||
if (currentKey == "body") { | if (currentKey == "body") { | ||||
bodyHtml += tagBuffer; | bodyHtml += tagBuffer; | ||||
CKEDITOR.instances["body"].setData(bodyHtml) | CKEDITOR.instances["body"].setData(bodyHtml) | ||||
} else if(currentKey == "typeid"){ | |||||
} else if (currentKey == "typeid") { | |||||
typeid += char; | typeid += char; | ||||
} else { | } else { | ||||
const input = document.querySelector(`[name="${currentKey}"]`); | const input = document.querySelector(`[name="${currentKey}"]`); | ||||
if (input) input.value += tagBuffer; | if (input) input.value += tagBuffer; | ||||
} | } | ||||
isClosingTag = false; | isClosingTag = false; | ||||
tagBuffer = ""; | tagBuffer = ""; | ||||
} | } | ||||
} else { | } else { | ||||
if (currentKey == "body") { | if (currentKey == "body") { | ||||
// CKEDITOR.instances["body"].insertHtml(char); | |||||
//CKEDITOR.instances["body"].insertHtml(char); | |||||
bodyHtml += char; | bodyHtml += char; | ||||
CKEDITOR.instances["body"].setData(bodyHtml) | CKEDITOR.instances["body"].setData(bodyHtml) | ||||
} else if(currentKey == "typeid"){ | |||||
} else if (currentKey == "typeid") { | |||||
typeid += char; | typeid += char; | ||||
} else { | } else { | ||||
const input = document.querySelector(`[name="${currentKey}"]`); | const input = document.querySelector(`[name="${currentKey}"]`); | ||||
if (input) { | if (input) { | ||||
input.value += char; | input.value += char; | ||||
input.scrollTop = input.scrollHeight; // 滚动到底部 | |||||
input.scrollTop = input.scrollHeight; //滚动到底部 | |||||
} | } | ||||
} | } | ||||
} | } | ||||
} else { | } else { | ||||
if (char === '{') { | if (char === '{') { | ||||
@@ -373,7 +369,7 @@ | |||||
} else { | } else { | ||||
const input = document.querySelector(`[name="${currentKey}"]`); | const input = document.querySelector(`[name="${currentKey}"]`); | ||||
if (input) { | if (input) { | ||||
$(input).prop("disabled", true).addClass("disabled"); // 仅禁用当前输入框 | |||||
$(input).prop("disabled", true).addClass("disabled"); //仅禁用当前输入框 | |||||
input.value = ""; | input.value = ""; | ||||
} | } | ||||
} | } | ||||
@@ -384,22 +380,20 @@ | |||||
} | } | ||||
}); | }); | ||||
}; | }; | ||||
eventSource.onerror = (error) => { | eventSource.onerror = (error) => { | ||||
if (error.target.readyState === EventSource.CONNECTING) { | if (error.target.readyState === EventSource.CONNECTING) { | ||||
ShowMsg("连接失败,请确保您已开启并正确配置了DedeBIZ智能助手服务器。 <a class='text-success' href='https://www.dedebiz.com/ai?from=dedebiz' target='_blank'>如何配置?</a>"); | |||||
ShowMsg("连接失败,请确保您已开启并正确配置了DedeBIZ小德AI助手。 <a class='text-success' href='https://www.dedebiz.com/ai?from=dedebiz' target='_blank'>如何配置?</a>"); | |||||
} else if (typeof error.data!=="undefined" && error.data !== "" && error.target.readyState !== EventSource.CLOSED) { | } else if (typeof error.data!=="undefined" && error.data !== "" && error.target.readyState !== EventSource.CLOSED) { | ||||
ShowMsg(error.data); | ShowMsg(error.data); | ||||
} | } | ||||
$("#btnAI").prop("disabled", false); | $("#btnAI").prop("disabled", false); | ||||
eventSource.close(); | eventSource.close(); | ||||
}; | }; | ||||
// 监听特定事件 "close" | |||||
//监听特定事件 "close" | |||||
eventSource.addEventListener('close', (event) => { | eventSource.addEventListener('close', (event) => { | ||||
console.log('SSE connection closed:', event.data); | console.log('SSE connection closed:', event.data); | ||||
$("#btnAI").prop("disabled", false); | $("#btnAI").prop("disabled", false); | ||||
eventSource.close(); // 关闭连接 | |||||
eventSource.close(); //关闭连接 | |||||
}); | }); | ||||
}); | }); | ||||
</script> | </script> | ||||
@@ -19,7 +19,7 @@ | |||||
<li class="breadcrumb-item active">添加栏目</li> | <li class="breadcrumb-item active">添加栏目</li> | ||||
</ol> | </ol> | ||||
<div class="card shadow-sm"> | <div class="card shadow-sm"> | ||||
<div class="card-header d-flex justify-content-between align-items-center">添加栏目 <?php if($cfg_ai_enabled == 'Y'){ ;?><button type="button" id="btnAI" onclick="showAI();" class="btn btn-success btn-sm">智能助手</button><?php } ;?></div> | |||||
<div class="card-header d-flex justify-content-between align-items-center">添加栏目<?php if($cfg_ai_enabled == 'Y'){;?><button type="button" id="btnAI" onclick="showAI();" class="btn btn-success btn-sm">小德AI助手</button><?php };?></div> | |||||
<div class="card-body"> | <div class="card-body"> | ||||
<form name="form1" action="catalog_add.php" method="post"> | <form name="form1" action="catalog_add.php" method="post"> | ||||
<input type="hidden" name="dopost" value="save"> | <input type="hidden" name="dopost" value="save"> | ||||
@@ -297,14 +297,17 @@ | |||||
<div class="modal-dialog modal-xl"> | <div class="modal-dialog modal-xl"> | ||||
<div class="modal-content"> | <div class="modal-content"> | ||||
<div class="modal-header"> | <div class="modal-header"> | ||||
<h5 class="modal-title">智能助手-创建栏目</h5> | |||||
<h5 class="modal-title">小德AI助手:创建栏目</h5> | |||||
<button type="button" class="update-close" data-dismiss="modal" aria-label="Close"><i class="fa fa-times"></i></button> | <button type="button" class="update-close" data-dismiss="modal" aria-label="Close"><i class="fa fa-times"></i></button> | ||||
</div> | </div> | ||||
<div class="modal-body"> | <div class="modal-body"> | ||||
<form> | <form> | ||||
<div class="form-group"> | <div class="form-group"> | ||||
<textarea class="admin-input-sm" style="width: 100%;height: 100px;" id="prompt" placeholder="填写您需要创建栏目的要求,例如:我需要创建一个介绍穆云智能科技公司的栏目"></textarea><br/> | |||||
选择模型:<select id="modelid" class="admin-input-sm" style="width: 100%;"> | |||||
<textarea id="prompt" class="form-control" style="height:160px" placeholder="请输入创建栏目要求,例如:我需要创建一个介绍穆云智能科技公司的栏目"></textarea> | |||||
</div> | |||||
<div class="form-group"> | |||||
<label for="modelid" class="form-label">选择模型</label> | |||||
<select id="modelid" class="form-control"> | |||||
<?php | <?php | ||||
$dsql->SetQuery("SELECT AM.*,A.title as aititle FROM `#@__ai_model` AM LEFT JOIN `#@__ai` A ON A.id = AM.aiid ORDER BY AM.sortrank ASC,AM.id DESC"); | $dsql->SetQuery("SELECT AM.*,A.title as aititle FROM `#@__ai_model` AM LEFT JOIN `#@__ai` A ON A.id = AM.aiid ORDER BY AM.sortrank ASC,AM.id DESC"); | ||||
$dsql->Execute(); | $dsql->Execute(); | ||||
@@ -314,13 +317,12 @@ | |||||
<?php | <?php | ||||
} | } | ||||
?> | ?> | ||||
</select><br/> | |||||
</select> | |||||
</div> | </div> | ||||
</form> | </form> | ||||
</div> | </div> | ||||
<div class="modal-footer"> | <div class="modal-footer"> | ||||
<button id="btnAIAction" class="btn btn-success">AI生成</button> | |||||
<button id="btnAIAction" class="btn btn-success btn-sm">确定</button> | |||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
@@ -407,7 +409,7 @@ | |||||
jQuery("#apikey").val(data); | jQuery("#apikey").val(data); | ||||
}); | }); | ||||
} | } | ||||
let eventSource; // 保存 EventSource 实例 | |||||
let eventSource; //保存EventSource实例 | |||||
let modelid = 0; | let modelid = 0; | ||||
function showAI() { | function showAI() { | ||||
$("#mdlAI").modal('show'); | $("#mdlAI").modal('show'); | ||||
@@ -423,29 +425,26 @@ | |||||
return | return | ||||
} | } | ||||
let eventSource = new EventSource(resp.data); | let eventSource = new EventSource(resp.data); | ||||
// 新增状态跟踪变量 | |||||
//新增状态跟踪变量 | |||||
let currentKey = null; | let currentKey = null; | ||||
let tagBuffer = ""; | let tagBuffer = ""; | ||||
let isClosingTag = false; | let isClosingTag = false; | ||||
$("#mdlAI").modal('hide'); | $("#mdlAI").modal('hide'); | ||||
$("#btnAI").attr("disabled", "disabled"); | $("#btnAI").attr("disabled", "disabled"); | ||||
prompt = ""; | prompt = ""; | ||||
let bodyHtml = ""; | let bodyHtml = ""; | ||||
let lastChar = ""; | let lastChar = ""; | ||||
eventSource.onmessage = (event) => { | eventSource.onmessage = (event) => { | ||||
const chars = event.data.split(''); | const chars = event.data.split(''); | ||||
chars.forEach(char => { | chars.forEach(char => { | ||||
if (lastChar === '\\' && char === 'r') { | if (lastChar === '\\' && char === 'r') { | ||||
char = '<br>'; // 替换为 <br> 标签 | |||||
lastChar = ""; // 清空追踪字符 | |||||
char = '<br>'; //替换为br标签 | |||||
lastChar = ""; //清空追踪字符 | |||||
} else { | } else { | ||||
lastChar = char; // 记录当前字符 | |||||
lastChar = char; //记录当前字符 | |||||
} | } | ||||
if (char === '\\') { | if (char === '\\') { | ||||
return; // 如果是反斜杠,跳过处理 | |||||
return; //如果是反斜杠,跳过处理 | |||||
} | } | ||||
if (currentKey) { | if (currentKey) { | ||||
if (char === '{') { | if (char === '{') { | ||||
@@ -453,24 +452,21 @@ | |||||
tagBuffer = '{'; | tagBuffer = '{'; | ||||
return; | return; | ||||
} | } | ||||
if (isClosingTag) { | if (isClosingTag) { | ||||
tagBuffer += char; | tagBuffer += char; | ||||
if (tagBuffer === `{/${currentKey}}`) { | if (tagBuffer === `{/${currentKey}}`) { | ||||
if (currentKey == "content") { | if (currentKey == "content") { | ||||
CKEDITOR.instances["content"].setReadOnly(false); | CKEDITOR.instances["content"].setReadOnly(false); | ||||
bodyHtml = ""; | bodyHtml = ""; | ||||
} else { | } else { | ||||
const input = document.querySelector(`[name="${currentKey}"]`); | const input = document.querySelector(`[name="${currentKey}"]`); | ||||
if (input) $(input).prop("disabled", false).removeClass("disabled"); // 恢复输入状态 | |||||
if (input) $(input).prop("disabled", false).removeClass("disabled"); //恢复输入状态 | |||||
} | } | ||||
currentKey = null; | currentKey = null; | ||||
isClosingTag = false; | isClosingTag = false; | ||||
tagBuffer = ""; | tagBuffer = ""; | ||||
return; | return; | ||||
} | } | ||||
if (!`{/${currentKey}}`.startsWith(tagBuffer)) { | if (!`{/${currentKey}}`.startsWith(tagBuffer)) { | ||||
if (currentKey == "content") { | if (currentKey == "content") { | ||||
bodyHtml += tagBuffer; | bodyHtml += tagBuffer; | ||||
@@ -480,7 +476,6 @@ | |||||
const input = document.querySelector(`[name="${currentKey}"]`); | const input = document.querySelector(`[name="${currentKey}"]`); | ||||
if (input) input.value += tagBuffer; | if (input) input.value += tagBuffer; | ||||
} | } | ||||
isClosingTag = false; | isClosingTag = false; | ||||
tagBuffer = ""; | tagBuffer = ""; | ||||
} | } | ||||
@@ -492,7 +487,7 @@ | |||||
const input = document.querySelector(`[name="${currentKey}"]`); | const input = document.querySelector(`[name="${currentKey}"]`); | ||||
if (input) { | if (input) { | ||||
input.value += char; | input.value += char; | ||||
input.scrollTop = input.scrollHeight; // 滚动到底部 | |||||
input.scrollTop = input.scrollHeight; //滚动到底部 | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -510,7 +505,7 @@ | |||||
} else { | } else { | ||||
const input = document.querySelector(`[name="${currentKey}"]`); | const input = document.querySelector(`[name="${currentKey}"]`); | ||||
if (input) { | if (input) { | ||||
$(input).prop("disabled", true).addClass("disabled"); // 仅禁用当前输入框 | |||||
$(input).prop("disabled", true).addClass("disabled"); //仅禁用当前输入框 | |||||
input.value = ""; | input.value = ""; | ||||
} | } | ||||
} | } | ||||
@@ -521,22 +516,20 @@ | |||||
} | } | ||||
}); | }); | ||||
}; | }; | ||||
eventSource.onerror = (error) => { | eventSource.onerror = (error) => { | ||||
if (error.target.readyState === EventSource.CONNECTING) { | if (error.target.readyState === EventSource.CONNECTING) { | ||||
ShowMsg("连接失败,请确保您已开启并正确配置了DedeBIZ智能助手服务器。 <a class='text-success' href='https://www.dedebiz.com/ai?from=dedebiz' target='_blank'>如何配置?</a>"); | |||||
ShowMsg("连接失败,请确保您已开启并正确配置了DedeBIZ小德AI助手。 <a class='text-success' href='https://www.dedebiz.com/ai?from=dedebiz' target='_blank'>如何配置?</a>"); | |||||
} else if (typeof error.data!=="undefined" && error.data !== "" && error.target.readyState !== EventSource.CLOSED) { | } else if (typeof error.data!=="undefined" && error.data !== "" && error.target.readyState !== EventSource.CLOSED) { | ||||
ShowMsg(error.data); | ShowMsg(error.data); | ||||
} | } | ||||
$("#btnAI").prop("disabled", false); | $("#btnAI").prop("disabled", false); | ||||
eventSource.close(); | eventSource.close(); | ||||
}; | }; | ||||
// 监听特定事件 "close" | |||||
//监听特定事件"close" | |||||
eventSource.addEventListener('close', (event) => { | eventSource.addEventListener('close', (event) => { | ||||
console.log('SSE connection closed:', event.data); | console.log('SSE connection closed:', event.data); | ||||
$("#btnAI").prop("disabled", false); | $("#btnAI").prop("disabled", false); | ||||
eventSource.close(); // 关闭连接 | |||||
eventSource.close(); //关闭连接 | |||||
}); | }); | ||||
}); | }); | ||||
</script> | </script> | ||||
@@ -19,7 +19,7 @@ | |||||
<li class="breadcrumb-item active">批量添加栏目</li> | <li class="breadcrumb-item active">批量添加栏目</li> | ||||
</ol> | </ol> | ||||
<div class="card shadow-sm"> | <div class="card shadow-sm"> | ||||
<div class="card-header d-flex justify-content-between align-items-center">批量添加栏目 <?php if($cfg_ai_enabled == 'Y'){ ;?><button type="button" id="btnAI" onclick="showAI();" class="btn btn-success btn-sm">智能助手</button><?php } ;?></div> | |||||
<div class="card-header d-flex justify-content-between align-items-center">批量添加栏目<?php if($cfg_ai_enabled == 'Y'){;?><button type="button" id="btnAI" onclick="showAI();" class="btn btn-success btn-sm">小德AI助手</button><?php };?></div> | |||||
<div class="card-body"> | <div class="card-body"> | ||||
<form name="form1" action="catalog_add.php" method="post"> | <form name="form1" action="catalog_add.php" method="post"> | ||||
<input type="hidden" name="dopost" value="savequick"> | <input type="hidden" name="dopost" value="savequick"> | ||||
@@ -194,14 +194,17 @@ | |||||
<div class="modal-dialog modal-xl"> | <div class="modal-dialog modal-xl"> | ||||
<div class="modal-content"> | <div class="modal-content"> | ||||
<div class="modal-header"> | <div class="modal-header"> | ||||
<h5 class="modal-title">智能助手-批量创建栏目</h5> | |||||
<h5 class="modal-title">小德AI助手:批量创建栏目</h5> | |||||
<button type="button" class="update-close" data-dismiss="modal" aria-label="Close"><i class="fa fa-times"></i></button> | <button type="button" class="update-close" data-dismiss="modal" aria-label="Close"><i class="fa fa-times"></i></button> | ||||
</div> | </div> | ||||
<div class="modal-body"> | <div class="modal-body"> | ||||
<form> | <form> | ||||
<div class="form-group"> | <div class="form-group"> | ||||
<textarea class="admin-input-sm" style="width: 100%;height: 100px;" id="prompt" placeholder="填写您站点规划,AI帮您自动规划栏目,例如:我需要创建一个企业信息展示类站点"></textarea><br/> | |||||
选择模型:<select id="modelid" class="admin-input-sm" style="width: 100%;"> | |||||
<textarea id="prompt" class="form-control" style="height:160px" placeholder="请输入批量创建栏目要求,例如:我需要创建一个企业信息展示类站点"></textarea> | |||||
</div> | |||||
<div class="form-group"> | |||||
<label for="modelid" class="form-label">选择模型</label> | |||||
<select id="modelid" class="form-control"> | |||||
<?php | <?php | ||||
$dsql->SetQuery("SELECT AM.*,A.title as aititle FROM `#@__ai_model` AM LEFT JOIN `#@__ai` A ON A.id = AM.aiid ORDER BY AM.sortrank ASC,AM.id DESC"); | $dsql->SetQuery("SELECT AM.*,A.title as aititle FROM `#@__ai_model` AM LEFT JOIN `#@__ai` A ON A.id = AM.aiid ORDER BY AM.sortrank ASC,AM.id DESC"); | ||||
$dsql->Execute(); | $dsql->Execute(); | ||||
@@ -211,13 +214,12 @@ | |||||
<?php | <?php | ||||
} | } | ||||
?> | ?> | ||||
</select><br/> | |||||
</select> | |||||
</div> | </div> | ||||
</form> | </form> | ||||
</div> | </div> | ||||
<div class="modal-footer"> | <div class="modal-footer"> | ||||
<button id="btnAIAction" class="btn btn-success">AI生成</button> | |||||
<button id="btnAIAction" class="btn btn-success btn-sm">确定</button> | |||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
@@ -294,12 +296,10 @@ | |||||
return | return | ||||
} | } | ||||
let eventSource = new EventSource(resp.data); | let eventSource = new EventSource(resp.data); | ||||
// 新增状态跟踪变量 | |||||
//新增状态跟踪变量 | |||||
let currentKey = null; | let currentKey = null; | ||||
let tagBuffer = ""; | let tagBuffer = ""; | ||||
let isClosingTag = false; | let isClosingTag = false; | ||||
$("#mdlAI").modal('hide'); | $("#mdlAI").modal('hide'); | ||||
$("#btnAI").attr("disabled", "disabled"); | $("#btnAI").attr("disabled", "disabled"); | ||||
prompt = ""; | prompt = ""; | ||||
@@ -308,13 +308,13 @@ | |||||
const chars = event.data.split(''); | const chars = event.data.split(''); | ||||
chars.forEach(char => { | chars.forEach(char => { | ||||
if (lastChar === '\\' && char === 'r') { | if (lastChar === '\\' && char === 'r') { | ||||
char = '<br>'; // 替换为 <br> 标签 | |||||
lastChar = ""; // 清空追踪字符 | |||||
char = '<br>'; //替换为br标签 | |||||
lastChar = ""; //清空追踪字符 | |||||
} else { | } else { | ||||
lastChar = char; // 记录当前字符 | |||||
lastChar = char; //记录当前字符 | |||||
} | } | ||||
if (char === '\\') { | if (char === '\\') { | ||||
return; // 如果是反斜杠,跳过处理 | |||||
return; //如果是反斜杠,跳过处理 | |||||
} | } | ||||
if (currentKey) { | if (currentKey) { | ||||
if (char === '{') { | if (char === '{') { | ||||
@@ -322,23 +322,20 @@ | |||||
tagBuffer = '{'; | tagBuffer = '{'; | ||||
return; | return; | ||||
} | } | ||||
if (isClosingTag) { | if (isClosingTag) { | ||||
tagBuffer += char; | tagBuffer += char; | ||||
if (tagBuffer === `{/${currentKey}}`) { | if (tagBuffer === `{/${currentKey}}`) { | ||||
if (currentKey == "content") { | if (currentKey == "content") { | ||||
// CKEDITOR.instances["content"].setReadOnly(false); | |||||
//CKEDITOR.instances["content"].setReadOnly(false); | |||||
} else { | } else { | ||||
const input = document.querySelector(`[name="${currentKey}"]`); | const input = document.querySelector(`[name="${currentKey}"]`); | ||||
if (input) $(input).prop("disabled", false).removeClass("disabled"); // 恢复输入状态 | |||||
if (input) $(input).prop("disabled", false).removeClass("disabled"); //恢复输入状态 | |||||
} | } | ||||
currentKey = null; | currentKey = null; | ||||
isClosingTag = false; | isClosingTag = false; | ||||
tagBuffer = ""; | tagBuffer = ""; | ||||
return; | return; | ||||
} | } | ||||
if (!`{/${currentKey}}`.startsWith(tagBuffer)) { | if (!`{/${currentKey}}`.startsWith(tagBuffer)) { | ||||
if (currentKey == "content") { | if (currentKey == "content") { | ||||
CKEDITOR.instances["content"].insertHtml(tagBuffer); | CKEDITOR.instances["content"].insertHtml(tagBuffer); | ||||
@@ -357,7 +354,7 @@ | |||||
const input = document.querySelector(`[name="${currentKey}"]`); | const input = document.querySelector(`[name="${currentKey}"]`); | ||||
if (input) { | if (input) { | ||||
input.value += char; | input.value += char; | ||||
input.scrollTop = input.scrollHeight; // 滚动到底部 | |||||
input.scrollTop = input.scrollHeight; //滚动到底部 | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -371,12 +368,12 @@ | |||||
if (match) { | if (match) { | ||||
currentKey = match[1]; | currentKey = match[1]; | ||||
if (currentKey == "content") { | if (currentKey == "content") { | ||||
// CKEDITOR.instances["content"].setReadOnly(true); | |||||
//CKEDITOR.instances["content"].setReadOnly(true); | |||||
CKEDITOR.instances["content"].setData("") | CKEDITOR.instances["content"].setData("") | ||||
} else { | } else { | ||||
const input = document.querySelector(`[name="${currentKey}"]`); | const input = document.querySelector(`[name="${currentKey}"]`); | ||||
if (input) { | if (input) { | ||||
$(input).prop("disabled", true).addClass("disabled"); // 仅禁用当前输入框 | |||||
$(input).prop("disabled", true).addClass("disabled"); //仅禁用当前输入框 | |||||
input.value = ""; | input.value = ""; | ||||
} | } | ||||
} | } | ||||
@@ -387,22 +384,20 @@ | |||||
} | } | ||||
}); | }); | ||||
}; | }; | ||||
eventSource.onerror = (error) => { | eventSource.onerror = (error) => { | ||||
if (error.target.readyState === EventSource.CONNECTING) { | if (error.target.readyState === EventSource.CONNECTING) { | ||||
ShowMsg("连接失败,请确保您已开启并正确配置了DedeBIZ智能助手服务器。 <a class='text-success' href='https://www.dedebiz.com/ai?from=dedebiz' target='_blank'>如何配置?</a>"); | |||||
ShowMsg("连接失败,请确保您已开启并正确配置了DedeBIZ小德AI助手。 <a class='text-success' href='https://www.dedebiz.com/ai?from=dedebiz' target='_blank'>如何配置?</a>"); | |||||
} else if (typeof error.data!=="undefined" && error.data !== "" && error.target.readyState !== EventSource.CLOSED) { | } else if (typeof error.data!=="undefined" && error.data !== "" && error.target.readyState !== EventSource.CLOSED) { | ||||
ShowMsg(error.data); | ShowMsg(error.data); | ||||
} | } | ||||
$("#btnAI").prop("disabled", false); | $("#btnAI").prop("disabled", false); | ||||
eventSource.close(); | eventSource.close(); | ||||
}; | }; | ||||
// 监听特定事件 "close" | |||||
//监听特定事件"close" | |||||
eventSource.addEventListener('close', (event) => { | eventSource.addEventListener('close', (event) => { | ||||
console.log('SSE connection closed:', event.data); | console.log('SSE connection closed:', event.data); | ||||
$("#btnAI").prop("disabled", false); | $("#btnAI").prop("disabled", false); | ||||
eventSource.close(); // 关闭连接 | |||||
eventSource.close(); //关闭连接 | |||||
}); | }); | ||||
}); | }); | ||||
</script> | </script> | ||||
@@ -19,7 +19,7 @@ | |||||
<li class="breadcrumb-item active">修改栏目</li> | <li class="breadcrumb-item active">修改栏目</li> | ||||
</ol> | </ol> | ||||
<div class="card shadow-sm"> | <div class="card shadow-sm"> | ||||
<div class="card-header d-flex justify-content-between align-items-center">修改栏目 <?php if($cfg_ai_enabled == 'Y'){ ;?><button type="button" id="btnAI" onclick="showAI();" class="btn btn-success btn-sm">智能助手</button><?php } ;?></div> | |||||
<div class="card-header d-flex justify-content-between align-items-center">修改栏目<?php if($cfg_ai_enabled == 'Y'){;?><button type="button" id="btnAI" onclick="showAI();" class="btn btn-success btn-sm">小德AI助手</button><?php };?></div> | |||||
<div class="card-body"> | <div class="card-body"> | ||||
<form name="form1" action="catalog_edit.php" method="post"> | <form name="form1" action="catalog_edit.php" method="post"> | ||||
<input type="hidden" name="dopost" value="save"> | <input type="hidden" name="dopost" value="save"> | ||||
@@ -327,14 +327,16 @@ | |||||
<div class="modal-dialog modal-xl"> | <div class="modal-dialog modal-xl"> | ||||
<div class="modal-content"> | <div class="modal-content"> | ||||
<div class="modal-header"> | <div class="modal-header"> | ||||
<h5 class="modal-title">智能助手-修改栏目</h5> | |||||
<h5 class="modal-title">小德AI助手:修改栏目</h5> | |||||
<button type="button" class="update-close" data-dismiss="modal" aria-label="Close"><i class="fa fa-times"></i></button> | <button type="button" class="update-close" data-dismiss="modal" aria-label="Close"><i class="fa fa-times"></i></button> | ||||
</div> | </div> | ||||
<div class="modal-body"> | <div class="modal-body"> | ||||
<form> | <form> | ||||
<div class="form-group"> | <div class="form-group"> | ||||
<textarea class="admin-input-sm" style="width: 100%;height: 100px;" id="prompt" placeholder="填写您需要修改栏目的要求,例如:我需要栏目信息内容更丰富一些"></textarea><br/> | |||||
选择模型:<select id="modelid" class="admin-input-sm" style="width: 100%;"> | |||||
<textarea id="prompt" class="form-control" style="height:160px" placeholder="请输入修改栏目要求,例如:我需要栏目信息内容更丰富一些"></textarea> | |||||
</div> | |||||
<div class="form-group"> | |||||
<label for="modelid" class="form-label">选择模型</label> | |||||
<?php | <?php | ||||
$dsql->SetQuery("SELECT AM.*,A.title as aititle FROM `#@__ai_model` AM LEFT JOIN `#@__ai` A ON A.id = AM.aiid ORDER BY AM.sortrank ASC,AM.id DESC"); | $dsql->SetQuery("SELECT AM.*,A.title as aititle FROM `#@__ai_model` AM LEFT JOIN `#@__ai` A ON A.id = AM.aiid ORDER BY AM.sortrank ASC,AM.id DESC"); | ||||
$dsql->Execute(); | $dsql->Execute(); | ||||
@@ -344,13 +346,12 @@ | |||||
<?php | <?php | ||||
} | } | ||||
?> | ?> | ||||
</select><br/> | |||||
</select> | |||||
</div> | </div> | ||||
</form> | </form> | ||||
</div> | </div> | ||||
<div class="modal-footer"> | <div class="modal-footer"> | ||||
<button id="btnAIAction" class="btn btn-success">AI生成</button> | |||||
<button id="btnAIAction" class="btn btn-success btn-sm">确定</button> | |||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
@@ -454,12 +455,10 @@ | |||||
return | return | ||||
} | } | ||||
let eventSource = new EventSource(resp.data); | let eventSource = new EventSource(resp.data); | ||||
// 新增状态跟踪变量 | |||||
//新增状态跟踪变量 | |||||
let currentKey = null; | let currentKey = null; | ||||
let tagBuffer = ""; | let tagBuffer = ""; | ||||
let isClosingTag = false; | let isClosingTag = false; | ||||
$("#mdlAI").modal('hide'); | $("#mdlAI").modal('hide'); | ||||
$("#btnAI").attr("disabled", "disabled"); | $("#btnAI").attr("disabled", "disabled"); | ||||
prompt = ""; | prompt = ""; | ||||
@@ -468,13 +467,13 @@ | |||||
const chars = event.data.split(''); | const chars = event.data.split(''); | ||||
chars.forEach(char => { | chars.forEach(char => { | ||||
if (lastChar === '\\' && char === 'r') { | if (lastChar === '\\' && char === 'r') { | ||||
char = '<br>'; // 替换为 <br> 标签 | |||||
lastChar = ""; // 清空追踪字符 | |||||
char = '<br>'; //替换为br标签 | |||||
lastChar = ""; //清空追踪字符 | |||||
} else { | } else { | ||||
lastChar = char; // 记录当前字符 | |||||
lastChar = char; //记录当前字符 | |||||
} | } | ||||
if (char === '\\') { | if (char === '\\') { | ||||
return; // 如果是反斜杠,跳过处理 | |||||
return; //如果是反斜杠,跳过处理 | |||||
} | } | ||||
if (currentKey) { | if (currentKey) { | ||||
if (char === '{') { | if (char === '{') { | ||||
@@ -482,24 +481,21 @@ | |||||
tagBuffer = '{'; | tagBuffer = '{'; | ||||
return; | return; | ||||
} | } | ||||
if (isClosingTag) { | if (isClosingTag) { | ||||
tagBuffer += char; | tagBuffer += char; | ||||
if (tagBuffer === `{/${currentKey}}`) { | if (tagBuffer === `{/${currentKey}}`) { | ||||
if (currentKey == "content") { | if (currentKey == "content") { | ||||
CKEDITOR.instances["content"].setReadOnly(false); | CKEDITOR.instances["content"].setReadOnly(false); | ||||
bodyHtml = ""; | bodyHtml = ""; | ||||
} else { | } else { | ||||
const input = document.querySelector(`[name="${currentKey}"]`); | const input = document.querySelector(`[name="${currentKey}"]`); | ||||
if (input) $(input).prop("disabled", false).removeClass("disabled"); // 恢复输入状态 | |||||
if (input) $(input).prop("disabled", false).removeClass("disabled"); //恢复输入状态 | |||||
} | } | ||||
currentKey = null; | currentKey = null; | ||||
isClosingTag = false; | isClosingTag = false; | ||||
tagBuffer = ""; | tagBuffer = ""; | ||||
return; | return; | ||||
} | } | ||||
if (!`{/${currentKey}}`.startsWith(tagBuffer)) { | if (!`{/${currentKey}}`.startsWith(tagBuffer)) { | ||||
if (currentKey == "content") { | if (currentKey == "content") { | ||||
bodyHtml += tagBuffer; | bodyHtml += tagBuffer; | ||||
@@ -521,7 +517,7 @@ | |||||
const input = document.querySelector(`[name="${currentKey}"]`); | const input = document.querySelector(`[name="${currentKey}"]`); | ||||
if (input) { | if (input) { | ||||
input.value += char; | input.value += char; | ||||
input.scrollTop = input.scrollHeight; // 滚动到底部 | |||||
input.scrollTop = input.scrollHeight; //滚动到底部 | |||||
} | } | ||||
} | } | ||||
@@ -540,7 +536,7 @@ | |||||
} else { | } else { | ||||
const input = document.querySelector(`[name="${currentKey}"]`); | const input = document.querySelector(`[name="${currentKey}"]`); | ||||
if (input) { | if (input) { | ||||
$(input).prop("disabled", true).addClass("disabled"); // 仅禁用当前输入框 | |||||
$(input).prop("disabled", true).addClass("disabled"); //仅禁用当前输入框 | |||||
input.value = ""; | input.value = ""; | ||||
} | } | ||||
} | } | ||||
@@ -551,22 +547,20 @@ | |||||
} | } | ||||
}); | }); | ||||
}; | }; | ||||
eventSource.onerror = (error) => { | eventSource.onerror = (error) => { | ||||
if (error.target.readyState === EventSource.CONNECTING) { | if (error.target.readyState === EventSource.CONNECTING) { | ||||
ShowMsg("连接失败,请确保您已开启并正确配置了DedeBIZ智能助手服务器。 <a class='text-success' href='https://www.dedebiz.com/ai?from=dedebiz' target='_blank'>如何配置?</a>"); | |||||
ShowMsg("连接失败,请确保您已开启并正确配置了DedeBIZ小德AI助手。 <a class='text-success' href='https://www.dedebiz.com/ai?from=dedebiz' target='_blank'>如何配置?</a>"); | |||||
} else if (typeof error.data!=="undefined" && error.data !== "" && error.target.readyState !== EventSource.CLOSED) { | } else if (typeof error.data!=="undefined" && error.data !== "" && error.target.readyState !== EventSource.CLOSED) { | ||||
ShowMsg(error.data); | ShowMsg(error.data); | ||||
} | } | ||||
$("#btnAI").prop("disabled", false); | $("#btnAI").prop("disabled", false); | ||||
eventSource.close(); | eventSource.close(); | ||||
}; | }; | ||||
// 监听特定事件 "close" | |||||
//监听特定事件"close" | |||||
eventSource.addEventListener('close', (event) => { | eventSource.addEventListener('close', (event) => { | ||||
console.log('SSE connection closed:', event.data); | console.log('SSE connection closed:', event.data); | ||||
$("#btnAI").prop("disabled", false); | $("#btnAI").prop("disabled", false); | ||||
eventSource.close(); // 关闭连接 | |||||
eventSource.close(); //关闭连接 | |||||
}); | }); | ||||
}); | }); | ||||
</script> | </script> | ||||
@@ -238,9 +238,9 @@ | |||||
let apikey = jQuery("#edit___cfg_ai_apikey").val(); | let apikey = jQuery("#edit___cfg_ai_apikey").val(); | ||||
jQuery.get("sys_info.php?dopost=ping_ai_server&server="+server+"&apikey="+apikey, function(data) { | jQuery.get("sys_info.php?dopost=ping_ai_server&server="+server+"&apikey="+apikey, function(data) { | ||||
if (data == "ok") { | if (data == "ok") { | ||||
ShowMsg("DedeBIZ智能助手服务连接成功") | |||||
ShowMsg("DedeBIZ小德AI助手连接成功") | |||||
} else { | } else { | ||||
ShowMsg("DedeBIZ智能助手服务连接失败,请检查配置") | |||||
ShowMsg("DedeBIZ小德AI助手连接失败,请检查配置") | |||||
} | } | ||||
}); | }); | ||||
} | } | ||||
@@ -28,36 +28,32 @@ if (!function_exists('HtmlReplace')) { | |||||
if (!is_string($str)) { | if (!is_string($str)) { | ||||
return ''; | return ''; | ||||
} | } | ||||
$str = stripslashes($str); // 取消转义 | |||||
// 初始化 HTMLPurifier 配置(静态变量优化性能) | |||||
$str = stripslashes($str); //取消转义 | |||||
//初始化HTMLPurifier配置(静态变量优化性能) | |||||
static $purifier = null; | static $purifier = null; | ||||
$config = HTMLPurifier_Config::createDefault(); | $config = HTMLPurifier_Config::createDefault(); | ||||
$config->set('HTML.Allowed', ''); // 只保留文本 | |||||
$config->set('HTML.Allowed', ''); //只保留文本 | |||||
if ($purifier === null) { | if ($purifier === null) { | ||||
$config->set('Cache.SerializerPath', DEDEDATA.'/cache'); | $config->set('Cache.SerializerPath', DEDEDATA.'/cache'); | ||||
$purifier = new HTMLPurifier($config); | $purifier = new HTMLPurifier($config); | ||||
} | } | ||||
// 处理不同模式 | |||||
//处理不同模式 | |||||
if ($rptype == 0) { | if ($rptype == 0) { | ||||
// 仅替换 HTML 标记 | |||||
//仅替换网页标记 | |||||
$str = $purifier->purify($str); | $str = $purifier->purify($str); | ||||
} elseif ($rptype == 1) { | } elseif ($rptype == 1) { | ||||
// 替换 HTML 标记 + 去除连续空白字符 | |||||
//替换网页标记,去除连续空白字符 | |||||
$str = $purifier->purify($str); | $str = $purifier->purify($str); | ||||
$str = preg_replace("/[\r\n\t ]+/", ' ', $str); // 合并多余空格 | |||||
$str = preg_replace("/[\r\n\t ]+/", ' ', $str); //合并多余空格 | |||||
} elseif ($rptype == 2) { | } elseif ($rptype == 2) { | ||||
// 替换 HTML 标记 + 去除所有空白字符 | |||||
//替换网页标记,去除所有空白字符 | |||||
$str = $purifier->purify($str); | $str = $purifier->purify($str); | ||||
$str = preg_replace("/\s+/", '', $str); | $str = preg_replace("/\s+/", '', $str); | ||||
} else { | } else { | ||||
// 仅替换 HTML 危险标记 | |||||
//仅替换网页危险标记 | |||||
$config->set('HTML.ForbiddenElements', ['script', 'iframe', 'object', 'embed', 'form', 'input', 'button', 'textarea', 'select', 'meta', 'link']); | $config->set('HTML.ForbiddenElements', ['script', 'iframe', 'object', 'embed', 'form', 'input', 'button', 'textarea', 'select', 'meta', 'link']); | ||||
$str = $purifier->purify($str); | $str = $purifier->purify($str); | ||||
} | } | ||||
return addslashes($str); | return addslashes($str); | ||||
} | } | ||||
} | } | ||||
@@ -73,21 +69,16 @@ if (!function_exists('RemoveXSS')) { | |||||
static $purifier = null; | static $purifier = null; | ||||
if ($purifier === null) { | if ($purifier === null) { | ||||
$config = HTMLPurifier_Config::createDefault(); | $config = HTMLPurifier_Config::createDefault(); | ||||
// 启用缓存(提升性能) | |||||
$config->set('Cache.SerializerPath', DEDEDATA.'/cache'); // 生产环境建议设定缓存目录 | |||||
// 允许的 HTML 元素(可以根据需要调整) | |||||
//启用缓存(提升性能) | |||||
$config->set('Cache.SerializerPath', DEDEDATA.'/cache'); //生产环境建议设定缓存目录 | |||||
//允许的网页元素(可以根据需要调整) | |||||
$config->set('HTML.Allowed', 'p,b,strong,i,em,u,a[href|title],ul,ol,li,img[src|alt|width|height],br,span[class]'); | $config->set('HTML.Allowed', 'p,b,strong,i,em,u,a[href|title],ul,ol,li,img[src|alt|width|height],br,span[class]'); | ||||
// 过滤 JavaScript、CSS 注入 | |||||
//过滤JavaScript、CSS注入 | |||||
$config->set('CSS.AllowedProperties', []); | $config->set('CSS.AllowedProperties', []); | ||||
$config->set('URI.DisableExternalResources', true); | $config->set('URI.DisableExternalResources', true); | ||||
$config->set('URI.DisableResources', true); | $config->set('URI.DisableResources', true); | ||||
$purifier = new HTMLPurifier($config); | $purifier = new HTMLPurifier($config); | ||||
} | } | ||||
return $purifier->purify($val); | return $purifier->purify($val); | ||||
} | } | ||||
} | } | ||||
@@ -3,28 +3,22 @@ if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
require_once DEDEINC."/libraries/HTMLPurifier/HTMLPurifier.auto.php"; | require_once DEDEINC."/libraries/HTMLPurifier/HTMLPurifier.auto.php"; | ||||
function SpHtml2Text($html) | function SpHtml2Text($html) | ||||
{ | { | ||||
// 初始化 HTMLPurifier 配置 | |||||
//初始化HTMLPurifier配置 | |||||
static $purifier = null; | static $purifier = null; | ||||
if ($purifier === null) { | if ($purifier === null) { | ||||
$config = HTMLPurifier_Config::createDefault(); | $config = HTMLPurifier_Config::createDefault(); | ||||
// 禁止所有 HTML 标签,只允许文本 | |||||
//禁止所有网页标签,只允许文本 | |||||
$config->set('HTML.Allowed', ''); | $config->set('HTML.Allowed', ''); | ||||
// 配置缓存 | |||||
//配置缓存 | |||||
$cacheDir = DEDEDATA.'/cache'; | $cacheDir = DEDEDATA.'/cache'; | ||||
$config->set('Cache.SerializerPath', $cacheDir); | $config->set('Cache.SerializerPath', $cacheDir); | ||||
$purifier = new HTMLPurifier($config); | $purifier = new HTMLPurifier($config); | ||||
} | } | ||||
// 过滤掉所有 HTML,只保留纯文本 | |||||
//过滤掉所有网页,只保留纯文本 | |||||
$cleanText = $purifier->purify($html); | $cleanText = $purifier->purify($html); | ||||
// 进一步去除可能的额外空格和换行符 | |||||
//进一步去除可能的额外空格和换行符 | |||||
$cleanText = trim($cleanText); | $cleanText = trim($cleanText); | ||||
$cleanText = preg_replace("/[\r\n\t ]+/", ' ', $cleanText); | $cleanText = preg_replace("/[\r\n\t ]+/", ' ', $cleanText); | ||||
return $cleanText; | return $cleanText; | ||||
} | } | ||||
?> | ?> |