Feature: 调整AI聊天机器人的形象为“AI小班长”并更新了军人卡通风格头像
This commit is contained in:
@@ -68,7 +68,7 @@ class ChatBotController extends Controller
|
|||||||
'id' => $this->chatState->nextMessageId($roomId),
|
'id' => $this->chatState->nextMessageId($roomId),
|
||||||
'room_id' => $roomId,
|
'room_id' => $roomId,
|
||||||
'from_user' => $user->username,
|
'from_user' => $user->username,
|
||||||
'to_user' => 'AI小助手',
|
'to_user' => 'AI小班长',
|
||||||
'content' => $message,
|
'content' => $message,
|
||||||
'is_secret' => false,
|
'is_secret' => false,
|
||||||
'font_color' => '#000000',
|
'font_color' => '#000000',
|
||||||
@@ -85,7 +85,7 @@ class ChatBotController extends Controller
|
|||||||
$botMsg = [
|
$botMsg = [
|
||||||
'id' => $this->chatState->nextMessageId($roomId),
|
'id' => $this->chatState->nextMessageId($roomId),
|
||||||
'room_id' => $roomId,
|
'room_id' => $roomId,
|
||||||
'from_user' => 'AI小助手',
|
'from_user' => 'AI小班长',
|
||||||
'to_user' => $user->username,
|
'to_user' => $user->username,
|
||||||
'content' => $result['reply'],
|
'content' => $result['reply'],
|
||||||
'is_secret' => false,
|
'is_secret' => false,
|
||||||
|
|||||||
@@ -548,7 +548,7 @@ class ChatController extends Controller
|
|||||||
* 聊天获取魅力值(方案 B:每条消息触发,Redis 每小时上限控制)
|
* 聊天获取魅力值(方案 B:每条消息触发,Redis 每小时上限控制)
|
||||||
*
|
*
|
||||||
* 异性聊天给更多魅力,同性少一些。
|
* 异性聊天给更多魅力,同性少一些。
|
||||||
* 系统用户(如 AI小助手)不触发魅力奖励。
|
* 系统用户(如 AI小班长)不触发魅力奖励。
|
||||||
* 发送者和接收者都会获得对应魅力值。
|
* 发送者和接收者都会获得对应魅力值。
|
||||||
*
|
*
|
||||||
* @param mixed $sender 发送消息的用户模型
|
* @param mixed $sender 发送消息的用户模型
|
||||||
@@ -557,7 +557,7 @@ class ChatController extends Controller
|
|||||||
private function grantChatCharm(mixed $sender, string $toUsername): void
|
private function grantChatCharm(mixed $sender, string $toUsername): void
|
||||||
{
|
{
|
||||||
// 系统用户不参与魅力计算
|
// 系统用户不参与魅力计算
|
||||||
$systemNames = ['大家', '系统传音', '系统公告', '钓鱼播报', '星海小博士', 'AI小助手', '送花播报'];
|
$systemNames = ['大家', '系统传音', '系统公告', '钓鱼播报', '星海小博士', 'AI小班长', '送花播报'];
|
||||||
if (in_array($toUsername, $systemNames)) {
|
if (in_array($toUsername, $systemNames)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class AiChatService
|
|||||||
* 系统提示词(机器人人设)
|
* 系统提示词(机器人人设)
|
||||||
*/
|
*/
|
||||||
private const SYSTEM_PROMPT = <<<'PROMPT'
|
private const SYSTEM_PROMPT = <<<'PROMPT'
|
||||||
你是一个聊天室小助手,名叫"AI小助手"。你的工作是陪用户聊天,回答他们的问题。
|
你是一个聊天室小助手,名叫"AI小班长"。你的工作是陪用户聊天,回答他们的问题。
|
||||||
要求:
|
要求:
|
||||||
1. 始终使用中文回复
|
1. 始终使用中文回复
|
||||||
2. 语气活泼友好,像朋友一样交流
|
2. 语气活泼友好,像朋友一样交流
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 60 KiB |
@@ -97,18 +97,18 @@
|
|||||||
botDiv.className = 'user-item';
|
botDiv.className = 'user-item';
|
||||||
botDiv.innerHTML = `
|
botDiv.innerHTML = `
|
||||||
<img class="user-head" src="/images/headface/1.gif" onerror="this.src='/images/headface/1.gif'">
|
<img class="user-head" src="/images/headface/1.gif" onerror="this.src='/images/headface/1.gif'">
|
||||||
<span class="user-name">AI小助手</span><span style="font-size:12px; margin-left:2px;" title="聊天机器人">🤖</span>
|
<span class="user-name">AI小班长</span><span style="font-size:12px; margin-left:2px;" title="聊天机器人">🤖</span>
|
||||||
`;
|
`;
|
||||||
botDiv.onclick = () => {
|
botDiv.onclick = () => {
|
||||||
toUserSelect.value = 'AI小助手';
|
toUserSelect.value = 'AI小班长';
|
||||||
document.getElementById('content').focus();
|
document.getElementById('content').focus();
|
||||||
};
|
};
|
||||||
userList.appendChild(botDiv);
|
userList.appendChild(botDiv);
|
||||||
|
|
||||||
// 在发言对象下拉框中也添加 AI 小助手
|
// 在发言对象下拉框中也添加 AI 小助手
|
||||||
let botOption = document.createElement('option');
|
let botOption = document.createElement('option');
|
||||||
botOption.value = 'AI小助手';
|
botOption.value = 'AI小班长';
|
||||||
botOption.textContent = '🤖 AI小助手';
|
botOption.textContent = '🤖 AI小班长';
|
||||||
toUserSelect.appendChild(botOption);
|
toUserSelect.appendChild(botOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,7 +217,7 @@
|
|||||||
const timeStr = msg.sent_at || '';
|
const timeStr = msg.sent_at || '';
|
||||||
|
|
||||||
// 系统用户名列表(不可被选为聊天对象)
|
// 系统用户名列表(不可被选为聊天对象)
|
||||||
const systemUsers = ['钓鱼播报', '星海小博士', '系统传音', '系统公告', 'AI小助手', '送花播报'];
|
const systemUsers = ['钓鱼播报', '星海小博士', '系统传音', '系统公告', 'AI小班长', '送花播报'];
|
||||||
// 用户名(单击切换发言对象,双击查看资料;系统用户仅显示文本)
|
// 用户名(单击切换发言对象,双击查看资料;系统用户仅显示文本)
|
||||||
const clickableUser = (uName, color) => {
|
const clickableUser = (uName, color) => {
|
||||||
if (systemUsers.includes(uName)) {
|
if (systemUsers.includes(uName)) {
|
||||||
@@ -243,7 +243,7 @@
|
|||||||
html =
|
html =
|
||||||
`<div style="font-size: 14px; font-weight: bold; color: #dc2626;">${msg.content}</div>`;
|
`<div style="font-size: 14px; font-weight: bold; color: #dc2626;">${msg.content}</div>`;
|
||||||
} else {
|
} else {
|
||||||
// 其他系统用户(钓鱼播报、送花播报、AI小助手等):普通样式
|
// 其他系统用户(钓鱼播报、送花播报、AI小班长等):普通样式
|
||||||
let giftHtml = '';
|
let giftHtml = '';
|
||||||
if (msg.gift_image) {
|
if (msg.gift_image) {
|
||||||
giftHtml =
|
giftHtml =
|
||||||
@@ -555,7 +555,7 @@
|
|||||||
|
|
||||||
// 如果发言对象是 AI 小助手,走专用机器人 API
|
// 如果发言对象是 AI 小助手,走专用机器人 API
|
||||||
const toUser = formData.get('to_user');
|
const toUser = formData.get('to_user');
|
||||||
if (toUser === 'AI小助手') {
|
if (toUser === 'AI小班长') {
|
||||||
contentInput.value = '';
|
contentInput.value = '';
|
||||||
contentInput.focus();
|
contentInput.focus();
|
||||||
await sendToChatBot(content);
|
await sendToChatBot(content);
|
||||||
@@ -1065,7 +1065,7 @@
|
|||||||
// 延迟显示"思考中",让广播消息先到达
|
// 延迟显示"思考中",让广播消息先到达
|
||||||
const thinkDiv = document.createElement('div');
|
const thinkDiv = document.createElement('div');
|
||||||
thinkDiv.className = 'msg-line';
|
thinkDiv.className = 'msg-line';
|
||||||
thinkDiv.innerHTML = '<span style="color: #16a34a;">🤖 <b>AI小助手</b> 正在思考中...</span>';
|
thinkDiv.innerHTML = '<span style="color: #16a34a;">🤖 <b>AI小班长</b> 正在思考中...</span>';
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
container2.appendChild(thinkDiv);
|
container2.appendChild(thinkDiv);
|
||||||
if (autoScroll) container2.scrollTop = container2.scrollHeight;
|
if (autoScroll) container2.scrollTop = container2.scrollHeight;
|
||||||
@@ -1094,14 +1094,14 @@
|
|||||||
if (!res.ok || data.status !== 'success') {
|
if (!res.ok || data.status !== 'success') {
|
||||||
const errDiv = document.createElement('div');
|
const errDiv = document.createElement('div');
|
||||||
errDiv.className = 'msg-line';
|
errDiv.className = 'msg-line';
|
||||||
errDiv.innerHTML = `<span style="color: #dc2626;">🤖【AI小助手】${data.message || '回复失败,请稍后重试'}</span>`;
|
errDiv.innerHTML = `<span style="color: #dc2626;">🤖【AI小班长】${data.message || '回复失败,请稍后重试'}</span>`;
|
||||||
container.appendChild(errDiv);
|
container.appendChild(errDiv);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
thinkDiv.remove();
|
thinkDiv.remove();
|
||||||
const errDiv = document.createElement('div');
|
const errDiv = document.createElement('div');
|
||||||
errDiv.className = 'msg-line';
|
errDiv.className = 'msg-line';
|
||||||
errDiv.innerHTML = '<span style="color: #dc2626;">🤖【AI小助手】网络连接错误,请稍后重试</span>';
|
errDiv.innerHTML = '<span style="color: #dc2626;">🤖【AI小班长】网络连接错误,请稍后重试</span>';
|
||||||
container.appendChild(errDiv);
|
container.appendChild(errDiv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user