fix chatmanager setting time

This commit is contained in:
CakeCN
2025-09-12 15:01:44 +08:00
parent e025ac6a9c
commit 33d321070d
3 changed files with 10 additions and 6 deletions

View File

@@ -26,7 +26,11 @@ class ProcRecord:
class ChatManager:
def __init__(self,user_uuid,ase_client,raw_markdown,raw_markdown_prompts,raw_score_prompts,max_iter = 5, app=None, socketio=None):
def __init__(self):
self._procs: Dict[str, ProcRecord] = {}
self._lock = threading.RLock()
def init(self,user_uuid,ase_client,raw_markdown,raw_markdown_prompts,raw_score_prompts,max_iter = 5, app=None, socketio=None):
self.chapter_chain_now = -1
self.ase_client = ase_client
self.app = app
@@ -38,8 +42,6 @@ class ChatManager:
self.chapter_chain = load_chapters(raw_markdown, raw_markdown_prompts, raw_score_prompts)
self.function_manager = FunctionManager()
self.bb = None
self._procs: Dict[str, ProcRecord] = {}
self._lock = threading.RLock()
def disconnect(self, uuid):
self.stop(uuid)

View File

@@ -78,8 +78,8 @@ class AgentNamespace(Namespace):
)
fmd,fmdp,fsp = load_full_markdown_file(course_id, chapter_name, lesson_name)
user_uuid2chatmanager[user_uuid] = ChatManager(user_uuid, user_uuid2ase_client[user_uuid], fmd, fmdp, fsp, max_iter=5, app=current_app, socketio=self)
chatmanager = user_uuid2chatmanager[user_uuid]
chatmanager.init(user_uuid, user_uuid2ase_client[user_uuid], fmd, fmdp, fsp, max_iter=5, app=current_app, socketio=self)
chatmanager.function_manager.add_function(judge, {'course_id': course_id, 'lesson_name': lesson_name, 'root_path': f'../../study/{user_id}/{course_id}/{chapter_name}/{lesson_name}'})
chatmanager.function_manager.add_function(next_chapter, {'user_uuid': user_uuid})

View File

@@ -2,6 +2,7 @@
import os, uuid, json
from flask import Blueprint, current_app, session, redirect, url_for, render_template, request, jsonify
from ..services.backboard_service import realtime_response
from ..extension_ase.ase_client.manager import ChatManager
import subprocess
bp = Blueprint("vscode", __name__)
@@ -31,8 +32,9 @@ def desktop(user_uuid, course_id, chapter_name, lesson_name):
except subprocess.CalledProcessError as e:
print(f"Error creating directory {path_dir} details {str(e)}")
chatmanager = current_app.extensions["user_uuid2chatmanager"][user_uuid]
chatmanager = ChatManager()
chatmanager.init(user_uuid, user_id, path_dir)
current_app.extensions["user_uuid2chatmanager"][user_uuid] = chatmanager
code_server_port = 10000 + int(uuid.uuid4().int % 10000)
chatmanager.start_code_server(user_uuid, user_id, path_dir, code_server_port)