Merge branch 'feature/paste_deteced'

This commit is contained in:
Cai
2025-10-26 13:40:43 +08:00
8 changed files with 35 additions and 10 deletions

View File

@@ -1,8 +1,11 @@
# myapp/services/backboard_service.py
import os
from flask import current_app
from flask_socketio import emit
from backboardManager import Backboard # 你已有的类
from ..utils.sudoUtil import sudo_open
from ..extension_ase.ase_client import HSAEngineClient
from manager import ChatManager
def _to_wsl_path_if_needed(path: str) -> str:
cfg = current_app.config["VSCODE_WEB_PATH"]
@@ -44,8 +47,19 @@ def realtime_response(config: dict, realtime_action: dict) -> None:
bb.pasted_content = realtime_action.get("content")
with open(os.path.join(bb.root_path, bb.active_file_path), "r", encoding="utf-8") as f:
bb.active_file_content = f.read()
# TODO: 让大模型检查当前这个文件和用户paste的代码,基于此判断是否需要打断学生写代码并询问其理解
# chatmanager.ase_client.send("check_code", {"file_path": file_path, "content": bb.pasted_content})
#处理粘贴事件
# paste_data = {
# 'pasted_file_path': file_path,
# 'pasted_content': bb.pasted_content,
# 'pasted_content_length': len(bb.pasted_content)
# }
# emit('paste_detected', paste_data)
#判断一下,如果粘帖内容过多就发送,后期可加入更多条件判断
if bb.pasted_content and len(bb.pasted_content) > 250:
chatmanager.ase_client.send("pasted_detected_in", {"file_path": file_path, "content": bb.pasted_content})
elif rtype == "fileEdit":
file_path = realtime_action.get("filePath")

View File

@@ -126,6 +126,12 @@ class AgentNamespace(Namespace):
entry=self,
init_data={'room': user_uuid}
)
user_uuid2ase_client[user_uuid].register_route_with_entry(
route='paste_detected',
callback=self.receive_ase_paste_detected,
entry=self,
init_data={'room': user_uuid}
)
user_uuid2ase_client[user_uuid].connect()
@@ -175,6 +181,12 @@ class AgentNamespace(Namespace):
ase_client.send_text("chapter-start", "")
namespace_entry.emit('message', "Multi-Agents服务已连接", room=init_data['room'], namespace='/agent')
#接受消息回来直接让message监听发送
def receive_ase_paste_detected(client_entry: HSAEngineClient, namespace_entry: Namespace, data, init_data):
print("receive_ase_paste_detected", data)
client_entry.chatmanager.chat_historys.append({'role': 'assistant', 'content': data['data']})
namespace_entry.emit('message', data['data'], room=init_data['room'], namespace='/agent')
def receive_ase_dialog(client_entry: HSAEngineClient, namespace_entry: Namespace, data, init_data):
print("receive_ase_dialog", data)
client_entry.chatmanager.chat_historys.append({'role': 'assistant', 'content': data['data']})
@@ -191,7 +203,6 @@ class AgentNamespace(Namespace):
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):
print("receive_ase_judge", data)
namespace_entry.emit('request_function', data, room=init_data['room'], namespace='/agent') # data 是一个列表 /dict也支持

View File

@@ -20,7 +20,7 @@ class Backboard:
self.pasted_file_path = ""
self.pasted_content = ""
def next_chapter(self):
self.enter_chapter_time = time.time()

View File

@@ -1 +1 @@
{"username": "agnes"}
{"username": "Agnes"}

View File

@@ -1 +1 @@
{"username": "ttt"}
{"username": "Ttt"}

View File

@@ -32,7 +32,7 @@ api_key = sk-aMpnWklN2IbsK44d1kNpy6YOP9bk1pdPJjFeEmbb0a5ytEFf
model=gpt-4.1-nano
[VSCODE_WEB]
url = https://hsamooc.com
url = https://hsamooc.cn
#http://asengine.net:8282
[VSCODE_WEB_PATH]
is_wsl = true
@@ -43,7 +43,7 @@ dir = db/data/user/
[COURSE_DATA]
dir = db/data/course/
[MONGO]
uri = mongodb://admin:12138cake@hsamooc.com:27017/hsamooc_test?authSource=admin
uri = mongodb://admin:12138cake@hsamooc.cn:27017/hsamooc_test?authSource=admin
[TENCENT_COS]
secret_id = AKIDZ0EG4f2FE0YszsXzEF5h5GDwSlOtDLGx

View File

@@ -60,7 +60,7 @@ function ChangeWorkspacefileTree(fileTree) {
// vscode.window.showInformationMessage('Connecting to server...');
vs_socket = io('wss://hsamooc.com/vscode');
vs_socket = io('wss://hsamooc.cn/vscode');
vs_socket.on('connect', () => {
// vscode.window.showInformationMessage('Connected to server');
console.log('Connected to server');

View File

@@ -24,7 +24,7 @@
});
});
socket = io('https://hsamooc.com/vsc-like',{path:'/vsc-like-ws'});
socket = io('https://hsamooc.cn/vsc-like',{path:'/vsc-like-ws'});
const status = document.getElementById("status")
socket.on("pty_output", function(data){