many ok
This commit is contained in:
@@ -93,7 +93,6 @@ class ASEngineClient:
|
|||||||
@self.sio.on(route, namespace=self.namespace)
|
@self.sio.on(route, namespace=self.namespace)
|
||||||
def on_route_message(data, _route=route):
|
def on_route_message(data, _route=route):
|
||||||
if not self.connected: return
|
if not self.connected: return
|
||||||
print(f"Received message on route '{_route}': {data}")
|
|
||||||
route_info = self.routes.get(_route)
|
route_info = self.routes.get(_route)
|
||||||
if not route_info:
|
if not route_info:
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -224,6 +224,7 @@ class ChatManager:
|
|||||||
return record
|
return record
|
||||||
|
|
||||||
def stop(self, key: str, grace_seconds: int = 5) -> bool:
|
def stop(self, key: str, grace_seconds: int = 5) -> bool:
|
||||||
|
return True # code-like 不需要杀进程
|
||||||
with self._lock:
|
with self._lock:
|
||||||
rec = self._procs.pop(key, None)
|
rec = self._procs.pop(key, None)
|
||||||
|
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ class AgentNamespace(Namespace):
|
|||||||
|
|
||||||
user_uuid2chatmanager = ex["user_uuid2chatmanager"]
|
user_uuid2chatmanager = ex["user_uuid2chatmanager"]
|
||||||
user_uuid2ase_client = ex["user_uuid2ase_client"]
|
user_uuid2ase_client = ex["user_uuid2ase_client"]
|
||||||
# if (user_uuid2ase_client[user_uuid] is not None and user_uuid2ase_client[user_uuid].connected):
|
if (user_uuid2ase_client.get(user_uuid,None) is not None and user_uuid2ase_client[user_uuid].connected):
|
||||||
# user_uuid2ase_client[user_uuid].disconnect()
|
user_uuid2ase_client[user_uuid].disconnect()
|
||||||
chatmanager = user_uuid2chatmanager[user_uuid]
|
chatmanager = user_uuid2chatmanager[user_uuid]
|
||||||
chatmanager.function_manager.add_function(judge, {'course_id': course_id, 'root_path': f'/home/{user_id}/{course_id}/{chapter_name}/{lesson_name}'})
|
chatmanager.function_manager.add_function(judge, {'course_id': course_id, 'root_path': f'/home/{user_id}/{course_id}/{chapter_name}/{lesson_name}'})
|
||||||
chatmanager.function_manager.add_function(next_chapter, {'user_uuid': user_uuid})
|
chatmanager.function_manager.add_function(next_chapter, {'user_uuid': user_uuid})
|
||||||
@@ -90,11 +90,17 @@ class AgentNamespace(Namespace):
|
|||||||
entry=self,
|
entry=self,
|
||||||
init_data={'room': user_uuid}
|
init_data={'room': user_uuid}
|
||||||
)
|
)
|
||||||
|
user_uuid2ase_client[user_uuid].register_route_with_entry(
|
||||||
|
route='dialog-hint',
|
||||||
|
callback=self.receive_ase_message_hint,
|
||||||
|
entry=self,
|
||||||
|
init_data={'room': user_uuid}
|
||||||
|
)
|
||||||
user_uuid2ase_client[user_uuid].register_route_with_entry(
|
user_uuid2ase_client[user_uuid].register_route_with_entry(
|
||||||
route='voice_out',
|
route='voice_out',
|
||||||
callback=self.receive_ase_voice_out,
|
callback=self.receive_ase_voice_out,
|
||||||
entry=self,
|
entry=self,
|
||||||
init_data={'room': user_uuid}
|
init_data={'room': user_uuid}
|
||||||
)
|
)
|
||||||
user_uuid2ase_client[user_uuid].register_route_with_entry(
|
user_uuid2ase_client[user_uuid].register_route_with_entry(
|
||||||
route='judge',
|
route='judge',
|
||||||
@@ -178,10 +184,17 @@ class AgentNamespace(Namespace):
|
|||||||
client_entry.chatmanager.chat_historys.append({'role': 'assistant', 'content': data['data']})
|
client_entry.chatmanager.chat_historys.append({'role': 'assistant', 'content': data['data']})
|
||||||
namespace_entry.emit('message', data['data'], room=init_data['room'], namespace='/agent')
|
namespace_entry.emit('message', data['data'], room=init_data['room'], namespace='/agent')
|
||||||
|
|
||||||
|
def receive_ase_message_hint(client_entry: HSAEngineClient, namespace_entry: Namespace, data, init_data):
|
||||||
|
print("receive_ase_message_hint", data)
|
||||||
|
namespace_entry.emit('message-hint', data['data'], room=init_data['room'], namespace='/agent')
|
||||||
|
|
||||||
#接受语音信息
|
#接受语音信息
|
||||||
def receive_ase_voice_out(client_entry: HSAEngineClient, namespace_entry: Namespace, data, init_data):
|
def receive_ase_voice_out(client_entry: HSAEngineClient, namespace_entry: Namespace, data, init_data):
|
||||||
print("receive_ase_voice_out", data)
|
namespace_entry.emit('voiceMessage', data['data'], room=init_data['room'], namespace='/agent')
|
||||||
namespace_entry.emit('voiceMessage', data, room=init_data['room'], namespace='/agent')
|
|
||||||
|
def receive_ase_process(client_entry: HSAEngineClient, namespace_entry: Namespace, data, init_data):
|
||||||
|
namespace_entry.emit('process', data['data'], room=init_data['room'], namespace='/agent')
|
||||||
|
|
||||||
|
|
||||||
def receive_ase_judge(client_entry: HSAEngineClient, namespace_entry: Namespace, data, init_data):
|
def receive_ase_judge(client_entry: HSAEngineClient, namespace_entry: Namespace, data, init_data):
|
||||||
print("receive_ase_judge", data)
|
print("receive_ase_judge", data)
|
||||||
@@ -200,10 +213,6 @@ class AgentNamespace(Namespace):
|
|||||||
user.set_course_progress(chatmanager.chat_historys, chatmanager.scores, chatmanager.material_id, chatmanager.chapter_name, chatmanager.lesson_name)
|
user.set_course_progress(chatmanager.chat_historys, chatmanager.scores, chatmanager.material_id, chatmanager.chapter_name, chatmanager.lesson_name)
|
||||||
chatmanager.load_next_chapter()
|
chatmanager.load_next_chapter()
|
||||||
|
|
||||||
def receive_ase_process(client_entry: HSAEngineClient, namespace_entry: Namespace, data, init_data):
|
|
||||||
print("receive_ase_process", data)
|
|
||||||
namespace_entry.emit('process', data, room=init_data['room'], namespace='/agent')
|
|
||||||
pass
|
|
||||||
|
|
||||||
def on_initiative(self,data): # 主动call
|
def on_initiative(self,data): # 主动call
|
||||||
print("User active function call")
|
print("User active function call")
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
.floating-window {
|
.floating-window {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 10%; /* 距离页面顶部 10% */
|
top: 8%; /* 距离页面顶部 8% */
|
||||||
right: 5%; /* 距离页面右边 5%,固定在右侧 */
|
right: 1%; /* 距离页面右边 1%,固定在右侧 */
|
||||||
width: 10vw; /* 根据视窗宽度动态调整 */
|
width: 10vw; /* 根据视窗宽度动态调整 */
|
||||||
height: 7vh; /* 根据视窗高度动态调整 */
|
height: 8vh; /* 根据视窗高度动态调整 */
|
||||||
max-width: 300px; /* 最大宽度 */
|
max-width: 300px; /* 最大宽度 */
|
||||||
max-height: 200px; /* 最大高度 */
|
max-height: 200px; /* 最大高度 */
|
||||||
min-width: 100px; /* 最小宽度 */
|
min-width: 100px; /* 最小宽度 */
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
z-index: 999;
|
z-index: 999;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header {
|
.floating-header {
|
||||||
background-color: #f0f0f0;
|
background-color: #f0f0f0;
|
||||||
cursor: move;
|
cursor: move;
|
||||||
height: 10%; /* 让头部高度为浮动窗口高度的10% */
|
height: 10%; /* 让头部高度为浮动窗口高度的10% */
|
||||||
@@ -27,44 +27,49 @@
|
|||||||
width: 30px;
|
width: 30px;
|
||||||
height: 100%; /* 占满头部的高度 */
|
height: 100%; /* 占满头部的高度 */
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 1.2vw; /* 字体大小根据窗口宽度变化 */
|
font-size: 0.8vw; /* 字体大小根据窗口宽度变化 */
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.content {
|
.entry-content {
|
||||||
padding-top: 10%; /* 留出顶部空间,防止内容与头部重叠 */
|
padding-top: 5%; /* 留出顶部空间,防止内容与头部重叠 */
|
||||||
height: 90%; /* 占剩余空间 */
|
height: 95%; /* 占剩余空间 */
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
font-size: 0.8vw;
|
||||||
}
|
}
|
||||||
|
|
||||||
.entry {
|
.entry {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
height: 15%; /* 每个条目的高度占浮动窗口高度的15% */
|
height: 33%; /* 每个条目的高度占浮动窗口高度的15% */
|
||||||
border-bottom: 1px solid #e0e0e0;
|
border-bottom: 1px solid #e0e0e0;
|
||||||
padding: 2px 5px;
|
padding-left: 2px;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-dot {
|
.status-dot {
|
||||||
width: 2vw; /* 根据视窗宽度动态调整 */
|
text-align: right; /* 文本右对齐 */
|
||||||
height: 2vw; /* 根据视窗宽度动态调整 */
|
width: 0.5vw; /* 根据视窗宽度动态调整 */
|
||||||
|
height: 0.5vw; /* 根据视窗宽度动态调整 */
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
background-color: blue; /* 默认蓝色 */
|
background-color: blue; /* 默认蓝色 */
|
||||||
}
|
}
|
||||||
|
|
||||||
.node-name {
|
.node-name {
|
||||||
|
max-width: 30%;
|
||||||
flex: 3;
|
flex: 3;
|
||||||
font-size: 2vw; /* 根据浮动窗口宽度调整字体大小 */
|
|
||||||
color: #333;
|
color: #333;
|
||||||
}
|
|
||||||
|
|
||||||
.status-data {
|
|
||||||
flex: 6;
|
|
||||||
font-size: 1.8vw; /* 根据浮动窗口宽度调整字体大小 */
|
|
||||||
color: #666;
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.status-data {
|
||||||
|
flex: 6;
|
||||||
|
color: #666;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|||||||
@@ -19,9 +19,9 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
});
|
});
|
||||||
// 监听来自服务器的消息
|
// 监听来自服务器的消息
|
||||||
socket.on('voiceMessage', function (data) {
|
socket.on('voiceMessage', function (data) {
|
||||||
console.log(data)
|
console.log(data);
|
||||||
const input = document.createElement('messageInput');
|
const input = document.getElementById('messageInput');
|
||||||
input.data = data['data'];
|
input.value += data;
|
||||||
});
|
});
|
||||||
socket.on('message', function (data) {
|
socket.on('message', function (data) {
|
||||||
// 显示服务器的回复消息
|
// 显示服务器的回复消息
|
||||||
|
|||||||
@@ -48,28 +48,50 @@ function createEntry(nodeName) {
|
|||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
function cleanString(str) {
|
||||||
|
// 去除所有空白字符(包括中间的)
|
||||||
|
return str.replace(/\s+/g, '');
|
||||||
|
}
|
||||||
// 更新条目内容
|
// 更新条目内容
|
||||||
function updateEntry(nodeName, statusData) {
|
function updateEntry(nodeName, statusData) {
|
||||||
const contentDiv = document.getElementById('content');
|
const contentDiv = document.getElementById('entry-content');
|
||||||
const entries = contentDiv.children;
|
const entries = [...contentDiv.children];
|
||||||
|
entries.forEach(entry => {
|
||||||
|
entry.style.display = 'none';
|
||||||
|
});
|
||||||
|
// 只显示前8个条目
|
||||||
|
const displayEntries = entries.slice(0, 8);
|
||||||
|
displayEntries.forEach(entry => {
|
||||||
|
entry.style.display = ''; // 恢复默认显示
|
||||||
|
});
|
||||||
// 查找对应的条目
|
// 查找对应的条目
|
||||||
for (let entry of entries) {
|
for (let entry of entries) {
|
||||||
const nodeNameElement = entry.querySelector('.node-name');
|
const nodeNameElement = entry.querySelector('.node-name');
|
||||||
if (nodeNameElement.textContent === nodeName) {
|
if (nodeNameElement.textContent === nodeName) {
|
||||||
const statusDot = entry.querySelector('.status-dot');
|
let statusDataElement = entry.querySelector('.status-data');
|
||||||
const statusDataElement = entry.querySelector('.status-data');
|
// 如果内容和要更新的内容一样,跳过
|
||||||
|
if (!statusData)return;
|
||||||
|
if (cleanString(statusData) === cleanString(statusDataElement.textContent)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将元素滚动到最底部
|
||||||
|
const parent = entry.parentElement; // 获取条目所在的父容器
|
||||||
|
parent.appendChild(entry); // 移动到父容器末尾(自动移除原有位置)
|
||||||
|
const statusDot = entry.querySelector('.status-dot');
|
||||||
|
statusDataElement = entry.querySelector('.status-data');
|
||||||
// 更新状态圆点颜色(根据状态来决定颜色,可以根据后端发送的状态修改)
|
// 更新状态圆点颜色(根据状态来决定颜色,可以根据后端发送的状态修改)
|
||||||
statusDot.style.backgroundColor = 'green'; // 假设状态是正常的,暂时设置为绿色
|
statusDot.style.backgroundColor = 'green'; // 假设状态是正常的,暂时设置为绿色
|
||||||
|
|
||||||
// 更新流式数据
|
// 更新流式数据
|
||||||
statusDataElement.textContent = statusData;
|
statusDataElement.textContent = statusData;
|
||||||
|
statusDataElement.scrollLeft = statusDataElement.scrollWidth - statusDataElement.clientWidth
|
||||||
|
contentDiv.scrollTop = contentDiv.scrollHeight;
|
||||||
return; // 找到对应的条目后退出
|
return; // 找到对应的条目后退出
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 如果没有找到对应条目,创建一个新的条目并添加到页面
|
// 如果没有找到对应条目,创建一个新的条目并添加到页面
|
||||||
contentDiv.appendChild(createEntry(nodeName));
|
contentDiv.appendChild(createEntry(nodeName));
|
||||||
updateEntry(nodeName, statusData); // 立即更新新条目
|
updateEntry(nodeName, statusData); // 立即更新新条目
|
||||||
|
|||||||
@@ -110,10 +110,10 @@
|
|||||||
|
|
||||||
<link rel="stylesheet" href="/static/css/process_show_floating_window.css">
|
<link rel="stylesheet" href="/static/css/process_show_floating_window.css">
|
||||||
<div class="floating-window" id="floatingWindow">
|
<div class="floating-window" id="floatingWindow">
|
||||||
<div class="header">
|
<div class="floating-header">
|
||||||
<span class="draggable">•••</span>
|
<span class="draggable">•••</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="entry-content" id="entry-content">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
1
Html/db/data/user/visenzz.json
Normal file
1
Html/db/data/user/visenzz.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"username": "visenzz"}
|
||||||
Reference in New Issue
Block a user