@@ -17,12 +17,12 @@ $sql = $where = ''; | |||||
if (empty($adminid)) $adminid = 0; | if (empty($adminid)) $adminid = 0; | ||||
if (empty($cip)) $cip = ''; | if (empty($cip)) $cip = ''; | ||||
if (empty($dtime)) $dtime = 0; | if (empty($dtime)) $dtime = 0; | ||||
if ($adminid > 0) $where .= " AND `#@__log`.adminid='$adminid' "; | |||||
if ($cip != "") $where .= " AND `#@__log`.cip LIKE '%$cip%' "; | |||||
if ($adminid > 0) $where .= " AND `#@__ai_log`.adminid='$adminid' "; | |||||
if ($cip != "") $where .= " AND `#@__ai_log`.cip LIKE '%$cip%' "; | |||||
if ($dtime > 0) { | if ($dtime > 0) { | ||||
$nowtime = time(); | $nowtime = time(); | ||||
$starttime = $nowtime - ($dtime * 24 * 3600); | $starttime = $nowtime - ($dtime * 24 * 3600); | ||||
$where .= " AND `#@__log`.dtime>'$starttime' "; | |||||
$where .= " AND `#@__ai_log`.dtime>'$starttime' "; | |||||
} | } | ||||
$sql = "SELECT `#@__ai_log`.*,`#@__admin`.userid FROM `#@__ai_log` LEFT JOIN `#@__admin` ON `#@__admin`.id=`#@__ai_log`.adminid WHERE 1=1 $where ORDER BY `#@__ai_log`.lid DESC"; | $sql = "SELECT `#@__ai_log`.*,`#@__admin`.userid FROM `#@__ai_log` LEFT JOIN `#@__admin` ON `#@__admin`.id=`#@__ai_log`.adminid WHERE 1=1 $where ORDER BY `#@__ai_log`.lid DESC"; | ||||
$adminlist = ''; | $adminlist = ''; | ||||
@@ -15,7 +15,8 @@ if ($dopost == "add") { | |||||
$model = isset($model)? HtmlReplace($model, -1) : ''; | $model = isset($model)? HtmlReplace($model, -1) : ''; | ||||
$title = isset($title)? HtmlReplace($title, -1) : ''; | $title = isset($title)? HtmlReplace($title, -1) : ''; | ||||
$description = isset($description)? HtmlReplace($description, -1) : ''; | $description = isset($description)? HtmlReplace($description, -1) : ''; | ||||
$query = "INSERT INTO `#@__ai_model` (aiid,title,model,description) VALUES ('$aiid','$title','$model','$description'); "; | |||||
$sortrank = isset($sortrank)? intval($sortrank) : 50; | |||||
$query = "INSERT INTO `#@__ai_model` (aiid,title,model,description,sortrank) VALUES ('$aiid','$title','$model','$description','$sortrank'); "; | |||||
$rs = $dsql->ExecuteNoneQuery($query); | $rs = $dsql->ExecuteNoneQuery($query); | ||||
$burl = "ai_edit.php?id=".$aiid; | $burl = "ai_edit.php?id=".$aiid; | ||||
if ($rs) { | if ($rs) { | ||||
@@ -20,7 +20,8 @@ if ($dopost == "delete") { | |||||
$title = isset($title)? HtmlReplace($title, -1) : ''; | $title = isset($title)? HtmlReplace($title, -1) : ''; | ||||
$description = isset($description)? HtmlReplace($description, -1) : ''; | $description = isset($description)? HtmlReplace($description, -1) : ''; | ||||
$model = isset($model)? HtmlReplace($model, -1) : ''; | $model = isset($model)? HtmlReplace($model, -1) : ''; | ||||
$query = "UPDATE `#@__ai_model` SET title='$title',description='$description',model='$model' WHERE id='$id' "; | |||||
$sortrank = isset($sortrank)? intval($sortrank) : 50; | |||||
$query = "UPDATE `#@__ai_model` SET title='$title',description='$description',model='$model',sortrank='$sortrank' WHERE id='$id' "; | |||||
$dsql->ExecuteNoneQuery($query); | $dsql->ExecuteNoneQuery($query); | ||||
ShowMsg("成功修改一个模型版本", "ai_edit.php?id={$myModel['aiid']}&dopost=getedit"); | ShowMsg("成功修改一个模型版本", "ai_edit.php?id={$myModel['aiid']}&dopost=getedit"); | ||||
exit(); | exit(); | ||||
@@ -12,7 +12,7 @@ require_once(dirname(__FILE__).'/config.php'); | |||||
require_once(DEDEINC.'/datalistcp.class.php'); | require_once(DEDEINC.'/datalistcp.class.php'); | ||||
DedeSetCookie('ENV_GOBACK_URL', $dedeNowurl, time() + 3600, '/'); | DedeSetCookie('ENV_GOBACK_URL', $dedeNowurl, time() + 3600, '/'); | ||||
$sql = "SELECT AM.*,A.title as aititle FROM `#@__ai_model` AM LEFT JOIN `#@__ai` A ON A.id = AM.aiid ORDER BY 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'); | ||||
$dlist->SetSource($sql); | $dlist->SetSource($sql); | ||||
@@ -0,0 +1,30 @@ | |||||
<?php | |||||
/** | |||||
* 预览提示词 | |||||
* | |||||
* @version $id:ai_prompt_view.php 2025 tianya $ | |||||
* @package DedeBIZ.Administrator | |||||
* @copyright Copyright (c) 2025 DedeBIZ.COM | |||||
* @license GNU GPL v2 (https://www.dedebiz.com/license) | |||||
* @link https://www.dedebiz.com | |||||
*/ | |||||
require_once(dirname(__FILE__)."/config.php"); | |||||
if (empty($dopost)) $dopost = ''; | |||||
$id = isset($id)? intval($id) : 0; | |||||
$myPrompt = $dsql->GetOne("SELECT * FROM `#@__ai_prompt` WHERE id=$id"); | |||||
if ($dopost == "delete") { | |||||
$dsql->ExecuteNoneQuery("DELETE FROM `#@__ai_prompt` WHERE id='$id'"); | |||||
ShowMsg("成功删除一个提示词", "ai_prompt_main.php"); | |||||
exit(); | |||||
} else if ($dopost == "saveedit") { | |||||
$title = isset($title)? HtmlReplace($title, -1) : ''; | |||||
$description = isset($description)? HtmlReplace($description, -1) : ''; | |||||
$prompt = isset($prompt)? $prompt : ''; | |||||
$dfprompt = isset($dfprompt)? $dfprompt : ''; | |||||
$query = "UPDATE `#@__ai_prompt` SET title='$title',description='$description',prompt='$prompt',dfprompt='$dfprompt' WHERE id='$id' "; | |||||
$dsql->ExecuteNoneQuery($query); | |||||
ShowMsg("成功修改一个提示词", "ai_prompt_edit.php?id={$myPrompt['id']}"); | |||||
exit(); | |||||
} | |||||
include DedeInclude('templets/ai_prompt_view.htm'); | |||||
?> |
@@ -48,7 +48,7 @@ | |||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
<td>接口地址</td> | <td>接口地址</td> | ||||
<td><input type="text" name="baseurl" id="baseurl" class="admin-input-lg" required></td> | |||||
<td><input type="text" name="baseurl" id="baseurl" class="admin-input-lg" required>(需兼容OpenAI接口标准)</td> | |||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
<td colspan="2" align="center"> | <td colspan="2" align="center"> | ||||
@@ -46,7 +46,7 @@ | |||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
<td>接口地址</td> | <td>接口地址</td> | ||||
<td><input type="text" name="baseurl" id="baseurl" class="admin-input-lg" value="<?php echo $myAI['baseurl']?>" required></td> | |||||
<td><input type="text" name="baseurl" id="baseurl" class="admin-input-lg" value="<?php echo $myAI['baseurl']?>" required>(需兼容OpenAI接口标准)</td> | |||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
<td colspan="2"> | <td colspan="2"> | ||||
@@ -61,6 +61,7 @@ | |||||
<td scope="col">Model</td> | <td scope="col">Model</td> | ||||
<td scope="col">名称</td> | <td scope="col">名称</td> | ||||
<td scope="col" width="30%">描述</td> | <td scope="col" width="30%">描述</td> | ||||
<td scope="col">排序</td> | |||||
<td scope="col">操作</td> | <td scope="col">操作</td> | ||||
</tr> | </tr> | ||||
</thead> | </thead> | ||||
@@ -71,6 +72,7 @@ | |||||
<td>{dede:field.model function='dede_htmlspecialchars(@me)'/}</td> | <td>{dede:field.model function='dede_htmlspecialchars(@me)'/}</td> | ||||
<td>{dede:field.title function='dede_htmlspecialchars(@me)'/}</td> | <td>{dede:field.title function='dede_htmlspecialchars(@me)'/}</td> | ||||
<td>{dede:field.description/}</td> | <td>{dede:field.description/}</td> | ||||
<td>{dede:field.sortrank/}</td> | |||||
<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/}" 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> | <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> | ||||
@@ -17,7 +17,7 @@ | |||||
<div class="card shadow-sm mb-3"> | <div class="card shadow-sm mb-3"> | ||||
<div class="card-body"> | <div class="card-body"> | ||||
<form name="formsearch"> | <form name="formsearch"> | ||||
<input type="text" name="cip" id="cip" placeholder="请输入ip地址" class="admin-input-lg mr-2"> | |||||
<input type="text" name="cip" id="cip" placeholder="请输入ip地址" class="admin-input-lg mr-2" value="<?php echo empty($cip)? '' : $cip?>"> | |||||
<select name="adminid" id="adminid" class="admin-input-sm mr-2"> | <select name="adminid" id="adminid" class="admin-input-sm mr-2"> | ||||
<option value="0" selected>全部</option> | <option value="0" selected>全部</option> | ||||
<?php echo $adminlist?> | <?php echo $adminlist?> | ||||
@@ -29,7 +29,8 @@ | |||||
<option value="30">30天以内</option> | <option value="30">30天以内</option> | ||||
<option value="60">60天以内</option> | <option value="60">60天以内</option> | ||||
</select> | </select> | ||||
<button type="submit"class="btn btn-success btn-sm">搜索</button> | |||||
<button type="submit" class="btn btn-success btn-sm">搜索</button> | |||||
<a href="ai_log_main.php" class="btn btn-outline-success btn-sm">重置</a> | |||||
</form> | </form> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
@@ -48,6 +49,8 @@ | |||||
<td scope="col">提示词</td> | <td scope="col">提示词</td> | ||||
<td scope="col">地址</td> | <td scope="col">地址</td> | ||||
<td scope="col">时间</td> | <td scope="col">时间</td> | ||||
<td scope="col">提示</td> | |||||
<td scope="col">补全</td> | |||||
<td scope="col">消耗</td> | <td scope="col">消耗</td> | ||||
</tr> | </tr> | ||||
<thead> | <thead> | ||||
@@ -61,11 +64,9 @@ | |||||
<td><input type="text" name="t0" value="{dede:field.prompt/}" class="admin-input-lg"></td> | <td><input type="text" name="t0" value="{dede:field.prompt/}" class="admin-input-lg"></td> | ||||
<td>{dede:field.cip/}</td> | <td>{dede:field.cip/}</td> | ||||
<td>{dede:field.dtime function="MyDate('y/m/d H:i:s',@me)"/}</td> | <td>{dede:field.dtime function="MyDate('y/m/d H:i:s',@me)"/}</td> | ||||
<td> | |||||
提示:{dede:field.prompt_tokens/} <br/> | |||||
对话:{dede:field.completion_tokens/} <br/> | |||||
总计:{dede:field.total_tokens/} | |||||
</td> | |||||
<td>{dede:field.prompt_tokens/}</td> | |||||
<td>{dede:field.completion_tokens/}</td> | |||||
<td>{dede:field.total_tokens/}</td> | |||||
</tr> | </tr> | ||||
{/dede:datalist} | {/dede:datalist} | ||||
<tr> | <tr> | ||||
@@ -1,4 +1,4 @@ | |||||
{dede:config.pagesize value='30'/} | |||||
{dede:config.pagesize value='15'/} | |||||
<!DOCTYPE html> | <!DOCTYPE html> | ||||
<html> | <html> | ||||
@@ -56,6 +56,10 @@ | |||||
<td>名称</td> | <td>名称</td> | ||||
<td><input type="text" name="title" id="title" class="admin-input-lg" required></td> | <td><input type="text" name="title" id="title" class="admin-input-lg" required></td> | ||||
</tr> | </tr> | ||||
<tr> | |||||
<td>排序</td> | |||||
<td><input type="text" name="sortrank" id="sortrank" class="admin-input-lg" required>(由低到高)</td> | |||||
</tr> | |||||
<tr> | <tr> | ||||
<td>描述</td> | <td>描述</td> | ||||
<td><textarea name="description" id="description" class="admin-textarea-sm"></textarea></td> | <td><textarea name="description" id="description" class="admin-textarea-sm"></textarea></td> | ||||
@@ -41,6 +41,10 @@ | |||||
<td>名称</td> | <td>名称</td> | ||||
<td><input type="text" name="title" id="title" value="<?php echo $myModel['title']?>" class="admin-input-lg" required></td> | <td><input type="text" name="title" id="title" value="<?php echo $myModel['title']?>" class="admin-input-lg" required></td> | ||||
</tr> | </tr> | ||||
<tr> | |||||
<td>排序</td> | |||||
<td><input type="text" name="sortrank" id="sortrank" value="<?php echo $myModel['sortrank']?>" class="admin-input-lg" required>(由低到高)</td> | |||||
</tr> | |||||
<tr> | <tr> | ||||
<td>描述</td> | <td>描述</td> | ||||
<td><textarea name="description" id="description" class="admin-textarea-sm"><?php echo $myModel['description']?></textarea></td> | <td><textarea name="description" id="description" class="admin-textarea-sm"><?php echo $myModel['description']?></textarea></td> | ||||
@@ -36,6 +36,7 @@ | |||||
<td scope="col">名称</td> | <td scope="col">名称</td> | ||||
<td scope="col">大模型</td> | <td scope="col">大模型</td> | ||||
<td scope="col" width="30%">描述</td> | <td scope="col" width="30%">描述</td> | ||||
<td scope="col">排序</td> | |||||
<td scope="col">操作</td> | <td scope="col">操作</td> | ||||
</tr> | </tr> | ||||
</thead> | </thead> | ||||
@@ -47,6 +48,7 @@ | |||||
<td>{dede:field.title function='dede_htmlspecialchars(@me)'/}</td> | <td>{dede:field.title function='dede_htmlspecialchars(@me)'/}</td> | ||||
<td>{dede:field.aititle/}</td> | <td>{dede:field.aititle/}</td> | ||||
<td>{dede:field.description/}</td> | <td>{dede:field.description/}</td> | ||||
<td>{dede:field.sortrank/}</td> | |||||
<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/}" 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> | <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> | ||||
@@ -48,7 +48,7 @@ | |||||
class="admin-textarea-sm"></textarea></td> | class="admin-textarea-sm"></textarea></td> | ||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
<td>提示词规则</td> | |||||
<td>系统提示词</td> | |||||
<td> | <td> | ||||
<textarea name="prompt" id="prompt" class="admin-textarea-sm" style="height: 200px;"></textarea>(AI系统提示词) | <textarea name="prompt" id="prompt" class="admin-textarea-sm" style="height: 200px;"></textarea>(AI系统提示词) | ||||
</td> | </td> | ||||
@@ -55,7 +55,7 @@ | |||||
class="admin-textarea-sm"><?php echo $myPrompt['description']?></textarea></td> | class="admin-textarea-sm"><?php echo $myPrompt['description']?></textarea></td> | ||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
<td>提示词规则</td> | |||||
<td>系统提示词</td> | |||||
<td> | <td> | ||||
<textarea name="prompt" id="prompt" class="admin-textarea-sm" style="height: 200px;"><?php echo $myPrompt['prompt']?></textarea> | <textarea name="prompt" id="prompt" class="admin-textarea-sm" style="height: 200px;"><?php echo $myPrompt['prompt']?></textarea> | ||||
</td> | </td> | ||||
@@ -56,6 +56,8 @@ | |||||
class="btn btn-light btn-sm"><i class="fa fa-pencil-square" | class="btn btn-light btn-sm"><i class="fa fa-pencil-square" | ||||
title="修改"></i></a> | title="修改"></i></a> | ||||
<?php if($fields['issystem']==0) {?> | <?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" | <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> | class="btn btn-danger btn-sm"><i class="fa fa-trash" title="删除"></i></a> | ||||
<?php }?> | <?php }?> | ||||
@@ -0,0 +1,131 @@ | |||||
<!DOCTYPE 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"> | |||||
<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> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<script> | |||||
let eventSource; // 保存 EventSource 实例 | |||||
let modelid = 0; | |||||
$("#btnAIAction").click(async function() { | |||||
let prompt = document.getElementById("prompt").value; | |||||
let modelid = document.getElementById("modelid").value; | |||||
let req = await fetch(`api.php?action=get_ai_server&pname=<?php echo $myPrompt['pname']?>&modelid=${modelid}&prompt=${prompt}`); | |||||
let resp = await req.json(); | |||||
if (resp.code !== 0) { | |||||
ShowMsg("获取服务器地址失败"); | |||||
return | |||||
} | |||||
let eventSource = new EventSource(resp.data); | |||||
// 新增状态跟踪变量 | |||||
let currentKey = null; | |||||
let tagBuffer = ""; | |||||
let isClosingTag = false; | |||||
$("#btnAI").attr("disabled", "disabled"); | |||||
prompt = ""; | |||||
let lastChar = ""; | |||||
const input = document.querySelector(`[name="result"]`); | |||||
input.value = ""; | |||||
eventSource.onmessage = (event) => { | |||||
$(input).prop("disabled", true).addClass("disabled"); | |||||
const msg = event.data; | |||||
input.value += msg; | |||||
}; | |||||
eventSource.onerror = (error) => { | |||||
if (error.target.readyState === EventSource.CONNECTING) { | |||||
ShowMsg("连接失败,请确保您已开启并正确配置了DedeBIZ智能助手服务器。 <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) { | |||||
ShowMsg(error.data); | |||||
} | |||||
$("#btnAI").prop("disabled", false); | |||||
eventSource.close(); | |||||
}; | |||||
// 监听特定事件 "close" | |||||
eventSource.addEventListener('close', (event) => { | |||||
console.log('SSE connection closed:', event.data); | |||||
$("#btnAI").prop("disabled", false); | |||||
$(input).prop("disabled", false); | |||||
eventSource.close(); // 关闭连接 | |||||
}); | |||||
}); | |||||
</script> | |||||
</body> | |||||
</html> |
@@ -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">AI发布文档</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">智能助手</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,7 +227,7 @@ | |||||
<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">AI发布文档</h5> | |||||
<h5 class="modal-title">智能助手-发布文档</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"> | ||||
@@ -236,7 +236,7 @@ | |||||
<textarea class="admin-input-sm" style="width: 100%;height: 100px;" id="prompt" placeholder="我需要写一篇介绍穆云智能科技公司的文章"></textarea><br/> | <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%;"> | 选择模型:<select id="modelid" class="admin-input-sm" style="width: 100%;"> | ||||
<?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 id"); | |||||
$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()) { | ||||
?> | ?> | ||||
@@ -383,10 +383,21 @@ | |||||
}; | }; | ||||
eventSource.onerror = (error) => { | eventSource.onerror = (error) => { | ||||
console.log("连接已关闭"); | |||||
if (error.target.readyState === EventSource.CONNECTING) { | |||||
ShowMsg("连接失败,请确保您已开启并正确配置了DedeBIZ智能助手服务器。 <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) { | |||||
ShowMsg(error.data); | |||||
} | |||||
$("#btnAI").prop("disabled", false); | $("#btnAI").prop("disabled", false); | ||||
eventSource.close(); | eventSource.close(); | ||||
}; | }; | ||||
// 监听特定事件 "close" | |||||
eventSource.addEventListener('close', (event) => { | |||||
console.log('SSE connection closed:', event.data); | |||||
$("#btnAI").prop("disabled", false); | |||||
eventSource.close(); // 关闭连接 | |||||
}); | |||||
}); | }); | ||||
</script> | </script> | ||||
</body> | </body> |
@@ -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">AI修改文档</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">智能助手</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,7 +231,7 @@ | |||||
<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">AI修改文档</h5> | |||||
<h5 class="modal-title">智能助手-修改文档</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"> | ||||
@@ -240,7 +240,7 @@ | |||||
<textarea class="admin-input-sm" style="width: 100%;height: 100px;" id="prompt" placeholder="填写您需要对当前的内容进行怎样的优化,例如:我需要对当前文章就行润色,内容轻松活泼些,不要出现错别字"></textarea><br/> | <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%;"> | 选择模型:<select id="modelid" class="admin-input-sm" style="width: 100%;"> | ||||
<?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 id"); | |||||
$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()) { | ||||
?> | ?> | ||||
@@ -386,10 +386,21 @@ | |||||
}; | }; | ||||
eventSource.onerror = (error) => { | eventSource.onerror = (error) => { | ||||
console.log("连接已关闭"); | |||||
if (error.target.readyState === EventSource.CONNECTING) { | |||||
ShowMsg("连接失败,请确保您已开启并正确配置了DedeBIZ智能助手服务器。 <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) { | |||||
ShowMsg(error.data); | |||||
} | |||||
$("#btnAI").prop("disabled", false); | $("#btnAI").prop("disabled", false); | ||||
eventSource.close(); | eventSource.close(); | ||||
}; | }; | ||||
// 监听特定事件 "close" | |||||
eventSource.addEventListener('close', (event) => { | |||||
console.log('SSE connection closed:', event.data); | |||||
$("#btnAI").prop("disabled", false); | |||||
eventSource.close(); // 关闭连接 | |||||
}); | |||||
}); | }); | ||||
</script> | </script> | ||||
</body> | </body> |
@@ -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">AI创建栏目</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">智能助手</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,7 +297,7 @@ | |||||
<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">AI创建栏目</h5> | |||||
<h5 class="modal-title">智能助手-创建栏目</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"> | ||||
@@ -306,7 +306,7 @@ | |||||
<textarea class="admin-input-sm" style="width: 100%;height: 100px;" id="prompt" placeholder="填写您需要创建栏目的要求,例如:我需要创建一个介绍穆云智能科技公司的栏目"></textarea><br/> | <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%;"> | 选择模型:<select id="modelid" class="admin-input-sm" style="width: 100%;"> | ||||
<?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 id"); | |||||
$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()) { | ||||
?> | ?> | ||||
@@ -523,10 +523,21 @@ | |||||
}; | }; | ||||
eventSource.onerror = (error) => { | eventSource.onerror = (error) => { | ||||
console.log("连接已关闭"); | |||||
if (error.target.readyState === EventSource.CONNECTING) { | |||||
ShowMsg("连接失败,请确保您已开启并正确配置了DedeBIZ智能助手服务器。 <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) { | |||||
ShowMsg(error.data); | |||||
} | |||||
$("#btnAI").prop("disabled", false); | $("#btnAI").prop("disabled", false); | ||||
eventSource.close(); | eventSource.close(); | ||||
}; | }; | ||||
// 监听特定事件 "close" | |||||
eventSource.addEventListener('close', (event) => { | |||||
console.log('SSE connection closed:', event.data); | |||||
$("#btnAI").prop("disabled", false); | |||||
eventSource.close(); // 关闭连接 | |||||
}); | |||||
}); | }); | ||||
</script> | </script> | ||||
</body> | </body> |
@@ -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">AI批量创建</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">智能助手</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,7 +194,7 @@ | |||||
<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">AI批量创建栏目</h5> | |||||
<h5 class="modal-title">智能助手-批量创建栏目</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"> | ||||
@@ -203,7 +203,7 @@ | |||||
<textarea class="admin-input-sm" style="width: 100%;height: 100px;" id="prompt" placeholder="填写您站点规划,AI帮您自动规划栏目,例如:我需要创建一个企业信息展示类站点"></textarea><br/> | <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%;"> | 选择模型:<select id="modelid" class="admin-input-sm" style="width: 100%;"> | ||||
<?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 id"); | |||||
$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()) { | ||||
?> | ?> | ||||
@@ -389,11 +389,21 @@ | |||||
}; | }; | ||||
eventSource.onerror = (error) => { | eventSource.onerror = (error) => { | ||||
console.log(error); | |||||
console.log("连接已关闭"); | |||||
if (error.target.readyState === EventSource.CONNECTING) { | |||||
ShowMsg("连接失败,请确保您已开启并正确配置了DedeBIZ智能助手服务器。 <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) { | |||||
ShowMsg(error.data); | |||||
} | |||||
$("#btnAI").prop("disabled", false); | $("#btnAI").prop("disabled", false); | ||||
eventSource.close(); | eventSource.close(); | ||||
}; | }; | ||||
// 监听特定事件 "close" | |||||
eventSource.addEventListener('close', (event) => { | |||||
console.log('SSE connection closed:', event.data); | |||||
$("#btnAI").prop("disabled", false); | |||||
eventSource.close(); // 关闭连接 | |||||
}); | |||||
}); | }); | ||||
</script> | </script> | ||||
</body> | </body> |
@@ -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">AI修改栏目</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">智能助手</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,7 +327,7 @@ | |||||
<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">AI修改栏目</h5> | |||||
<h5 class="modal-title">智能助手-修改栏目</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"> | ||||
@@ -336,7 +336,7 @@ | |||||
<textarea class="admin-input-sm" style="width: 100%;height: 100px;" id="prompt" placeholder="填写您需要修改栏目的要求,例如:我需要栏目信息内容更丰富一些"></textarea><br/> | <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%;"> | 选择模型:<select id="modelid" class="admin-input-sm" style="width: 100%;"> | ||||
<?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 id"); | |||||
$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()) { | ||||
?> | ?> | ||||
@@ -553,10 +553,21 @@ | |||||
}; | }; | ||||
eventSource.onerror = (error) => { | eventSource.onerror = (error) => { | ||||
console.log("连接已关闭"); | |||||
if (error.target.readyState === EventSource.CONNECTING) { | |||||
ShowMsg("连接失败,请确保您已开启并正确配置了DedeBIZ智能助手服务器。 <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) { | |||||
ShowMsg(error.data); | |||||
} | |||||
$("#btnAI").prop("disabled", false); | $("#btnAI").prop("disabled", false); | ||||
eventSource.close(); | eventSource.close(); | ||||
}; | }; | ||||
// 监听特定事件 "close" | |||||
eventSource.addEventListener('close', (event) => { | |||||
console.log('SSE connection closed:', event.data); | |||||
$("#btnAI").prop("disabled", false); | |||||
eventSource.close(); // 关闭连接 | |||||
}); | |||||
}); | }); | ||||
</script> | </script> | ||||
</body> | </body> |