add next_chapter
This commit is contained in:
0
Html/apps/function_tools/chapter.py
Normal file
0
Html/apps/function_tools/chapter.py
Normal file
@@ -4,12 +4,14 @@ from flask import current_app, request, session
|
|||||||
from flask_socketio import Namespace, join_room, leave_room, emit
|
from flask_socketio import Namespace, join_room, leave_room, emit
|
||||||
|
|
||||||
from ..function_tools import judge
|
from ..function_tools import judge
|
||||||
|
from ..function_tools import next_chapter
|
||||||
from ..services.memory_service import save_chapter_memory_by_uuid
|
from ..services.memory_service import save_chapter_memory_by_uuid
|
||||||
from ..services.backboard_service import realtime_response
|
from ..services.backboard_service import realtime_response
|
||||||
from ..services.markdown_service import load_full_markdown_file
|
from ..services.markdown_service import load_full_markdown_file
|
||||||
from ..extension_ase.ase_client import HSAEngineClient, ChatManager
|
from ..extension_ase.ase_client import HSAEngineClient, ChatManager
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class VSCodeNamespace(Namespace):
|
class VSCodeNamespace(Namespace):
|
||||||
def on_login(self,data):
|
def on_login(self,data):
|
||||||
ex = current_app.extensions
|
ex = current_app.extensions
|
||||||
@@ -69,10 +71,18 @@ 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='next_chapter',
|
||||||
|
callback=self.receive_ase_next_chapter,
|
||||||
|
entry=self,
|
||||||
|
init_data={'room': user_uuid}
|
||||||
|
)
|
||||||
|
|
||||||
fmd,fmdp,fsp = load_full_markdown_file(course_id, chapter_name, lesson_name)
|
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)
|
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 = user_uuid2chatmanager[user_uuid]
|
||||||
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(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})
|
||||||
|
|
||||||
user_uuid2ase_client[user_uuid].loadmarkdown(fmd, fmdp, fsp)
|
user_uuid2ase_client[user_uuid].loadmarkdown(fmd, fmdp, fsp)
|
||||||
|
|
||||||
@@ -103,6 +113,7 @@ class AgentNamespace(Namespace):
|
|||||||
# emit('request_function',res.content['function'], room=uuid, namespace='/agent')
|
# emit('request_function',res.content['function'], room=uuid, namespace='/agent')
|
||||||
|
|
||||||
if data['type'] == 'function':
|
if data['type'] == 'function':
|
||||||
|
print("function_call", data['data'])
|
||||||
agent_manager.function_call(uuid, data['data'])
|
agent_manager.function_call(uuid, data['data'])
|
||||||
|
|
||||||
|
|
||||||
@@ -113,6 +124,10 @@ class AgentNamespace(Namespace):
|
|||||||
print("receive_ase_judge", data)
|
print("receive_ase_judge", data)
|
||||||
namespace_entry.emit('request_function', data['data'], room=init_data['room'], namespace='/agent')
|
namespace_entry.emit('request_function', data['data'], room=init_data['room'], namespace='/agent')
|
||||||
|
|
||||||
|
def receive_ase_next_chapter(client_entry: HSAEngineClient, namespace_entry: Namespace, data, init_data):
|
||||||
|
print("receive_ase_next_chapter", data)
|
||||||
|
namespace_entry.emit('next_chapter', room=init_data['room'], namespace='/agent')
|
||||||
|
|
||||||
def on_initiative(self,data):
|
def on_initiative(self,data):
|
||||||
print("User active function call")
|
print("User active function call")
|
||||||
ex = current_app.extensions
|
ex = current_app.extensions
|
||||||
|
|||||||
Reference in New Issue
Block a user