Merge branch 'feature/paste_deteced'
This commit is contained in:
@@ -1,8 +1,11 @@
|
|||||||
# myapp/services/backboard_service.py
|
# myapp/services/backboard_service.py
|
||||||
import os
|
import os
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
|
from flask_socketio import emit
|
||||||
from backboardManager import Backboard # 你已有的类
|
from backboardManager import Backboard # 你已有的类
|
||||||
from ..utils.sudoUtil import sudo_open
|
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:
|
def _to_wsl_path_if_needed(path: str) -> str:
|
||||||
cfg = current_app.config["VSCODE_WEB_PATH"]
|
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")
|
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:
|
with open(os.path.join(bb.root_path, bb.active_file_path), "r", encoding="utf-8") as f:
|
||||||
bb.active_file_content = f.read()
|
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":
|
elif rtype == "fileEdit":
|
||||||
file_path = realtime_action.get("filePath")
|
file_path = realtime_action.get("filePath")
|
||||||
|
|||||||
@@ -126,6 +126,12 @@ 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='paste_detected',
|
||||||
|
callback=self.receive_ase_paste_detected,
|
||||||
|
entry=self,
|
||||||
|
init_data={'room': user_uuid}
|
||||||
|
)
|
||||||
user_uuid2ase_client[user_uuid].connect()
|
user_uuid2ase_client[user_uuid].connect()
|
||||||
|
|
||||||
|
|
||||||
@@ -175,6 +181,12 @@ class AgentNamespace(Namespace):
|
|||||||
ase_client.send_text("chapter-start", "")
|
ase_client.send_text("chapter-start", "")
|
||||||
namespace_entry.emit('message', "Multi-Agents服务已连接", room=init_data['room'], namespace='/agent')
|
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):
|
def receive_ase_dialog(client_entry: HSAEngineClient, namespace_entry: Namespace, data, init_data):
|
||||||
print("receive_ase_dialog", data)
|
print("receive_ase_dialog", data)
|
||||||
client_entry.chatmanager.chat_historys.append({'role': 'assistant', 'content': data['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):
|
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')
|
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)
|
||||||
namespace_entry.emit('request_function', data, room=init_data['room'], namespace='/agent') # data 是一个列表 /dict也支持
|
namespace_entry.emit('request_function', data, room=init_data['room'], namespace='/agent') # data 是一个列表 /dict也支持
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class Backboard:
|
|||||||
self.pasted_file_path = ""
|
self.pasted_file_path = ""
|
||||||
self.pasted_content = ""
|
self.pasted_content = ""
|
||||||
|
|
||||||
|
|
||||||
def next_chapter(self):
|
def next_chapter(self):
|
||||||
self.enter_chapter_time = time.time()
|
self.enter_chapter_time = time.time()
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"username": "agnes"}
|
{"username": "Agnes"}
|
||||||
@@ -1 +1 @@
|
|||||||
{"username": "ttt"}
|
{"username": "Ttt"}
|
||||||
@@ -32,7 +32,7 @@ api_key = sk-aMpnWklN2IbsK44d1kNpy6YOP9bk1pdPJjFeEmbb0a5ytEFf
|
|||||||
model=gpt-4.1-nano
|
model=gpt-4.1-nano
|
||||||
|
|
||||||
[VSCODE_WEB]
|
[VSCODE_WEB]
|
||||||
url = https://hsamooc.com
|
url = https://hsamooc.cn
|
||||||
#http://asengine.net:8282
|
#http://asengine.net:8282
|
||||||
[VSCODE_WEB_PATH]
|
[VSCODE_WEB_PATH]
|
||||||
is_wsl = true
|
is_wsl = true
|
||||||
@@ -43,7 +43,7 @@ dir = db/data/user/
|
|||||||
[COURSE_DATA]
|
[COURSE_DATA]
|
||||||
dir = db/data/course/
|
dir = db/data/course/
|
||||||
[MONGO]
|
[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]
|
[TENCENT_COS]
|
||||||
secret_id = AKIDZ0EG4f2FE0YszsXzEF5h5GDwSlOtDLGx
|
secret_id = AKIDZ0EG4f2FE0YszsXzEF5h5GDwSlOtDLGx
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ function ChangeWorkspacefileTree(fileTree) {
|
|||||||
|
|
||||||
// vscode.window.showInformationMessage('Connecting to server...');
|
// vscode.window.showInformationMessage('Connecting to server...');
|
||||||
|
|
||||||
vs_socket = io('wss://hsamooc.com/vscode');
|
vs_socket = io('wss://hsamooc.cn/vscode');
|
||||||
vs_socket.on('connect', () => {
|
vs_socket.on('connect', () => {
|
||||||
// vscode.window.showInformationMessage('Connected to server');
|
// vscode.window.showInformationMessage('Connected to server');
|
||||||
console.log('Connected to server');
|
console.log('Connected to server');
|
||||||
|
|||||||
@@ -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")
|
const status = document.getElementById("status")
|
||||||
|
|
||||||
socket.on("pty_output", function(data){
|
socket.on("pty_output", function(data){
|
||||||
|
|||||||
Reference in New Issue
Block a user