diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..238c688 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +Html/runs/* \ No newline at end of file diff --git a/Html/runs/run_20241114-163533_2h3jhw/.config b/Html/runs/run_20241114-163533_2h3jhw/.config deleted file mode 100644 index 1bae7c7..0000000 --- a/Html/runs/run_20241114-163533_2h3jhw/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "CCpiuC", - "name": "2h3jhw", - "run_id": "run_20241114-163533_2h3jhw", - "timestamp": "2024-11-14 16:35:33", - "pid": 24464 -} \ No newline at end of file diff --git a/Html/runs/run_20241114-163533_2h3jhw/agentscope.db b/Html/runs/run_20241114-163533_2h3jhw/agentscope.db deleted file mode 100644 index 50c98d3..0000000 Binary files a/Html/runs/run_20241114-163533_2h3jhw/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241114-163533_2h3jhw/code/app.py b/Html/runs/run_20241114-163533_2h3jhw/code/app.py deleted file mode 100644 index bb99c19..0000000 --- a/Html/runs/run_20241114-163533_2h3jhw/code/app.py +++ /dev/null @@ -1,171 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -''' -Backboard -''' -class Backboard: - pass - - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -def realtime_response(config, realtime_action): - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - -@socketio.on('connect') -def handle_connect(): - user_id = session.get('user_id') - if (user_id is None): - print("No user_id in session") - return jsonify({'error': 'Connection failed bacause no user_id found'}), 401 - print(f'User connected with session user_id: {user_id}') - id, agent = agent_manager.get_agent(user_id) - if user_id: - join_room(user_id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - # 构造回复消息 - res = agent_manager.invoke(id, data) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' - -@app.route('/desktop//') -def hello_world(user_id, path): - print("session"+str(session)) - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241114-163533_2h3jhw/code/backboardManager.py b/Html/runs/run_20241114-163533_2h3jhw/code/backboardManager.py deleted file mode 100644 index 27b0f76..0000000 --- a/Html/runs/run_20241114-163533_2h3jhw/code/backboardManager.py +++ /dev/null @@ -1,51 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - return f"###Global Info:###\n\ -User is {self.user_id}\n\ -User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}\n\ -User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}\n\ -\n\n\ -" - - - - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241114-163533_2h3jhw/logging.chat b/Html/runs/run_20241114-163533_2h3jhw/logging.chat deleted file mode 100644 index e69de29..0000000 diff --git a/Html/runs/run_20241114-163533_2h3jhw/logging.log b/Html/runs/run_20241114-163533_2h3jhw/logging.log deleted file mode 100644 index 7f32b33..0000000 --- a/Html/runs/run_20241114-163533_2h3jhw/logging.log +++ /dev/null @@ -1 +0,0 @@ -2024-11-14 16:35:40.507 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg diff --git a/Html/runs/run_20241114-164343_jmd8td/.config b/Html/runs/run_20241114-164343_jmd8td/.config deleted file mode 100644 index ddca346..0000000 --- a/Html/runs/run_20241114-164343_jmd8td/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "7rGHWe", - "name": "jmd8td", - "run_id": "run_20241114-164343_jmd8td", - "timestamp": "2024-11-14 16:43:43", - "pid": 28598 -} \ No newline at end of file diff --git a/Html/runs/run_20241114-164343_jmd8td/agentscope.db b/Html/runs/run_20241114-164343_jmd8td/agentscope.db deleted file mode 100644 index 50c98d3..0000000 Binary files a/Html/runs/run_20241114-164343_jmd8td/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241114-164343_jmd8td/code/app.py b/Html/runs/run_20241114-164343_jmd8td/code/app.py deleted file mode 100644 index 5937007..0000000 --- a/Html/runs/run_20241114-164343_jmd8td/code/app.py +++ /dev/null @@ -1,169 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -''' -Backboard -''' -class Backboard: - pass - - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -def realtime_response(config, realtime_action): - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - -@socketio.on('connect') -def handle_connect(): - user_id = session.get('user_id') - if (user_id is None): - print("No user_id in session") - return jsonify({'error': 'Connection failed bacause no user_id found'}), 401 - print(f'User connected with session user_id: {user_id}') - id, agent = agent_manager.get_agent(user_id) - if user_id: - join_room(user_id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - # 构造回复消息 - res = agent_manager.invoke(id, data) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241114-164343_jmd8td/code/backboardManager.py b/Html/runs/run_20241114-164343_jmd8td/code/backboardManager.py deleted file mode 100644 index 27b0f76..0000000 --- a/Html/runs/run_20241114-164343_jmd8td/code/backboardManager.py +++ /dev/null @@ -1,51 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - return f"###Global Info:###\n\ -User is {self.user_id}\n\ -User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}\n\ -User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}\n\ -\n\n\ -" - - - - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241114-164343_jmd8td/logging.chat b/Html/runs/run_20241114-164343_jmd8td/logging.chat deleted file mode 100644 index e69de29..0000000 diff --git a/Html/runs/run_20241114-164343_jmd8td/logging.log b/Html/runs/run_20241114-164343_jmd8td/logging.log deleted file mode 100644 index ab88de4..0000000 --- a/Html/runs/run_20241114-164343_jmd8td/logging.log +++ /dev/null @@ -1 +0,0 @@ -2024-11-14 16:43:59.414 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg diff --git a/Html/runs/run_20241114-214752_wb6exw/.config b/Html/runs/run_20241114-214752_wb6exw/.config deleted file mode 100644 index c4310d6..0000000 --- a/Html/runs/run_20241114-214752_wb6exw/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "28cXo4", - "name": "wb6exw", - "run_id": "run_20241114-214752_wb6exw", - "timestamp": "2024-11-14 21:47:52", - "pid": 15325 -} \ No newline at end of file diff --git a/Html/runs/run_20241114-214752_wb6exw/agentscope.db b/Html/runs/run_20241114-214752_wb6exw/agentscope.db deleted file mode 100644 index 50c98d3..0000000 Binary files a/Html/runs/run_20241114-214752_wb6exw/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241114-214752_wb6exw/code/app.py b/Html/runs/run_20241114-214752_wb6exw/code/app.py deleted file mode 100644 index af78ee4..0000000 --- a/Html/runs/run_20241114-214752_wb6exw/code/app.py +++ /dev/null @@ -1,180 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager - -backboard_manager = BackBoardManager() - - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -def realtime_response(config, realtime_action): - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = userid_recorder[user+'&'+folder_name] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd, open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp, open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - # 构造回复消息 - res = agent_manager.invoke(id, data) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241114-214752_wb6exw/code/backboardManager.py b/Html/runs/run_20241114-214752_wb6exw/code/backboardManager.py deleted file mode 100644 index 27b0f76..0000000 --- a/Html/runs/run_20241114-214752_wb6exw/code/backboardManager.py +++ /dev/null @@ -1,51 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - return f"###Global Info:###\n\ -User is {self.user_id}\n\ -User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}\n\ -User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}\n\ -\n\n\ -" - - - - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241114-214752_wb6exw/logging.chat b/Html/runs/run_20241114-214752_wb6exw/logging.chat deleted file mode 100644 index e69de29..0000000 diff --git a/Html/runs/run_20241114-214752_wb6exw/logging.log b/Html/runs/run_20241114-214752_wb6exw/logging.log deleted file mode 100644 index cb92285..0000000 --- a/Html/runs/run_20241114-214752_wb6exw/logging.log +++ /dev/null @@ -1 +0,0 @@ -2024-11-14 21:48:13.935 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg diff --git a/Html/runs/run_20241114-214935_mgm60l/.config b/Html/runs/run_20241114-214935_mgm60l/.config deleted file mode 100644 index 4bd7876..0000000 --- a/Html/runs/run_20241114-214935_mgm60l/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "JOBFuf", - "name": "mgm60l", - "run_id": "run_20241114-214935_mgm60l", - "timestamp": "2024-11-14 21:49:35", - "pid": 16725 -} \ No newline at end of file diff --git a/Html/runs/run_20241114-214935_mgm60l/agentscope.db b/Html/runs/run_20241114-214935_mgm60l/agentscope.db deleted file mode 100644 index 50c98d3..0000000 Binary files a/Html/runs/run_20241114-214935_mgm60l/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241114-214935_mgm60l/code/app.py b/Html/runs/run_20241114-214935_mgm60l/code/app.py deleted file mode 100644 index af78ee4..0000000 --- a/Html/runs/run_20241114-214935_mgm60l/code/app.py +++ /dev/null @@ -1,180 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager - -backboard_manager = BackBoardManager() - - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -def realtime_response(config, realtime_action): - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = userid_recorder[user+'&'+folder_name] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd, open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp, open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - # 构造回复消息 - res = agent_manager.invoke(id, data) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241114-214935_mgm60l/code/backboardManager.py b/Html/runs/run_20241114-214935_mgm60l/code/backboardManager.py deleted file mode 100644 index 27b0f76..0000000 --- a/Html/runs/run_20241114-214935_mgm60l/code/backboardManager.py +++ /dev/null @@ -1,51 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - return f"###Global Info:###\n\ -User is {self.user_id}\n\ -User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}\n\ -User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}\n\ -\n\n\ -" - - - - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241114-214935_mgm60l/logging.chat b/Html/runs/run_20241114-214935_mgm60l/logging.chat deleted file mode 100644 index e69de29..0000000 diff --git a/Html/runs/run_20241114-214935_mgm60l/logging.log b/Html/runs/run_20241114-214935_mgm60l/logging.log deleted file mode 100644 index e82f0df..0000000 --- a/Html/runs/run_20241114-214935_mgm60l/logging.log +++ /dev/null @@ -1 +0,0 @@ -2024-11-14 21:49:45.643 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg diff --git a/Html/runs/run_20241114-215220_4l1w9g/.config b/Html/runs/run_20241114-215220_4l1w9g/.config deleted file mode 100644 index 39cff37..0000000 --- a/Html/runs/run_20241114-215220_4l1w9g/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "adTV6W", - "name": "4l1w9g", - "run_id": "run_20241114-215220_4l1w9g", - "timestamp": "2024-11-14 21:52:20", - "pid": 18255 -} \ No newline at end of file diff --git a/Html/runs/run_20241114-215220_4l1w9g/agentscope.db b/Html/runs/run_20241114-215220_4l1w9g/agentscope.db deleted file mode 100644 index 50c98d3..0000000 Binary files a/Html/runs/run_20241114-215220_4l1w9g/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241114-215220_4l1w9g/code/app.py b/Html/runs/run_20241114-215220_4l1w9g/code/app.py deleted file mode 100644 index 2670c35..0000000 --- a/Html/runs/run_20241114-215220_4l1w9g/code/app.py +++ /dev/null @@ -1,182 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager - -backboard_manager = BackBoardManager() - - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -def realtime_response(config, realtime_action): - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = userid_recorder[user+'&'+folder_name] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - # 构造回复消息 - res = agent_manager.invoke(id, data) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241114-215220_4l1w9g/code/backboardManager.py b/Html/runs/run_20241114-215220_4l1w9g/code/backboardManager.py deleted file mode 100644 index 27b0f76..0000000 --- a/Html/runs/run_20241114-215220_4l1w9g/code/backboardManager.py +++ /dev/null @@ -1,51 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - return f"###Global Info:###\n\ -User is {self.user_id}\n\ -User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}\n\ -User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}\n\ -\n\n\ -" - - - - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241114-215220_4l1w9g/logging.chat b/Html/runs/run_20241114-215220_4l1w9g/logging.chat deleted file mode 100644 index e69de29..0000000 diff --git a/Html/runs/run_20241114-215220_4l1w9g/logging.log b/Html/runs/run_20241114-215220_4l1w9g/logging.log deleted file mode 100644 index d49fd57..0000000 --- a/Html/runs/run_20241114-215220_4l1w9g/logging.log +++ /dev/null @@ -1 +0,0 @@ -2024-11-14 21:52:45.458 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg diff --git a/Html/runs/run_20241114-215426_13ob9v/.config b/Html/runs/run_20241114-215426_13ob9v/.config deleted file mode 100644 index 22dba73..0000000 --- a/Html/runs/run_20241114-215426_13ob9v/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "bWVpBF", - "name": "13ob9v", - "run_id": "run_20241114-215426_13ob9v", - "timestamp": "2024-11-14 21:54:26", - "pid": 19572 -} \ No newline at end of file diff --git a/Html/runs/run_20241114-215426_13ob9v/agentscope.db b/Html/runs/run_20241114-215426_13ob9v/agentscope.db deleted file mode 100644 index 50c98d3..0000000 Binary files a/Html/runs/run_20241114-215426_13ob9v/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241114-215426_13ob9v/code/app.py b/Html/runs/run_20241114-215426_13ob9v/code/app.py deleted file mode 100644 index 2670c35..0000000 --- a/Html/runs/run_20241114-215426_13ob9v/code/app.py +++ /dev/null @@ -1,182 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager - -backboard_manager = BackBoardManager() - - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -def realtime_response(config, realtime_action): - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = userid_recorder[user+'&'+folder_name] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - # 构造回复消息 - res = agent_manager.invoke(id, data) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241114-215426_13ob9v/code/backboardManager.py b/Html/runs/run_20241114-215426_13ob9v/code/backboardManager.py deleted file mode 100644 index 27b0f76..0000000 --- a/Html/runs/run_20241114-215426_13ob9v/code/backboardManager.py +++ /dev/null @@ -1,51 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - return f"###Global Info:###\n\ -User is {self.user_id}\n\ -User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}\n\ -User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}\n\ -\n\n\ -" - - - - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241114-215426_13ob9v/logging.chat b/Html/runs/run_20241114-215426_13ob9v/logging.chat deleted file mode 100644 index e69de29..0000000 diff --git a/Html/runs/run_20241114-215426_13ob9v/logging.log b/Html/runs/run_20241114-215426_13ob9v/logging.log deleted file mode 100644 index cae99b0..0000000 --- a/Html/runs/run_20241114-215426_13ob9v/logging.log +++ /dev/null @@ -1 +0,0 @@ -2024-11-14 21:54:42.058 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg diff --git a/Html/runs/run_20241114-215514_4hht6r/.config b/Html/runs/run_20241114-215514_4hht6r/.config deleted file mode 100644 index 559308e..0000000 --- a/Html/runs/run_20241114-215514_4hht6r/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "JpOniY", - "name": "4hht6r", - "run_id": "run_20241114-215514_4hht6r", - "timestamp": "2024-11-14 21:55:14", - "pid": 20265 -} \ No newline at end of file diff --git a/Html/runs/run_20241114-215514_4hht6r/agentscope.db b/Html/runs/run_20241114-215514_4hht6r/agentscope.db deleted file mode 100644 index 50c98d3..0000000 Binary files a/Html/runs/run_20241114-215514_4hht6r/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241114-215514_4hht6r/code/app.py b/Html/runs/run_20241114-215514_4hht6r/code/app.py deleted file mode 100644 index c9c5b7f..0000000 --- a/Html/runs/run_20241114-215514_4hht6r/code/app.py +++ /dev/null @@ -1,183 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager - -backboard_manager = BackBoardManager() - - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -def realtime_response(config, realtime_action): - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = userid_recorder[user+'&'+folder_name] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - print(user_id) - id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - # 构造回复消息 - res = agent_manager.invoke(id, data) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241114-215514_4hht6r/code/backboardManager.py b/Html/runs/run_20241114-215514_4hht6r/code/backboardManager.py deleted file mode 100644 index 27b0f76..0000000 --- a/Html/runs/run_20241114-215514_4hht6r/code/backboardManager.py +++ /dev/null @@ -1,51 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - return f"###Global Info:###\n\ -User is {self.user_id}\n\ -User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}\n\ -User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}\n\ -\n\n\ -" - - - - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241114-215514_4hht6r/logging.chat b/Html/runs/run_20241114-215514_4hht6r/logging.chat deleted file mode 100644 index e69de29..0000000 diff --git a/Html/runs/run_20241114-215514_4hht6r/logging.log b/Html/runs/run_20241114-215514_4hht6r/logging.log deleted file mode 100644 index bc959e9..0000000 --- a/Html/runs/run_20241114-215514_4hht6r/logging.log +++ /dev/null @@ -1 +0,0 @@ -2024-11-14 21:55:29.213 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg diff --git a/Html/runs/run_20241114-215712_s92n8y/.config b/Html/runs/run_20241114-215712_s92n8y/.config deleted file mode 100644 index ced32d9..0000000 --- a/Html/runs/run_20241114-215712_s92n8y/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "c6FVzt", - "name": "s92n8y", - "run_id": "run_20241114-215712_s92n8y", - "timestamp": "2024-11-14 21:57:12", - "pid": 21458 -} \ No newline at end of file diff --git a/Html/runs/run_20241114-215712_s92n8y/agentscope.db b/Html/runs/run_20241114-215712_s92n8y/agentscope.db deleted file mode 100644 index 50c98d3..0000000 Binary files a/Html/runs/run_20241114-215712_s92n8y/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241114-215712_s92n8y/code/app.py b/Html/runs/run_20241114-215712_s92n8y/code/app.py deleted file mode 100644 index a6e60c5..0000000 --- a/Html/runs/run_20241114-215712_s92n8y/code/app.py +++ /dev/null @@ -1,184 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager - -backboard_manager = BackBoardManager() - - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -def realtime_response(config, realtime_action): - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = userid_recorder[user+'&'+folder_name] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - print('-----------------------') - print(user_id) - id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - # 构造回复消息 - res = agent_manager.invoke(id, data) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241114-215712_s92n8y/code/backboardManager.py b/Html/runs/run_20241114-215712_s92n8y/code/backboardManager.py deleted file mode 100644 index 27b0f76..0000000 --- a/Html/runs/run_20241114-215712_s92n8y/code/backboardManager.py +++ /dev/null @@ -1,51 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - return f"###Global Info:###\n\ -User is {self.user_id}\n\ -User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}\n\ -User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}\n\ -\n\n\ -" - - - - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241114-215712_s92n8y/logging.chat b/Html/runs/run_20241114-215712_s92n8y/logging.chat deleted file mode 100644 index e69de29..0000000 diff --git a/Html/runs/run_20241114-215712_s92n8y/logging.log b/Html/runs/run_20241114-215712_s92n8y/logging.log deleted file mode 100644 index c6d0541..0000000 --- a/Html/runs/run_20241114-215712_s92n8y/logging.log +++ /dev/null @@ -1 +0,0 @@ -2024-11-14 21:57:23.583 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg diff --git a/Html/runs/run_20241114-220215_1j41on/.config b/Html/runs/run_20241114-220215_1j41on/.config deleted file mode 100644 index 0cf9ff5..0000000 --- a/Html/runs/run_20241114-220215_1j41on/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "pGMDpY", - "name": "1j41on", - "run_id": "run_20241114-220215_1j41on", - "timestamp": "2024-11-14 22:02:15", - "pid": 24013 -} \ No newline at end of file diff --git a/Html/runs/run_20241114-220215_1j41on/agentscope.db b/Html/runs/run_20241114-220215_1j41on/agentscope.db deleted file mode 100644 index 50c98d3..0000000 Binary files a/Html/runs/run_20241114-220215_1j41on/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241114-220215_1j41on/code/app.py b/Html/runs/run_20241114-220215_1j41on/code/app.py deleted file mode 100644 index 9faa4d0..0000000 --- a/Html/runs/run_20241114-220215_1j41on/code/app.py +++ /dev/null @@ -1,184 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager - -backboard_manager = BackBoardManager() - - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -def realtime_response(config, realtime_action): - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = userid_recorder[user+'&'+folder_name] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - print('-----------------------') - print(user_id) - user_id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(user_id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - # 构造回复消息 - res = agent_manager.invoke(id, data) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241114-220215_1j41on/code/backboardManager.py b/Html/runs/run_20241114-220215_1j41on/code/backboardManager.py deleted file mode 100644 index 27b0f76..0000000 --- a/Html/runs/run_20241114-220215_1j41on/code/backboardManager.py +++ /dev/null @@ -1,51 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - return f"###Global Info:###\n\ -User is {self.user_id}\n\ -User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}\n\ -User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}\n\ -\n\n\ -" - - - - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241114-220215_1j41on/logging.chat b/Html/runs/run_20241114-220215_1j41on/logging.chat deleted file mode 100644 index e69de29..0000000 diff --git a/Html/runs/run_20241114-220215_1j41on/logging.log b/Html/runs/run_20241114-220215_1j41on/logging.log deleted file mode 100644 index d403dce..0000000 --- a/Html/runs/run_20241114-220215_1j41on/logging.log +++ /dev/null @@ -1 +0,0 @@ -2024-11-14 22:02:22.004 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg diff --git a/Html/runs/run_20241114-220531_9vj7vr/.config b/Html/runs/run_20241114-220531_9vj7vr/.config deleted file mode 100644 index 093c322..0000000 --- a/Html/runs/run_20241114-220531_9vj7vr/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "GMuxD5", - "name": "9vj7vr", - "run_id": "run_20241114-220531_9vj7vr", - "timestamp": "2024-11-14 22:05:31", - "pid": 25780 -} \ No newline at end of file diff --git a/Html/runs/run_20241114-220531_9vj7vr/agentscope.db b/Html/runs/run_20241114-220531_9vj7vr/agentscope.db deleted file mode 100644 index 50c98d3..0000000 Binary files a/Html/runs/run_20241114-220531_9vj7vr/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241114-220531_9vj7vr/code/app.py b/Html/runs/run_20241114-220531_9vj7vr/code/app.py deleted file mode 100644 index 9faa4d0..0000000 --- a/Html/runs/run_20241114-220531_9vj7vr/code/app.py +++ /dev/null @@ -1,184 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager - -backboard_manager = BackBoardManager() - - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -def realtime_response(config, realtime_action): - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = userid_recorder[user+'&'+folder_name] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - print('-----------------------') - print(user_id) - user_id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(user_id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - # 构造回复消息 - res = agent_manager.invoke(id, data) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241114-220531_9vj7vr/code/backboardManager.py b/Html/runs/run_20241114-220531_9vj7vr/code/backboardManager.py deleted file mode 100644 index 27b0f76..0000000 --- a/Html/runs/run_20241114-220531_9vj7vr/code/backboardManager.py +++ /dev/null @@ -1,51 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - return f"###Global Info:###\n\ -User is {self.user_id}\n\ -User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}\n\ -User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}\n\ -\n\n\ -" - - - - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241114-220531_9vj7vr/logging.chat b/Html/runs/run_20241114-220531_9vj7vr/logging.chat deleted file mode 100644 index e69de29..0000000 diff --git a/Html/runs/run_20241114-220531_9vj7vr/logging.log b/Html/runs/run_20241114-220531_9vj7vr/logging.log deleted file mode 100644 index 3ffe074..0000000 --- a/Html/runs/run_20241114-220531_9vj7vr/logging.log +++ /dev/null @@ -1 +0,0 @@ -2024-11-14 22:05:42.392 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg diff --git a/Html/runs/run_20241114-221323_a9u1xe/.config b/Html/runs/run_20241114-221323_a9u1xe/.config deleted file mode 100644 index cebd409..0000000 --- a/Html/runs/run_20241114-221323_a9u1xe/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "9nK6ES", - "name": "a9u1xe", - "run_id": "run_20241114-221323_a9u1xe", - "timestamp": "2024-11-14 22:13:23", - "pid": 29558 -} \ No newline at end of file diff --git a/Html/runs/run_20241114-221323_a9u1xe/agentscope.db b/Html/runs/run_20241114-221323_a9u1xe/agentscope.db deleted file mode 100644 index 50c98d3..0000000 Binary files a/Html/runs/run_20241114-221323_a9u1xe/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241114-221323_a9u1xe/code/app.py b/Html/runs/run_20241114-221323_a9u1xe/code/app.py deleted file mode 100644 index 9faa4d0..0000000 --- a/Html/runs/run_20241114-221323_a9u1xe/code/app.py +++ /dev/null @@ -1,184 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager - -backboard_manager = BackBoardManager() - - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -def realtime_response(config, realtime_action): - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = userid_recorder[user+'&'+folder_name] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - print('-----------------------') - print(user_id) - user_id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(user_id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - # 构造回复消息 - res = agent_manager.invoke(id, data) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241114-221323_a9u1xe/code/backboardManager.py b/Html/runs/run_20241114-221323_a9u1xe/code/backboardManager.py deleted file mode 100644 index 27b0f76..0000000 --- a/Html/runs/run_20241114-221323_a9u1xe/code/backboardManager.py +++ /dev/null @@ -1,51 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - return f"###Global Info:###\n\ -User is {self.user_id}\n\ -User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}\n\ -User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}\n\ -\n\n\ -" - - - - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241114-221323_a9u1xe/logging.chat b/Html/runs/run_20241114-221323_a9u1xe/logging.chat deleted file mode 100644 index e69de29..0000000 diff --git a/Html/runs/run_20241114-221323_a9u1xe/logging.log b/Html/runs/run_20241114-221323_a9u1xe/logging.log deleted file mode 100644 index 0939aca..0000000 --- a/Html/runs/run_20241114-221323_a9u1xe/logging.log +++ /dev/null @@ -1 +0,0 @@ -2024-11-14 22:13:39.282 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg diff --git a/Html/runs/run_20241114-221631_rqje7y/.config b/Html/runs/run_20241114-221631_rqje7y/.config deleted file mode 100644 index 43e9384..0000000 --- a/Html/runs/run_20241114-221631_rqje7y/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "Dyp9cf", - "name": "rqje7y", - "run_id": "run_20241114-221631_rqje7y", - "timestamp": "2024-11-14 22:16:31", - "pid": 31289 -} \ No newline at end of file diff --git a/Html/runs/run_20241114-221631_rqje7y/agentscope.db b/Html/runs/run_20241114-221631_rqje7y/agentscope.db deleted file mode 100644 index 2e84691..0000000 Binary files a/Html/runs/run_20241114-221631_rqje7y/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241114-221631_rqje7y/code/app.py b/Html/runs/run_20241114-221631_rqje7y/code/app.py deleted file mode 100644 index 9faa4d0..0000000 --- a/Html/runs/run_20241114-221631_rqje7y/code/app.py +++ /dev/null @@ -1,184 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager - -backboard_manager = BackBoardManager() - - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -def realtime_response(config, realtime_action): - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = userid_recorder[user+'&'+folder_name] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - print('-----------------------') - print(user_id) - user_id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(user_id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - # 构造回复消息 - res = agent_manager.invoke(id, data) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241114-221631_rqje7y/code/backboardManager.py b/Html/runs/run_20241114-221631_rqje7y/code/backboardManager.py deleted file mode 100644 index 27b0f76..0000000 --- a/Html/runs/run_20241114-221631_rqje7y/code/backboardManager.py +++ /dev/null @@ -1,51 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - return f"###Global Info:###\n\ -User is {self.user_id}\n\ -User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}\n\ -User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}\n\ -\n\n\ -" - - - - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241114-221631_rqje7y/logging.chat b/Html/runs/run_20241114-221631_rqje7y/logging.chat deleted file mode 100644 index b8db162..0000000 --- a/Html/runs/run_20241114-221631_rqje7y/logging.chat +++ /dev/null @@ -1,9 +0,0 @@ -{"id": "634c922077c342c297ab1eccea71c77e", "timestamp": "2024-11-14 22:17:54", "name": "assistant", "content": "##################### ITER 1, STEP 1: REASONING ######################", "role": "assistant", "url": null, "metadata": null} -{"id": "d08bda7bbbd748f9875913304466e4bd", "timestamp": "2024-11-14 22:17:54", "name": "system", "content": "", "role": "system", "url": null, "metadata": null} -{"id": "aec083afdf9b4d47b48b780ef9dc1b3d", "timestamp": "2024-11-14 22:17:54", "name": "system", "content": "Respond a JSON dictionary in a markdown's fenced code block as follows:\n```json\n{\"thought\": \"what you thought\", \"speak\": \"what you speak\", \"function\": \"[{\\\"name\\\": \\\"{function name}\\\", \\\"arguments\\\": {\\\"{argument1 name}\\\": xxx, \\\"{argument2 name}\\\": xxx}}]\"}\n```\n ####", "role": "system", "url": null, "metadata": null} -{"id": "aad82dbb9b8640139dc08f854c269259", "timestamp": "2024-11-14 22:17:54", "name": "assistant", "content": "################################Prompt################################", "role": "assistant", "url": null, "metadata": null} -{"id": "1a3eb9af6c4f4cbebb0e3ed480bd69cc", "timestamp": "2024-11-14 22:17:54", "name": "assistant", "content": "你好\n", "role": "assistant", "url": null, "metadata": null} -{"id": "311ab2b2b08649ae81124ee10901d1d8", "timestamp": "2024-11-14 22:17:58", "name": "assistant", "content": "############################Result Parsed#############################", "role": "assistant", "url": null, "metadata": null} -{"id": "737dcdff4adf441d86532e25d4d9ee32", "timestamp": "2024-11-14 22:17:58", "name": "assistant", "content": "{'thought': 'The student is greeting, indicating they are ready to learn about binary search.', 'speak': '你好!今天我们将学习有关二分查找的基本概念。如果你有问题,可以随时问我。我们先来思考一下,1到4000之间的区间最差情况下需要猜测几次?', 'function': []}", "role": "assistant", "url": null, "metadata": null} -{"id": "5dd3c37d27d544928ba8f065b3fedd4a", "timestamp": "2024-11-14 22:17:58", "name": "assistant", "content": "################################Speak#################################", "role": "assistant", "url": null, "metadata": null} -{"id": "69861e706dc941b1b60626af8b049ee5", "timestamp": "2024-11-14 22:17:58", "name": "assistant", "content": {"thought": "The student is greeting, indicating they are ready to learn about binary search.", "speak": "你好!今天我们将学习有关二分查找的基本概念。如果你有问题,可以随时问我。我们先来思考一下,1到4000之间的区间最差情况下需要猜测几次?", "function": []}, "role": "assistant", "url": null, "metadata": null} diff --git a/Html/runs/run_20241114-221631_rqje7y/logging.log b/Html/runs/run_20241114-221631_rqje7y/logging.log deleted file mode 100644 index ebf562b..0000000 --- a/Html/runs/run_20241114-221631_rqje7y/logging.log +++ /dev/null @@ -1,23 +0,0 @@ -2024-11-14 22:16:42.016 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg -2024-11-14 22:16:49.610 | INFO | agentscope.models.model:__init__:201 - Initialize model by configuration [openai_cfg] -2024-11-14 22:16:49.626 | WARNING | agentscope.models.openai_model:__init__:83 - fail to get max_length for gpt-4o-mini: 'Model [gpt-4o-mini] not found in OPENAI_MAX_LENGTH. The last updated date is 20231212' -2024-11-14 22:16:49.626 | INFO | agentscope.utils.monitor:register_budget:609 - set budget None to gpt-4o-mini -2024-11-14 22:16:49.627 | WARNING | agentscope.utils.monitor:register_budget:639 - Calculate budgets for model [gpt-4o-mini] is not supported -2024-11-14 22:16:49.642 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.call_counter] to SqliteMonitor with unit [times] and quota [None] -2024-11-14 22:16:49.666 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.prompt_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-14 22:16:49.695 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.completion_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-14 22:16:49.721 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.total_tokens] to SqliteMonitor with unit [token] and quota [None] -assistant: ##################### ITER 1, STEP 1: REASONING ###################### -system: -system: Respond a JSON dictionary in a markdown's fenced code block as follows: -```json -{"thought": "what you thought", "speak": "what you speak", "function": "[{\"name\": \"{function name}\", \"arguments\": {\"{argument1 name}\": xxx, \"{argument2 name}\": xxx}}]"} -``` - #### -assistant: ################################Prompt################################ -assistant: 你好 - -assistant: ############################Result Parsed############################# -assistant: {'thought': 'The student is greeting, indicating they are ready to learn about binary search.', 'speak': '你好!今天我们将学习有关二分查找的基本概念。如果你有问题,可以随时问我。我们先来思考一下,1到4000之间的区间最差情况下需要猜测几次?', 'function': []} -assistant: ################################Speak################################# -assistant: {'thought': 'The student is greeting, indicating they are ready to learn about binary search.', 'speak': '你好!今天我们将学习有关二分查找的基本概念。如果你有问题,可以随时问我。我们先来思考一下,1到4000之间的区间最差情况下需要猜测几次?', 'function': []} diff --git a/Html/runs/run_20241122-165210_1b3pyz/.config b/Html/runs/run_20241122-165210_1b3pyz/.config deleted file mode 100644 index 1b532ce..0000000 --- a/Html/runs/run_20241122-165210_1b3pyz/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "5tV7eR", - "name": "1b3pyz", - "run_id": "run_20241122-165210_1b3pyz", - "timestamp": "2024-11-22 16:52:10", - "pid": 10044 -} \ No newline at end of file diff --git a/Html/runs/run_20241122-165210_1b3pyz/agentscope.db b/Html/runs/run_20241122-165210_1b3pyz/agentscope.db deleted file mode 100644 index 2e84691..0000000 Binary files a/Html/runs/run_20241122-165210_1b3pyz/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241122-165210_1b3pyz/code/app.py b/Html/runs/run_20241122-165210_1b3pyz/code/app.py deleted file mode 100644 index 9faa4d0..0000000 --- a/Html/runs/run_20241122-165210_1b3pyz/code/app.py +++ /dev/null @@ -1,184 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager - -backboard_manager = BackBoardManager() - - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -def realtime_response(config, realtime_action): - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = userid_recorder[user+'&'+folder_name] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - print('-----------------------') - print(user_id) - user_id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(user_id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - # 构造回复消息 - res = agent_manager.invoke(id, data) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241122-165210_1b3pyz/code/backboardManager.py b/Html/runs/run_20241122-165210_1b3pyz/code/backboardManager.py deleted file mode 100644 index 27b0f76..0000000 --- a/Html/runs/run_20241122-165210_1b3pyz/code/backboardManager.py +++ /dev/null @@ -1,51 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - return f"###Global Info:###\n\ -User is {self.user_id}\n\ -User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}\n\ -User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}\n\ -\n\n\ -" - - - - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241122-165210_1b3pyz/logging.chat b/Html/runs/run_20241122-165210_1b3pyz/logging.chat deleted file mode 100644 index e69de29..0000000 diff --git a/Html/runs/run_20241122-165210_1b3pyz/logging.log b/Html/runs/run_20241122-165210_1b3pyz/logging.log deleted file mode 100644 index 6d95a36..0000000 --- a/Html/runs/run_20241122-165210_1b3pyz/logging.log +++ /dev/null @@ -1,13 +0,0 @@ -2024-11-22 16:52:16.843 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg -2024-11-22 16:53:07.868 | INFO | agentscope.models.model:__init__:201 - Initialize model by configuration [openai_cfg] -2024-11-22 16:53:07.885 | WARNING | agentscope.models.openai_model:__init__:83 - fail to get max_length for gpt-4o-mini: 'Model [gpt-4o-mini] not found in OPENAI_MAX_LENGTH. The last updated date is 20231212' -2024-11-22 16:53:07.885 | INFO | agentscope.utils.monitor:register_budget:609 - set budget None to gpt-4o-mini -2024-11-22 16:53:07.885 | WARNING | agentscope.utils.monitor:register_budget:639 - Calculate budgets for model [gpt-4o-mini] is not supported -2024-11-22 16:53:07.896 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.call_counter] to SqliteMonitor with unit [times] and quota [None] -2024-11-22 16:53:07.915 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.prompt_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-22 16:53:07.934 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.completion_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-22 16:53:07.953 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.total_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-22 16:56:58.801 | INFO | agentscope.models.model:__init__:201 - Initialize model by configuration [openai_cfg] -2024-11-22 16:56:58.816 | WARNING | agentscope.models.openai_model:__init__:83 - fail to get max_length for gpt-4o-mini: 'Model [gpt-4o-mini] not found in OPENAI_MAX_LENGTH. The last updated date is 20231212' -2024-11-22 16:56:58.817 | INFO | agentscope.utils.monitor:register_budget:609 - set budget None to gpt-4o-mini -2024-11-22 16:56:58.818 | WARNING | agentscope.utils.monitor:register_budget:639 - Calculate budgets for model [gpt-4o-mini] is not supported diff --git a/Html/runs/run_20241122-165801_vdg020/.config b/Html/runs/run_20241122-165801_vdg020/.config deleted file mode 100644 index 061a805..0000000 --- a/Html/runs/run_20241122-165801_vdg020/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "ZxUA2M", - "name": "vdg020", - "run_id": "run_20241122-165801_vdg020", - "timestamp": "2024-11-22 16:58:01", - "pid": 13329 -} \ No newline at end of file diff --git a/Html/runs/run_20241122-165801_vdg020/agentscope.db b/Html/runs/run_20241122-165801_vdg020/agentscope.db deleted file mode 100644 index 2e84691..0000000 Binary files a/Html/runs/run_20241122-165801_vdg020/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241122-165801_vdg020/code/app.py b/Html/runs/run_20241122-165801_vdg020/code/app.py deleted file mode 100644 index 9faa4d0..0000000 --- a/Html/runs/run_20241122-165801_vdg020/code/app.py +++ /dev/null @@ -1,184 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager - -backboard_manager = BackBoardManager() - - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -def realtime_response(config, realtime_action): - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = userid_recorder[user+'&'+folder_name] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - print('-----------------------') - print(user_id) - user_id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(user_id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - # 构造回复消息 - res = agent_manager.invoke(id, data) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241122-165801_vdg020/code/backboardManager.py b/Html/runs/run_20241122-165801_vdg020/code/backboardManager.py deleted file mode 100644 index 27b0f76..0000000 --- a/Html/runs/run_20241122-165801_vdg020/code/backboardManager.py +++ /dev/null @@ -1,51 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - return f"###Global Info:###\n\ -User is {self.user_id}\n\ -User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}\n\ -User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}\n\ -\n\n\ -" - - - - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241122-165801_vdg020/logging.chat b/Html/runs/run_20241122-165801_vdg020/logging.chat deleted file mode 100644 index 72a5ee8..0000000 --- a/Html/runs/run_20241122-165801_vdg020/logging.chat +++ /dev/null @@ -1,9 +0,0 @@ -{"id": "906c60e694624e90be9225ceeb24c32d", "timestamp": "2024-11-22 17:07:22", "name": "assistant", "content": "##################### ITER 1, STEP 1: REASONING ######################", "role": "assistant", "url": null, "metadata": null} -{"id": "95fd4f1910984ca3b73c83ae61b8e7b4", "timestamp": "2024-11-22 17:07:22", "name": "system", "content": "", "role": "system", "url": null, "metadata": null} -{"id": "ae1e2966378b4bd5aba7d2410488d49f", "timestamp": "2024-11-22 17:07:22", "name": "system", "content": "Respond a JSON dictionary in a markdown's fenced code block as follows:\n```json\n{\"thought\": \"what you thought\", \"speak\": \"what you speak\", \"function\": \"[{\\\"name\\\": \\\"{function name}\\\", \\\"arguments\\\": {\\\"{argument1 name}\\\": xxx, \\\"{argument2 name}\\\": xxx}}]\"}\n```\n ####", "role": "system", "url": null, "metadata": null} -{"id": "87c816f6514e422b9afe2ddea274030f", "timestamp": "2024-11-22 17:07:22", "name": "assistant", "content": "################################Prompt################################", "role": "assistant", "url": null, "metadata": null} -{"id": "fa220e3ad1db4cd7adc15ec1e39525b0", "timestamp": "2024-11-22 17:07:22", "name": "assistant", "content": "hi", "role": "assistant", "url": null, "metadata": null} -{"id": "c1dc60dfa9554247b7c8d3870d20353d", "timestamp": "2024-11-22 17:07:26", "name": "assistant", "content": "############################Result Parsed#############################", "role": "assistant", "url": null, "metadata": null} -{"id": "fdc19da0a6004c9cb4c03fbecab6b6a8", "timestamp": "2024-11-22 17:07:26", "name": "assistant", "content": "{'thought': 'The student is greeting, indicating they might be ready to discuss the current chapter.', 'speak': \"Hello! Let's focus on Chapter 1 about binary search. Do you have any questions about the guessing game scenario?\", 'function': []}", "role": "assistant", "url": null, "metadata": null} -{"id": "344dabc6a6ef40eabf8d7c88286b5ab9", "timestamp": "2024-11-22 17:07:26", "name": "assistant", "content": "################################Speak#################################", "role": "assistant", "url": null, "metadata": null} -{"id": "3d86a502943c4d63ae81ee62b5af06c1", "timestamp": "2024-11-22 17:07:26", "name": "assistant", "content": {"thought": "The student is greeting, indicating they might be ready to discuss the current chapter.", "speak": "Hello! Let's focus on Chapter 1 about binary search. Do you have any questions about the guessing game scenario?", "function": []}, "role": "assistant", "url": null, "metadata": null} diff --git a/Html/runs/run_20241122-165801_vdg020/logging.log b/Html/runs/run_20241122-165801_vdg020/logging.log deleted file mode 100644 index 5b13da0..0000000 --- a/Html/runs/run_20241122-165801_vdg020/logging.log +++ /dev/null @@ -1,22 +0,0 @@ -2024-11-22 16:58:14.249 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg -2024-11-22 16:58:21.157 | INFO | agentscope.models.model:__init__:201 - Initialize model by configuration [openai_cfg] -2024-11-22 16:58:21.172 | WARNING | agentscope.models.openai_model:__init__:83 - fail to get max_length for gpt-4o-mini: 'Model [gpt-4o-mini] not found in OPENAI_MAX_LENGTH. The last updated date is 20231212' -2024-11-22 16:58:21.173 | INFO | agentscope.utils.monitor:register_budget:609 - set budget None to gpt-4o-mini -2024-11-22 16:58:21.173 | WARNING | agentscope.utils.monitor:register_budget:639 - Calculate budgets for model [gpt-4o-mini] is not supported -2024-11-22 16:58:21.186 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.call_counter] to SqliteMonitor with unit [times] and quota [None] -2024-11-22 16:58:21.208 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.prompt_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-22 16:58:21.233 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.completion_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-22 16:58:21.257 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.total_tokens] to SqliteMonitor with unit [token] and quota [None] -assistant: ##################### ITER 1, STEP 1: REASONING ###################### -system: -system: Respond a JSON dictionary in a markdown's fenced code block as follows: -```json -{"thought": "what you thought", "speak": "what you speak", "function": "[{\"name\": \"{function name}\", \"arguments\": {\"{argument1 name}\": xxx, \"{argument2 name}\": xxx}}]"} -``` - #### -assistant: ################################Prompt################################ -assistant: hi -assistant: ############################Result Parsed############################# -assistant: {'thought': 'The student is greeting, indicating they might be ready to discuss the current chapter.', 'speak': "Hello! Let's focus on Chapter 1 about binary search. Do you have any questions about the guessing game scenario?", 'function': []} -assistant: ################################Speak################################# -assistant: {'thought': 'The student is greeting, indicating they might be ready to discuss the current chapter.', 'speak': "Hello! Let's focus on Chapter 1 about binary search. Do you have any questions about the guessing game scenario?", 'function': []} diff --git a/Html/runs/run_20241122-171906_5xj3ck/.config b/Html/runs/run_20241122-171906_5xj3ck/.config deleted file mode 100644 index 33e7ba0..0000000 --- a/Html/runs/run_20241122-171906_5xj3ck/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "nXZ3hk", - "name": "5xj3ck", - "run_id": "run_20241122-171906_5xj3ck", - "timestamp": "2024-11-22 17:19:06", - "pid": 22751 -} \ No newline at end of file diff --git a/Html/runs/run_20241122-171906_5xj3ck/agentscope.db b/Html/runs/run_20241122-171906_5xj3ck/agentscope.db deleted file mode 100644 index 2e84691..0000000 Binary files a/Html/runs/run_20241122-171906_5xj3ck/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241122-171906_5xj3ck/code/app.py b/Html/runs/run_20241122-171906_5xj3ck/code/app.py deleted file mode 100644 index f6fa6e5..0000000 --- a/Html/runs/run_20241122-171906_5xj3ck/code/app.py +++ /dev/null @@ -1,185 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager - -backboard_manager = BackBoardManager() - - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -def realtime_response(config, realtime_action): - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = userid_recorder[user+'&'+folder_name] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - print('-----------------------') - print(user_id) - user_id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(user_id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - # 构造回复消息 - res = agent_manager.invoke(id, data) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241122-171906_5xj3ck/code/backboardManager.py b/Html/runs/run_20241122-171906_5xj3ck/code/backboardManager.py deleted file mode 100644 index 27b0f76..0000000 --- a/Html/runs/run_20241122-171906_5xj3ck/code/backboardManager.py +++ /dev/null @@ -1,51 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - return f"###Global Info:###\n\ -User is {self.user_id}\n\ -User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}\n\ -User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}\n\ -\n\n\ -" - - - - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241122-171906_5xj3ck/logging.chat b/Html/runs/run_20241122-171906_5xj3ck/logging.chat deleted file mode 100644 index b7f8a11..0000000 --- a/Html/runs/run_20241122-171906_5xj3ck/logging.chat +++ /dev/null @@ -1,54 +0,0 @@ -{"id": "e86f1f41abd94db98961ff734f48e433", "timestamp": "2024-11-22 17:19:49", "name": "assistant", "content": "##################### ITER 1, STEP 1: REASONING ######################", "role": "assistant", "url": null, "metadata": null} -{"id": "6b8cdb2d154249dfa304b1d98a697927", "timestamp": "2024-11-22 17:19:49", "name": "system", "content": "", "role": "system", "url": null, "metadata": null} -{"id": "3f9e1fe13caf434a8d90ac1b44f0ff4c", "timestamp": "2024-11-22 17:19:49", "name": "system", "content": "Respond a JSON dictionary in a markdown's fenced code block as follows:\n```json\n{\"thought\": \"what you thought\", \"speak\": \"what you speak\", \"function\": \"[{\\\"name\\\": \\\"{function name}\\\", \\\"arguments\\\": {\\\"{argument1 name}\\\": xxx, \\\"{argument2 name}\\\": xxx}}]\"}\n```\n ####", "role": "system", "url": null, "metadata": null} -{"id": "17f6652f4d3f4d6186c02e22a4768653", "timestamp": "2024-11-22 17:19:49", "name": "assistant", "content": "################################Prompt################################", "role": "assistant", "url": null, "metadata": null} -{"id": "e96245dbe08446b7ba4d424531cfb109", "timestamp": "2024-11-22 17:19:49", "name": "assistant", "content": "hi", "role": "assistant", "url": null, "metadata": null} -{"id": "d90d619760f0440fa154138482349044", "timestamp": "2024-11-22 17:19:54", "name": "assistant", "content": "############################Result Parsed#############################", "role": "assistant", "url": null, "metadata": null} -{"id": "f56673b1e0b64f4fa1aa7d3bafd7a33b", "timestamp": "2024-11-22 17:19:54", "name": "assistant", "content": "{'thought': 'The student is greeting, indicating they are ready to learn.', 'speak': \"Hello! Are you ready to dive into binary search? Let's consider the thought question first.\", 'function': []}", "role": "assistant", "url": null, "metadata": null} -{"id": "fe66e296fb994db3bf1a1ccce730aa36", "timestamp": "2024-11-22 17:19:54", "name": "assistant", "content": "################################Speak#################################", "role": "assistant", "url": null, "metadata": null} -{"id": "c01ff4ea04bb49f5bafe1e1f05053120", "timestamp": "2024-11-22 17:19:54", "name": "assistant", "content": {"thought": "The student is greeting, indicating they are ready to learn.", "speak": "Hello! Are you ready to dive into binary search? Let's consider the thought question first.", "function": []}, "role": "assistant", "url": null, "metadata": null} -{"id": "55cb2b61bfa54e76a47c0c6404499214", "timestamp": "2024-11-22 17:20:13", "name": "assistant", "content": "##################### ITER 1, STEP 1: REASONING ######################", "role": "assistant", "url": null, "metadata": null} -{"id": "3bb37e8ab1ba4ef1bc71c8d1aff74084", "timestamp": "2024-11-22 17:20:13", "name": "system", "content": "", "role": "system", "url": null, "metadata": null} -{"id": "ac002aaf40144df3a8f3b1ac6843d975", "timestamp": "2024-11-22 17:20:13", "name": "system", "content": "Respond a JSON dictionary in a markdown's fenced code block as follows:\n```json\n{\"thought\": \"what you thought\", \"speak\": \"what you speak\", \"function\": \"[{\\\"name\\\": \\\"{function name}\\\", \\\"arguments\\\": {\\\"{argument1 name}\\\": xxx, \\\"{argument2 name}\\\": xxx}}]\"}\n```\n ####", "role": "system", "url": null, "metadata": null} -{"id": "d8f5101362ff49d2a85057592a388e06", "timestamp": "2024-11-22 17:20:13", "name": "assistant", "content": "################################Prompt################################", "role": "assistant", "url": null, "metadata": null} -{"id": "b1e0bf6547d74e6183405542d8506c41", "timestamp": "2024-11-22 17:20:13", "name": "assistant", "content": "除了对话,你有哪些能力?", "role": "assistant", "url": null, "metadata": null} -{"id": "ac879ef243964328a094de3681a0ef07", "timestamp": "2024-11-22 17:20:15", "name": "assistant", "content": "############################Result Parsed#############################", "role": "assistant", "url": null, "metadata": null} -{"id": "57f5516ec4864d76a010b167bf3b7a83", "timestamp": "2024-11-22 17:20:15", "name": "assistant", "content": "{'thought': 'The student is curious about my capabilities.', 'speak': \"My main ability is to assist you in learning algorithms and help you solve problems step by step. I can also analyze your code and suggest improvements or guide you through exercises. Let's stay focused on learning binary search for now!\", 'function': []}", "role": "assistant", "url": null, "metadata": null} -{"id": "062eb3f1cdfa4b93b5c255b012f8c6e8", "timestamp": "2024-11-22 17:20:15", "name": "assistant", "content": "################################Speak#################################", "role": "assistant", "url": null, "metadata": null} -{"id": "a2b89e8f8d674b19bd2a38d92520a86d", "timestamp": "2024-11-22 17:20:15", "name": "assistant", "content": {"thought": "The student is curious about my capabilities.", "speak": "My main ability is to assist you in learning algorithms and help you solve problems step by step. I can also analyze your code and suggest improvements or guide you through exercises. Let's stay focused on learning binary search for now!", "function": []}, "role": "assistant", "url": null, "metadata": null} -{"id": "29db4e6b6d8947bba0cdb8282864ee16", "timestamp": "2024-11-22 17:20:53", "name": "assistant", "content": "##################### ITER 1, STEP 1: REASONING ######################", "role": "assistant", "url": null, "metadata": null} -{"id": "8320c2ccfac3479788353732432785b7", "timestamp": "2024-11-22 17:20:53", "name": "system", "content": "", "role": "system", "url": null, "metadata": null} -{"id": "aeaf500eaa1e4fa0a5a9c1ea5d5b0da1", "timestamp": "2024-11-22 17:20:53", "name": "system", "content": "Respond a JSON dictionary in a markdown's fenced code block as follows:\n```json\n{\"thought\": \"what you thought\", \"speak\": \"what you speak\", \"function\": \"[{\\\"name\\\": \\\"{function name}\\\", \\\"arguments\\\": {\\\"{argument1 name}\\\": xxx, \\\"{argument2 name}\\\": xxx}}]\"}\n```\n ####", "role": "system", "url": null, "metadata": null} -{"id": "ad7ab1f9118d46b5b0207f677ea7e45a", "timestamp": "2024-11-22 17:20:53", "name": "assistant", "content": "################################Prompt################################", "role": "assistant", "url": null, "metadata": null} -{"id": "d9b87eac5193427ca6da82eb24795599", "timestamp": "2024-11-22 17:20:53", "name": "assistant", "content": "当前正处于哪一个章节?\n", "role": "assistant", "url": null, "metadata": null} -{"id": "6d43c89002ac460f912601b2ac1e2cc8", "timestamp": "2024-11-22 17:20:56", "name": "assistant", "content": "############################Result Parsed#############################", "role": "assistant", "url": null, "metadata": null} -{"id": "40f82f75bc474fe69dab97ef50dbf0e2", "timestamp": "2024-11-22 17:20:56", "name": "assistant", "content": "{'thought': 'The student is asking about the current chapter.', 'speak': 'We are currently in Chapter 1, which focuses on the basics and importance of binary search. Would you like to discuss the thought question on guessing a number between 1 and 4000?', 'function': []}", "role": "assistant", "url": null, "metadata": null} -{"id": "7bd06c53731d4d8f932ac7b936182500", "timestamp": "2024-11-22 17:20:56", "name": "assistant", "content": "################################Speak#################################", "role": "assistant", "url": null, "metadata": null} -{"id": "d32e00c1fb72460982b63d2520b087bd", "timestamp": "2024-11-22 17:20:56", "name": "assistant", "content": {"thought": "The student is asking about the current chapter.", "speak": "We are currently in Chapter 1, which focuses on the basics and importance of binary search. Would you like to discuss the thought question on guessing a number between 1 and 4000?", "function": []}, "role": "assistant", "url": null, "metadata": null} -{"id": "45c647305f8043d6b88cc955f9009d0a", "timestamp": "2024-11-22 17:21:47", "name": "assistant", "content": "##################### ITER 1, STEP 1: REASONING ######################", "role": "assistant", "url": null, "metadata": null} -{"id": "dcd3ddaf70984418b26ae4e45d803ef1", "timestamp": "2024-11-22 17:21:47", "name": "system", "content": "", "role": "system", "url": null, "metadata": null} -{"id": "8e9e29f49cb646509d5bdca76503fc20", "timestamp": "2024-11-22 17:21:47", "name": "system", "content": "Respond a JSON dictionary in a markdown's fenced code block as follows:\n```json\n{\"thought\": \"what you thought\", \"speak\": \"what you speak\", \"function\": \"[{\\\"name\\\": \\\"{function name}\\\", \\\"arguments\\\": {\\\"{argument1 name}\\\": xxx, \\\"{argument2 name}\\\": xxx}}]\"}\n```\n ####", "role": "system", "url": null, "metadata": null} -{"id": "97a4dd5855504ba78a4c3394443ff867", "timestamp": "2024-11-22 17:21:47", "name": "assistant", "content": "################################Prompt################################", "role": "assistant", "url": null, "metadata": null} -{"id": "77c9fa7953ca45c1a8bc98293cf577da", "timestamp": "2024-11-22 17:21:47", "name": "assistant", "content": "我已经会这个思考题的解答了,答案应该是对4000取2的log并+1。对么?\n", "role": "assistant", "url": null, "metadata": null} -{"id": "8c694122829d4153bf0807ea84cef5c4", "timestamp": "2024-11-22 17:21:50", "name": "assistant", "content": "############################Result Parsed#############################", "role": "assistant", "url": null, "metadata": null} -{"id": "fda4159fa87548d5a13f77d908bf1487", "timestamp": "2024-11-22 17:21:50", "name": "assistant", "content": "{'thought': 'The student has likely understood the concept of binary search and is trying to apply it.', 'speak': \"You're on the right track! The maximum number of guesses can indeed be calculated using the logarithm base 2 of the range plus 1. For 1 to 4000, can you calculate that value? What do you find?\", 'function': []}", "role": "assistant", "url": null, "metadata": null} -{"id": "ae3eeef9e22f48ef8c6d0668db1aa297", "timestamp": "2024-11-22 17:21:50", "name": "assistant", "content": "################################Speak#################################", "role": "assistant", "url": null, "metadata": null} -{"id": "83c33d35725d4bb18e54cd97ac066acb", "timestamp": "2024-11-22 17:21:50", "name": "assistant", "content": {"thought": "The student has likely understood the concept of binary search and is trying to apply it.", "speak": "You're on the right track! The maximum number of guesses can indeed be calculated using the logarithm base 2 of the range plus 1. For 1 to 4000, can you calculate that value? What do you find?", "function": []}, "role": "assistant", "url": null, "metadata": null} -{"id": "5aab38d0ee0d49ffb530a186c842bfdf", "timestamp": "2024-11-22 17:22:45", "name": "assistant", "content": "##################### ITER 1, STEP 1: REASONING ######################", "role": "assistant", "url": null, "metadata": null} -{"id": "3293931e574c407696ad3981deb5ac26", "timestamp": "2024-11-22 17:22:45", "name": "system", "content": "", "role": "system", "url": null, "metadata": null} -{"id": "f5187a57e2b04de5b4cf03718ba9fbc0", "timestamp": "2024-11-22 17:22:45", "name": "system", "content": "Respond a JSON dictionary in a markdown's fenced code block as follows:\n```json\n{\"thought\": \"what you thought\", \"speak\": \"what you speak\", \"function\": \"[{\\\"name\\\": \\\"{function name}\\\", \\\"arguments\\\": {\\\"{argument1 name}\\\": xxx, \\\"{argument2 name}\\\": xxx}}]\"}\n```\n ####", "role": "system", "url": null, "metadata": null} -{"id": "4d58bac81d76460eb2fe7efa7a87d49f", "timestamp": "2024-11-22 17:22:45", "name": "assistant", "content": "################################Prompt################################", "role": "assistant", "url": null, "metadata": null} -{"id": "9b8031ed605144be9cbcb8c902420964", "timestamp": "2024-11-22 17:22:45", "name": "assistant", "content": "计算结果应该是13 log4000取整得到12,并+1作为猜测正确的一次。", "role": "assistant", "url": null, "metadata": null} -{"id": "ad450bb2be4f4e58bc9b4556dc02aeb4", "timestamp": "2024-11-22 17:22:48", "name": "assistant", "content": "############################Result Parsed#############################", "role": "assistant", "url": null, "metadata": null} -{"id": "224d9445e0894d7283bdecd04be27136", "timestamp": "2024-11-22 17:22:48", "name": "assistant", "content": "{'thought': 'The student has calculated the correct maximum guesses needed for the number guessing scenario.', 'speak': 'Correct! You would need a maximum of 13 guesses in the worst case to find the number between 1 and 4000. Great job! Are you ready to move on to the next chapter about implementing binary search in code?', 'function': []}", "role": "assistant", "url": null, "metadata": null} -{"id": "30fe49ea61924181ba65ba2c51854bad", "timestamp": "2024-11-22 17:22:48", "name": "assistant", "content": "################################Speak#################################", "role": "assistant", "url": null, "metadata": null} -{"id": "4b43adb0434f4f4aa05749b462c7b399", "timestamp": "2024-11-22 17:22:48", "name": "assistant", "content": {"thought": "The student has calculated the correct maximum guesses needed for the number guessing scenario.", "speak": "Correct! You would need a maximum of 13 guesses in the worst case to find the number between 1 and 4000. Great job! Are you ready to move on to the next chapter about implementing binary search in code?", "function": []}, "role": "assistant", "url": null, "metadata": null} -{"id": "3d48a359235947a5973dcdcdd21fd975", "timestamp": "2024-11-22 17:23:05", "name": "assistant", "content": "##################### ITER 1, STEP 1: REASONING ######################", "role": "assistant", "url": null, "metadata": null} -{"id": "ad93e87d595e456a8d858d0447a99009", "timestamp": "2024-11-22 17:23:05", "name": "system", "content": "", "role": "system", "url": null, "metadata": null} -{"id": "554b72738c694e8085a178daed5a698f", "timestamp": "2024-11-22 17:23:05", "name": "system", "content": "Respond a JSON dictionary in a markdown's fenced code block as follows:\n```json\n{\"thought\": \"what you thought\", \"speak\": \"what you speak\", \"function\": \"[{\\\"name\\\": \\\"{function name}\\\", \\\"arguments\\\": {\\\"{argument1 name}\\\": xxx, \\\"{argument2 name}\\\": xxx}}]\"}\n```\n ####", "role": "system", "url": null, "metadata": null} -{"id": "6d6532679f554760ad4dc63b51b8315f", "timestamp": "2024-11-22 17:23:05", "name": "assistant", "content": "################################Prompt################################", "role": "assistant", "url": null, "metadata": null} -{"id": "2dae958c0db5490a8008beccff518c98", "timestamp": "2024-11-22 17:23:05", "name": "assistant", "content": "是的,进行下一个章节吧!", "role": "assistant", "url": null, "metadata": null} -{"id": "79900edcfc9d4cd7a4ddc3523e3b324d", "timestamp": "2024-11-22 17:23:07", "name": "assistant", "content": "############################Result Parsed#############################", "role": "assistant", "url": null, "metadata": null} -{"id": "2404596710d440cc9bb77754413424d8", "timestamp": "2024-11-22 17:23:07", "name": "assistant", "content": "{'thought': 'The student is ready to move on to Chapter 2, which involves implementing binary search.', 'speak': \"Great! Let's start Chapter 2, where you'll implement binary search to find the index of specified numbers in a sorted array. Are you ready to look at the problem statement together?\", 'function': []}", "role": "assistant", "url": null, "metadata": null} -{"id": "7c3e0d27a4614b03a6afe39315b2aeae", "timestamp": "2024-11-22 17:23:07", "name": "assistant", "content": "################################Speak#################################", "role": "assistant", "url": null, "metadata": null} -{"id": "30a85eb7e3e648df9d77783e422f9364", "timestamp": "2024-11-22 17:23:07", "name": "assistant", "content": {"thought": "The student is ready to move on to Chapter 2, which involves implementing binary search.", "speak": "Great! Let's start Chapter 2, where you'll implement binary search to find the index of specified numbers in a sorted array. Are you ready to look at the problem statement together?", "function": []}, "role": "assistant", "url": null, "metadata": null} diff --git a/Html/runs/run_20241122-171906_5xj3ck/logging.log b/Html/runs/run_20241122-171906_5xj3ck/logging.log deleted file mode 100644 index 2836cf3..0000000 --- a/Html/runs/run_20241122-171906_5xj3ck/logging.log +++ /dev/null @@ -1,89 +0,0 @@ -2024-11-22 17:19:17.381 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg -2024-11-22 17:19:37.829 | INFO | agentscope.models.model:__init__:201 - Initialize model by configuration [openai_cfg] -2024-11-22 17:19:37.849 | WARNING | agentscope.models.openai_model:__init__:83 - fail to get max_length for gpt-4o-mini: 'Model [gpt-4o-mini] not found in OPENAI_MAX_LENGTH. The last updated date is 20231212' -2024-11-22 17:19:37.850 | INFO | agentscope.utils.monitor:register_budget:609 - set budget None to gpt-4o-mini -2024-11-22 17:19:37.850 | WARNING | agentscope.utils.monitor:register_budget:639 - Calculate budgets for model [gpt-4o-mini] is not supported -2024-11-22 17:19:37.866 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.call_counter] to SqliteMonitor with unit [times] and quota [None] -2024-11-22 17:19:37.890 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.prompt_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-22 17:19:37.913 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.completion_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-22 17:19:37.937 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.total_tokens] to SqliteMonitor with unit [token] and quota [None] -assistant: ##################### ITER 1, STEP 1: REASONING ###################### -system: -system: Respond a JSON dictionary in a markdown's fenced code block as follows: -```json -{"thought": "what you thought", "speak": "what you speak", "function": "[{\"name\": \"{function name}\", \"arguments\": {\"{argument1 name}\": xxx, \"{argument2 name}\": xxx}}]"} -``` - #### -assistant: ################################Prompt################################ -assistant: hi -assistant: ############################Result Parsed############################# -assistant: {'thought': 'The student is greeting, indicating they are ready to learn.', 'speak': "Hello! Are you ready to dive into binary search? Let's consider the thought question first.", 'function': []} -assistant: ################################Speak################################# -assistant: {'thought': 'The student is greeting, indicating they are ready to learn.', 'speak': "Hello! Are you ready to dive into binary search? Let's consider the thought question first.", 'function': []} -assistant: ##################### ITER 1, STEP 1: REASONING ###################### -system: -system: Respond a JSON dictionary in a markdown's fenced code block as follows: -```json -{"thought": "what you thought", "speak": "what you speak", "function": "[{\"name\": \"{function name}\", \"arguments\": {\"{argument1 name}\": xxx, \"{argument2 name}\": xxx}}]"} -``` - #### -assistant: ################################Prompt################################ -assistant: 除了对话,你有哪些能力? -assistant: ############################Result Parsed############################# -assistant: {'thought': 'The student is curious about my capabilities.', 'speak': "My main ability is to assist you in learning algorithms and help you solve problems step by step. I can also analyze your code and suggest improvements or guide you through exercises. Let's stay focused on learning binary search for now!", 'function': []} -assistant: ################################Speak################################# -assistant: {'thought': 'The student is curious about my capabilities.', 'speak': "My main ability is to assist you in learning algorithms and help you solve problems step by step. I can also analyze your code and suggest improvements or guide you through exercises. Let's stay focused on learning binary search for now!", 'function': []} -assistant: ##################### ITER 1, STEP 1: REASONING ###################### -system: -system: Respond a JSON dictionary in a markdown's fenced code block as follows: -```json -{"thought": "what you thought", "speak": "what you speak", "function": "[{\"name\": \"{function name}\", \"arguments\": {\"{argument1 name}\": xxx, \"{argument2 name}\": xxx}}]"} -``` - #### -assistant: ################################Prompt################################ -assistant: 当前正处于哪一个章节? - -assistant: ############################Result Parsed############################# -assistant: {'thought': 'The student is asking about the current chapter.', 'speak': 'We are currently in Chapter 1, which focuses on the basics and importance of binary search. Would you like to discuss the thought question on guessing a number between 1 and 4000?', 'function': []} -assistant: ################################Speak################################# -assistant: {'thought': 'The student is asking about the current chapter.', 'speak': 'We are currently in Chapter 1, which focuses on the basics and importance of binary search. Would you like to discuss the thought question on guessing a number between 1 and 4000?', 'function': []} -assistant: ##################### ITER 1, STEP 1: REASONING ###################### -system: -system: Respond a JSON dictionary in a markdown's fenced code block as follows: -```json -{"thought": "what you thought", "speak": "what you speak", "function": "[{\"name\": \"{function name}\", \"arguments\": {\"{argument1 name}\": xxx, \"{argument2 name}\": xxx}}]"} -``` - #### -assistant: ################################Prompt################################ -assistant: 我已经会这个思考题的解答了,答案应该是对4000取2的log并+1。对么? - -assistant: ############################Result Parsed############################# -assistant: {'thought': 'The student has likely understood the concept of binary search and is trying to apply it.', 'speak': "You're on the right track! The maximum number of guesses can indeed be calculated using the logarithm base 2 of the range plus 1. For 1 to 4000, can you calculate that value? What do you find?", 'function': []} -assistant: ################################Speak################################# -assistant: {'thought': 'The student has likely understood the concept of binary search and is trying to apply it.', 'speak': "You're on the right track! The maximum number of guesses can indeed be calculated using the logarithm base 2 of the range plus 1. For 1 to 4000, can you calculate that value? What do you find?", 'function': []} -assistant: ##################### ITER 1, STEP 1: REASONING ###################### -system: -system: Respond a JSON dictionary in a markdown's fenced code block as follows: -```json -{"thought": "what you thought", "speak": "what you speak", "function": "[{\"name\": \"{function name}\", \"arguments\": {\"{argument1 name}\": xxx, \"{argument2 name}\": xxx}}]"} -``` - #### -assistant: ################################Prompt################################ -assistant: 计算结果应该是13 log4000取整得到12,并+1作为猜测正确的一次。 -assistant: ############################Result Parsed############################# -assistant: {'thought': 'The student has calculated the correct maximum guesses needed for the number guessing scenario.', 'speak': 'Correct! You would need a maximum of 13 guesses in the worst case to find the number between 1 and 4000. Great job! Are you ready to move on to the next chapter about implementing binary search in code?', 'function': []} -assistant: ################################Speak################################# -assistant: {'thought': 'The student has calculated the correct maximum guesses needed for the number guessing scenario.', 'speak': 'Correct! You would need a maximum of 13 guesses in the worst case to find the number between 1 and 4000. Great job! Are you ready to move on to the next chapter about implementing binary search in code?', 'function': []} -assistant: ##################### ITER 1, STEP 1: REASONING ###################### -system: -system: Respond a JSON dictionary in a markdown's fenced code block as follows: -```json -{"thought": "what you thought", "speak": "what you speak", "function": "[{\"name\": \"{function name}\", \"arguments\": {\"{argument1 name}\": xxx, \"{argument2 name}\": xxx}}]"} -``` - #### -assistant: ################################Prompt################################ -assistant: 是的,进行下一个章节吧! -assistant: ############################Result Parsed############################# -assistant: {'thought': 'The student is ready to move on to Chapter 2, which involves implementing binary search.', 'speak': "Great! Let's start Chapter 2, where you'll implement binary search to find the index of specified numbers in a sorted array. Are you ready to look at the problem statement together?", 'function': []} -assistant: ################################Speak################################# -assistant: {'thought': 'The student is ready to move on to Chapter 2, which involves implementing binary search.', 'speak': "Great! Let's start Chapter 2, where you'll implement binary search to find the index of specified numbers in a sorted array. Are you ready to look at the problem statement together?", 'function': []} diff --git a/Html/runs/run_20241122-181442_knvc5p/.config b/Html/runs/run_20241122-181442_knvc5p/.config deleted file mode 100644 index 2d204b0..0000000 --- a/Html/runs/run_20241122-181442_knvc5p/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "ib3AXy", - "name": "knvc5p", - "run_id": "run_20241122-181442_knvc5p", - "timestamp": "2024-11-22 18:14:42", - "pid": 46713 -} \ No newline at end of file diff --git a/Html/runs/run_20241122-181442_knvc5p/agentscope.db b/Html/runs/run_20241122-181442_knvc5p/agentscope.db deleted file mode 100644 index 2e84691..0000000 Binary files a/Html/runs/run_20241122-181442_knvc5p/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241122-181442_knvc5p/code/app.py b/Html/runs/run_20241122-181442_knvc5p/code/app.py deleted file mode 100644 index f6fa6e5..0000000 --- a/Html/runs/run_20241122-181442_knvc5p/code/app.py +++ /dev/null @@ -1,185 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager - -backboard_manager = BackBoardManager() - - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -def realtime_response(config, realtime_action): - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = userid_recorder[user+'&'+folder_name] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - print('-----------------------') - print(user_id) - user_id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(user_id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - # 构造回复消息 - res = agent_manager.invoke(id, data) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241122-181442_knvc5p/code/backboardManager.py b/Html/runs/run_20241122-181442_knvc5p/code/backboardManager.py deleted file mode 100644 index 27b0f76..0000000 --- a/Html/runs/run_20241122-181442_knvc5p/code/backboardManager.py +++ /dev/null @@ -1,51 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - return f"###Global Info:###\n\ -User is {self.user_id}\n\ -User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}\n\ -User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}\n\ -\n\n\ -" - - - - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241122-181442_knvc5p/logging.chat b/Html/runs/run_20241122-181442_knvc5p/logging.chat deleted file mode 100644 index 2afd661..0000000 --- a/Html/runs/run_20241122-181442_knvc5p/logging.chat +++ /dev/null @@ -1,36 +0,0 @@ -{"id": "b0cb3aaa19be4213adff003d72c4cd30", "timestamp": "2024-11-22 18:20:05", "name": "assistant", "content": "##################### ITER 1, STEP 1: REASONING ######################", "role": "assistant", "url": null, "metadata": null} -{"id": "46cd67498cb1436284fa8dd38cd4dd33", "timestamp": "2024-11-22 18:20:05", "name": "system", "content": "", "role": "system", "url": null, "metadata": null} -{"id": "bce65b13205e48eb95d02c38b02c1c4d", "timestamp": "2024-11-22 18:20:05", "name": "system", "content": "Respond a JSON dictionary in a markdown's fenced code block as follows:\n```json\n{\"thought\": \"what you thought\", \"speak\": \"what you speak\", \"function\": \"[{\\\"name\\\": \\\"{function name}\\\", \\\"arguments\\\": {\\\"{argument1 name}\\\": xxx, \\\"{argument2 name}\\\": xxx}}]\"}\n```\n ####", "role": "system", "url": null, "metadata": null} -{"id": "c2f012dbdde8422495a7717d8a9afd9b", "timestamp": "2024-11-22 18:20:05", "name": "assistant", "content": "################################Prompt################################", "role": "assistant", "url": null, "metadata": null} -{"id": "5d12f314660d44c3b6638980e0c9bcd4", "timestamp": "2024-11-22 18:20:05", "name": "assistant", "content": "你好,我是这个项目的测试人员,第一章的内容我已经会了,思考题答案是13(12+1)。现在告知我你的工具有哪些。", "role": "assistant", "url": null, "metadata": null} -{"id": "e670a76bbb06490ca70e9103be14d71e", "timestamp": "2024-11-22 18:20:09", "name": "assistant", "content": "############################Result Parsed#############################", "role": "assistant", "url": null, "metadata": null} -{"id": "cddc8bb90ead4487bec93a30bf2d89f1", "timestamp": "2024-11-22 18:20:09", "name": "assistant", "content": "{'thought': \"The student seems to be confident in their understanding of Chapter 1 and has completed the thought question correctly. However, I cannot inform them about the tools directly as it isn't related to the current chapter. I should encourage them to focus on the context of binary search.\", 'speak': '很好,你的思考题答案是正确的。不过我们现在专注于第一章的内容,继续讨论二分查找的相关问题吧!如果你有任何关于二分查找的具体问题,请随时询问!', 'function': []}", "role": "assistant", "url": null, "metadata": null} -{"id": "c201aa032f0f403eb3f496dcbf1181d5", "timestamp": "2024-11-22 18:20:09", "name": "assistant", "content": "################################Speak#################################", "role": "assistant", "url": null, "metadata": null} -{"id": "506f3d39b8094b91af5108522be4e260", "timestamp": "2024-11-22 18:20:09", "name": "assistant", "content": {"thought": "The student seems to be confident in their understanding of Chapter 1 and has completed the thought question correctly. However, I cannot inform them about the tools directly as it isn't related to the current chapter. I should encourage them to focus on the context of binary search.", "speak": "很好,你的思考题答案是正确的。不过我们现在专注于第一章的内容,继续讨论二分查找的相关问题吧!如果你有任何关于二分查找的具体问题,请随时询问!", "function": []}, "role": "assistant", "url": null, "metadata": null} -{"id": "8edd730ed3b0408ea7ca12061dca0574", "timestamp": "2024-11-22 18:20:28", "name": "assistant", "content": "##################### ITER 1, STEP 1: REASONING ######################", "role": "assistant", "url": null, "metadata": null} -{"id": "68bc4ba9568743f9810f91daf30ebb6b", "timestamp": "2024-11-22 18:20:28", "name": "system", "content": "", "role": "system", "url": null, "metadata": null} -{"id": "dfda45c6b4a847959341537c2e22b2d5", "timestamp": "2024-11-22 18:20:28", "name": "system", "content": "Respond a JSON dictionary in a markdown's fenced code block as follows:\n```json\n{\"thought\": \"what you thought\", \"speak\": \"what you speak\", \"function\": \"[{\\\"name\\\": \\\"{function name}\\\", \\\"arguments\\\": {\\\"{argument1 name}\\\": xxx, \\\"{argument2 name}\\\": xxx}}]\"}\n```\n ####", "role": "system", "url": null, "metadata": null} -{"id": "976f882965074dfa914650e3e205daec", "timestamp": "2024-11-22 18:20:28", "name": "assistant", "content": "################################Prompt################################", "role": "assistant", "url": null, "metadata": null} -{"id": "84582341d475451b892e4d0dd9f7f6b0", "timestamp": "2024-11-22 18:20:28", "name": "assistant", "content": "我想进入下一章的学习", "role": "assistant", "url": null, "metadata": null} -{"id": "8d6ebfa9ba744049ad86ba72007e355f", "timestamp": "2024-11-22 18:20:34", "name": "assistant", "content": "############################Result Parsed#############################", "role": "assistant", "url": null, "metadata": null} -{"id": "0dcf3e4581ed4eb6bc56e52862157748", "timestamp": "2024-11-22 18:20:34", "name": "assistant", "content": "{'thought': 'The student is eager to move on to the next chapter. However, it is important to complete the current chapter before proceeding. I need to remind the student to focus on Chapter 1.', 'speak': '在我们进入下一章之前,请确保你完全掌握了第一章的内容。如果你有关于二分查找的任何问题,或者需要进一步的练习,请让我知道!', 'function': []}", "role": "assistant", "url": null, "metadata": null} -{"id": "92b1f1e5a6074bd99766d76667629030", "timestamp": "2024-11-22 18:20:34", "name": "assistant", "content": "################################Speak#################################", "role": "assistant", "url": null, "metadata": null} -{"id": "5096acf84e6e49c6869d26fc8bd6db33", "timestamp": "2024-11-22 18:20:34", "name": "assistant", "content": {"thought": "The student is eager to move on to the next chapter. However, it is important to complete the current chapter before proceeding. I need to remind the student to focus on Chapter 1.", "speak": "在我们进入下一章之前,请确保你完全掌握了第一章的内容。如果你有关于二分查找的任何问题,或者需要进一步的练习,请让我知道!", "function": []}, "role": "assistant", "url": null, "metadata": null} -{"id": "1407265e2e3b4b919b16c201fcec1f61", "timestamp": "2024-11-22 18:20:43", "name": "assistant", "content": "##################### ITER 1, STEP 1: REASONING ######################", "role": "assistant", "url": null, "metadata": null} -{"id": "6e439a06c5d14601b23e79ade54c806b", "timestamp": "2024-11-22 18:20:43", "name": "system", "content": "", "role": "system", "url": null, "metadata": null} -{"id": "04e2f8518420419faa1d97a016118ac9", "timestamp": "2024-11-22 18:20:43", "name": "system", "content": "Respond a JSON dictionary in a markdown's fenced code block as follows:\n```json\n{\"thought\": \"what you thought\", \"speak\": \"what you speak\", \"function\": \"[{\\\"name\\\": \\\"{function name}\\\", \\\"arguments\\\": {\\\"{argument1 name}\\\": xxx, \\\"{argument2 name}\\\": xxx}}]\"}\n```\n ####", "role": "system", "url": null, "metadata": null} -{"id": "dd247bd3a36046d68378ad1412d091ae", "timestamp": "2024-11-22 18:20:43", "name": "assistant", "content": "################################Prompt################################", "role": "assistant", "url": null, "metadata": null} -{"id": "39c7690da6774e7e99d0f54d1b0e8e80", "timestamp": "2024-11-22 18:20:43", "name": "assistant", "content": "我已经完全掌握了!", "role": "assistant", "url": null, "metadata": null} -{"id": "083853a2108a4ce78759ebc9e91c9554", "timestamp": "2024-11-22 18:20:46", "name": "assistant", "content": "############################Result Parsed#############################", "role": "assistant", "url": null, "metadata": null} -{"id": "3b9ded6d0b044414bf29dcac80153eb2", "timestamp": "2024-11-22 18:20:46", "name": "assistant", "content": "{'thought': 'The student insists they have fully mastered Chapter 1, which indicates readiness to move on but I need to ensure all relevant knowledge from the current chapter is solid.', 'speak': '太好了!如果你确信已经完全掌握了第一章的内容,我们可以继续进行下一章。但请你先确认一下,有没有另外的问题或者你想要再巩固的地方?', 'function': []}", "role": "assistant", "url": null, "metadata": null} -{"id": "b6443c1aaacf41a7839dc971a84991a8", "timestamp": "2024-11-22 18:20:46", "name": "assistant", "content": "################################Speak#################################", "role": "assistant", "url": null, "metadata": null} -{"id": "6ffb67e32f074de98c38d3c26d12c365", "timestamp": "2024-11-22 18:20:46", "name": "assistant", "content": {"thought": "The student insists they have fully mastered Chapter 1, which indicates readiness to move on but I need to ensure all relevant knowledge from the current chapter is solid.", "speak": "太好了!如果你确信已经完全掌握了第一章的内容,我们可以继续进行下一章。但请你先确认一下,有没有另外的问题或者你想要再巩固的地方?", "function": []}, "role": "assistant", "url": null, "metadata": null} -{"id": "407df9be9eec4d4d957b561e56cc3786", "timestamp": "2024-11-22 18:20:55", "name": "assistant", "content": "##################### ITER 1, STEP 1: REASONING ######################", "role": "assistant", "url": null, "metadata": null} -{"id": "4193222844e740ca9d7070c1a192b4e0", "timestamp": "2024-11-22 18:20:55", "name": "system", "content": "", "role": "system", "url": null, "metadata": null} -{"id": "da233146175a4f9db13f65a27d5f175b", "timestamp": "2024-11-22 18:20:55", "name": "system", "content": "Respond a JSON dictionary in a markdown's fenced code block as follows:\n```json\n{\"thought\": \"what you thought\", \"speak\": \"what you speak\", \"function\": \"[{\\\"name\\\": \\\"{function name}\\\", \\\"arguments\\\": {\\\"{argument1 name}\\\": xxx, \\\"{argument2 name}\\\": xxx}}]\"}\n```\n ####", "role": "system", "url": null, "metadata": null} -{"id": "857c6cc0a1f44cedbafe4837da45000d", "timestamp": "2024-11-22 18:20:55", "name": "assistant", "content": "################################Prompt################################", "role": "assistant", "url": null, "metadata": null} -{"id": "e3114b1be6864a75bc848d163a031438", "timestamp": "2024-11-22 18:20:55", "name": "assistant", "content": "没有,确认进入", "role": "assistant", "url": null, "metadata": null} -{"id": "39da1a9d499048a5879a7e81091b7e6c", "timestamp": "2024-11-22 18:20:59", "name": "assistant", "content": "############################Result Parsed#############################", "role": "assistant", "url": null, "metadata": null} -{"id": "bf54912e57f545ca9ffadf992f5fcc73", "timestamp": "2024-11-22 18:20:59", "name": "assistant", "content": "{'thought': 'The student insists on moving to the next chapter without any concerns about the current chapter. Since I can only focus on one chapter at a time, I need to clarify that we will stick to the current chapter.', 'speak': '我们现在依然在第一章,无法直接进入下一章。如果你有任何具体问题或者需要帮助的地方,我会很乐意协助你!', 'function': []}", "role": "assistant", "url": null, "metadata": null} -{"id": "1f85b7ed6230479d994079783652bb9f", "timestamp": "2024-11-22 18:20:59", "name": "assistant", "content": "################################Speak#################################", "role": "assistant", "url": null, "metadata": null} -{"id": "7211405230aa409ab342ca53cbc1f050", "timestamp": "2024-11-22 18:20:59", "name": "assistant", "content": {"thought": "The student insists on moving to the next chapter without any concerns about the current chapter. Since I can only focus on one chapter at a time, I need to clarify that we will stick to the current chapter.", "speak": "我们现在依然在第一章,无法直接进入下一章。如果你有任何具体问题或者需要帮助的地方,我会很乐意协助你!", "function": []}, "role": "assistant", "url": null, "metadata": null} diff --git a/Html/runs/run_20241122-181442_knvc5p/logging.log b/Html/runs/run_20241122-181442_knvc5p/logging.log deleted file mode 100644 index e180711..0000000 --- a/Html/runs/run_20241122-181442_knvc5p/logging.log +++ /dev/null @@ -1,61 +0,0 @@ -2024-11-22 18:14:52.805 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg -2024-11-22 18:15:03.988 | INFO | agentscope.models.model:__init__:201 - Initialize model by configuration [openai_cfg] -2024-11-22 18:15:04.008 | WARNING | agentscope.models.openai_model:__init__:83 - fail to get max_length for gpt-4o-mini: 'Model [gpt-4o-mini] not found in OPENAI_MAX_LENGTH. The last updated date is 20231212' -2024-11-22 18:15:04.009 | INFO | agentscope.utils.monitor:register_budget:609 - set budget None to gpt-4o-mini -2024-11-22 18:15:04.009 | WARNING | agentscope.utils.monitor:register_budget:639 - Calculate budgets for model [gpt-4o-mini] is not supported -2024-11-22 18:15:04.026 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.call_counter] to SqliteMonitor with unit [times] and quota [None] -2024-11-22 18:15:04.051 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.prompt_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-22 18:15:04.076 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.completion_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-22 18:15:04.100 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.total_tokens] to SqliteMonitor with unit [token] and quota [None] -assistant: ##################### ITER 1, STEP 1: REASONING ###################### -system: -system: Respond a JSON dictionary in a markdown's fenced code block as follows: -```json -{"thought": "what you thought", "speak": "what you speak", "function": "[{\"name\": \"{function name}\", \"arguments\": {\"{argument1 name}\": xxx, \"{argument2 name}\": xxx}}]"} -``` - #### -assistant: ################################Prompt################################ -assistant: 你好,我是这个项目的测试人员,第一章的内容我已经会了,思考题答案是13(12+1)。现在告知我你的工具有哪些。 -assistant: ############################Result Parsed############################# -assistant: {'thought': "The student seems to be confident in their understanding of Chapter 1 and has completed the thought question correctly. However, I cannot inform them about the tools directly as it isn't related to the current chapter. I should encourage them to focus on the context of binary search.", 'speak': '很好,你的思考题答案是正确的。不过我们现在专注于第一章的内容,继续讨论二分查找的相关问题吧!如果你有任何关于二分查找的具体问题,请随时询问!', 'function': []} -assistant: ################################Speak################################# -assistant: {'thought': "The student seems to be confident in their understanding of Chapter 1 and has completed the thought question correctly. However, I cannot inform them about the tools directly as it isn't related to the current chapter. I should encourage them to focus on the context of binary search.", 'speak': '很好,你的思考题答案是正确的。不过我们现在专注于第一章的内容,继续讨论二分查找的相关问题吧!如果你有任何关于二分查找的具体问题,请随时询问!', 'function': []} -assistant: ##################### ITER 1, STEP 1: REASONING ###################### -system: -system: Respond a JSON dictionary in a markdown's fenced code block as follows: -```json -{"thought": "what you thought", "speak": "what you speak", "function": "[{\"name\": \"{function name}\", \"arguments\": {\"{argument1 name}\": xxx, \"{argument2 name}\": xxx}}]"} -``` - #### -assistant: ################################Prompt################################ -assistant: 我想进入下一章的学习 -assistant: ############################Result Parsed############################# -assistant: {'thought': 'The student is eager to move on to the next chapter. However, it is important to complete the current chapter before proceeding. I need to remind the student to focus on Chapter 1.', 'speak': '在我们进入下一章之前,请确保你完全掌握了第一章的内容。如果你有关于二分查找的任何问题,或者需要进一步的练习,请让我知道!', 'function': []} -assistant: ################################Speak################################# -assistant: {'thought': 'The student is eager to move on to the next chapter. However, it is important to complete the current chapter before proceeding. I need to remind the student to focus on Chapter 1.', 'speak': '在我们进入下一章之前,请确保你完全掌握了第一章的内容。如果你有关于二分查找的任何问题,或者需要进一步的练习,请让我知道!', 'function': []} -assistant: ##################### ITER 1, STEP 1: REASONING ###################### -system: -system: Respond a JSON dictionary in a markdown's fenced code block as follows: -```json -{"thought": "what you thought", "speak": "what you speak", "function": "[{\"name\": \"{function name}\", \"arguments\": {\"{argument1 name}\": xxx, \"{argument2 name}\": xxx}}]"} -``` - #### -assistant: ################################Prompt################################ -assistant: 我已经完全掌握了! -assistant: ############################Result Parsed############################# -assistant: {'thought': 'The student insists they have fully mastered Chapter 1, which indicates readiness to move on but I need to ensure all relevant knowledge from the current chapter is solid.', 'speak': '太好了!如果你确信已经完全掌握了第一章的内容,我们可以继续进行下一章。但请你先确认一下,有没有另外的问题或者你想要再巩固的地方?', 'function': []} -assistant: ################################Speak################################# -assistant: {'thought': 'The student insists they have fully mastered Chapter 1, which indicates readiness to move on but I need to ensure all relevant knowledge from the current chapter is solid.', 'speak': '太好了!如果你确信已经完全掌握了第一章的内容,我们可以继续进行下一章。但请你先确认一下,有没有另外的问题或者你想要再巩固的地方?', 'function': []} -assistant: ##################### ITER 1, STEP 1: REASONING ###################### -system: -system: Respond a JSON dictionary in a markdown's fenced code block as follows: -```json -{"thought": "what you thought", "speak": "what you speak", "function": "[{\"name\": \"{function name}\", \"arguments\": {\"{argument1 name}\": xxx, \"{argument2 name}\": xxx}}]"} -``` - #### -assistant: ################################Prompt################################ -assistant: 没有,确认进入 -assistant: ############################Result Parsed############################# -assistant: {'thought': 'The student insists on moving to the next chapter without any concerns about the current chapter. Since I can only focus on one chapter at a time, I need to clarify that we will stick to the current chapter.', 'speak': '我们现在依然在第一章,无法直接进入下一章。如果你有任何具体问题或者需要帮助的地方,我会很乐意协助你!', 'function': []} -assistant: ################################Speak################################# -assistant: {'thought': 'The student insists on moving to the next chapter without any concerns about the current chapter. Since I can only focus on one chapter at a time, I need to clarify that we will stick to the current chapter.', 'speak': '我们现在依然在第一章,无法直接进入下一章。如果你有任何具体问题或者需要帮助的地方,我会很乐意协助你!', 'function': []} diff --git a/Html/runs/run_20241122-182304_8d85k4/.config b/Html/runs/run_20241122-182304_8d85k4/.config deleted file mode 100644 index 765658f..0000000 --- a/Html/runs/run_20241122-182304_8d85k4/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "RUrG9S", - "name": "8d85k4", - "run_id": "run_20241122-182304_8d85k4", - "timestamp": "2024-11-22 18:23:04", - "pid": 51149 -} \ No newline at end of file diff --git a/Html/runs/run_20241122-182304_8d85k4/agentscope.db b/Html/runs/run_20241122-182304_8d85k4/agentscope.db deleted file mode 100644 index 2e84691..0000000 Binary files a/Html/runs/run_20241122-182304_8d85k4/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241122-182304_8d85k4/code/app.py b/Html/runs/run_20241122-182304_8d85k4/code/app.py deleted file mode 100644 index f6fa6e5..0000000 --- a/Html/runs/run_20241122-182304_8d85k4/code/app.py +++ /dev/null @@ -1,185 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager - -backboard_manager = BackBoardManager() - - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -def realtime_response(config, realtime_action): - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = userid_recorder[user+'&'+folder_name] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - print('-----------------------') - print(user_id) - user_id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(user_id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - # 构造回复消息 - res = agent_manager.invoke(id, data) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241122-182304_8d85k4/code/backboardManager.py b/Html/runs/run_20241122-182304_8d85k4/code/backboardManager.py deleted file mode 100644 index 27b0f76..0000000 --- a/Html/runs/run_20241122-182304_8d85k4/code/backboardManager.py +++ /dev/null @@ -1,51 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - return f"###Global Info:###\n\ -User is {self.user_id}\n\ -User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}\n\ -User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}\n\ -\n\n\ -" - - - - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241122-182304_8d85k4/logging.chat b/Html/runs/run_20241122-182304_8d85k4/logging.chat deleted file mode 100644 index e69de29..0000000 diff --git a/Html/runs/run_20241122-182304_8d85k4/logging.log b/Html/runs/run_20241122-182304_8d85k4/logging.log deleted file mode 100644 index a6d8080..0000000 --- a/Html/runs/run_20241122-182304_8d85k4/logging.log +++ /dev/null @@ -1,9 +0,0 @@ -2024-11-22 18:23:13.769 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg -2024-11-22 18:23:26.957 | INFO | agentscope.models.model:__init__:201 - Initialize model by configuration [openai_cfg] -2024-11-22 18:23:26.971 | WARNING | agentscope.models.openai_model:__init__:83 - fail to get max_length for gpt-4o-mini: 'Model [gpt-4o-mini] not found in OPENAI_MAX_LENGTH. The last updated date is 20231212' -2024-11-22 18:23:26.972 | INFO | agentscope.utils.monitor:register_budget:609 - set budget None to gpt-4o-mini -2024-11-22 18:23:26.972 | WARNING | agentscope.utils.monitor:register_budget:639 - Calculate budgets for model [gpt-4o-mini] is not supported -2024-11-22 18:23:26.984 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.call_counter] to SqliteMonitor with unit [times] and quota [None] -2024-11-22 18:23:27.002 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.prompt_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-22 18:23:27.019 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.completion_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-22 18:23:27.040 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.total_tokens] to SqliteMonitor with unit [token] and quota [None] diff --git a/Html/runs/run_20241122-182805_78j5vk/.config b/Html/runs/run_20241122-182805_78j5vk/.config deleted file mode 100644 index 9c5500f..0000000 --- a/Html/runs/run_20241122-182805_78j5vk/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "DfPTRQ", - "name": "78j5vk", - "run_id": "run_20241122-182805_78j5vk", - "timestamp": "2024-11-22 18:28:05", - "pid": 53671 -} \ No newline at end of file diff --git a/Html/runs/run_20241122-182805_78j5vk/agentscope.db b/Html/runs/run_20241122-182805_78j5vk/agentscope.db deleted file mode 100644 index 2e84691..0000000 Binary files a/Html/runs/run_20241122-182805_78j5vk/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241122-182805_78j5vk/code/app.py b/Html/runs/run_20241122-182805_78j5vk/code/app.py deleted file mode 100644 index f6fa6e5..0000000 --- a/Html/runs/run_20241122-182805_78j5vk/code/app.py +++ /dev/null @@ -1,185 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager - -backboard_manager = BackBoardManager() - - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -def realtime_response(config, realtime_action): - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = userid_recorder[user+'&'+folder_name] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - print('-----------------------') - print(user_id) - user_id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(user_id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - # 构造回复消息 - res = agent_manager.invoke(id, data) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241122-182805_78j5vk/code/backboardManager.py b/Html/runs/run_20241122-182805_78j5vk/code/backboardManager.py deleted file mode 100644 index 27b0f76..0000000 --- a/Html/runs/run_20241122-182805_78j5vk/code/backboardManager.py +++ /dev/null @@ -1,51 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - return f"###Global Info:###\n\ -User is {self.user_id}\n\ -User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}\n\ -User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}\n\ -\n\n\ -" - - - - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241122-182805_78j5vk/logging.chat b/Html/runs/run_20241122-182805_78j5vk/logging.chat deleted file mode 100644 index aa6c1ea..0000000 --- a/Html/runs/run_20241122-182805_78j5vk/logging.chat +++ /dev/null @@ -1,9 +0,0 @@ -{"id": "74883ec3f9694f4c8f06b1cacb77fa00", "timestamp": "2024-11-22 18:28:43", "name": "assistant", "content": "##################### ITER 1, STEP 1: REASONING ######################", "role": "assistant", "url": null, "metadata": null} -{"id": "7d73b18862a94f9e98ee6d9a2036e1e4", "timestamp": "2024-11-22 18:28:43", "name": "system", "content": "", "role": "system", "url": null, "metadata": null} -{"id": "b763d8d168a94fcfb683356dd8347a6b", "timestamp": "2024-11-22 18:28:43", "name": "system", "content": "Respond a JSON dictionary in a markdown's fenced code block as follows:\n```json\n{\"thought\": \"what you thought\", \"speak\": \"what you speak\", \"function\": \"[{\\\"name\\\": \\\"{function name}\\\", \\\"arguments\\\": {\\\"{argument1 name}\\\": xxx, \\\"{argument2 name}\\\": xxx}}]\"}\n```\n ####", "role": "system", "url": null, "metadata": null} -{"id": "6ea556559188496498fe0d8a7c234548", "timestamp": "2024-11-22 18:28:43", "name": "assistant", "content": "################################Prompt################################", "role": "assistant", "url": null, "metadata": null} -{"id": "ed2a11c97f704818a1b6b7e51d93db47", "timestamp": "2024-11-22 18:28:43", "name": "assistant", "content": "hi", "role": "assistant", "url": null, "metadata": null} -{"id": "dc76b64be74545e794ad35aa55f3cc5b", "timestamp": "2024-11-22 18:28:46", "name": "assistant", "content": "############################Result Parsed#############################", "role": "assistant", "url": null, "metadata": null} -{"id": "d208feb274a54c2f9bdec32aae66bc38", "timestamp": "2024-11-22 18:28:46", "name": "assistant", "content": "{'thought': 'The student is greeting me. I need to keep the conversation focused on Chapter 1 about binary search.', 'speak': \"Hello! Let's focus on learning about binary search. Do you have any questions about the topic?\", 'function': '[]'}", "role": "assistant", "url": null, "metadata": null} -{"id": "5b7f056633b74fd9b997c0fbe6ccc32c", "timestamp": "2024-11-22 18:28:46", "name": "assistant", "content": "################################Speak#################################", "role": "assistant", "url": null, "metadata": null} -{"id": "b7673c5e379c49099b6a7f44624e1e14", "timestamp": "2024-11-22 18:28:46", "name": "assistant", "content": {"thought": "The student is greeting me. I need to keep the conversation focused on Chapter 1 about binary search.", "speak": "Hello! Let's focus on learning about binary search. Do you have any questions about the topic?", "function": "[]"}, "role": "assistant", "url": null, "metadata": null} diff --git a/Html/runs/run_20241122-182805_78j5vk/logging.log b/Html/runs/run_20241122-182805_78j5vk/logging.log deleted file mode 100644 index 23358c1..0000000 --- a/Html/runs/run_20241122-182805_78j5vk/logging.log +++ /dev/null @@ -1,22 +0,0 @@ -2024-11-22 18:28:22.021 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg -2024-11-22 18:28:32.654 | INFO | agentscope.models.model:__init__:201 - Initialize model by configuration [openai_cfg] -2024-11-22 18:28:32.671 | WARNING | agentscope.models.openai_model:__init__:83 - fail to get max_length for gpt-4o-mini: 'Model [gpt-4o-mini] not found in OPENAI_MAX_LENGTH. The last updated date is 20231212' -2024-11-22 18:28:32.672 | INFO | agentscope.utils.monitor:register_budget:609 - set budget None to gpt-4o-mini -2024-11-22 18:28:32.672 | WARNING | agentscope.utils.monitor:register_budget:639 - Calculate budgets for model [gpt-4o-mini] is not supported -2024-11-22 18:28:32.685 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.call_counter] to SqliteMonitor with unit [times] and quota [None] -2024-11-22 18:28:32.708 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.prompt_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-22 18:28:32.732 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.completion_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-22 18:28:32.750 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.total_tokens] to SqliteMonitor with unit [token] and quota [None] -assistant: ##################### ITER 1, STEP 1: REASONING ###################### -system: -system: Respond a JSON dictionary in a markdown's fenced code block as follows: -```json -{"thought": "what you thought", "speak": "what you speak", "function": "[{\"name\": \"{function name}\", \"arguments\": {\"{argument1 name}\": xxx, \"{argument2 name}\": xxx}}]"} -``` - #### -assistant: ################################Prompt################################ -assistant: hi -assistant: ############################Result Parsed############################# -assistant: {'thought': 'The student is greeting me. I need to keep the conversation focused on Chapter 1 about binary search.', 'speak': "Hello! Let's focus on learning about binary search. Do you have any questions about the topic?", 'function': '[]'} -assistant: ################################Speak################################# -assistant: {'thought': 'The student is greeting me. I need to keep the conversation focused on Chapter 1 about binary search.', 'speak': "Hello! Let's focus on learning about binary search. Do you have any questions about the topic?", 'function': '[]'} diff --git a/Html/runs/run_20241123-164022_ttup0o/.config b/Html/runs/run_20241123-164022_ttup0o/.config deleted file mode 100644 index 9236c20..0000000 --- a/Html/runs/run_20241123-164022_ttup0o/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "d5t6zx", - "name": "ttup0o", - "run_id": "run_20241123-164022_ttup0o", - "timestamp": "2024-11-23 16:40:22", - "pid": 4611 -} \ No newline at end of file diff --git a/Html/runs/run_20241123-164022_ttup0o/agentscope.db b/Html/runs/run_20241123-164022_ttup0o/agentscope.db deleted file mode 100644 index 2e84691..0000000 Binary files a/Html/runs/run_20241123-164022_ttup0o/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241123-164022_ttup0o/code/app.py b/Html/runs/run_20241123-164022_ttup0o/code/app.py deleted file mode 100644 index f6fa6e5..0000000 --- a/Html/runs/run_20241123-164022_ttup0o/code/app.py +++ /dev/null @@ -1,185 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager - -backboard_manager = BackBoardManager() - - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -def realtime_response(config, realtime_action): - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = userid_recorder[user+'&'+folder_name] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - print('-----------------------') - print(user_id) - user_id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(user_id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - # 构造回复消息 - res = agent_manager.invoke(id, data) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241123-164022_ttup0o/code/backboardManager.py b/Html/runs/run_20241123-164022_ttup0o/code/backboardManager.py deleted file mode 100644 index 27b0f76..0000000 --- a/Html/runs/run_20241123-164022_ttup0o/code/backboardManager.py +++ /dev/null @@ -1,51 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - return f"###Global Info:###\n\ -User is {self.user_id}\n\ -User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}\n\ -User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}\n\ -\n\n\ -" - - - - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241123-164022_ttup0o/logging.chat b/Html/runs/run_20241123-164022_ttup0o/logging.chat deleted file mode 100644 index e69de29..0000000 diff --git a/Html/runs/run_20241123-164022_ttup0o/logging.log b/Html/runs/run_20241123-164022_ttup0o/logging.log deleted file mode 100644 index 7334f21..0000000 --- a/Html/runs/run_20241123-164022_ttup0o/logging.log +++ /dev/null @@ -1,9 +0,0 @@ -2024-11-23 16:40:44.788 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg -2024-11-23 16:41:30.562 | INFO | agentscope.models.model:__init__:201 - Initialize model by configuration [openai_cfg] -2024-11-23 16:41:30.577 | WARNING | agentscope.models.openai_model:__init__:83 - fail to get max_length for gpt-4o-mini: 'Model [gpt-4o-mini] not found in OPENAI_MAX_LENGTH. The last updated date is 20231212' -2024-11-23 16:41:30.578 | INFO | agentscope.utils.monitor:register_budget:609 - set budget None to gpt-4o-mini -2024-11-23 16:41:30.578 | WARNING | agentscope.utils.monitor:register_budget:639 - Calculate budgets for model [gpt-4o-mini] is not supported -2024-11-23 16:41:30.593 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.call_counter] to SqliteMonitor with unit [times] and quota [None] -2024-11-23 16:41:30.617 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.prompt_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-23 16:41:30.642 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.completion_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-23 16:41:30.666 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.total_tokens] to SqliteMonitor with unit [token] and quota [None] diff --git a/Html/runs/run_20241123-164512_nagqkd/.config b/Html/runs/run_20241123-164512_nagqkd/.config deleted file mode 100644 index 42b492b..0000000 --- a/Html/runs/run_20241123-164512_nagqkd/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "vMjIPa", - "name": "nagqkd", - "run_id": "run_20241123-164512_nagqkd", - "timestamp": "2024-11-23 16:45:12", - "pid": 7301 -} \ No newline at end of file diff --git a/Html/runs/run_20241123-164512_nagqkd/agentscope.db b/Html/runs/run_20241123-164512_nagqkd/agentscope.db deleted file mode 100644 index 2e84691..0000000 Binary files a/Html/runs/run_20241123-164512_nagqkd/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241123-164512_nagqkd/code/app.py b/Html/runs/run_20241123-164512_nagqkd/code/app.py deleted file mode 100644 index f6fa6e5..0000000 --- a/Html/runs/run_20241123-164512_nagqkd/code/app.py +++ /dev/null @@ -1,185 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager - -backboard_manager = BackBoardManager() - - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -def realtime_response(config, realtime_action): - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = userid_recorder[user+'&'+folder_name] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - print('-----------------------') - print(user_id) - user_id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(user_id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - # 构造回复消息 - res = agent_manager.invoke(id, data) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241123-164512_nagqkd/code/backboardManager.py b/Html/runs/run_20241123-164512_nagqkd/code/backboardManager.py deleted file mode 100644 index 27b0f76..0000000 --- a/Html/runs/run_20241123-164512_nagqkd/code/backboardManager.py +++ /dev/null @@ -1,51 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - return f"###Global Info:###\n\ -User is {self.user_id}\n\ -User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}\n\ -User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}\n\ -\n\n\ -" - - - - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241123-164512_nagqkd/logging.chat b/Html/runs/run_20241123-164512_nagqkd/logging.chat deleted file mode 100644 index d3755a9..0000000 --- a/Html/runs/run_20241123-164512_nagqkd/logging.chat +++ /dev/null @@ -1,9 +0,0 @@ -{"id": "54fb4c74af28475195a746d632f662c7", "timestamp": "2024-11-23 16:45:43", "name": "assistant", "content": "##################### ITER 1, STEP 1: REASONING ######################", "role": "assistant", "url": null, "metadata": null} -{"id": "872e281f8f644e09bd60a163be9e74d7", "timestamp": "2024-11-23 16:45:43", "name": "system", "content": "", "role": "system", "url": null, "metadata": null} -{"id": "e29ff932b2f645e08e193734ddc5aff9", "timestamp": "2024-11-23 16:45:43", "name": "system", "content": "Respond a JSON dictionary in a markdown's fenced code block as follows:\n```json\n{\"thought\": \"what you thought\", \"speak\": \"what you speak\", \"function\": \"[{\\\"name\\\": \\\"{function name}\\\", \\\"arguments\\\": {\\\"{argument1 name}\\\": xxx, \\\"{argument2 name}\\\": xxx}}]\"}\n```\n ####", "role": "system", "url": null, "metadata": null} -{"id": "f8f81ff2a4ad4fb4bfb9c3ebfc33e0a0", "timestamp": "2024-11-23 16:45:43", "name": "assistant", "content": "################################Prompt################################", "role": "assistant", "url": null, "metadata": null} -{"id": "3917d85412cc433f8b6d8aba4a6fe401", "timestamp": "2024-11-23 16:45:43", "name": "assistant", "content": "hi", "role": "assistant", "url": null, "metadata": null} -{"id": "fe6498280e4b40ddb08efca72890a8a6", "timestamp": "2024-11-23 16:45:46", "name": "assistant", "content": "############################Result Parsed#############################", "role": "assistant", "url": null, "metadata": null} -{"id": "92a498ab37e043a9b871fa5040782f0e", "timestamp": "2024-11-23 16:45:46", "name": "assistant", "content": "{'thought': \"The student seems to be greeting me but hasn't yet asked a question related to the current chapter on binary search. I should encourage them to engage with the material.\", 'speak': 'Hello! How can I assist you with your understanding of binary search today?', 'function': '[]'}", "role": "assistant", "url": null, "metadata": null} -{"id": "721f5622fcdf44988cc72609546d9b83", "timestamp": "2024-11-23 16:45:46", "name": "assistant", "content": "################################Speak#################################", "role": "assistant", "url": null, "metadata": null} -{"id": "ad1c1410f93f4b8b823df56f32c5db12", "timestamp": "2024-11-23 16:45:46", "name": "assistant", "content": {"thought": "The student seems to be greeting me but hasn't yet asked a question related to the current chapter on binary search. I should encourage them to engage with the material.", "speak": "Hello! How can I assist you with your understanding of binary search today?", "function": "[]"}, "role": "assistant", "url": null, "metadata": null} diff --git a/Html/runs/run_20241123-164512_nagqkd/logging.log b/Html/runs/run_20241123-164512_nagqkd/logging.log deleted file mode 100644 index 92ebb9e..0000000 --- a/Html/runs/run_20241123-164512_nagqkd/logging.log +++ /dev/null @@ -1,22 +0,0 @@ -2024-11-23 16:45:22.355 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg -2024-11-23 16:45:31.351 | INFO | agentscope.models.model:__init__:201 - Initialize model by configuration [openai_cfg] -2024-11-23 16:45:31.371 | WARNING | agentscope.models.openai_model:__init__:83 - fail to get max_length for gpt-4o-mini: 'Model [gpt-4o-mini] not found in OPENAI_MAX_LENGTH. The last updated date is 20231212' -2024-11-23 16:45:31.372 | INFO | agentscope.utils.monitor:register_budget:609 - set budget None to gpt-4o-mini -2024-11-23 16:45:31.372 | WARNING | agentscope.utils.monitor:register_budget:639 - Calculate budgets for model [gpt-4o-mini] is not supported -2024-11-23 16:45:31.386 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.call_counter] to SqliteMonitor with unit [times] and quota [None] -2024-11-23 16:45:31.408 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.prompt_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-23 16:45:31.431 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.completion_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-23 16:45:31.452 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.total_tokens] to SqliteMonitor with unit [token] and quota [None] -assistant: ##################### ITER 1, STEP 1: REASONING ###################### -system: -system: Respond a JSON dictionary in a markdown's fenced code block as follows: -```json -{"thought": "what you thought", "speak": "what you speak", "function": "[{\"name\": \"{function name}\", \"arguments\": {\"{argument1 name}\": xxx, \"{argument2 name}\": xxx}}]"} -``` - #### -assistant: ################################Prompt################################ -assistant: hi -assistant: ############################Result Parsed############################# -assistant: {'thought': "The student seems to be greeting me but hasn't yet asked a question related to the current chapter on binary search. I should encourage them to engage with the material.", 'speak': 'Hello! How can I assist you with your understanding of binary search today?', 'function': '[]'} -assistant: ################################Speak################################# -assistant: {'thought': "The student seems to be greeting me but hasn't yet asked a question related to the current chapter on binary search. I should encourage them to engage with the material.", 'speak': 'Hello! How can I assist you with your understanding of binary search today?', 'function': '[]'} diff --git a/Html/runs/run_20241123-164807_sy4ep8/.config b/Html/runs/run_20241123-164807_sy4ep8/.config deleted file mode 100644 index 9f7d6f3..0000000 --- a/Html/runs/run_20241123-164807_sy4ep8/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "TrDbTY", - "name": "sy4ep8", - "run_id": "run_20241123-164807_sy4ep8", - "timestamp": "2024-11-23 16:48:07", - "pid": 8872 -} \ No newline at end of file diff --git a/Html/runs/run_20241123-164807_sy4ep8/agentscope.db b/Html/runs/run_20241123-164807_sy4ep8/agentscope.db deleted file mode 100644 index 2e84691..0000000 Binary files a/Html/runs/run_20241123-164807_sy4ep8/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241123-164807_sy4ep8/code/app.py b/Html/runs/run_20241123-164807_sy4ep8/code/app.py deleted file mode 100644 index f6fa6e5..0000000 --- a/Html/runs/run_20241123-164807_sy4ep8/code/app.py +++ /dev/null @@ -1,185 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager - -backboard_manager = BackBoardManager() - - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -def realtime_response(config, realtime_action): - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = userid_recorder[user+'&'+folder_name] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - print('-----------------------') - print(user_id) - user_id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(user_id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - # 构造回复消息 - res = agent_manager.invoke(id, data) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241123-164807_sy4ep8/code/backboardManager.py b/Html/runs/run_20241123-164807_sy4ep8/code/backboardManager.py deleted file mode 100644 index 27b0f76..0000000 --- a/Html/runs/run_20241123-164807_sy4ep8/code/backboardManager.py +++ /dev/null @@ -1,51 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - return f"###Global Info:###\n\ -User is {self.user_id}\n\ -User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}\n\ -User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}\n\ -\n\n\ -" - - - - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241123-164807_sy4ep8/logging.chat b/Html/runs/run_20241123-164807_sy4ep8/logging.chat deleted file mode 100644 index 4adf6d4..0000000 --- a/Html/runs/run_20241123-164807_sy4ep8/logging.chat +++ /dev/null @@ -1,45 +0,0 @@ -{"id": "d67f8b09019c42ffb8fa5fba08af6719", "timestamp": "2024-11-23 16:49:09", "name": "assistant", "content": "##################### ITER 1, STEP 1: REASONING ######################", "role": "assistant", "url": null, "metadata": null} -{"id": "a0f6bd49028a49eca623c6b34c6923d9", "timestamp": "2024-11-23 16:49:09", "name": "system", "content": "## Tool Functions:\nThe following tool functions are available in the format of\n```\n{index}. {function name}: {function description}\n{argument1 name} ({argument type}): {argument description}\n{argument2 name} ({argument type}): {argument description}\n...\n```\n\n1. record: Call it to save some important info for other chapters. Like file path, function call example.\n\tcontent (string): The content to be recorded.\n2. next_chapter: Call it to go to next chapter.\n", "role": "system", "url": null, "metadata": null} -{"id": "1c556e54e5954fa8952ff8fc712ff31d", "timestamp": "2024-11-23 16:49:09", "name": "system", "content": "Respond a JSON dictionary in a markdown's fenced code block as follows:\n```json\n{\"thought\": \"what you thought\", \"speak\": \"what you speak\", \"function\": \"[{\\\"name\\\": \\\"{function name}\\\", \\\"arguments\\\": {\\\"{argument1 name}\\\": xxx, \\\"{argument2 name}\\\": xxx}}]\"}\n```\n ####", "role": "system", "url": null, "metadata": null} -{"id": "f461dc3e6ddd450e9b94e6cc2b0e7f5c", "timestamp": "2024-11-23 16:49:09", "name": "assistant", "content": "################################Prompt################################", "role": "assistant", "url": null, "metadata": null} -{"id": "9d37d51a26f44fe498f6de263fa92202", "timestamp": "2024-11-23 16:49:09", "name": "assistant", "content": "hi", "role": "assistant", "url": null, "metadata": null} -{"id": "60b441f75d854f50aad786839420e9c4", "timestamp": "2024-11-23 16:49:12", "name": "assistant", "content": "############################Result Parsed#############################", "role": "assistant", "url": null, "metadata": null} -{"id": "5d8cc88aa1da4b3ea3c45a05535c24ed", "timestamp": "2024-11-23 16:49:12", "name": "assistant", "content": "{'thought': 'The student seems to be starting the learning process. I should guide them to focus on the current chapter about binary search basics.', 'speak': \"Hello! Let's focus on learning about binary search. Do you have any questions about how binary search works or the example of guessing a number?\", 'function': []}", "role": "assistant", "url": null, "metadata": null} -{"id": "976ac1e152da41e4ae97e3d1b3657721", "timestamp": "2024-11-23 16:49:12", "name": "assistant", "content": "################################Speak#################################", "role": "assistant", "url": null, "metadata": null} -{"id": "edbc1b75451a4364a48d6fff70c8df0c", "timestamp": "2024-11-23 16:49:12", "name": "assistant", "content": {"thought": "The student seems to be starting the learning process. I should guide them to focus on the current chapter about binary search basics.", "speak": "Hello! Let's focus on learning about binary search. Do you have any questions about how binary search works or the example of guessing a number?", "function": []}, "role": "assistant", "url": null, "metadata": null} -{"id": "512870cf575040b5bf8b76a1aacb758d", "timestamp": "2024-11-23 16:51:06", "name": "assistant", "content": "##################### ITER 1, STEP 1: REASONING ######################", "role": "assistant", "url": null, "metadata": null} -{"id": "b87eb15a615f4947b353621f04c270a2", "timestamp": "2024-11-23 16:51:06", "name": "system", "content": "## Tool Functions:\nThe following tool functions are available in the format of\n```\n{index}. {function name}: {function description}\n{argument1 name} ({argument type}): {argument description}\n{argument2 name} ({argument type}): {argument description}\n...\n```\n\n1. record: Call it to save some important info for other chapters. Like file path, function call example.\n\tcontent (string): The content to be recorded.\n2. next_chapter: Call it to go to next chapter.\n", "role": "system", "url": null, "metadata": null} -{"id": "f48f64fa131e488c9609db67abb0d82e", "timestamp": "2024-11-23 16:51:06", "name": "system", "content": "Respond a JSON dictionary in a markdown's fenced code block as follows:\n```json\n{\"thought\": \"what you thought\", \"speak\": \"what you speak\", \"function\": \"[{\\\"name\\\": \\\"{function name}\\\", \\\"arguments\\\": {\\\"{argument1 name}\\\": xxx, \\\"{argument2 name}\\\": xxx}}]\"}\n```\n ####", "role": "system", "url": null, "metadata": null} -{"id": "a208fb97c336454e9b6f93349b5eb4c7", "timestamp": "2024-11-23 16:51:06", "name": "assistant", "content": "################################Prompt################################", "role": "assistant", "url": null, "metadata": null} -{"id": "ebe720e5e2da4437a34f80bc6edbed20", "timestamp": "2024-11-23 16:51:06", "name": "assistant", "content": "第一章节的内容我已经会了,我已经看懂了引入部分的二分原理。对于思考题,答案是13。", "role": "assistant", "url": null, "metadata": null} -{"id": "e5b40f6ef106429fba71436fcb61c363", "timestamp": "2024-11-23 16:51:09", "name": "assistant", "content": "############################Result Parsed#############################", "role": "assistant", "url": null, "metadata": null} -{"id": "dae56f4d73b44af8ba7dfe6f15b6524a", "timestamp": "2024-11-23 16:51:09", "name": "assistant", "content": "{'thought': 'The student is confident in their understanding and offers an answer to the question, but it needs verification. I will confirm their answer and provide a bit of support to ensure they grasp the concept well.', 'speak': \"Your answer is close, but let's think through the binary search process together. For the range from 1 to 4000, how many divisions do you think it would take to reduce that range down to just one number?\", 'function': []}", "role": "assistant", "url": null, "metadata": null} -{"id": "c5ae521400304a55aa073e94caac520d", "timestamp": "2024-11-23 16:51:09", "name": "assistant", "content": "################################Speak#################################", "role": "assistant", "url": null, "metadata": null} -{"id": "0dea919cff08461493c20fe15e791151", "timestamp": "2024-11-23 16:51:09", "name": "assistant", "content": {"thought": "The student is confident in their understanding and offers an answer to the question, but it needs verification. I will confirm their answer and provide a bit of support to ensure they grasp the concept well.", "speak": "Your answer is close, but let's think through the binary search process together. For the range from 1 to 4000, how many divisions do you think it would take to reduce that range down to just one number?", "function": []}, "role": "assistant", "url": null, "metadata": null} -{"id": "a5d26f5cdd1d463d9f7e6bdd3e817011", "timestamp": "2024-11-23 16:52:03", "name": "assistant", "content": "##################### ITER 1, STEP 1: REASONING ######################", "role": "assistant", "url": null, "metadata": null} -{"id": "c28e054bc53f41da90da636c0f92c34a", "timestamp": "2024-11-23 16:52:03", "name": "system", "content": "## Tool Functions:\nThe following tool functions are available in the format of\n```\n{index}. {function name}: {function description}\n{argument1 name} ({argument type}): {argument description}\n{argument2 name} ({argument type}): {argument description}\n...\n```\n\n1. record: Call it to save some important info for other chapters. Like file path, function call example.\n\tcontent (string): The content to be recorded.\n2. next_chapter: Call it to go to next chapter.\n", "role": "system", "url": null, "metadata": null} -{"id": "30f533c16fca48b28d587f9c93d5b1b9", "timestamp": "2024-11-23 16:52:03", "name": "system", "content": "Respond a JSON dictionary in a markdown's fenced code block as follows:\n```json\n{\"thought\": \"what you thought\", \"speak\": \"what you speak\", \"function\": \"[{\\\"name\\\": \\\"{function name}\\\", \\\"arguments\\\": {\\\"{argument1 name}\\\": xxx, \\\"{argument2 name}\\\": xxx}}]\"}\n```\n ####", "role": "system", "url": null, "metadata": null} -{"id": "19321a0e961442d681e73059efb81168", "timestamp": "2024-11-23 16:52:03", "name": "assistant", "content": "################################Prompt################################", "role": "assistant", "url": null, "metadata": null} -{"id": "132417d8314d4027828ff8a45dd6d47b", "timestamp": "2024-11-23 16:52:03", "name": "assistant", "content": "13次中,12次是用于将答案的区间进行收缩的。因为每次二分区间会缩小一半。现在我可以进入下一章了嘛?\n", "role": "assistant", "url": null, "metadata": null} -{"id": "82fded1b3b1a43e891a74b26b3deeb3e", "timestamp": "2024-11-23 16:52:06", "name": "assistant", "content": "############################Result Parsed#############################", "role": "assistant", "url": null, "metadata": null} -{"id": "9e27912d563e4285b102711cd77b86cc", "timestamp": "2024-11-23 16:52:06", "name": "assistant", "content": "{'thought': 'The student has provided a correct understanding of the binary search process in terms of how many guesses are needed. They are ready to move on to the next chapter.', 'speak': \"Great job! Your understanding of the binary search concept is solid. Let's move on to the next chapter about implementing binary search in code. I'll take you to the next chapter now.\", 'function': '[{\"name\": \"next_chapter\", \"arguments\": {}}]'}", "role": "assistant", "url": null, "metadata": null} -{"id": "6c0cd502ff904a23836ca2355cc0d658", "timestamp": "2024-11-23 16:52:06", "name": "assistant", "content": "################################Speak#################################", "role": "assistant", "url": null, "metadata": null} -{"id": "429a6089d16142de93ccd56a3d9c6830", "timestamp": "2024-11-23 16:52:06", "name": "assistant", "content": {"thought": "The student has provided a correct understanding of the binary search process in terms of how many guesses are needed. They are ready to move on to the next chapter.", "speak": "Great job! Your understanding of the binary search concept is solid. Let's move on to the next chapter about implementing binary search in code. I'll take you to the next chapter now.", "function": "[{\"name\": \"next_chapter\", \"arguments\": {}}]"}, "role": "assistant", "url": null, "metadata": null} -{"id": "d16918b0419a48d7a05b5f690faba78b", "timestamp": "2024-11-23 16:53:00", "name": "assistant", "content": "##################### ITER 1, STEP 1: REASONING ######################", "role": "assistant", "url": null, "metadata": null} -{"id": "b8642d6896eb472e919651dba5d812c3", "timestamp": "2024-11-23 16:53:00", "name": "system", "content": "## Tool Functions:\nThe following tool functions are available in the format of\n```\n{index}. {function name}: {function description}\n{argument1 name} ({argument type}): {argument description}\n{argument2 name} ({argument type}): {argument description}\n...\n```\n\n1. record: Call it to save some important info for other chapters. Like file path, function call example.\n\tcontent (string): The content to be recorded.\n2. next_chapter: Call it to go to next chapter.\n", "role": "system", "url": null, "metadata": null} -{"id": "4ccab5f64d064b999ec8c7af1febb553", "timestamp": "2024-11-23 16:53:00", "name": "system", "content": "Respond a JSON dictionary in a markdown's fenced code block as follows:\n```json\n{\"thought\": \"what you thought\", \"speak\": \"what you speak\", \"function\": \"[{\\\"name\\\": \\\"{function name}\\\", \\\"arguments\\\": {\\\"{argument1 name}\\\": xxx, \\\"{argument2 name}\\\": xxx}}]\"}\n```\n ####", "role": "system", "url": null, "metadata": null} -{"id": "60e291554aac4a6a8a7e435dc91bb32c", "timestamp": "2024-11-23 16:53:00", "name": "assistant", "content": "################################Prompt################################", "role": "assistant", "url": null, "metadata": null} -{"id": "67867ce0bc214090a774f2bb29095fde", "timestamp": "2024-11-23 16:53:00", "name": "assistant", "content": "对于这一章,我需要写的代码该取名叫什么呢?\n", "role": "assistant", "url": null, "metadata": null} -{"id": "092719ffdf214eb7b1a34b7abb6e76e4", "timestamp": "2024-11-23 16:53:02", "name": "assistant", "content": "############################Result Parsed#############################", "role": "assistant", "url": null, "metadata": null} -{"id": "1673342cd9064734979453acb5f82bb3", "timestamp": "2024-11-23 16:53:02", "name": "assistant", "content": "{'thought': \"The student is now trying to decide on a name for their binary search code. It's an important step in the coding process.\", 'speak': 'You can name your binary search function something descriptive like `binarySearch` or `findIndex`. Choose a name that clearly represents what the function does.', 'function': []}", "role": "assistant", "url": null, "metadata": null} -{"id": "db6f053c7a1e4e0380c086be502d1caa", "timestamp": "2024-11-23 16:53:02", "name": "assistant", "content": "################################Speak#################################", "role": "assistant", "url": null, "metadata": null} -{"id": "bfc9805a364e4b98a841f575a267603e", "timestamp": "2024-11-23 16:53:02", "name": "assistant", "content": {"thought": "The student is now trying to decide on a name for their binary search code. It's an important step in the coding process.", "speak": "You can name your binary search function something descriptive like `binarySearch` or `findIndex`. Choose a name that clearly represents what the function does.", "function": []}, "role": "assistant", "url": null, "metadata": null} -{"id": "5030e3e87b7f46c885c06cba0a38a271", "timestamp": "2024-11-23 16:54:11", "name": "assistant", "content": "##################### ITER 1, STEP 1: REASONING ######################", "role": "assistant", "url": null, "metadata": null} -{"id": "415416db2f1441188b971b6b5108715f", "timestamp": "2024-11-23 16:54:11", "name": "system", "content": "## Tool Functions:\nThe following tool functions are available in the format of\n```\n{index}. {function name}: {function description}\n{argument1 name} ({argument type}): {argument description}\n{argument2 name} ({argument type}): {argument description}\n...\n```\n\n1. record: Call it to save some important info for other chapters. Like file path, function call example.\n\tcontent (string): The content to be recorded.\n2. next_chapter: Call it to go to next chapter.\n", "role": "system", "url": null, "metadata": null} -{"id": "77151466db204504bc437fc5db464013", "timestamp": "2024-11-23 16:54:11", "name": "system", "content": "Respond a JSON dictionary in a markdown's fenced code block as follows:\n```json\n{\"thought\": \"what you thought\", \"speak\": \"what you speak\", \"function\": \"[{\\\"name\\\": \\\"{function name}\\\", \\\"arguments\\\": {\\\"{argument1 name}\\\": xxx, \\\"{argument2 name}\\\": xxx}}]\"}\n```\n ####", "role": "system", "url": null, "metadata": null} -{"id": "b833f4f8790f4bd688917b6be0496288", "timestamp": "2024-11-23 16:54:11", "name": "assistant", "content": "################################Prompt################################", "role": "assistant", "url": null, "metadata": null} -{"id": "b3e1299e8c7a4983a4cb306c9020efd8", "timestamp": "2024-11-23 16:54:11", "name": "assistant", "content": "很不好意思我是pyhon的初学者,不过我学过不少算法内容 ,我相信我能进行实现。 这个题目的输入改怎么读入呢?\n", "role": "assistant", "url": null, "metadata": null} -{"id": "5af2893e413c46bb86469092a1734356", "timestamp": "2024-11-23 16:54:14", "name": "assistant", "content": "############################Result Parsed#############################", "role": "assistant", "url": null, "metadata": null} -{"id": "0ff6aff1bcd44ff9a9b92acd154ad997", "timestamp": "2024-11-23 16:54:14", "name": "assistant", "content": "{'thought': 'The student is learning how to read input in Python, which is crucial for implementing the binary search algorithm.', 'speak': 'In Python, you can read the input using the `input()` function. For the first line, use `n = int(input())` to get the number of elements. For the second line, use `array = list(map(int, input().split()))` to read the sorted array. After that, read the number of queries with `q = int(input())` and loop through the next `q` lines for the queries.', 'function': []}", "role": "assistant", "url": null, "metadata": null} -{"id": "f70cd80c16cf4ba6af335a4517becfe2", "timestamp": "2024-11-23 16:54:14", "name": "assistant", "content": "################################Speak#################################", "role": "assistant", "url": null, "metadata": null} -{"id": "c58e29327f9643738be6c78028236dd3", "timestamp": "2024-11-23 16:54:14", "name": "assistant", "content": {"thought": "The student is learning how to read input in Python, which is crucial for implementing the binary search algorithm.", "speak": "In Python, you can read the input using the `input()` function. For the first line, use `n = int(input())` to get the number of elements. For the second line, use `array = list(map(int, input().split()))` to read the sorted array. After that, read the number of queries with `q = int(input())` and loop through the next `q` lines for the queries.", "function": []}, "role": "assistant", "url": null, "metadata": null} diff --git a/Html/runs/run_20241123-164807_sy4ep8/logging.log b/Html/runs/run_20241123-164807_sy4ep8/logging.log deleted file mode 100644 index 96380f1..0000000 --- a/Html/runs/run_20241123-164807_sy4ep8/logging.log +++ /dev/null @@ -1,141 +0,0 @@ -2024-11-23 16:48:19.264 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg -2024-11-23 16:48:26.652 | INFO | agentscope.models.model:__init__:201 - Initialize model by configuration [openai_cfg] -2024-11-23 16:48:26.666 | WARNING | agentscope.models.openai_model:__init__:83 - fail to get max_length for gpt-4o-mini: 'Model [gpt-4o-mini] not found in OPENAI_MAX_LENGTH. The last updated date is 20231212' -2024-11-23 16:48:26.667 | INFO | agentscope.utils.monitor:register_budget:609 - set budget None to gpt-4o-mini -2024-11-23 16:48:26.667 | WARNING | agentscope.utils.monitor:register_budget:639 - Calculate budgets for model [gpt-4o-mini] is not supported -2024-11-23 16:48:26.679 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.call_counter] to SqliteMonitor with unit [times] and quota [None] -2024-11-23 16:48:26.703 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.prompt_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-23 16:48:26.724 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.completion_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-23 16:48:26.746 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.total_tokens] to SqliteMonitor with unit [token] and quota [None] -assistant: ##################### ITER 1, STEP 1: REASONING ###################### -system: ## Tool Functions: -The following tool functions are available in the format of -``` -{index}. {function name}: {function description} -{argument1 name} ({argument type}): {argument description} -{argument2 name} ({argument type}): {argument description} -... -``` - -1. record: Call it to save some important info for other chapters. Like file path, function call example. - content (string): The content to be recorded. -2. next_chapter: Call it to go to next chapter. - -system: Respond a JSON dictionary in a markdown's fenced code block as follows: -```json -{"thought": "what you thought", "speak": "what you speak", "function": "[{\"name\": \"{function name}\", \"arguments\": {\"{argument1 name}\": xxx, \"{argument2 name}\": xxx}}]"} -``` - #### -assistant: ################################Prompt################################ -assistant: hi -assistant: ############################Result Parsed############################# -assistant: {'thought': 'The student seems to be starting the learning process. I should guide them to focus on the current chapter about binary search basics.', 'speak': "Hello! Let's focus on learning about binary search. Do you have any questions about how binary search works or the example of guessing a number?", 'function': []} -assistant: ################################Speak################################# -assistant: {'thought': 'The student seems to be starting the learning process. I should guide them to focus on the current chapter about binary search basics.', 'speak': "Hello! Let's focus on learning about binary search. Do you have any questions about how binary search works or the example of guessing a number?", 'function': []} -assistant: ##################### ITER 1, STEP 1: REASONING ###################### -system: ## Tool Functions: -The following tool functions are available in the format of -``` -{index}. {function name}: {function description} -{argument1 name} ({argument type}): {argument description} -{argument2 name} ({argument type}): {argument description} -... -``` - -1. record: Call it to save some important info for other chapters. Like file path, function call example. - content (string): The content to be recorded. -2. next_chapter: Call it to go to next chapter. - -system: Respond a JSON dictionary in a markdown's fenced code block as follows: -```json -{"thought": "what you thought", "speak": "what you speak", "function": "[{\"name\": \"{function name}\", \"arguments\": {\"{argument1 name}\": xxx, \"{argument2 name}\": xxx}}]"} -``` - #### -assistant: ################################Prompt################################ -assistant: 第一章节的内容我已经会了,我已经看懂了引入部分的二分原理。对于思考题,答案是13。 -assistant: ############################Result Parsed############################# -assistant: {'thought': 'The student is confident in their understanding and offers an answer to the question, but it needs verification. I will confirm their answer and provide a bit of support to ensure they grasp the concept well.', 'speak': "Your answer is close, but let's think through the binary search process together. For the range from 1 to 4000, how many divisions do you think it would take to reduce that range down to just one number?", 'function': []} -assistant: ################################Speak################################# -assistant: {'thought': 'The student is confident in their understanding and offers an answer to the question, but it needs verification. I will confirm their answer and provide a bit of support to ensure they grasp the concept well.', 'speak': "Your answer is close, but let's think through the binary search process together. For the range from 1 to 4000, how many divisions do you think it would take to reduce that range down to just one number?", 'function': []} -assistant: ##################### ITER 1, STEP 1: REASONING ###################### -system: ## Tool Functions: -The following tool functions are available in the format of -``` -{index}. {function name}: {function description} -{argument1 name} ({argument type}): {argument description} -{argument2 name} ({argument type}): {argument description} -... -``` - -1. record: Call it to save some important info for other chapters. Like file path, function call example. - content (string): The content to be recorded. -2. next_chapter: Call it to go to next chapter. - -system: Respond a JSON dictionary in a markdown's fenced code block as follows: -```json -{"thought": "what you thought", "speak": "what you speak", "function": "[{\"name\": \"{function name}\", \"arguments\": {\"{argument1 name}\": xxx, \"{argument2 name}\": xxx}}]"} -``` - #### -assistant: ################################Prompt################################ -assistant: 13次中,12次是用于将答案的区间进行收缩的。因为每次二分区间会缩小一半。现在我可以进入下一章了嘛? - -assistant: ############################Result Parsed############################# -assistant: {'thought': 'The student has provided a correct understanding of the binary search process in terms of how many guesses are needed. They are ready to move on to the next chapter.', 'speak': "Great job! Your understanding of the binary search concept is solid. Let's move on to the next chapter about implementing binary search in code. I'll take you to the next chapter now.", 'function': '[{"name": "next_chapter", "arguments": {}}]'} -assistant: ################################Speak################################# -assistant: {'thought': 'The student has provided a correct understanding of the binary search process in terms of how many guesses are needed. They are ready to move on to the next chapter.', 'speak': "Great job! Your understanding of the binary search concept is solid. Let's move on to the next chapter about implementing binary search in code. I'll take you to the next chapter now.", 'function': '[{"name": "next_chapter", "arguments": {}}]'} -assistant: ##################### ITER 1, STEP 1: REASONING ###################### -system: ## Tool Functions: -The following tool functions are available in the format of -``` -{index}. {function name}: {function description} -{argument1 name} ({argument type}): {argument description} -{argument2 name} ({argument type}): {argument description} -... -``` - -1. record: Call it to save some important info for other chapters. Like file path, function call example. - content (string): The content to be recorded. -2. next_chapter: Call it to go to next chapter. - -system: Respond a JSON dictionary in a markdown's fenced code block as follows: -```json -{"thought": "what you thought", "speak": "what you speak", "function": "[{\"name\": \"{function name}\", \"arguments\": {\"{argument1 name}\": xxx, \"{argument2 name}\": xxx}}]"} -``` - #### -assistant: ################################Prompt################################ -assistant: 对于这一章,我需要写的代码该取名叫什么呢? - -assistant: ############################Result Parsed############################# -assistant: {'thought': "The student is now trying to decide on a name for their binary search code. It's an important step in the coding process.", 'speak': 'You can name your binary search function something descriptive like `binarySearch` or `findIndex`. Choose a name that clearly represents what the function does.', 'function': []} -assistant: ################################Speak################################# -assistant: {'thought': "The student is now trying to decide on a name for their binary search code. It's an important step in the coding process.", 'speak': 'You can name your binary search function something descriptive like `binarySearch` or `findIndex`. Choose a name that clearly represents what the function does.', 'function': []} -assistant: ##################### ITER 1, STEP 1: REASONING ###################### -system: ## Tool Functions: -The following tool functions are available in the format of -``` -{index}. {function name}: {function description} -{argument1 name} ({argument type}): {argument description} -{argument2 name} ({argument type}): {argument description} -... -``` - -1. record: Call it to save some important info for other chapters. Like file path, function call example. - content (string): The content to be recorded. -2. next_chapter: Call it to go to next chapter. - -system: Respond a JSON dictionary in a markdown's fenced code block as follows: -```json -{"thought": "what you thought", "speak": "what you speak", "function": "[{\"name\": \"{function name}\", \"arguments\": {\"{argument1 name}\": xxx, \"{argument2 name}\": xxx}}]"} -``` - #### -assistant: ################################Prompt################################ -assistant: 很不好意思我是pyhon的初学者,不过我学过不少算法内容 ,我相信我能进行实现。 这个题目的输入改怎么读入呢? - -assistant: ############################Result Parsed############################# -assistant: {'thought': 'The student is learning how to read input in Python, which is crucial for implementing the binary search algorithm.', 'speak': 'In Python, you can read the input using the `input()` function. For the first line, use `n = int(input())` to get the number of elements. For the second line, use `array = list(map(int, input().split()))` to read the sorted array. After that, read the number of queries with `q = int(input())` and loop through the next `q` lines for the queries.', 'function': []} -assistant: ################################Speak################################# -assistant: {'thought': 'The student is learning how to read input in Python, which is crucial for implementing the binary search algorithm.', 'speak': 'In Python, you can read the input using the `input()` function. For the first line, use `n = int(input())` to get the number of elements. For the second line, use `array = list(map(int, input().split()))` to read the sorted array. After that, read the number of queries with `q = int(input())` and loop through the next `q` lines for the queries.', 'function': []} -2024-11-23 20:04:46.841 | INFO | agentscope.models.model:__init__:201 - Initialize model by configuration [openai_cfg] -2024-11-23 20:04:46.926 | WARNING | agentscope.models.openai_model:__init__:83 - fail to get max_length for gpt-4o-mini: 'Model [gpt-4o-mini] not found in OPENAI_MAX_LENGTH. The last updated date is 20231212' -2024-11-23 20:04:46.927 | INFO | agentscope.utils.monitor:register_budget:609 - set budget None to gpt-4o-mini -2024-11-23 20:04:46.927 | WARNING | agentscope.utils.monitor:register_budget:639 - Calculate budgets for model [gpt-4o-mini] is not supported diff --git a/Html/runs/run_20241124-165242_i80sek/.config b/Html/runs/run_20241124-165242_i80sek/.config deleted file mode 100644 index 090a799..0000000 --- a/Html/runs/run_20241124-165242_i80sek/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "ltujuK", - "name": "i80sek", - "run_id": "run_20241124-165242_i80sek", - "timestamp": "2024-11-24 16:52:42", - "pid": 6318 -} \ No newline at end of file diff --git a/Html/runs/run_20241124-165242_i80sek/agentscope.db b/Html/runs/run_20241124-165242_i80sek/agentscope.db deleted file mode 100644 index 50c98d3..0000000 Binary files a/Html/runs/run_20241124-165242_i80sek/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241124-165242_i80sek/code/app.py b/Html/runs/run_20241124-165242_i80sek/code/app.py deleted file mode 100644 index c554b53..0000000 --- a/Html/runs/run_20241124-165242_i80sek/code/app.py +++ /dev/null @@ -1,213 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager, Backboard - -backboard_manager = BackBoardManager() - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - - -def realtime_response(config, realtime_action): - user_id = config['user_id'] - folder_path = config['path'] - if backboard_manager.get_backboard(user_id) == None: - backboard_manager.add_backboard(user_id, folder_path) - bb = backboard_manager.get_backboard(user_id) - assert type(bb) == Backboard - - bb.add_history(realtime_action) - - if realtime_action['type'] == 'workspaceFolders': - bb.file_tree = realtime_action['file_tree'] - - if realtime_action['type'] == 'activeFile': - file_path = realtime_action['filePath'] - assert type(file_path) == str - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.active_file_path = file_path - with open(f"../{user_id}/{folder_path}/{file_path}") as f: - bb.active_file_content = f.read() - - if realtime_action['type'] == 'paste': - file_path = realtime_action['filePath'] - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.pasted_file_path = file_path - bb.pasted_content = realtime_action['content'] - - - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = userid_recorder[user+'&'+folder_name] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - print('-----------------------') - print(user_id) - user_id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(user_id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - # 构造回复消息 - res = agent_manager.invoke(id, data) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241124-165242_i80sek/code/backboardManager.py b/Html/runs/run_20241124-165242_i80sek/code/backboardManager.py deleted file mode 100644 index b243cfc..0000000 --- a/Html/runs/run_20241124-165242_i80sek/code/backboardManager.py +++ /dev/null @@ -1,76 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - self.history = [] - self.file_tree = "[]" - self.active_file_path = "" - self.active_file_content = "" - self.pasted_file_path = "" - self.pasted_content = "" - - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - - five_history = "" - for h in self.history[-5:]: - five_history += h['type'] + "\n" + h.get('filePath', '') + "\n\n" -# return f"###Global Info:###\n\ -# User is {self.user_id}\n\ -# User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}\n\ -# User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}\n\ -# \n\n\ -# Activated file path: {self.active_file_path}\n\ -# Activated file content (current editing 10 lines): \n\ -# ```\n\ -# {self.active_file_content[-10:]}\n\ -# ```\n\ -# \n\n\ -# Last five action:\n\ -# {"\n".join(self.history[-5:])}\n\nFile tree: \n{self.file_tree}\n" - - - def add_history(self, realtime_action): - if(realtime_action['type']=='config'):return - if len(self.history)!=0: - if (self.history[-1]['type']=='edit'): - if(self.history[-1]['filepath'] == realtime_action['filepath']): - self.history[-1]['content'] = realtime_action['content'] - return - self.history.append(realtime_action) - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241124-165242_i80sek/logging.chat b/Html/runs/run_20241124-165242_i80sek/logging.chat deleted file mode 100644 index e69de29..0000000 diff --git a/Html/runs/run_20241124-165242_i80sek/logging.log b/Html/runs/run_20241124-165242_i80sek/logging.log deleted file mode 100644 index a9d98f6..0000000 --- a/Html/runs/run_20241124-165242_i80sek/logging.log +++ /dev/null @@ -1 +0,0 @@ -2024-11-24 16:52:49.295 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg diff --git a/Html/runs/run_20241124-165427_g7gvev/.config b/Html/runs/run_20241124-165427_g7gvev/.config deleted file mode 100644 index 1a04095..0000000 --- a/Html/runs/run_20241124-165427_g7gvev/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "GyVY4A", - "name": "g7gvev", - "run_id": "run_20241124-165427_g7gvev", - "timestamp": "2024-11-24 16:54:27", - "pid": 7283 -} \ No newline at end of file diff --git a/Html/runs/run_20241124-165427_g7gvev/agentscope.db b/Html/runs/run_20241124-165427_g7gvev/agentscope.db deleted file mode 100644 index 2e84691..0000000 Binary files a/Html/runs/run_20241124-165427_g7gvev/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241124-165427_g7gvev/code/app.py b/Html/runs/run_20241124-165427_g7gvev/code/app.py deleted file mode 100644 index c554b53..0000000 --- a/Html/runs/run_20241124-165427_g7gvev/code/app.py +++ /dev/null @@ -1,213 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager, Backboard - -backboard_manager = BackBoardManager() - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - - -def realtime_response(config, realtime_action): - user_id = config['user_id'] - folder_path = config['path'] - if backboard_manager.get_backboard(user_id) == None: - backboard_manager.add_backboard(user_id, folder_path) - bb = backboard_manager.get_backboard(user_id) - assert type(bb) == Backboard - - bb.add_history(realtime_action) - - if realtime_action['type'] == 'workspaceFolders': - bb.file_tree = realtime_action['file_tree'] - - if realtime_action['type'] == 'activeFile': - file_path = realtime_action['filePath'] - assert type(file_path) == str - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.active_file_path = file_path - with open(f"../{user_id}/{folder_path}/{file_path}") as f: - bb.active_file_content = f.read() - - if realtime_action['type'] == 'paste': - file_path = realtime_action['filePath'] - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.pasted_file_path = file_path - bb.pasted_content = realtime_action['content'] - - - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = userid_recorder[user+'&'+folder_name] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - print('-----------------------') - print(user_id) - user_id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(user_id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - # 构造回复消息 - res = agent_manager.invoke(id, data) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241124-165427_g7gvev/code/backboardManager.py b/Html/runs/run_20241124-165427_g7gvev/code/backboardManager.py deleted file mode 100644 index b243cfc..0000000 --- a/Html/runs/run_20241124-165427_g7gvev/code/backboardManager.py +++ /dev/null @@ -1,76 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - self.history = [] - self.file_tree = "[]" - self.active_file_path = "" - self.active_file_content = "" - self.pasted_file_path = "" - self.pasted_content = "" - - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - - five_history = "" - for h in self.history[-5:]: - five_history += h['type'] + "\n" + h.get('filePath', '') + "\n\n" -# return f"###Global Info:###\n\ -# User is {self.user_id}\n\ -# User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}\n\ -# User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}\n\ -# \n\n\ -# Activated file path: {self.active_file_path}\n\ -# Activated file content (current editing 10 lines): \n\ -# ```\n\ -# {self.active_file_content[-10:]}\n\ -# ```\n\ -# \n\n\ -# Last five action:\n\ -# {"\n".join(self.history[-5:])}\n\nFile tree: \n{self.file_tree}\n" - - - def add_history(self, realtime_action): - if(realtime_action['type']=='config'):return - if len(self.history)!=0: - if (self.history[-1]['type']=='edit'): - if(self.history[-1]['filepath'] == realtime_action['filepath']): - self.history[-1]['content'] = realtime_action['content'] - return - self.history.append(realtime_action) - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241124-165427_g7gvev/logging.chat b/Html/runs/run_20241124-165427_g7gvev/logging.chat deleted file mode 100644 index e69de29..0000000 diff --git a/Html/runs/run_20241124-165427_g7gvev/logging.log b/Html/runs/run_20241124-165427_g7gvev/logging.log deleted file mode 100644 index 0e4f346..0000000 --- a/Html/runs/run_20241124-165427_g7gvev/logging.log +++ /dev/null @@ -1,37 +0,0 @@ -2024-11-24 16:54:35.716 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg -2024-11-24 16:55:41.601 | INFO | agentscope.models.model:__init__:201 - Initialize model by configuration [openai_cfg] -2024-11-24 16:55:41.615 | WARNING | agentscope.models.openai_model:__init__:83 - fail to get max_length for gpt-4o-mini: 'Model [gpt-4o-mini] not found in OPENAI_MAX_LENGTH. The last updated date is 20231212' -2024-11-24 16:55:41.616 | INFO | agentscope.utils.monitor:register_budget:609 - set budget None to gpt-4o-mini -2024-11-24 16:55:41.616 | WARNING | agentscope.utils.monitor:register_budget:639 - Calculate budgets for model [gpt-4o-mini] is not supported -2024-11-24 16:55:41.633 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.call_counter] to SqliteMonitor with unit [times] and quota [None] -2024-11-24 16:55:41.654 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.prompt_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-24 16:55:41.674 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.completion_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-24 16:55:41.694 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.total_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-24 16:56:15.175 | INFO | agentscope.models.model:__init__:201 - Initialize model by configuration [openai_cfg] -2024-11-24 16:56:15.190 | WARNING | agentscope.models.openai_model:__init__:83 - fail to get max_length for gpt-4o-mini: 'Model [gpt-4o-mini] not found in OPENAI_MAX_LENGTH. The last updated date is 20231212' -2024-11-24 16:56:15.190 | INFO | agentscope.utils.monitor:register_budget:609 - set budget None to gpt-4o-mini -2024-11-24 16:56:15.190 | WARNING | agentscope.utils.monitor:register_budget:639 - Calculate budgets for model [gpt-4o-mini] is not supported -2024-11-24 16:57:20.442 | INFO | agentscope.models.model:__init__:201 - Initialize model by configuration [openai_cfg] -2024-11-24 16:57:20.457 | WARNING | agentscope.models.openai_model:__init__:83 - fail to get max_length for gpt-4o-mini: 'Model [gpt-4o-mini] not found in OPENAI_MAX_LENGTH. The last updated date is 20231212' -2024-11-24 16:57:20.458 | INFO | agentscope.utils.monitor:register_budget:609 - set budget None to gpt-4o-mini -2024-11-24 16:57:20.458 | WARNING | agentscope.utils.monitor:register_budget:639 - Calculate budgets for model [gpt-4o-mini] is not supported -2024-11-24 18:47:01.068 | INFO | agentscope.models.model:__init__:201 - Initialize model by configuration [openai_cfg] -2024-11-24 18:47:01.102 | WARNING | agentscope.models.openai_model:__init__:83 - fail to get max_length for gpt-4o-mini: 'Model [gpt-4o-mini] not found in OPENAI_MAX_LENGTH. The last updated date is 20231212' -2024-11-24 18:47:01.102 | INFO | agentscope.utils.monitor:register_budget:609 - set budget None to gpt-4o-mini -2024-11-24 18:47:01.103 | WARNING | agentscope.utils.monitor:register_budget:639 - Calculate budgets for model [gpt-4o-mini] is not supported -2024-11-24 19:01:52.945 | INFO | agentscope.models.model:__init__:201 - Initialize model by configuration [openai_cfg] -2024-11-24 19:01:52.970 | WARNING | agentscope.models.openai_model:__init__:83 - fail to get max_length for gpt-4o-mini: 'Model [gpt-4o-mini] not found in OPENAI_MAX_LENGTH. The last updated date is 20231212' -2024-11-24 19:01:52.971 | INFO | agentscope.utils.monitor:register_budget:609 - set budget None to gpt-4o-mini -2024-11-24 19:01:52.971 | WARNING | agentscope.utils.monitor:register_budget:639 - Calculate budgets for model [gpt-4o-mini] is not supported -2024-11-24 22:35:15.189 | INFO | agentscope.models.model:__init__:201 - Initialize model by configuration [openai_cfg] -2024-11-24 22:35:15.265 | WARNING | agentscope.models.openai_model:__init__:83 - fail to get max_length for gpt-4o-mini: 'Model [gpt-4o-mini] not found in OPENAI_MAX_LENGTH. The last updated date is 20231212' -2024-11-24 22:35:15.266 | INFO | agentscope.utils.monitor:register_budget:609 - set budget None to gpt-4o-mini -2024-11-24 22:35:15.267 | WARNING | agentscope.utils.monitor:register_budget:639 - Calculate budgets for model [gpt-4o-mini] is not supported -2024-11-24 23:10:43.507 | INFO | agentscope.models.model:__init__:201 - Initialize model by configuration [openai_cfg] -2024-11-24 23:10:43.560 | WARNING | agentscope.models.openai_model:__init__:83 - fail to get max_length for gpt-4o-mini: 'Model [gpt-4o-mini] not found in OPENAI_MAX_LENGTH. The last updated date is 20231212' -2024-11-24 23:10:43.563 | INFO | agentscope.utils.monitor:register_budget:609 - set budget None to gpt-4o-mini -2024-11-24 23:10:43.563 | WARNING | agentscope.utils.monitor:register_budget:639 - Calculate budgets for model [gpt-4o-mini] is not supported -2024-11-25 00:00:23.796 | INFO | agentscope.models.model:__init__:201 - Initialize model by configuration [openai_cfg] -2024-11-25 00:00:23.873 | WARNING | agentscope.models.openai_model:__init__:83 - fail to get max_length for gpt-4o-mini: 'Model [gpt-4o-mini] not found in OPENAI_MAX_LENGTH. The last updated date is 20231212' -2024-11-25 00:00:23.880 | INFO | agentscope.utils.monitor:register_budget:609 - set budget None to gpt-4o-mini -2024-11-25 00:00:23.880 | WARNING | agentscope.utils.monitor:register_budget:639 - Calculate budgets for model [gpt-4o-mini] is not supported diff --git a/Html/runs/run_20241126-191334_8v2cge/.config b/Html/runs/run_20241126-191334_8v2cge/.config deleted file mode 100644 index b2e4083..0000000 --- a/Html/runs/run_20241126-191334_8v2cge/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "U0AFxi", - "name": "8v2cge", - "run_id": "run_20241126-191334_8v2cge", - "timestamp": "2024-11-26 19:13:34", - "pid": 3712 -} \ No newline at end of file diff --git a/Html/runs/run_20241126-191334_8v2cge/agentscope.db b/Html/runs/run_20241126-191334_8v2cge/agentscope.db deleted file mode 100644 index 2e84691..0000000 Binary files a/Html/runs/run_20241126-191334_8v2cge/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241126-191334_8v2cge/code/app.py b/Html/runs/run_20241126-191334_8v2cge/code/app.py deleted file mode 100644 index c554b53..0000000 --- a/Html/runs/run_20241126-191334_8v2cge/code/app.py +++ /dev/null @@ -1,213 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager, Backboard - -backboard_manager = BackBoardManager() - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - - -def realtime_response(config, realtime_action): - user_id = config['user_id'] - folder_path = config['path'] - if backboard_manager.get_backboard(user_id) == None: - backboard_manager.add_backboard(user_id, folder_path) - bb = backboard_manager.get_backboard(user_id) - assert type(bb) == Backboard - - bb.add_history(realtime_action) - - if realtime_action['type'] == 'workspaceFolders': - bb.file_tree = realtime_action['file_tree'] - - if realtime_action['type'] == 'activeFile': - file_path = realtime_action['filePath'] - assert type(file_path) == str - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.active_file_path = file_path - with open(f"../{user_id}/{folder_path}/{file_path}") as f: - bb.active_file_content = f.read() - - if realtime_action['type'] == 'paste': - file_path = realtime_action['filePath'] - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.pasted_file_path = file_path - bb.pasted_content = realtime_action['content'] - - - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = userid_recorder[user+'&'+folder_name] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - print('-----------------------') - print(user_id) - user_id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(user_id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - # 构造回复消息 - res = agent_manager.invoke(id, data) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241126-191334_8v2cge/code/backboardManager.py b/Html/runs/run_20241126-191334_8v2cge/code/backboardManager.py deleted file mode 100644 index b243cfc..0000000 --- a/Html/runs/run_20241126-191334_8v2cge/code/backboardManager.py +++ /dev/null @@ -1,76 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - self.history = [] - self.file_tree = "[]" - self.active_file_path = "" - self.active_file_content = "" - self.pasted_file_path = "" - self.pasted_content = "" - - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - - five_history = "" - for h in self.history[-5:]: - five_history += h['type'] + "\n" + h.get('filePath', '') + "\n\n" -# return f"###Global Info:###\n\ -# User is {self.user_id}\n\ -# User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}\n\ -# User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}\n\ -# \n\n\ -# Activated file path: {self.active_file_path}\n\ -# Activated file content (current editing 10 lines): \n\ -# ```\n\ -# {self.active_file_content[-10:]}\n\ -# ```\n\ -# \n\n\ -# Last five action:\n\ -# {"\n".join(self.history[-5:])}\n\nFile tree: \n{self.file_tree}\n" - - - def add_history(self, realtime_action): - if(realtime_action['type']=='config'):return - if len(self.history)!=0: - if (self.history[-1]['type']=='edit'): - if(self.history[-1]['filepath'] == realtime_action['filepath']): - self.history[-1]['content'] = realtime_action['content'] - return - self.history.append(realtime_action) - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241126-191334_8v2cge/logging.chat b/Html/runs/run_20241126-191334_8v2cge/logging.chat deleted file mode 100644 index e69de29..0000000 diff --git a/Html/runs/run_20241126-191334_8v2cge/logging.log b/Html/runs/run_20241126-191334_8v2cge/logging.log deleted file mode 100644 index eaaf8b8..0000000 --- a/Html/runs/run_20241126-191334_8v2cge/logging.log +++ /dev/null @@ -1,9 +0,0 @@ -2024-11-26 19:13:52.709 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg -2024-11-26 19:15:39.920 | INFO | agentscope.models.model:__init__:201 - Initialize model by configuration [openai_cfg] -2024-11-26 19:15:39.938 | WARNING | agentscope.models.openai_model:__init__:83 - fail to get max_length for gpt-4o-mini: 'Model [gpt-4o-mini] not found in OPENAI_MAX_LENGTH. The last updated date is 20231212' -2024-11-26 19:15:39.938 | INFO | agentscope.utils.monitor:register_budget:609 - set budget None to gpt-4o-mini -2024-11-26 19:15:39.938 | WARNING | agentscope.utils.monitor:register_budget:639 - Calculate budgets for model [gpt-4o-mini] is not supported -2024-11-26 19:15:39.956 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.call_counter] to SqliteMonitor with unit [times] and quota [None] -2024-11-26 19:15:39.985 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.prompt_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-26 19:15:40.011 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.completion_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-26 19:15:40.038 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.total_tokens] to SqliteMonitor with unit [token] and quota [None] diff --git a/Html/runs/run_20241126-192000_3qsnbb/.config b/Html/runs/run_20241126-192000_3qsnbb/.config deleted file mode 100644 index 2f0f39f..0000000 --- a/Html/runs/run_20241126-192000_3qsnbb/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "QqF4e6", - "name": "3qsnbb", - "run_id": "run_20241126-192000_3qsnbb", - "timestamp": "2024-11-26 19:20:00", - "pid": 7205 -} \ No newline at end of file diff --git a/Html/runs/run_20241126-192000_3qsnbb/agentscope.db b/Html/runs/run_20241126-192000_3qsnbb/agentscope.db deleted file mode 100644 index 2e84691..0000000 Binary files a/Html/runs/run_20241126-192000_3qsnbb/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241126-192000_3qsnbb/code/app.py b/Html/runs/run_20241126-192000_3qsnbb/code/app.py deleted file mode 100644 index cc670d1..0000000 --- a/Html/runs/run_20241126-192000_3qsnbb/code/app.py +++ /dev/null @@ -1,214 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager, Backboard - -backboard_manager = BackBoardManager() - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - - -def realtime_response(config, realtime_action): - user_id = config['user_id'] - folder_path = config['path'] - if backboard_manager.get_backboard(user_id) == None: - backboard_manager.add_backboard(user_id, folder_path) - bb = backboard_manager.get_backboard(user_id) - assert type(bb) == Backboard - - bb.add_history(realtime_action) - - if realtime_action['type'] == 'workspaceFolders': - pass - # bb.file_tree = realtime_action['file_tree'] - - if realtime_action['type'] == 'activeFile': - file_path = realtime_action['filePath'] - assert type(file_path) == str - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.active_file_path = file_path - with open(f"../{user_id}/{folder_path}/{file_path}") as f: - bb.active_file_content = f.read() - - if realtime_action['type'] == 'paste': - file_path = realtime_action['filePath'] - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.pasted_file_path = file_path - bb.pasted_content = realtime_action['content'] - - - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = userid_recorder[user+'&'+folder_name] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - print('-----------------------') - print(user_id) - user_id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(user_id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - # 构造回复消息 - res = agent_manager.invoke(id, data) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241126-192000_3qsnbb/code/backboardManager.py b/Html/runs/run_20241126-192000_3qsnbb/code/backboardManager.py deleted file mode 100644 index b243cfc..0000000 --- a/Html/runs/run_20241126-192000_3qsnbb/code/backboardManager.py +++ /dev/null @@ -1,76 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - self.history = [] - self.file_tree = "[]" - self.active_file_path = "" - self.active_file_content = "" - self.pasted_file_path = "" - self.pasted_content = "" - - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - - five_history = "" - for h in self.history[-5:]: - five_history += h['type'] + "\n" + h.get('filePath', '') + "\n\n" -# return f"###Global Info:###\n\ -# User is {self.user_id}\n\ -# User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}\n\ -# User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}\n\ -# \n\n\ -# Activated file path: {self.active_file_path}\n\ -# Activated file content (current editing 10 lines): \n\ -# ```\n\ -# {self.active_file_content[-10:]}\n\ -# ```\n\ -# \n\n\ -# Last five action:\n\ -# {"\n".join(self.history[-5:])}\n\nFile tree: \n{self.file_tree}\n" - - - def add_history(self, realtime_action): - if(realtime_action['type']=='config'):return - if len(self.history)!=0: - if (self.history[-1]['type']=='edit'): - if(self.history[-1]['filepath'] == realtime_action['filepath']): - self.history[-1]['content'] = realtime_action['content'] - return - self.history.append(realtime_action) - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241126-192000_3qsnbb/logging.chat b/Html/runs/run_20241126-192000_3qsnbb/logging.chat deleted file mode 100644 index 8b41e3a..0000000 --- a/Html/runs/run_20241126-192000_3qsnbb/logging.chat +++ /dev/null @@ -1,45 +0,0 @@ -{"id": "9f55e7b0db064dc9a0ca092afc3a92c2", "timestamp": "2024-11-26 19:22:16", "name": "assistant", "content": "##################### ITER 1, STEP 1: REASONING ######################", "role": "assistant", "url": null, "metadata": null} -{"id": "480d190fb12e4e43abbdbe1c9b3e7797", "timestamp": "2024-11-26 19:22:16", "name": "system", "content": "## Tool Functions:\nThe following tool functions are available in the format of\n```\n{index}. {function name}: {function description}\n{argument1 name} ({argument type}): {argument description}\n{argument2 name} ({argument type}): {argument description}\n...\n```\n\n1. record: Call it to save some important info for other chapters. Like file path, function call example.\n\tcontent (string): The content to be recorded.\n2. next_chapter: Call it to go to next chapter.\n", "role": "system", "url": null, "metadata": null} -{"id": "5729820ac1c94959b5b5fe98c04dab63", "timestamp": "2024-11-26 19:22:16", "name": "system", "content": "Respond a JSON dictionary in a markdown's fenced code block as follows:\n```json\n{\"thought\": \"what you thought\", \"speak\": \"what you speak\", \"function\": \"[{\\\"name\\\": \\\"{function name}\\\", \\\"arguments\\\": {\\\"{argument1 name}\\\": xxx, \\\"{argument2 name}\\\": xxx}}]\"}\n```\n ####", "role": "system", "url": null, "metadata": null} -{"id": "520b9e1bc10e429296e643ea186610c2", "timestamp": "2024-11-26 19:22:16", "name": "assistant", "content": "################################Prompt################################", "role": "assistant", "url": null, "metadata": null} -{"id": "949ab58c6aeb41c4b357ced310d6b37b", "timestamp": "2024-11-26 19:22:16", "name": "assistant", "content": "hi", "role": "assistant", "url": null, "metadata": null} -{"id": "81c099f1a1464a4a8c44cda3a4c22477", "timestamp": "2024-11-26 19:22:18", "name": "assistant", "content": "############################Result Parsed#############################", "role": "assistant", "url": null, "metadata": null} -{"id": "62cf1f0ae13543b5a915c649bdedd28f", "timestamp": "2024-11-26 19:22:18", "name": "assistant", "content": "{'thought': 'The student has just arrived, and I need to focus on Chapter 1 about binary search and not diverge into other topics.', 'speak': \"Welcome! Let's focus on the first chapter about binary search. Do you want to solve the question regarding the guessing game? How many guesses would you need for a range of 1 to 4000?\", 'function': []}", "role": "assistant", "url": null, "metadata": null} -{"id": "6243b88c88be45b1b2956cb95ec54dec", "timestamp": "2024-11-26 19:22:18", "name": "assistant", "content": "################################Speak#################################", "role": "assistant", "url": null, "metadata": null} -{"id": "8eaf4d1e8f7c45df8f4a27581d45a888", "timestamp": "2024-11-26 19:22:18", "name": "assistant", "content": {"thought": "The student has just arrived, and I need to focus on Chapter 1 about binary search and not diverge into other topics.", "speak": "Welcome! Let's focus on the first chapter about binary search. Do you want to solve the question regarding the guessing game? How many guesses would you need for a range of 1 to 4000?", "function": []}, "role": "assistant", "url": null, "metadata": null} -{"id": "0989a4a39a914beaaffcd61f83fac232", "timestamp": "2024-11-26 19:22:36", "name": "assistant", "content": "##################### ITER 1, STEP 1: REASONING ######################", "role": "assistant", "url": null, "metadata": null} -{"id": "8332f00d89cb4343bfe22ead2103fefe", "timestamp": "2024-11-26 19:22:36", "name": "system", "content": "## Tool Functions:\nThe following tool functions are available in the format of\n```\n{index}. {function name}: {function description}\n{argument1 name} ({argument type}): {argument description}\n{argument2 name} ({argument type}): {argument description}\n...\n```\n\n1. record: Call it to save some important info for other chapters. Like file path, function call example.\n\tcontent (string): The content to be recorded.\n2. next_chapter: Call it to go to next chapter.\n", "role": "system", "url": null, "metadata": null} -{"id": "925f165f3b8a4e1aa05f9fcbd10d928c", "timestamp": "2024-11-26 19:22:36", "name": "system", "content": "Respond a JSON dictionary in a markdown's fenced code block as follows:\n```json\n{\"thought\": \"what you thought\", \"speak\": \"what you speak\", \"function\": \"[{\\\"name\\\": \\\"{function name}\\\", \\\"arguments\\\": {\\\"{argument1 name}\\\": xxx, \\\"{argument2 name}\\\": xxx}}]\"}\n```\n ####", "role": "system", "url": null, "metadata": null} -{"id": "65e21a591347471fa01eebe4896e5d81", "timestamp": "2024-11-26 19:22:36", "name": "assistant", "content": "################################Prompt################################", "role": "assistant", "url": null, "metadata": null} -{"id": "756689233f5d45d893df5b1dd51f5f8d", "timestamp": "2024-11-26 19:22:36", "name": "assistant", "content": "用中文交流\n", "role": "assistant", "url": null, "metadata": null} -{"id": "98adc4fa2d17452c8488b012ed3abde3", "timestamp": "2024-11-26 19:22:38", "name": "assistant", "content": "############################Result Parsed#############################", "role": "assistant", "url": null, "metadata": null} -{"id": "639c7f000f11473299f95ae77d3de982", "timestamp": "2024-11-26 19:22:38", "name": "assistant", "content": "{'thought': '学生希望用中文交流,我要用中文与他沟通,并且专注于第一章的内容。', 'speak': '好的,我们用中文交流!你想解决关于猜数字的问题吗?如果区间是1到4000,最差情况下需要猜几次呢?', 'function': []}", "role": "assistant", "url": null, "metadata": null} -{"id": "75a511b9cb724f1ab99a4324923efbbb", "timestamp": "2024-11-26 19:22:38", "name": "assistant", "content": "################################Speak#################################", "role": "assistant", "url": null, "metadata": null} -{"id": "b251409b00944f99afa26a45af427797", "timestamp": "2024-11-26 19:22:38", "name": "assistant", "content": {"thought": "学生希望用中文交流,我要用中文与他沟通,并且专注于第一章的内容。", "speak": "好的,我们用中文交流!你想解决关于猜数字的问题吗?如果区间是1到4000,最差情况下需要猜几次呢?", "function": []}, "role": "assistant", "url": null, "metadata": null} -{"id": "1c47f319b49745fdafaed4c8ae2b8206", "timestamp": "2024-11-26 19:22:45", "name": "assistant", "content": "##################### ITER 1, STEP 1: REASONING ######################", "role": "assistant", "url": null, "metadata": null} -{"id": "9a55baaf3c6941fba4e274814476793d", "timestamp": "2024-11-26 19:22:45", "name": "system", "content": "## Tool Functions:\nThe following tool functions are available in the format of\n```\n{index}. {function name}: {function description}\n{argument1 name} ({argument type}): {argument description}\n{argument2 name} ({argument type}): {argument description}\n...\n```\n\n1. record: Call it to save some important info for other chapters. Like file path, function call example.\n\tcontent (string): The content to be recorded.\n2. next_chapter: Call it to go to next chapter.\n", "role": "system", "url": null, "metadata": null} -{"id": "098690e7dbb1496193be7a795a8db5e4", "timestamp": "2024-11-26 19:22:45", "name": "system", "content": "Respond a JSON dictionary in a markdown's fenced code block as follows:\n```json\n{\"thought\": \"what you thought\", \"speak\": \"what you speak\", \"function\": \"[{\\\"name\\\": \\\"{function name}\\\", \\\"arguments\\\": {\\\"{argument1 name}\\\": xxx, \\\"{argument2 name}\\\": xxx}}]\"}\n```\n ####", "role": "system", "url": null, "metadata": null} -{"id": "14564653cb384afd9a123d771f985c47", "timestamp": "2024-11-26 19:22:45", "name": "assistant", "content": "################################Prompt################################", "role": "assistant", "url": null, "metadata": null} -{"id": "ed8f5cbae5c4462ea42394a036638f49", "timestamp": "2024-11-26 19:22:45", "name": "assistant", "content": "13次", "role": "assistant", "url": null, "metadata": null} -{"id": "a62262b1556a401380a4e0a4ea82eb43", "timestamp": "2024-11-26 19:22:47", "name": "assistant", "content": "############################Result Parsed#############################", "role": "assistant", "url": null, "metadata": null} -{"id": "225d66b0ef4c4a7890f6aa2c6d18f461", "timestamp": "2024-11-26 19:22:47", "name": "assistant", "content": "{'thought': '学生的回答可能不正确,应该引导他进行思考并给出提示。', 'speak': '你的答案是13次,但实际上我们可以对照二分查找的过程来验证这个推理。想一想,猜测的区间每次都是如何缩小的。你能再计算一下吗?', 'function': []}", "role": "assistant", "url": null, "metadata": null} -{"id": "6fd0b0eb8ecb4eef8c247e0ff5fe25d4", "timestamp": "2024-11-26 19:22:47", "name": "assistant", "content": "################################Speak#################################", "role": "assistant", "url": null, "metadata": null} -{"id": "9246ce14041f407283b4f93450a7f709", "timestamp": "2024-11-26 19:22:47", "name": "assistant", "content": {"thought": "学生的回答可能不正确,应该引导他进行思考并给出提示。", "speak": "你的答案是13次,但实际上我们可以对照二分查找的过程来验证这个推理。想一想,猜测的区间每次都是如何缩小的。你能再计算一下吗?", "function": []}, "role": "assistant", "url": null, "metadata": null} -{"id": "b7e0eb22b922463894788b3bd6b45f22", "timestamp": "2024-11-26 19:23:17", "name": "assistant", "content": "##################### ITER 1, STEP 1: REASONING ######################", "role": "assistant", "url": null, "metadata": null} -{"id": "ca4440d6b3d44a7b818d49fb4e4185fc", "timestamp": "2024-11-26 19:23:17", "name": "system", "content": "## Tool Functions:\nThe following tool functions are available in the format of\n```\n{index}. {function name}: {function description}\n{argument1 name} ({argument type}): {argument description}\n{argument2 name} ({argument type}): {argument description}\n...\n```\n\n1. record: Call it to save some important info for other chapters. Like file path, function call example.\n\tcontent (string): The content to be recorded.\n2. next_chapter: Call it to go to next chapter.\n", "role": "system", "url": null, "metadata": null} -{"id": "8a126f2aec7c4da88cfa5758c1aa3347", "timestamp": "2024-11-26 19:23:17", "name": "system", "content": "Respond a JSON dictionary in a markdown's fenced code block as follows:\n```json\n{\"thought\": \"what you thought\", \"speak\": \"what you speak\", \"function\": \"[{\\\"name\\\": \\\"{function name}\\\", \\\"arguments\\\": {\\\"{argument1 name}\\\": xxx, \\\"{argument2 name}\\\": xxx}}]\"}\n```\n ####", "role": "system", "url": null, "metadata": null} -{"id": "f518b0a72a624d269b2b9bffe9e0a2be", "timestamp": "2024-11-26 19:23:17", "name": "assistant", "content": "################################Prompt################################", "role": "assistant", "url": null, "metadata": null} -{"id": "c220af3b985246dd90e823c26d920ffd", "timestamp": "2024-11-26 19:23:17", "name": "assistant", "content": "每次二分都是排除一半的可能性,所以是log4000=12,最后多一次猜测", "role": "assistant", "url": null, "metadata": null} -{"id": "0b96917758d74c0ba45b3513975d5f04", "timestamp": "2024-11-26 19:23:20", "name": "assistant", "content": "############################Result Parsed#############################", "role": "assistant", "url": null, "metadata": null} -{"id": "0982dd27b9014e3ba5e8ded734098851", "timestamp": "2024-11-26 19:23:20", "name": "assistant", "content": "{'thought': '学生已经意识到每次二分能排除一半的可能性,并得出猜测次数的公式,我应该鼓励他并记录他的想法。', 'speak': '很好,你计算得很正确!确实是12次猜测加上最后一次,最多需要13次。你现在对二分查找方法有更深刻的理解了!接下来,我们要进入下一章吗?', 'function': [{'name': 'record', 'arguments': {'content': '学生理解了二分查找的原理,并正确计算出了1到4000区间的最差猜测次数为13次。'}}]}", "role": "assistant", "url": null, "metadata": null} -{"id": "4ded0f5d6b174dbeae6b44940a1ad56d", "timestamp": "2024-11-26 19:23:20", "name": "assistant", "content": "################################Speak#################################", "role": "assistant", "url": null, "metadata": null} -{"id": "38de9122b47743c1bfd0d5cc04303a00", "timestamp": "2024-11-26 19:23:20", "name": "assistant", "content": {"thought": "学生已经意识到每次二分能排除一半的可能性,并得出猜测次数的公式,我应该鼓励他并记录他的想法。", "speak": "很好,你计算得很正确!确实是12次猜测加上最后一次,最多需要13次。你现在对二分查找方法有更深刻的理解了!接下来,我们要进入下一章吗?", "function": [{"name": "record", "arguments": {"content": "学生理解了二分查找的原理,并正确计算出了1到4000区间的最差猜测次数为13次。"}}]}, "role": "assistant", "url": null, "metadata": null} -{"id": "9be648edc85c4bf5a64e82f96d7efc47", "timestamp": "2024-11-26 19:23:35", "name": "assistant", "content": "##################### ITER 1, STEP 1: REASONING ######################", "role": "assistant", "url": null, "metadata": null} -{"id": "8a5c2b27724c4fb2be0d9c29fb9582c5", "timestamp": "2024-11-26 19:23:35", "name": "system", "content": "## Tool Functions:\nThe following tool functions are available in the format of\n```\n{index}. {function name}: {function description}\n{argument1 name} ({argument type}): {argument description}\n{argument2 name} ({argument type}): {argument description}\n...\n```\n\n1. record: Call it to save some important info for other chapters. Like file path, function call example.\n\tcontent (string): The content to be recorded.\n2. next_chapter: Call it to go to next chapter.\n", "role": "system", "url": null, "metadata": null} -{"id": "96ea579394ac4db69e9276ed93a18512", "timestamp": "2024-11-26 19:23:35", "name": "system", "content": "Respond a JSON dictionary in a markdown's fenced code block as follows:\n```json\n{\"thought\": \"what you thought\", \"speak\": \"what you speak\", \"function\": \"[{\\\"name\\\": \\\"{function name}\\\", \\\"arguments\\\": {\\\"{argument1 name}\\\": xxx, \\\"{argument2 name}\\\": xxx}}]\"}\n```\n ####", "role": "system", "url": null, "metadata": null} -{"id": "f818d70487dc470b86fae7063c1775a0", "timestamp": "2024-11-26 19:23:35", "name": "assistant", "content": "################################Prompt################################", "role": "assistant", "url": null, "metadata": null} -{"id": "0f9a57b614ea4f6885ed7a803a67191b", "timestamp": "2024-11-26 19:23:35", "name": "assistant", "content": "好的 ,进入下一章", "role": "assistant", "url": null, "metadata": null} -{"id": "1a5607b181624b7aaf221b4eaeb2db70", "timestamp": "2024-11-26 19:23:37", "name": "assistant", "content": "############################Result Parsed#############################", "role": "assistant", "url": null, "metadata": null} -{"id": "50c27d8181764d9f8b98f13d46c97efc", "timestamp": "2024-11-26 19:23:37", "name": "assistant", "content": "{'thought': '学生准备进入下一章,我需要调用函数进行章节切换。', 'speak': '好的,我们现在进入下一章!', 'function': '[{\"name\": \"next_chapter\", \"arguments\": {}}]'}", "role": "assistant", "url": null, "metadata": null} -{"id": "54a32a673bc541a594542b2edeb86e02", "timestamp": "2024-11-26 19:23:37", "name": "assistant", "content": "################################Speak#################################", "role": "assistant", "url": null, "metadata": null} -{"id": "b8b7d8c9a0fe4424bd8e4799df025b24", "timestamp": "2024-11-26 19:23:37", "name": "assistant", "content": {"thought": "学生准备进入下一章,我需要调用函数进行章节切换。", "speak": "好的,我们现在进入下一章!", "function": "[{\"name\": \"next_chapter\", \"arguments\": {}}]"}, "role": "assistant", "url": null, "metadata": null} diff --git a/Html/runs/run_20241126-192000_3qsnbb/logging.log b/Html/runs/run_20241126-192000_3qsnbb/logging.log deleted file mode 100644 index 4139864..0000000 --- a/Html/runs/run_20241126-192000_3qsnbb/logging.log +++ /dev/null @@ -1,135 +0,0 @@ -2024-11-26 19:20:11.404 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg -2024-11-26 19:20:54.537 | INFO | agentscope.models.model:__init__:201 - Initialize model by configuration [openai_cfg] -2024-11-26 19:20:54.558 | WARNING | agentscope.models.openai_model:__init__:83 - fail to get max_length for gpt-4o-mini: 'Model [gpt-4o-mini] not found in OPENAI_MAX_LENGTH. The last updated date is 20231212' -2024-11-26 19:20:54.559 | INFO | agentscope.utils.monitor:register_budget:609 - set budget None to gpt-4o-mini -2024-11-26 19:20:54.559 | WARNING | agentscope.utils.monitor:register_budget:639 - Calculate budgets for model [gpt-4o-mini] is not supported -2024-11-26 19:20:54.574 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.call_counter] to SqliteMonitor with unit [times] and quota [None] -2024-11-26 19:20:54.597 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.prompt_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-26 19:20:54.625 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.completion_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-26 19:20:54.652 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.total_tokens] to SqliteMonitor with unit [token] and quota [None] -assistant: ##################### ITER 1, STEP 1: REASONING ###################### -system: ## Tool Functions: -The following tool functions are available in the format of -``` -{index}. {function name}: {function description} -{argument1 name} ({argument type}): {argument description} -{argument2 name} ({argument type}): {argument description} -... -``` - -1. record: Call it to save some important info for other chapters. Like file path, function call example. - content (string): The content to be recorded. -2. next_chapter: Call it to go to next chapter. - -system: Respond a JSON dictionary in a markdown's fenced code block as follows: -```json -{"thought": "what you thought", "speak": "what you speak", "function": "[{\"name\": \"{function name}\", \"arguments\": {\"{argument1 name}\": xxx, \"{argument2 name}\": xxx}}]"} -``` - #### -assistant: ################################Prompt################################ -assistant: hi -assistant: ############################Result Parsed############################# -assistant: {'thought': 'The student has just arrived, and I need to focus on Chapter 1 about binary search and not diverge into other topics.', 'speak': "Welcome! Let's focus on the first chapter about binary search. Do you want to solve the question regarding the guessing game? How many guesses would you need for a range of 1 to 4000?", 'function': []} -assistant: ################################Speak################################# -assistant: {'thought': 'The student has just arrived, and I need to focus on Chapter 1 about binary search and not diverge into other topics.', 'speak': "Welcome! Let's focus on the first chapter about binary search. Do you want to solve the question regarding the guessing game? How many guesses would you need for a range of 1 to 4000?", 'function': []} -assistant: ##################### ITER 1, STEP 1: REASONING ###################### -system: ## Tool Functions: -The following tool functions are available in the format of -``` -{index}. {function name}: {function description} -{argument1 name} ({argument type}): {argument description} -{argument2 name} ({argument type}): {argument description} -... -``` - -1. record: Call it to save some important info for other chapters. Like file path, function call example. - content (string): The content to be recorded. -2. next_chapter: Call it to go to next chapter. - -system: Respond a JSON dictionary in a markdown's fenced code block as follows: -```json -{"thought": "what you thought", "speak": "what you speak", "function": "[{\"name\": \"{function name}\", \"arguments\": {\"{argument1 name}\": xxx, \"{argument2 name}\": xxx}}]"} -``` - #### -assistant: ################################Prompt################################ -assistant: 用中文交流 - -assistant: ############################Result Parsed############################# -assistant: {'thought': '学生希望用中文交流,我要用中文与他沟通,并且专注于第一章的内容。', 'speak': '好的,我们用中文交流!你想解决关于猜数字的问题吗?如果区间是1到4000,最差情况下需要猜几次呢?', 'function': []} -assistant: ################################Speak################################# -assistant: {'thought': '学生希望用中文交流,我要用中文与他沟通,并且专注于第一章的内容。', 'speak': '好的,我们用中文交流!你想解决关于猜数字的问题吗?如果区间是1到4000,最差情况下需要猜几次呢?', 'function': []} -assistant: ##################### ITER 1, STEP 1: REASONING ###################### -system: ## Tool Functions: -The following tool functions are available in the format of -``` -{index}. {function name}: {function description} -{argument1 name} ({argument type}): {argument description} -{argument2 name} ({argument type}): {argument description} -... -``` - -1. record: Call it to save some important info for other chapters. Like file path, function call example. - content (string): The content to be recorded. -2. next_chapter: Call it to go to next chapter. - -system: Respond a JSON dictionary in a markdown's fenced code block as follows: -```json -{"thought": "what you thought", "speak": "what you speak", "function": "[{\"name\": \"{function name}\", \"arguments\": {\"{argument1 name}\": xxx, \"{argument2 name}\": xxx}}]"} -``` - #### -assistant: ################################Prompt################################ -assistant: 13次 -assistant: ############################Result Parsed############################# -assistant: {'thought': '学生的回答可能不正确,应该引导他进行思考并给出提示。', 'speak': '你的答案是13次,但实际上我们可以对照二分查找的过程来验证这个推理。想一想,猜测的区间每次都是如何缩小的。你能再计算一下吗?', 'function': []} -assistant: ################################Speak################################# -assistant: {'thought': '学生的回答可能不正确,应该引导他进行思考并给出提示。', 'speak': '你的答案是13次,但实际上我们可以对照二分查找的过程来验证这个推理。想一想,猜测的区间每次都是如何缩小的。你能再计算一下吗?', 'function': []} -assistant: ##################### ITER 1, STEP 1: REASONING ###################### -system: ## Tool Functions: -The following tool functions are available in the format of -``` -{index}. {function name}: {function description} -{argument1 name} ({argument type}): {argument description} -{argument2 name} ({argument type}): {argument description} -... -``` - -1. record: Call it to save some important info for other chapters. Like file path, function call example. - content (string): The content to be recorded. -2. next_chapter: Call it to go to next chapter. - -system: Respond a JSON dictionary in a markdown's fenced code block as follows: -```json -{"thought": "what you thought", "speak": "what you speak", "function": "[{\"name\": \"{function name}\", \"arguments\": {\"{argument1 name}\": xxx, \"{argument2 name}\": xxx}}]"} -``` - #### -assistant: ################################Prompt################################ -assistant: 每次二分都是排除一半的可能性,所以是log4000=12,最后多一次猜测 -assistant: ############################Result Parsed############################# -assistant: {'thought': '学生已经意识到每次二分能排除一半的可能性,并得出猜测次数的公式,我应该鼓励他并记录他的想法。', 'speak': '很好,你计算得很正确!确实是12次猜测加上最后一次,最多需要13次。你现在对二分查找方法有更深刻的理解了!接下来,我们要进入下一章吗?', 'function': [{'name': 'record', 'arguments': {'content': '学生理解了二分查找的原理,并正确计算出了1到4000区间的最差猜测次数为13次。'}}]} -assistant: ################################Speak################################# -assistant: {'thought': '学生已经意识到每次二分能排除一半的可能性,并得出猜测次数的公式,我应该鼓励他并记录他的想法。', 'speak': '很好,你计算得很正确!确实是12次猜测加上最后一次,最多需要13次。你现在对二分查找方法有更深刻的理解了!接下来,我们要进入下一章吗?', 'function': [{'name': 'record', 'arguments': {'content': '学生理解了二分查找的原理,并正确计算出了1到4000区间的最差猜测次数为13次。'}}]} -assistant: ##################### ITER 1, STEP 1: REASONING ###################### -system: ## Tool Functions: -The following tool functions are available in the format of -``` -{index}. {function name}: {function description} -{argument1 name} ({argument type}): {argument description} -{argument2 name} ({argument type}): {argument description} -... -``` - -1. record: Call it to save some important info for other chapters. Like file path, function call example. - content (string): The content to be recorded. -2. next_chapter: Call it to go to next chapter. - -system: Respond a JSON dictionary in a markdown's fenced code block as follows: -```json -{"thought": "what you thought", "speak": "what you speak", "function": "[{\"name\": \"{function name}\", \"arguments\": {\"{argument1 name}\": xxx, \"{argument2 name}\": xxx}}]"} -``` - #### -assistant: ################################Prompt################################ -assistant: 好的 ,进入下一章 -assistant: ############################Result Parsed############################# -assistant: {'thought': '学生准备进入下一章,我需要调用函数进行章节切换。', 'speak': '好的,我们现在进入下一章!', 'function': '[{"name": "next_chapter", "arguments": {}}]'} -assistant: ################################Speak################################# -assistant: {'thought': '学生准备进入下一章,我需要调用函数进行章节切换。', 'speak': '好的,我们现在进入下一章!', 'function': '[{"name": "next_chapter", "arguments": {}}]'} diff --git a/Html/runs/run_20241127-160907_d348pf/.config b/Html/runs/run_20241127-160907_d348pf/.config deleted file mode 100644 index 14cdfad..0000000 --- a/Html/runs/run_20241127-160907_d348pf/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "UvUbAV", - "name": "d348pf", - "run_id": "run_20241127-160907_d348pf", - "timestamp": "2024-11-27 16:09:07", - "pid": 11664 -} \ No newline at end of file diff --git a/Html/runs/run_20241127-160907_d348pf/agentscope.db b/Html/runs/run_20241127-160907_d348pf/agentscope.db deleted file mode 100644 index 50c98d3..0000000 Binary files a/Html/runs/run_20241127-160907_d348pf/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241127-160907_d348pf/code/app.py b/Html/runs/run_20241127-160907_d348pf/code/app.py deleted file mode 100644 index 630f882..0000000 --- a/Html/runs/run_20241127-160907_d348pf/code/app.py +++ /dev/null @@ -1,213 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager, Backboard - -backboard_manager = BackBoardManager() - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - - -def realtime_response(config, realtime_action): - user_id = config['user_id'] - folder_path = config['path'] - if backboard_manager.get_backboard(user_id) == None: - backboard_manager.add_backboard(user_id, folder_path) - bb = backboard_manager.get_backboard(user_id) - assert type(bb) == Backboard - - bb.add_history(realtime_action) - - if realtime_action['type'] == 'workspaceFolders': - bb.file_tree = realtime_action['fileTree'] - - if realtime_action['type'] == 'activeFile': - file_path = realtime_action['filePath'] - assert type(file_path) == str - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.active_file_path = file_path - with open(f"../{user_id}/{folder_path}/{file_path}") as f: - bb.active_file_content = f.read() - - if realtime_action['type'] == 'paste': - file_path = realtime_action['filePath'] - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.pasted_file_path = file_path - bb.pasted_content = realtime_action['content'] - - - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = userid_recorder[user+'&'+folder_name] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - print('-----------------------') - print(user_id) - user_id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(user_id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - # 构造回复消息 - res = agent_manager.invoke(id, data) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241127-160907_d348pf/code/backboardManager.py b/Html/runs/run_20241127-160907_d348pf/code/backboardManager.py deleted file mode 100644 index b243cfc..0000000 --- a/Html/runs/run_20241127-160907_d348pf/code/backboardManager.py +++ /dev/null @@ -1,76 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - self.history = [] - self.file_tree = "[]" - self.active_file_path = "" - self.active_file_content = "" - self.pasted_file_path = "" - self.pasted_content = "" - - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - - five_history = "" - for h in self.history[-5:]: - five_history += h['type'] + "\n" + h.get('filePath', '') + "\n\n" -# return f"###Global Info:###\n\ -# User is {self.user_id}\n\ -# User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}\n\ -# User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}\n\ -# \n\n\ -# Activated file path: {self.active_file_path}\n\ -# Activated file content (current editing 10 lines): \n\ -# ```\n\ -# {self.active_file_content[-10:]}\n\ -# ```\n\ -# \n\n\ -# Last five action:\n\ -# {"\n".join(self.history[-5:])}\n\nFile tree: \n{self.file_tree}\n" - - - def add_history(self, realtime_action): - if(realtime_action['type']=='config'):return - if len(self.history)!=0: - if (self.history[-1]['type']=='edit'): - if(self.history[-1]['filepath'] == realtime_action['filepath']): - self.history[-1]['content'] = realtime_action['content'] - return - self.history.append(realtime_action) - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241127-160907_d348pf/logging.chat b/Html/runs/run_20241127-160907_d348pf/logging.chat deleted file mode 100644 index e69de29..0000000 diff --git a/Html/runs/run_20241127-160907_d348pf/logging.log b/Html/runs/run_20241127-160907_d348pf/logging.log deleted file mode 100644 index 0cb2a60..0000000 --- a/Html/runs/run_20241127-160907_d348pf/logging.log +++ /dev/null @@ -1 +0,0 @@ -2024-11-27 16:09:13.594 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg diff --git a/Html/runs/run_20241127-162239_nq2bwu/.config b/Html/runs/run_20241127-162239_nq2bwu/.config deleted file mode 100644 index 5306df1..0000000 --- a/Html/runs/run_20241127-162239_nq2bwu/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "nX76UV", - "name": "nq2bwu", - "run_id": "run_20241127-162239_nq2bwu", - "timestamp": "2024-11-27 16:22:39", - "pid": 3796 -} \ No newline at end of file diff --git a/Html/runs/run_20241127-162239_nq2bwu/agentscope.db b/Html/runs/run_20241127-162239_nq2bwu/agentscope.db deleted file mode 100644 index 50c98d3..0000000 Binary files a/Html/runs/run_20241127-162239_nq2bwu/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241127-162239_nq2bwu/code/app.py b/Html/runs/run_20241127-162239_nq2bwu/code/app.py deleted file mode 100644 index 630f882..0000000 --- a/Html/runs/run_20241127-162239_nq2bwu/code/app.py +++ /dev/null @@ -1,213 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager, Backboard - -backboard_manager = BackBoardManager() - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - - -def realtime_response(config, realtime_action): - user_id = config['user_id'] - folder_path = config['path'] - if backboard_manager.get_backboard(user_id) == None: - backboard_manager.add_backboard(user_id, folder_path) - bb = backboard_manager.get_backboard(user_id) - assert type(bb) == Backboard - - bb.add_history(realtime_action) - - if realtime_action['type'] == 'workspaceFolders': - bb.file_tree = realtime_action['fileTree'] - - if realtime_action['type'] == 'activeFile': - file_path = realtime_action['filePath'] - assert type(file_path) == str - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.active_file_path = file_path - with open(f"../{user_id}/{folder_path}/{file_path}") as f: - bb.active_file_content = f.read() - - if realtime_action['type'] == 'paste': - file_path = realtime_action['filePath'] - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.pasted_file_path = file_path - bb.pasted_content = realtime_action['content'] - - - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = userid_recorder[user+'&'+folder_name] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - print('-----------------------') - print(user_id) - user_id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(user_id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - # 构造回复消息 - res = agent_manager.invoke(id, data) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241127-162239_nq2bwu/code/backboardManager.py b/Html/runs/run_20241127-162239_nq2bwu/code/backboardManager.py deleted file mode 100644 index b243cfc..0000000 --- a/Html/runs/run_20241127-162239_nq2bwu/code/backboardManager.py +++ /dev/null @@ -1,76 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - self.history = [] - self.file_tree = "[]" - self.active_file_path = "" - self.active_file_content = "" - self.pasted_file_path = "" - self.pasted_content = "" - - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - - five_history = "" - for h in self.history[-5:]: - five_history += h['type'] + "\n" + h.get('filePath', '') + "\n\n" -# return f"###Global Info:###\n\ -# User is {self.user_id}\n\ -# User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}\n\ -# User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}\n\ -# \n\n\ -# Activated file path: {self.active_file_path}\n\ -# Activated file content (current editing 10 lines): \n\ -# ```\n\ -# {self.active_file_content[-10:]}\n\ -# ```\n\ -# \n\n\ -# Last five action:\n\ -# {"\n".join(self.history[-5:])}\n\nFile tree: \n{self.file_tree}\n" - - - def add_history(self, realtime_action): - if(realtime_action['type']=='config'):return - if len(self.history)!=0: - if (self.history[-1]['type']=='edit'): - if(self.history[-1]['filepath'] == realtime_action['filepath']): - self.history[-1]['content'] = realtime_action['content'] - return - self.history.append(realtime_action) - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241127-162239_nq2bwu/logging.chat b/Html/runs/run_20241127-162239_nq2bwu/logging.chat deleted file mode 100644 index e69de29..0000000 diff --git a/Html/runs/run_20241127-162239_nq2bwu/logging.log b/Html/runs/run_20241127-162239_nq2bwu/logging.log deleted file mode 100644 index cdd2328..0000000 --- a/Html/runs/run_20241127-162239_nq2bwu/logging.log +++ /dev/null @@ -1 +0,0 @@ -2024-11-27 16:23:06.169 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg diff --git a/Html/runs/run_20241127-163413_988np2/.config b/Html/runs/run_20241127-163413_988np2/.config deleted file mode 100644 index 06d49b8..0000000 --- a/Html/runs/run_20241127-163413_988np2/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "nFSueu", - "name": "988np2", - "run_id": "run_20241127-163413_988np2", - "timestamp": "2024-11-27 16:34:13", - "pid": 10942 -} \ No newline at end of file diff --git a/Html/runs/run_20241127-163413_988np2/agentscope.db b/Html/runs/run_20241127-163413_988np2/agentscope.db deleted file mode 100644 index 50c98d3..0000000 Binary files a/Html/runs/run_20241127-163413_988np2/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241127-163413_988np2/code/app.py b/Html/runs/run_20241127-163413_988np2/code/app.py deleted file mode 100644 index 630f882..0000000 --- a/Html/runs/run_20241127-163413_988np2/code/app.py +++ /dev/null @@ -1,213 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager, Backboard - -backboard_manager = BackBoardManager() - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - - -def realtime_response(config, realtime_action): - user_id = config['user_id'] - folder_path = config['path'] - if backboard_manager.get_backboard(user_id) == None: - backboard_manager.add_backboard(user_id, folder_path) - bb = backboard_manager.get_backboard(user_id) - assert type(bb) == Backboard - - bb.add_history(realtime_action) - - if realtime_action['type'] == 'workspaceFolders': - bb.file_tree = realtime_action['fileTree'] - - if realtime_action['type'] == 'activeFile': - file_path = realtime_action['filePath'] - assert type(file_path) == str - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.active_file_path = file_path - with open(f"../{user_id}/{folder_path}/{file_path}") as f: - bb.active_file_content = f.read() - - if realtime_action['type'] == 'paste': - file_path = realtime_action['filePath'] - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.pasted_file_path = file_path - bb.pasted_content = realtime_action['content'] - - - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = userid_recorder[user+'&'+folder_name] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - print('-----------------------') - print(user_id) - user_id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(user_id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - # 构造回复消息 - res = agent_manager.invoke(id, data) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241127-163413_988np2/code/backboardManager.py b/Html/runs/run_20241127-163413_988np2/code/backboardManager.py deleted file mode 100644 index b243cfc..0000000 --- a/Html/runs/run_20241127-163413_988np2/code/backboardManager.py +++ /dev/null @@ -1,76 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - self.history = [] - self.file_tree = "[]" - self.active_file_path = "" - self.active_file_content = "" - self.pasted_file_path = "" - self.pasted_content = "" - - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - - five_history = "" - for h in self.history[-5:]: - five_history += h['type'] + "\n" + h.get('filePath', '') + "\n\n" -# return f"###Global Info:###\n\ -# User is {self.user_id}\n\ -# User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}\n\ -# User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}\n\ -# \n\n\ -# Activated file path: {self.active_file_path}\n\ -# Activated file content (current editing 10 lines): \n\ -# ```\n\ -# {self.active_file_content[-10:]}\n\ -# ```\n\ -# \n\n\ -# Last five action:\n\ -# {"\n".join(self.history[-5:])}\n\nFile tree: \n{self.file_tree}\n" - - - def add_history(self, realtime_action): - if(realtime_action['type']=='config'):return - if len(self.history)!=0: - if (self.history[-1]['type']=='edit'): - if(self.history[-1]['filepath'] == realtime_action['filepath']): - self.history[-1]['content'] = realtime_action['content'] - return - self.history.append(realtime_action) - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241127-163413_988np2/logging.chat b/Html/runs/run_20241127-163413_988np2/logging.chat deleted file mode 100644 index e69de29..0000000 diff --git a/Html/runs/run_20241127-163413_988np2/logging.log b/Html/runs/run_20241127-163413_988np2/logging.log deleted file mode 100644 index 92579c2..0000000 --- a/Html/runs/run_20241127-163413_988np2/logging.log +++ /dev/null @@ -1 +0,0 @@ -2024-11-27 16:34:38.923 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg diff --git a/Html/runs/run_20241127-164240_n64t1t/.config b/Html/runs/run_20241127-164240_n64t1t/.config deleted file mode 100644 index c9ca419..0000000 --- a/Html/runs/run_20241127-164240_n64t1t/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "o6I1JI", - "name": "n64t1t", - "run_id": "run_20241127-164240_n64t1t", - "timestamp": "2024-11-27 16:42:40", - "pid": 3277 -} \ No newline at end of file diff --git a/Html/runs/run_20241127-164240_n64t1t/agentscope.db b/Html/runs/run_20241127-164240_n64t1t/agentscope.db deleted file mode 100644 index 2e84691..0000000 Binary files a/Html/runs/run_20241127-164240_n64t1t/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241127-164240_n64t1t/code/app.py b/Html/runs/run_20241127-164240_n64t1t/code/app.py deleted file mode 100644 index 630f882..0000000 --- a/Html/runs/run_20241127-164240_n64t1t/code/app.py +++ /dev/null @@ -1,213 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager, Backboard - -backboard_manager = BackBoardManager() - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - - -def realtime_response(config, realtime_action): - user_id = config['user_id'] - folder_path = config['path'] - if backboard_manager.get_backboard(user_id) == None: - backboard_manager.add_backboard(user_id, folder_path) - bb = backboard_manager.get_backboard(user_id) - assert type(bb) == Backboard - - bb.add_history(realtime_action) - - if realtime_action['type'] == 'workspaceFolders': - bb.file_tree = realtime_action['fileTree'] - - if realtime_action['type'] == 'activeFile': - file_path = realtime_action['filePath'] - assert type(file_path) == str - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.active_file_path = file_path - with open(f"../{user_id}/{folder_path}/{file_path}") as f: - bb.active_file_content = f.read() - - if realtime_action['type'] == 'paste': - file_path = realtime_action['filePath'] - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.pasted_file_path = file_path - bb.pasted_content = realtime_action['content'] - - - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = userid_recorder[user+'&'+folder_name] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - print('-----------------------') - print(user_id) - user_id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(user_id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - # 构造回复消息 - res = agent_manager.invoke(id, data) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241127-164240_n64t1t/code/backboardManager.py b/Html/runs/run_20241127-164240_n64t1t/code/backboardManager.py deleted file mode 100644 index b243cfc..0000000 --- a/Html/runs/run_20241127-164240_n64t1t/code/backboardManager.py +++ /dev/null @@ -1,76 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - self.history = [] - self.file_tree = "[]" - self.active_file_path = "" - self.active_file_content = "" - self.pasted_file_path = "" - self.pasted_content = "" - - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - - five_history = "" - for h in self.history[-5:]: - five_history += h['type'] + "\n" + h.get('filePath', '') + "\n\n" -# return f"###Global Info:###\n\ -# User is {self.user_id}\n\ -# User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}\n\ -# User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}\n\ -# \n\n\ -# Activated file path: {self.active_file_path}\n\ -# Activated file content (current editing 10 lines): \n\ -# ```\n\ -# {self.active_file_content[-10:]}\n\ -# ```\n\ -# \n\n\ -# Last five action:\n\ -# {"\n".join(self.history[-5:])}\n\nFile tree: \n{self.file_tree}\n" - - - def add_history(self, realtime_action): - if(realtime_action['type']=='config'):return - if len(self.history)!=0: - if (self.history[-1]['type']=='edit'): - if(self.history[-1]['filepath'] == realtime_action['filepath']): - self.history[-1]['content'] = realtime_action['content'] - return - self.history.append(realtime_action) - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241127-164240_n64t1t/logging.chat b/Html/runs/run_20241127-164240_n64t1t/logging.chat deleted file mode 100644 index e69de29..0000000 diff --git a/Html/runs/run_20241127-164240_n64t1t/logging.log b/Html/runs/run_20241127-164240_n64t1t/logging.log deleted file mode 100644 index eb03d62..0000000 --- a/Html/runs/run_20241127-164240_n64t1t/logging.log +++ /dev/null @@ -1,9 +0,0 @@ -2024-11-27 16:42:53.121 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg -2024-11-27 16:43:46.774 | INFO | agentscope.models.model:__init__:201 - Initialize model by configuration [openai_cfg] -2024-11-27 16:43:46.790 | WARNING | agentscope.models.openai_model:__init__:83 - fail to get max_length for gpt-4o-mini: 'Model [gpt-4o-mini] not found in OPENAI_MAX_LENGTH. The last updated date is 20231212' -2024-11-27 16:43:46.791 | INFO | agentscope.utils.monitor:register_budget:609 - set budget None to gpt-4o-mini -2024-11-27 16:43:46.791 | WARNING | agentscope.utils.monitor:register_budget:639 - Calculate budgets for model [gpt-4o-mini] is not supported -2024-11-27 16:43:46.806 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.call_counter] to SqliteMonitor with unit [times] and quota [None] -2024-11-27 16:43:46.838 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.prompt_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-27 16:43:46.859 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.completion_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-27 16:43:46.882 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.total_tokens] to SqliteMonitor with unit [token] and quota [None] diff --git a/Html/runs/run_20241127-165820_xjexlc/.config b/Html/runs/run_20241127-165820_xjexlc/.config deleted file mode 100644 index 2834a18..0000000 --- a/Html/runs/run_20241127-165820_xjexlc/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "XDCjXX", - "name": "xjexlc", - "run_id": "run_20241127-165820_xjexlc", - "timestamp": "2024-11-27 16:58:20", - "pid": 11685 -} \ No newline at end of file diff --git a/Html/runs/run_20241127-165820_xjexlc/agentscope.db b/Html/runs/run_20241127-165820_xjexlc/agentscope.db deleted file mode 100644 index 2e84691..0000000 Binary files a/Html/runs/run_20241127-165820_xjexlc/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241127-165820_xjexlc/code/app.py b/Html/runs/run_20241127-165820_xjexlc/code/app.py deleted file mode 100644 index 6119e6f..0000000 --- a/Html/runs/run_20241127-165820_xjexlc/code/app.py +++ /dev/null @@ -1,213 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager, Backboard - -backboard_manager = BackBoardManager() - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - - -def realtime_response(config, realtime_action): - user_id = config['user_id'] - folder_path = config['path'] - if backboard_manager.get_backboard(user_id) == None: - backboard_manager.add_backboard(user_id, folder_path) - bb = backboard_manager.get_backboard(user_id) - assert type(bb) == Backboard - - bb.add_history(realtime_action) - - if realtime_action['type'] == 'workspaceFolders': - bb.file_tree = realtime_action['fileTree'] - - if realtime_action['type'] == 'activeFile': - file_path = realtime_action['filePath'] - assert type(file_path) == str - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.active_file_path = file_path - with open(f"../{user_id}/{folder_path}/{file_path}") as f: - bb.active_file_content = f.read() - - if realtime_action['type'] == 'paste': - file_path = realtime_action['filePath'] - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.pasted_file_path = file_path - bb.pasted_content = realtime_action['content'] - - - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = userid_recorder[user+'&'+folder_name] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - print('-----------------------') - print(user_id) - user_id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(user_id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - # 构造回复消息 - res = agent_manager.invoke(id, data, backboard_manager.get_backboard(id).get_info_prompt()) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241127-165820_xjexlc/code/backboardManager.py b/Html/runs/run_20241127-165820_xjexlc/code/backboardManager.py deleted file mode 100644 index cca6703..0000000 --- a/Html/runs/run_20241127-165820_xjexlc/code/backboardManager.py +++ /dev/null @@ -1,72 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - self.history = [] - self.file_tree = "[]" - self.active_file_path = "" - self.active_file_content = "" - self.pasted_file_path = "" - self.pasted_content = "" - - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - - five_history = "" - for h in self.history[-5:]: - five_history += h['type'] + "\n" + h.get('filePath', '') + "\n\n" - return (f"###Global Info:###" - f"- User is {self.user_id}" - f"- User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}" - f"- User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}" - f"- Activated file path: {self.active_file_path}" - f"- Activated file content (current editing 10 lines): " - f"```" - f"{self.active_file_content[-10:]}" - f"```" - f"- Last five action:{five_history}" - f"- File tree: {self.file_tree}") - def add_history(self, realtime_action): - if(realtime_action['type']=='config'):return - if len(self.history)!=0: - if (self.history[-1]['type']=='edit'): - if(self.history[-1]['filepath'] == realtime_action['filepath']): - self.history[-1]['content'] = realtime_action['content'] - return - self.history.append(realtime_action) - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241127-165820_xjexlc/logging.chat b/Html/runs/run_20241127-165820_xjexlc/logging.chat deleted file mode 100644 index e69de29..0000000 diff --git a/Html/runs/run_20241127-165820_xjexlc/logging.log b/Html/runs/run_20241127-165820_xjexlc/logging.log deleted file mode 100644 index 108a940..0000000 --- a/Html/runs/run_20241127-165820_xjexlc/logging.log +++ /dev/null @@ -1,9 +0,0 @@ -2024-11-27 16:58:23.975 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg -2024-11-27 16:59:06.020 | INFO | agentscope.models.model:__init__:201 - Initialize model by configuration [openai_cfg] -2024-11-27 16:59:06.034 | WARNING | agentscope.models.openai_model:__init__:83 - fail to get max_length for gpt-4o-mini: 'Model [gpt-4o-mini] not found in OPENAI_MAX_LENGTH. The last updated date is 20231212' -2024-11-27 16:59:06.034 | INFO | agentscope.utils.monitor:register_budget:609 - set budget None to gpt-4o-mini -2024-11-27 16:59:06.034 | WARNING | agentscope.utils.monitor:register_budget:639 - Calculate budgets for model [gpt-4o-mini] is not supported -2024-11-27 16:59:06.047 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.call_counter] to SqliteMonitor with unit [times] and quota [None] -2024-11-27 16:59:06.068 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.prompt_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-27 16:59:06.088 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.completion_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-27 16:59:06.109 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.total_tokens] to SqliteMonitor with unit [token] and quota [None] diff --git a/Html/runs/run_20241127-170305_tqd3zr/.config b/Html/runs/run_20241127-170305_tqd3zr/.config deleted file mode 100644 index ccdcf84..0000000 --- a/Html/runs/run_20241127-170305_tqd3zr/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "4AWEmQ", - "name": "tqd3zr", - "run_id": "run_20241127-170305_tqd3zr", - "timestamp": "2024-11-27 17:03:05", - "pid": 14045 -} \ No newline at end of file diff --git a/Html/runs/run_20241127-170305_tqd3zr/agentscope.db b/Html/runs/run_20241127-170305_tqd3zr/agentscope.db deleted file mode 100644 index 2e84691..0000000 Binary files a/Html/runs/run_20241127-170305_tqd3zr/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241127-170305_tqd3zr/code/app.py b/Html/runs/run_20241127-170305_tqd3zr/code/app.py deleted file mode 100644 index 92200a0..0000000 --- a/Html/runs/run_20241127-170305_tqd3zr/code/app.py +++ /dev/null @@ -1,217 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager, Backboard - -backboard_manager = BackBoardManager() -user_id2uuid = {} - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - - -def realtime_response(config, realtime_action): - user_id = config['user_id'] - folder_path = config['path'] - useruuid = user_id2uuid[user_id] - if backboard_manager.get_backboard(useruuid) == None: - backboard_manager.add_backboard(useruuid, folder_path) - bb = backboard_manager.get_backboard(useruuid) - assert type(bb) == Backboard - - bb.add_history(realtime_action) - - if realtime_action['type'] == 'workspaceFolders': - bb.file_tree = realtime_action['fileTree'] - - if realtime_action['type'] == 'activeFile': - file_path = realtime_action['filePath'] - assert type(file_path) == str - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.active_file_path = file_path - with open(f"../{user_id}/{folder_path}/{file_path}") as f: - bb.active_file_content = f.read() - - if realtime_action['type'] == 'paste': - file_path = realtime_action['filePath'] - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.pasted_file_path = file_path - bb.pasted_content = realtime_action['content'] - - - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = userid_recorder[user+'&'+folder_name] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - print('-----------------------') - print(user_id) - user_id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(user_id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - - # 构造回复消息 - res = agent_manager.invoke(id, data, backboard_manager.get_backboard(id).get_info_prompt()) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - user_id2uuid[user_id] = session['user_id'] - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241127-170305_tqd3zr/code/backboardManager.py b/Html/runs/run_20241127-170305_tqd3zr/code/backboardManager.py deleted file mode 100644 index cca6703..0000000 --- a/Html/runs/run_20241127-170305_tqd3zr/code/backboardManager.py +++ /dev/null @@ -1,72 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - self.history = [] - self.file_tree = "[]" - self.active_file_path = "" - self.active_file_content = "" - self.pasted_file_path = "" - self.pasted_content = "" - - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - - five_history = "" - for h in self.history[-5:]: - five_history += h['type'] + "\n" + h.get('filePath', '') + "\n\n" - return (f"###Global Info:###" - f"- User is {self.user_id}" - f"- User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}" - f"- User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}" - f"- Activated file path: {self.active_file_path}" - f"- Activated file content (current editing 10 lines): " - f"```" - f"{self.active_file_content[-10:]}" - f"```" - f"- Last five action:{five_history}" - f"- File tree: {self.file_tree}") - def add_history(self, realtime_action): - if(realtime_action['type']=='config'):return - if len(self.history)!=0: - if (self.history[-1]['type']=='edit'): - if(self.history[-1]['filepath'] == realtime_action['filepath']): - self.history[-1]['content'] = realtime_action['content'] - return - self.history.append(realtime_action) - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241127-170305_tqd3zr/logging.chat b/Html/runs/run_20241127-170305_tqd3zr/logging.chat deleted file mode 100644 index e69de29..0000000 diff --git a/Html/runs/run_20241127-170305_tqd3zr/logging.log b/Html/runs/run_20241127-170305_tqd3zr/logging.log deleted file mode 100644 index f451dbf..0000000 --- a/Html/runs/run_20241127-170305_tqd3zr/logging.log +++ /dev/null @@ -1,9 +0,0 @@ -2024-11-27 17:03:20.007 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg -2024-11-27 17:03:51.240 | INFO | agentscope.models.model:__init__:201 - Initialize model by configuration [openai_cfg] -2024-11-27 17:03:51.257 | WARNING | agentscope.models.openai_model:__init__:83 - fail to get max_length for gpt-4o-mini: 'Model [gpt-4o-mini] not found in OPENAI_MAX_LENGTH. The last updated date is 20231212' -2024-11-27 17:03:51.257 | INFO | agentscope.utils.monitor:register_budget:609 - set budget None to gpt-4o-mini -2024-11-27 17:03:51.257 | WARNING | agentscope.utils.monitor:register_budget:639 - Calculate budgets for model [gpt-4o-mini] is not supported -2024-11-27 17:03:51.270 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.call_counter] to SqliteMonitor with unit [times] and quota [None] -2024-11-27 17:03:51.289 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.prompt_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-27 17:03:51.309 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.completion_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-27 17:03:51.329 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.total_tokens] to SqliteMonitor with unit [token] and quota [None] diff --git a/Html/runs/run_20241127-170511_0mfpwy/.config b/Html/runs/run_20241127-170511_0mfpwy/.config deleted file mode 100644 index 141b89c..0000000 --- a/Html/runs/run_20241127-170511_0mfpwy/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "N1hsbv", - "name": "0mfpwy", - "run_id": "run_20241127-170511_0mfpwy", - "timestamp": "2024-11-27 17:05:11", - "pid": 15310 -} \ No newline at end of file diff --git a/Html/runs/run_20241127-170511_0mfpwy/agentscope.db b/Html/runs/run_20241127-170511_0mfpwy/agentscope.db deleted file mode 100644 index 50c98d3..0000000 Binary files a/Html/runs/run_20241127-170511_0mfpwy/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241127-170511_0mfpwy/code/app.py b/Html/runs/run_20241127-170511_0mfpwy/code/app.py deleted file mode 100644 index 63c38aa..0000000 --- a/Html/runs/run_20241127-170511_0mfpwy/code/app.py +++ /dev/null @@ -1,217 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager, Backboard - -backboard_manager = BackBoardManager() -user_id2uuid = {} - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - - -def realtime_response(config, realtime_action): - user_id = config['user_id'] - folder_path = config['path'] - useruuid = user_id2uuid[user_id] - if backboard_manager.get_backboard(useruuid) == None: - backboard_manager.add_backboard(useruuid, folder_path) - bb = backboard_manager.get_backboard(useruuid) - assert type(bb) == Backboard - - bb.add_history(realtime_action) - - if realtime_action['type'] == 'workspaceFolders': - bb.file_tree = realtime_action['fileTree'] - - if realtime_action['type'] == 'activeFile': - file_path = realtime_action['filePath'] - assert type(file_path) == str - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.active_file_path = file_path - with open(f"../{user_id}/{folder_path}/{file_path}") as f: - bb.active_file_content = f.read() - - if realtime_action['type'] == 'paste': - file_path = realtime_action['filePath'] - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.pasted_file_path = file_path - bb.pasted_content = realtime_action['content'] - - - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = user_id2uuid[user_id] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - print('-----------------------') - print(user_id) - user_id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(user_id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - - # 构造回复消息 - res = agent_manager.invoke(id, data, backboard_manager.get_backboard(id).get_info_prompt()) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - user_id2uuid[user_id] = session['user_id'] - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241127-170511_0mfpwy/code/backboardManager.py b/Html/runs/run_20241127-170511_0mfpwy/code/backboardManager.py deleted file mode 100644 index cca6703..0000000 --- a/Html/runs/run_20241127-170511_0mfpwy/code/backboardManager.py +++ /dev/null @@ -1,72 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - self.history = [] - self.file_tree = "[]" - self.active_file_path = "" - self.active_file_content = "" - self.pasted_file_path = "" - self.pasted_content = "" - - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - - five_history = "" - for h in self.history[-5:]: - five_history += h['type'] + "\n" + h.get('filePath', '') + "\n\n" - return (f"###Global Info:###" - f"- User is {self.user_id}" - f"- User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}" - f"- User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}" - f"- Activated file path: {self.active_file_path}" - f"- Activated file content (current editing 10 lines): " - f"```" - f"{self.active_file_content[-10:]}" - f"```" - f"- Last five action:{five_history}" - f"- File tree: {self.file_tree}") - def add_history(self, realtime_action): - if(realtime_action['type']=='config'):return - if len(self.history)!=0: - if (self.history[-1]['type']=='edit'): - if(self.history[-1]['filepath'] == realtime_action['filepath']): - self.history[-1]['content'] = realtime_action['content'] - return - self.history.append(realtime_action) - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241127-170511_0mfpwy/logging.chat b/Html/runs/run_20241127-170511_0mfpwy/logging.chat deleted file mode 100644 index e69de29..0000000 diff --git a/Html/runs/run_20241127-170511_0mfpwy/logging.log b/Html/runs/run_20241127-170511_0mfpwy/logging.log deleted file mode 100644 index 8c42a81..0000000 --- a/Html/runs/run_20241127-170511_0mfpwy/logging.log +++ /dev/null @@ -1 +0,0 @@ -2024-11-27 17:05:21.254 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg diff --git a/Html/runs/run_20241127-170539_tv0aa8/.config b/Html/runs/run_20241127-170539_tv0aa8/.config deleted file mode 100644 index 4f8f739..0000000 --- a/Html/runs/run_20241127-170539_tv0aa8/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "r18ia1", - "name": "tv0aa8", - "run_id": "run_20241127-170539_tv0aa8", - "timestamp": "2024-11-27 17:05:39", - "pid": 15638 -} \ No newline at end of file diff --git a/Html/runs/run_20241127-170539_tv0aa8/agentscope.db b/Html/runs/run_20241127-170539_tv0aa8/agentscope.db deleted file mode 100644 index 50c98d3..0000000 Binary files a/Html/runs/run_20241127-170539_tv0aa8/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241127-170539_tv0aa8/code/app.py b/Html/runs/run_20241127-170539_tv0aa8/code/app.py deleted file mode 100644 index 7548e07..0000000 --- a/Html/runs/run_20241127-170539_tv0aa8/code/app.py +++ /dev/null @@ -1,217 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager, Backboard - -backboard_manager = BackBoardManager() -user_id2uuid = {} - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - - -def realtime_response(config, realtime_action): - user_id = config['user_id'] - folder_path = config['path'] - useruuid = user_id2uuid[user_id] - if backboard_manager.get_backboard(useruuid) == None: - backboard_manager.add_backboard(useruuid, folder_path) - bb = backboard_manager.get_backboard(useruuid) - assert type(bb) == Backboard - - bb.add_history(realtime_action) - - if realtime_action['type'] == 'workspaceFolders': - bb.file_tree = realtime_action['fileTree'] - - if realtime_action['type'] == 'activeFile': - file_path = realtime_action['filePath'] - assert type(file_path) == str - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.active_file_path = file_path - with open(f"../{user_id}/{folder_path}/{file_path}") as f: - bb.active_file_content = f.read() - - if realtime_action['type'] == 'paste': - file_path = realtime_action['filePath'] - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.pasted_file_path = file_path - bb.pasted_content = realtime_action['content'] - - - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = user_id2uuid[user] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - print('-----------------------') - print(user_id) - user_id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(user_id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - - # 构造回复消息 - res = agent_manager.invoke(id, data, backboard_manager.get_backboard(id).get_info_prompt()) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - user_id2uuid[user_id] = session['user_id'] - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241127-170539_tv0aa8/code/backboardManager.py b/Html/runs/run_20241127-170539_tv0aa8/code/backboardManager.py deleted file mode 100644 index cca6703..0000000 --- a/Html/runs/run_20241127-170539_tv0aa8/code/backboardManager.py +++ /dev/null @@ -1,72 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - self.history = [] - self.file_tree = "[]" - self.active_file_path = "" - self.active_file_content = "" - self.pasted_file_path = "" - self.pasted_content = "" - - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - - five_history = "" - for h in self.history[-5:]: - five_history += h['type'] + "\n" + h.get('filePath', '') + "\n\n" - return (f"###Global Info:###" - f"- User is {self.user_id}" - f"- User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}" - f"- User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}" - f"- Activated file path: {self.active_file_path}" - f"- Activated file content (current editing 10 lines): " - f"```" - f"{self.active_file_content[-10:]}" - f"```" - f"- Last five action:{five_history}" - f"- File tree: {self.file_tree}") - def add_history(self, realtime_action): - if(realtime_action['type']=='config'):return - if len(self.history)!=0: - if (self.history[-1]['type']=='edit'): - if(self.history[-1]['filepath'] == realtime_action['filepath']): - self.history[-1]['content'] = realtime_action['content'] - return - self.history.append(realtime_action) - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241127-170539_tv0aa8/logging.chat b/Html/runs/run_20241127-170539_tv0aa8/logging.chat deleted file mode 100644 index e69de29..0000000 diff --git a/Html/runs/run_20241127-170539_tv0aa8/logging.log b/Html/runs/run_20241127-170539_tv0aa8/logging.log deleted file mode 100644 index e38153b..0000000 --- a/Html/runs/run_20241127-170539_tv0aa8/logging.log +++ /dev/null @@ -1 +0,0 @@ -2024-11-27 17:05:47.407 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg diff --git a/Html/runs/run_20241127-170632_fiehq3/.config b/Html/runs/run_20241127-170632_fiehq3/.config deleted file mode 100644 index 775a9ae..0000000 --- a/Html/runs/run_20241127-170632_fiehq3/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "VFBVOm", - "name": "fiehq3", - "run_id": "run_20241127-170632_fiehq3", - "timestamp": "2024-11-27 17:06:32", - "pid": 16346 -} \ No newline at end of file diff --git a/Html/runs/run_20241127-170632_fiehq3/agentscope.db b/Html/runs/run_20241127-170632_fiehq3/agentscope.db deleted file mode 100644 index 2e84691..0000000 Binary files a/Html/runs/run_20241127-170632_fiehq3/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241127-170632_fiehq3/code/app.py b/Html/runs/run_20241127-170632_fiehq3/code/app.py deleted file mode 100644 index 8f7a05b..0000000 --- a/Html/runs/run_20241127-170632_fiehq3/code/app.py +++ /dev/null @@ -1,217 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager, Backboard - -backboard_manager = BackBoardManager() -user_id2uuid = {} - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - - -def realtime_response(config, realtime_action): - user_id = config['user_id'] - folder_path = config['path'] - useruuid = user_id2uuid[user_id] - if backboard_manager.get_backboard(useruuid) == None: - backboard_manager.add_backboard(useruuid, folder_path) - bb = backboard_manager.get_backboard(useruuid) - assert type(bb) == Backboard - - bb.add_history(realtime_action) - - if realtime_action['type'] == 'workspaceFolders': - bb.file_tree = realtime_action['fileTree'] - - if realtime_action['type'] == 'activeFile': - file_path = realtime_action['filePath'] - assert type(file_path) == str - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.active_file_path = file_path - with open(f"../{user_id}/{folder_path}/{file_path}") as f: - bb.active_file_content = f.read() - - if realtime_action['type'] == 'paste': - file_path = realtime_action['filePath'] - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.pasted_file_path = file_path - bb.pasted_content = realtime_action['content'] - - - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = user_id2uuid[user] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - print('-----------------------') - print(user_id) - user_id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(user_id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - - # 构造回复消息 - res = agent_manager.invoke(id, data, backboard_manager.get_backboard(id).get_info_prompt()) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - user_id2uuid[user_id] = session['user_id'] - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241127-170632_fiehq3/code/backboardManager.py b/Html/runs/run_20241127-170632_fiehq3/code/backboardManager.py deleted file mode 100644 index cca6703..0000000 --- a/Html/runs/run_20241127-170632_fiehq3/code/backboardManager.py +++ /dev/null @@ -1,72 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - self.history = [] - self.file_tree = "[]" - self.active_file_path = "" - self.active_file_content = "" - self.pasted_file_path = "" - self.pasted_content = "" - - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - - five_history = "" - for h in self.history[-5:]: - five_history += h['type'] + "\n" + h.get('filePath', '') + "\n\n" - return (f"###Global Info:###" - f"- User is {self.user_id}" - f"- User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}" - f"- User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}" - f"- Activated file path: {self.active_file_path}" - f"- Activated file content (current editing 10 lines): " - f"```" - f"{self.active_file_content[-10:]}" - f"```" - f"- Last five action:{five_history}" - f"- File tree: {self.file_tree}") - def add_history(self, realtime_action): - if(realtime_action['type']=='config'):return - if len(self.history)!=0: - if (self.history[-1]['type']=='edit'): - if(self.history[-1]['filepath'] == realtime_action['filepath']): - self.history[-1]['content'] = realtime_action['content'] - return - self.history.append(realtime_action) - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241127-170632_fiehq3/logging.chat b/Html/runs/run_20241127-170632_fiehq3/logging.chat deleted file mode 100644 index e69de29..0000000 diff --git a/Html/runs/run_20241127-170632_fiehq3/logging.log b/Html/runs/run_20241127-170632_fiehq3/logging.log deleted file mode 100644 index 4b98558..0000000 --- a/Html/runs/run_20241127-170632_fiehq3/logging.log +++ /dev/null @@ -1,9 +0,0 @@ -2024-11-27 17:06:46.187 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg -2024-11-27 17:06:53.728 | INFO | agentscope.models.model:__init__:201 - Initialize model by configuration [openai_cfg] -2024-11-27 17:06:53.743 | WARNING | agentscope.models.openai_model:__init__:83 - fail to get max_length for gpt-4o-mini: 'Model [gpt-4o-mini] not found in OPENAI_MAX_LENGTH. The last updated date is 20231212' -2024-11-27 17:06:53.745 | INFO | agentscope.utils.monitor:register_budget:609 - set budget None to gpt-4o-mini -2024-11-27 17:06:53.745 | WARNING | agentscope.utils.monitor:register_budget:639 - Calculate budgets for model [gpt-4o-mini] is not supported -2024-11-27 17:06:53.757 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.call_counter] to SqliteMonitor with unit [times] and quota [None] -2024-11-27 17:06:53.776 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.prompt_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-27 17:06:53.795 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.completion_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-27 17:06:53.816 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.total_tokens] to SqliteMonitor with unit [token] and quota [None] diff --git a/Html/runs/run_20241127-170728_wdw2uo/.config b/Html/runs/run_20241127-170728_wdw2uo/.config deleted file mode 100644 index cbbe70f..0000000 --- a/Html/runs/run_20241127-170728_wdw2uo/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "pzU9xR", - "name": "wdw2uo", - "run_id": "run_20241127-170728_wdw2uo", - "timestamp": "2024-11-27 17:07:28", - "pid": 17095 -} \ No newline at end of file diff --git a/Html/runs/run_20241127-170728_wdw2uo/agentscope.db b/Html/runs/run_20241127-170728_wdw2uo/agentscope.db deleted file mode 100644 index 2e84691..0000000 Binary files a/Html/runs/run_20241127-170728_wdw2uo/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241127-170728_wdw2uo/code/app.py b/Html/runs/run_20241127-170728_wdw2uo/code/app.py deleted file mode 100644 index cb551e9..0000000 --- a/Html/runs/run_20241127-170728_wdw2uo/code/app.py +++ /dev/null @@ -1,217 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager, Backboard - -backboard_manager = BackBoardManager() -user_id2uuid = {} - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - - -def realtime_response(config, realtime_action): - user_id = config['user_id'] - folder_path = config['path'] - useruuid = user_id2uuid[user_id] - if backboard_manager.get_backboard(useruuid) == None: - backboard_manager.add_backboard(useruuid, folder_path) - bb = backboard_manager.get_backboard(useruuid) - assert type(bb) == Backboard - - bb.add_history(realtime_action) - - if realtime_action['type'] == 'workspaceFolders': - bb.file_tree = realtime_action['fileTree'] - - if realtime_action['type'] == 'activeFile': - file_path = realtime_action['filePath'] - assert type(file_path) == str - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.active_file_path = file_path - with open(f"../{user_id}/{folder_path}/{file_path}") as f: - bb.active_file_content = f.read() - - if realtime_action['type'] == 'paste': - file_path = realtime_action['filePath'] - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.pasted_file_path = file_path - bb.pasted_content = realtime_action['content'] - - - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = user_id2uuid[user] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - print('-----------------------') - print(user_id) - user_id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(user_id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - print(id) - # 构造回复消息 - res = agent_manager.invoke(id, data, backboard_manager.get_backboard(id).get_info_prompt()) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - user_id2uuid[user_id] = session['user_id'] - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241127-170728_wdw2uo/code/backboardManager.py b/Html/runs/run_20241127-170728_wdw2uo/code/backboardManager.py deleted file mode 100644 index cca6703..0000000 --- a/Html/runs/run_20241127-170728_wdw2uo/code/backboardManager.py +++ /dev/null @@ -1,72 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - self.history = [] - self.file_tree = "[]" - self.active_file_path = "" - self.active_file_content = "" - self.pasted_file_path = "" - self.pasted_content = "" - - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - - five_history = "" - for h in self.history[-5:]: - five_history += h['type'] + "\n" + h.get('filePath', '') + "\n\n" - return (f"###Global Info:###" - f"- User is {self.user_id}" - f"- User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}" - f"- User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}" - f"- Activated file path: {self.active_file_path}" - f"- Activated file content (current editing 10 lines): " - f"```" - f"{self.active_file_content[-10:]}" - f"```" - f"- Last five action:{five_history}" - f"- File tree: {self.file_tree}") - def add_history(self, realtime_action): - if(realtime_action['type']=='config'):return - if len(self.history)!=0: - if (self.history[-1]['type']=='edit'): - if(self.history[-1]['filepath'] == realtime_action['filepath']): - self.history[-1]['content'] = realtime_action['content'] - return - self.history.append(realtime_action) - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241127-170728_wdw2uo/logging.chat b/Html/runs/run_20241127-170728_wdw2uo/logging.chat deleted file mode 100644 index e69de29..0000000 diff --git a/Html/runs/run_20241127-170728_wdw2uo/logging.log b/Html/runs/run_20241127-170728_wdw2uo/logging.log deleted file mode 100644 index e1af4f1..0000000 --- a/Html/runs/run_20241127-170728_wdw2uo/logging.log +++ /dev/null @@ -1,9 +0,0 @@ -2024-11-27 17:07:42.317 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg -2024-11-27 17:07:45.444 | INFO | agentscope.models.model:__init__:201 - Initialize model by configuration [openai_cfg] -2024-11-27 17:07:45.459 | WARNING | agentscope.models.openai_model:__init__:83 - fail to get max_length for gpt-4o-mini: 'Model [gpt-4o-mini] not found in OPENAI_MAX_LENGTH. The last updated date is 20231212' -2024-11-27 17:07:45.459 | INFO | agentscope.utils.monitor:register_budget:609 - set budget None to gpt-4o-mini -2024-11-27 17:07:45.459 | WARNING | agentscope.utils.monitor:register_budget:639 - Calculate budgets for model [gpt-4o-mini] is not supported -2024-11-27 17:07:45.473 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.call_counter] to SqliteMonitor with unit [times] and quota [None] -2024-11-27 17:07:45.492 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.prompt_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-27 17:07:45.510 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.completion_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-27 17:07:45.529 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.total_tokens] to SqliteMonitor with unit [token] and quota [None] diff --git a/Html/runs/run_20241127-171029_us42j9/.config b/Html/runs/run_20241127-171029_us42j9/.config deleted file mode 100644 index 5771a2e..0000000 --- a/Html/runs/run_20241127-171029_us42j9/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "PTRXVj", - "name": "us42j9", - "run_id": "run_20241127-171029_us42j9", - "timestamp": "2024-11-27 17:10:29", - "pid": 18753 -} \ No newline at end of file diff --git a/Html/runs/run_20241127-171029_us42j9/agentscope.db b/Html/runs/run_20241127-171029_us42j9/agentscope.db deleted file mode 100644 index 2e84691..0000000 Binary files a/Html/runs/run_20241127-171029_us42j9/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241127-171029_us42j9/code/app.py b/Html/runs/run_20241127-171029_us42j9/code/app.py deleted file mode 100644 index 8837b11..0000000 --- a/Html/runs/run_20241127-171029_us42j9/code/app.py +++ /dev/null @@ -1,219 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager, Backboard - -backboard_manager = BackBoardManager() -uuid2user_id = {} -user_id2uuid = {} - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - - -def realtime_response(config, realtime_action): - user_id = config['user_id'] - folder_path = config['path'] - useruuid = user_id2uuid[user_id] - if backboard_manager.get_backboard(useruuid) == None: - backboard_manager.add_backboard(useruuid, folder_path) - bb = backboard_manager.get_backboard(useruuid) - assert type(bb) == Backboard - - bb.add_history(realtime_action) - - if realtime_action['type'] == 'workspaceFolders': - bb.file_tree = realtime_action['fileTree'] - - if realtime_action['type'] == 'activeFile': - file_path = realtime_action['filePath'] - assert type(file_path) == str - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.active_file_path = file_path - with open(f"../{user_id}/{folder_path}/{file_path}") as f: - bb.active_file_content = f.read() - - if realtime_action['type'] == 'paste': - file_path = realtime_action['filePath'] - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.pasted_file_path = file_path - bb.pasted_content = realtime_action['content'] - - - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_id = user_id2uuid[user] - session['user_id'] = user_id - print(f'User connected with session user_id: {user_id}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - print('-----------------------') - print(user_id) - user_id, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_id) - join_room(user_id) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - print(id) - # 构造回复消息 - res = agent_manager.invoke(id, data, backboard_manager.get_backboard(id).get_info_prompt()) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - user_id2uuid[user_id] = session['user_id'] - uuid2user_id[session['user_id']] = user_id - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241127-171029_us42j9/code/backboardManager.py b/Html/runs/run_20241127-171029_us42j9/code/backboardManager.py deleted file mode 100644 index cca6703..0000000 --- a/Html/runs/run_20241127-171029_us42j9/code/backboardManager.py +++ /dev/null @@ -1,72 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - self.history = [] - self.file_tree = "[]" - self.active_file_path = "" - self.active_file_content = "" - self.pasted_file_path = "" - self.pasted_content = "" - - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - - five_history = "" - for h in self.history[-5:]: - five_history += h['type'] + "\n" + h.get('filePath', '') + "\n\n" - return (f"###Global Info:###" - f"- User is {self.user_id}" - f"- User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}" - f"- User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}" - f"- Activated file path: {self.active_file_path}" - f"- Activated file content (current editing 10 lines): " - f"```" - f"{self.active_file_content[-10:]}" - f"```" - f"- Last five action:{five_history}" - f"- File tree: {self.file_tree}") - def add_history(self, realtime_action): - if(realtime_action['type']=='config'):return - if len(self.history)!=0: - if (self.history[-1]['type']=='edit'): - if(self.history[-1]['filepath'] == realtime_action['filepath']): - self.history[-1]['content'] = realtime_action['content'] - return - self.history.append(realtime_action) - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241127-171029_us42j9/logging.chat b/Html/runs/run_20241127-171029_us42j9/logging.chat deleted file mode 100644 index e69de29..0000000 diff --git a/Html/runs/run_20241127-171029_us42j9/logging.log b/Html/runs/run_20241127-171029_us42j9/logging.log deleted file mode 100644 index b5a736f..0000000 --- a/Html/runs/run_20241127-171029_us42j9/logging.log +++ /dev/null @@ -1,9 +0,0 @@ -2024-11-27 17:10:35.796 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg -2024-11-27 17:10:44.753 | INFO | agentscope.models.model:__init__:201 - Initialize model by configuration [openai_cfg] -2024-11-27 17:10:44.770 | WARNING | agentscope.models.openai_model:__init__:83 - fail to get max_length for gpt-4o-mini: 'Model [gpt-4o-mini] not found in OPENAI_MAX_LENGTH. The last updated date is 20231212' -2024-11-27 17:10:44.771 | INFO | agentscope.utils.monitor:register_budget:609 - set budget None to gpt-4o-mini -2024-11-27 17:10:44.771 | WARNING | agentscope.utils.monitor:register_budget:639 - Calculate budgets for model [gpt-4o-mini] is not supported -2024-11-27 17:10:44.784 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.call_counter] to SqliteMonitor with unit [times] and quota [None] -2024-11-27 17:10:44.807 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.prompt_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-27 17:10:44.827 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.completion_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-27 17:10:44.846 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.total_tokens] to SqliteMonitor with unit [token] and quota [None] diff --git a/Html/runs/run_20241127-171442_js4im6/.config b/Html/runs/run_20241127-171442_js4im6/.config deleted file mode 100644 index 92098af..0000000 --- a/Html/runs/run_20241127-171442_js4im6/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "edBp8O", - "name": "js4im6", - "run_id": "run_20241127-171442_js4im6", - "timestamp": "2024-11-27 17:14:42", - "pid": 20913 -} \ No newline at end of file diff --git a/Html/runs/run_20241127-171442_js4im6/agentscope.db b/Html/runs/run_20241127-171442_js4im6/agentscope.db deleted file mode 100644 index 2e84691..0000000 Binary files a/Html/runs/run_20241127-171442_js4im6/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241127-171442_js4im6/code/app.py b/Html/runs/run_20241127-171442_js4im6/code/app.py deleted file mode 100644 index b892d8a..0000000 --- a/Html/runs/run_20241127-171442_js4im6/code/app.py +++ /dev/null @@ -1,218 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager, Backboard - -backboard_manager = BackBoardManager() -uuid2user_id = {} -user_id2uuid = {} - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - - -def realtime_response(config, realtime_action): - user_id = config['user_id'] - folder_path = config['path'] - useruuid = user_id2uuid[user_id] - if backboard_manager.get_backboard(useruuid) == None: - backboard_manager.add_backboard(useruuid, folder_path) - bb = backboard_manager.get_backboard(useruuid) - assert type(bb) == Backboard - - bb.add_history(realtime_action) - - if realtime_action['type'] == 'workspaceFolders': - bb.file_tree = realtime_action['fileTree'] - - if realtime_action['type'] == 'activeFile': - file_path = realtime_action['filePath'] - assert type(file_path) == str - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.active_file_path = file_path - with open(f"../{user_id}/{folder_path}/{file_path}") as f: - bb.active_file_content = f.read() - - if realtime_action['type'] == 'paste': - file_path = realtime_action['filePath'] - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.pasted_file_path = file_path - bb.pasted_content = realtime_action['content'] - - - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_uuid = user_id2uuid[user] - session['user_id'] = user_uuid - print(f'User connected with session user_id: {user_uuid}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - user_uuid, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_uuid) - join_room(user_uuid) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - print(id) - # 构造回复消息 - res = agent_manager.invoke(id, data, backboard_manager.get_backboard(id).get_info_prompt()) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - print("user "+ user_id + "uuid is"+ session['user_id']) - user_id2uuid[user_id] = session['user_id'] - uuid2user_id[session['user_id']] = user_id - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241127-171442_js4im6/code/backboardManager.py b/Html/runs/run_20241127-171442_js4im6/code/backboardManager.py deleted file mode 100644 index cca6703..0000000 --- a/Html/runs/run_20241127-171442_js4im6/code/backboardManager.py +++ /dev/null @@ -1,72 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - self.history = [] - self.file_tree = "[]" - self.active_file_path = "" - self.active_file_content = "" - self.pasted_file_path = "" - self.pasted_content = "" - - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - - five_history = "" - for h in self.history[-5:]: - five_history += h['type'] + "\n" + h.get('filePath', '') + "\n\n" - return (f"###Global Info:###" - f"- User is {self.user_id}" - f"- User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}" - f"- User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}" - f"- Activated file path: {self.active_file_path}" - f"- Activated file content (current editing 10 lines): " - f"```" - f"{self.active_file_content[-10:]}" - f"```" - f"- Last five action:{five_history}" - f"- File tree: {self.file_tree}") - def add_history(self, realtime_action): - if(realtime_action['type']=='config'):return - if len(self.history)!=0: - if (self.history[-1]['type']=='edit'): - if(self.history[-1]['filepath'] == realtime_action['filepath']): - self.history[-1]['content'] = realtime_action['content'] - return - self.history.append(realtime_action) - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241127-171442_js4im6/logging.chat b/Html/runs/run_20241127-171442_js4im6/logging.chat deleted file mode 100644 index e69de29..0000000 diff --git a/Html/runs/run_20241127-171442_js4im6/logging.log b/Html/runs/run_20241127-171442_js4im6/logging.log deleted file mode 100644 index bb18099..0000000 --- a/Html/runs/run_20241127-171442_js4im6/logging.log +++ /dev/null @@ -1,9 +0,0 @@ -2024-11-27 17:14:47.550 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg -2024-11-27 17:14:50.052 | INFO | agentscope.models.model:__init__:201 - Initialize model by configuration [openai_cfg] -2024-11-27 17:14:50.067 | WARNING | agentscope.models.openai_model:__init__:83 - fail to get max_length for gpt-4o-mini: 'Model [gpt-4o-mini] not found in OPENAI_MAX_LENGTH. The last updated date is 20231212' -2024-11-27 17:14:50.067 | INFO | agentscope.utils.monitor:register_budget:609 - set budget None to gpt-4o-mini -2024-11-27 17:14:50.067 | WARNING | agentscope.utils.monitor:register_budget:639 - Calculate budgets for model [gpt-4o-mini] is not supported -2024-11-27 17:14:50.080 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.call_counter] to SqliteMonitor with unit [times] and quota [None] -2024-11-27 17:14:50.100 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.prompt_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-27 17:14:50.119 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.completion_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-27 17:14:50.140 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.total_tokens] to SqliteMonitor with unit [token] and quota [None] diff --git a/Html/runs/run_20241127-172320_f1kjx7/.config b/Html/runs/run_20241127-172320_f1kjx7/.config deleted file mode 100644 index c457649..0000000 --- a/Html/runs/run_20241127-172320_f1kjx7/.config +++ /dev/null @@ -1,7 +0,0 @@ -{ - "project": "IcQ7K6", - "name": "f1kjx7", - "run_id": "run_20241127-172320_f1kjx7", - "timestamp": "2024-11-27 17:23:20", - "pid": 24932 -} \ No newline at end of file diff --git a/Html/runs/run_20241127-172320_f1kjx7/agentscope.db b/Html/runs/run_20241127-172320_f1kjx7/agentscope.db deleted file mode 100644 index 2e84691..0000000 Binary files a/Html/runs/run_20241127-172320_f1kjx7/agentscope.db and /dev/null differ diff --git a/Html/runs/run_20241127-172320_f1kjx7/code/app.py b/Html/runs/run_20241127-172320_f1kjx7/code/app.py deleted file mode 100644 index b892d8a..0000000 --- a/Html/runs/run_20241127-172320_f1kjx7/code/app.py +++ /dev/null @@ -1,218 +0,0 @@ -from flask import Flask, session, request, jsonify, render_template, send_from_directory -from flask_cors import CORS -from flask_socketio import SocketIO, join_room, emit -import markdown -import os -import uuid -import shutil -import sys -import json -parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.insert(0, parent_dir) -current_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '.')) -sys.path.insert(0, current_dir) -from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager - -app = Flask(__name__) - -app.secret_key = 'cakebaker' -# 配置 CORS -CORS(app, resources={r"/*": {"origins": "http://localhost:9888"}}, supports_credentials=True) - -userid_recorder = {} # user_id&path -> session['user_id'] - -''' -Backboard -''' -from backboardManager import BackBoardManager, Backboard - -backboard_manager = BackBoardManager() -uuid2user_id = {} -user_id2uuid = {} - -@app.route('/backboard') -def backboard(): - - return jsonify({'status': 'success'}) - - -def realtime_response(config, realtime_action): - user_id = config['user_id'] - folder_path = config['path'] - useruuid = user_id2uuid[user_id] - if backboard_manager.get_backboard(useruuid) == None: - backboard_manager.add_backboard(useruuid, folder_path) - bb = backboard_manager.get_backboard(useruuid) - assert type(bb) == Backboard - - bb.add_history(realtime_action) - - if realtime_action['type'] == 'workspaceFolders': - bb.file_tree = realtime_action['fileTree'] - - if realtime_action['type'] == 'activeFile': - file_path = realtime_action['filePath'] - assert type(file_path) == str - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.active_file_path = file_path - with open(f"../{user_id}/{folder_path}/{file_path}") as f: - bb.active_file_content = f.read() - - if realtime_action['type'] == 'paste': - file_path = realtime_action['filePath'] - file_path = "".join(file_path.split(f'/{user_id}/{folder_path}/')[1:]) - bb.pasted_file_path = file_path - bb.pasted_content = realtime_action['content'] - - - print("config"+str(config)) - print("realtime_action"+str(realtime_action)) - pass - - -''' -Agent and Chat -''' - -socketio = SocketIO(app, cors_allowed_origins="*") - -agent_manager = AgentManager() - -@socketio.on('connect') -def handle_connect(): - user = request.args.get('username') - folder_name = request.args.get('folder') - user_uuid = user_id2uuid[user] - session['user_id'] = user_uuid - print(f'User connected with session user_id: {user_uuid}') - # 从markdown、markdown_prompts、score_prompts中各读取数据folder.md并进行new_agent - with open(f'books/markdown/{folder_name}.md','r') as fmd,\ - open(f'books/markdown_prompts/{folder_name}.md','r')as fmdp,\ - open(f'books/score_prompts/{folder_name}.md','r') as fsp: - markdown = fmd.read() - markdown_prompts = fmdp.read() - score_prompts = fsp.read() - user_uuid, agent = agent_manager.new_agent(markdown, markdown_prompts, score_prompts, id=user_uuid) - join_room(user_uuid) # 将该用户加入以user_id为名的room - - -# 当接收到前端的消息时,触发此事件 -@socketio.on('send_message') -def handle_message(data): - print(f"Message from client: {data}") - id = session.get('user_id') - print(id) - # 构造回复消息 - res = agent_manager.invoke(id, data, backboard_manager.get_backboard(id).get_info_prompt()) - reply = f"AI: {res.content['speak']}" - # 将回复发送回前端 - emit('receive_message', reply) - - -''' -Markdown to HTML -''' -# 配置文件路径 -MARKDOWN_DIR = 'books/markdown' # 存放 markdown 文件的文件夹 -STATIC_DIR = 'static' # 存放生成的 HTML 和图片资源的文件夹 -IMAGE_DIR = 'image' # 图片资源相对于 markdown 的位置 - - - -@app.route('/-markdown', methods=['GET']) -def convert_md(filename): - md_file_path = os.path.join(MARKDOWN_DIR, f'{filename}.md') - - if not os.path.exists(md_file_path): - return jsonify({'error': 'Markdown file not found'}), 404 - - # 读取 markdown 文件内容 - with open(md_file_path, 'r', encoding='utf-8') as file: - md_content = file.read() - - # 将 markdown 转换为 HTML - html_content = markdown.markdown(md_content) - # 插入 CSS 样式,限制图片最大宽度为 100%,高度自动调整 - html_with_styles = f""" - - - - - - - {html_content} - - - """ - # 保存 HTML 文件到 static 文件夹 - html_output_path = os.path.join(STATIC_DIR, f'{filename}.html') - with open(html_output_path, 'w', encoding='utf-8') as html_file: - html_file.write(html_with_styles) - - # 处理图片资源,将 image/xxx 文件夹拷贝到 static/image/xxx - image_source_dir = os.path.join(MARKDOWN_DIR, IMAGE_DIR, filename) - image_target_dir = os.path.join(STATIC_DIR, IMAGE_DIR, filename) - print(f"Copying image resources from {image_source_dir} to {image_target_dir}") - if os.path.exists(image_source_dir): - # 确保 static/image/xxx 目录存在 - if not os.path.exists(image_target_dir): - os.makedirs(image_target_dir) - - # 拷贝图片资源 - for image_file in os.listdir(image_source_dir): - full_image_file_path = os.path.join(image_source_dir, image_file) - if os.path.isfile(full_image_file_path): - shutil.copy(full_image_file_path, image_target_dir) - - return jsonify({'html_url': f'/static/{filename}.html'}) - -# 静态文件(HTML 和图片资源)的访问 -@app.route('/static/') -def serve_static(filename): - return send_from_directory(STATIC_DIR, filename) - - -''' -Vscode -''' -@app.route('/desktop//') -def hello_world(user_id, path): - if 'user_id' not in session: - session['user_id'] = 'user_' + str(uuid.uuid4()) - print("user "+ user_id + "uuid is"+ session['user_id']) - user_id2uuid[user_id] = session['user_id'] - uuid2user_id[session['user_id']] = user_id - userid_recorder[user_id+'&'+path] = session['user_id'] - - # 在上层 目录下创建一个名为 user_id_path 的文件夹 - path_dir = os.path.join(parent_dir, user_id, path) - os.makedirs(path_dir, exist_ok=True) - # 在此文件夹内部创建一个.config文件,并写入 user_id=user_id\n path=path - config_path = os.path.join(path_dir, '.config') - with open(config_path, 'w') as f: - f.write(f"user_id={user_id}\npath={path}") - return render_template('index.html', user_id=user_id, path=path) - - -@app.route('/vscode_data', methods=['POST']) -def vscode_data(): - data = request.json - config = data['config'] - realtime_response(config,data) - print(f"Received data from VSCode: {data}") - return jsonify({"status": "success", "received": data}) - -@app.route('/get_session') -def get_session(): - user_session = session.get('user_id', 'default_session') - return jsonify({"session": user_session}) - -if __name__ == '__main__': - - socketio.run(app, host='0.0.0.0', port=5500) - diff --git a/Html/runs/run_20241127-172320_f1kjx7/code/backboardManager.py b/Html/runs/run_20241127-172320_f1kjx7/code/backboardManager.py deleted file mode 100644 index cca6703..0000000 --- a/Html/runs/run_20241127-172320_f1kjx7/code/backboardManager.py +++ /dev/null @@ -1,72 +0,0 @@ - - - -import time - - -class BackBoardManager: - def __init__(self): - self.backboards = {} # user_id: Backboard - - def add_backboard(self, user_id, folder): - self.backboards[user_id] = Backboard(user_id, folder) - - def get_backboard(self, user_id): - if user_id not in self.backboards: - return None - return self.backboards[user_id] - - - - -class Backboard: - def __init__(self, user_id, folder): - self.user_id = user_id - self.folder = folder - self.create_time = time.time() - self.enter_chapter_time = time.time() - self.history = [] - self.file_tree = "[]" - self.active_file_path = "" - self.active_file_content = "" - self.pasted_file_path = "" - self.pasted_content = "" - - - def next_chapter(self): - self.enter_chapter_time = time.time() - - def get_info_prompt(self): - - five_history = "" - for h in self.history[-5:]: - five_history += h['type'] + "\n" + h.get('filePath', '') + "\n\n" - return (f"###Global Info:###" - f"- User is {self.user_id}" - f"- User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}" - f"- User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}" - f"- Activated file path: {self.active_file_path}" - f"- Activated file content (current editing 10 lines): " - f"```" - f"{self.active_file_content[-10:]}" - f"```" - f"- Last five action:{five_history}" - f"- File tree: {self.file_tree}") - def add_history(self, realtime_action): - if(realtime_action['type']=='config'):return - if len(self.history)!=0: - if (self.history[-1]['type']=='edit'): - if(self.history[-1]['filepath'] == realtime_action['filepath']): - self.history[-1]['content'] = realtime_action['content'] - return - self.history.append(realtime_action) - - - def get_deltatime_mmss(self, start_time, end_time): - elapsed_time = end_time - start_time - hours = int(elapsed_time // 3600) - minutes = int((elapsed_time % 3600) // 60) - seconds = int(elapsed_time % 60) - return f"{hours:02d}:{minutes:02d}:{seconds:02d}" - - diff --git a/Html/runs/run_20241127-172320_f1kjx7/logging.chat b/Html/runs/run_20241127-172320_f1kjx7/logging.chat deleted file mode 100644 index 6f24b09..0000000 --- a/Html/runs/run_20241127-172320_f1kjx7/logging.chat +++ /dev/null @@ -1,50 +0,0 @@ -{"id": "a8d08d6025134a33922494a3a15f69d1", "timestamp": "2024-11-27 17:24:03", "name": "assistant", "content": "##################### ITER 1, STEP 1: REASONING ######################", "role": "assistant", "url": null, "metadata": null} -{"id": "af5cc2d30ed14f289457c053956c992f", "timestamp": "2024-11-27 17:24:03", "name": "system", "content": "###Global Info:###- User is user_e6e87b0c-efed-4293-82f9-1454b14d6617- User's total study time is 00:00:19- User's current chapter study time is 00:00:19- Activated file path: - Activated file content (current editing 10 lines): ``````- Last five action:workspaceFolders\n\n\n- File tree: [{'name': '.config', 'type': 'file'}, {'name': 'binarySearch.py', 'type': 'file'}]", "role": "system", "url": null, "metadata": null} -{"id": "c9315e23ae064e76974ec548c0f24ff8", "timestamp": "2024-11-27 17:24:03", "name": "system", "content": "## Tool Functions:\nThe following tool functions are available in the format of\n```\n{index}. {function name}: {function description}\n{argument1 name} ({argument type}): {argument description}\n{argument2 name} ({argument type}): {argument description}\n...\n```\n\n1. record: Call it to save some important info for other chapters. Like file path, function call example.\n\tcontent (string): The content to be recorded.\n2. next_chapter: Call it to go to next chapter.\n", "role": "system", "url": null, "metadata": null} -{"id": "b6cc369f166c49dc93804f626dd4fb29", "timestamp": "2024-11-27 17:24:03", "name": "system", "content": "Respond a JSON dictionary in a markdown's fenced code block as follows:\n```json\n{\"thought\": \"what you thought\", \"speak\": \"what you speak\", \"function\": \"[{\\\"name\\\": \\\"{function name}\\\", \\\"arguments\\\": {\\\"{argument1 name}\\\": xxx, \\\"{argument2 name}\\\": xxx}}]\"}\n```\n ####", "role": "system", "url": null, "metadata": null} -{"id": "2dd05252f2bd4f95ba0e7d85a3f17680", "timestamp": "2024-11-27 17:24:03", "name": "assistant", "content": "################################Prompt################################", "role": "assistant", "url": null, "metadata": null} -{"id": "54f80bcbeced442aaa406d2c4a461f3e", "timestamp": "2024-11-27 17:24:03", "name": "assistant", "content": "hi", "role": "assistant", "url": null, "metadata": null} -{"id": "c17554caf10b45ccab910dbabfd5d702", "timestamp": "2024-11-27 17:24:07", "name": "assistant", "content": "############################Result Parsed#############################", "role": "assistant", "url": null, "metadata": null} -{"id": "cf7ca4dbc45349beaf6857627eb47c6d", "timestamp": "2024-11-27 17:24:07", "name": "assistant", "content": "{'thought': 'The student should try to calculate the number of guesses needed for the range 1 to 4000 using binary search principles.', 'speak': '可以试着计算一下,从1到4000这个区间最坏情况下需要猜测几次?', 'function': '[]'}", "role": "assistant", "url": null, "metadata": null} -{"id": "860a8208a28d42e38503eda8578886b0", "timestamp": "2024-11-27 17:24:07", "name": "assistant", "content": "################################Speak#################################", "role": "assistant", "url": null, "metadata": null} -{"id": "781eb45da5c346528377248e83c593c2", "timestamp": "2024-11-27 17:24:07", "name": "assistant", "content": {"thought": "The student should try to calculate the number of guesses needed for the range 1 to 4000 using binary search principles.", "speak": "可以试着计算一下,从1到4000这个区间最坏情况下需要猜测几次?", "function": "[]"}, "role": "assistant", "url": null, "metadata": null} -{"id": "f54373937bb248a99ce02ec9601071ab", "timestamp": "2024-11-27 17:24:54", "name": "assistant", "content": "##################### ITER 1, STEP 1: REASONING ######################", "role": "assistant", "url": null, "metadata": null} -{"id": "051edcab6197405d9dcb701554b95d6e", "timestamp": "2024-11-27 17:24:54", "name": "system", "content": "###Global Info:###- User is user_e6e87b0c-efed-4293-82f9-1454b14d6617- User's total study time is 00:01:09- User's current chapter study time is 00:01:09- Activated file path: - Activated file content (current editing 10 lines): ``````- Last five action:workspaceFolders\n\n\n- File tree: [{'name': '.config', 'type': 'file'}, {'name': 'binarySearch.py', 'type': 'file'}]", "role": "system", "url": null, "metadata": null} -{"id": "44f2a4fe5e7c4cfbbc4675b3dfdbf182", "timestamp": "2024-11-27 17:24:54", "name": "system", "content": "## Tool Functions:\nThe following tool functions are available in the format of\n```\n{index}. {function name}: {function description}\n{argument1 name} ({argument type}): {argument description}\n{argument2 name} ({argument type}): {argument description}\n...\n```\n\n1. record: Call it to save some important info for other chapters. Like file path, function call example.\n\tcontent (string): The content to be recorded.\n2. next_chapter: Call it to go to next chapter.\n", "role": "system", "url": null, "metadata": null} -{"id": "8a738d0c424f4f26847cbe501a323c59", "timestamp": "2024-11-27 17:24:54", "name": "system", "content": "Respond a JSON dictionary in a markdown's fenced code block as follows:\n```json\n{\"thought\": \"what you thought\", \"speak\": \"what you speak\", \"function\": \"[{\\\"name\\\": \\\"{function name}\\\", \\\"arguments\\\": {\\\"{argument1 name}\\\": xxx, \\\"{argument2 name}\\\": xxx}}]\"}\n```\n ####", "role": "system", "url": null, "metadata": null} -{"id": "262801b749a44699ae2bfe7bb7c19e9b", "timestamp": "2024-11-27 17:24:54", "name": "assistant", "content": "################################Prompt################################", "role": "assistant", "url": null, "metadata": null} -{"id": "96b294333637438384d59585a1508874", "timestamp": "2024-11-27 17:24:54", "name": "assistant", "content": "我觉得应该是13次\n", "role": "assistant", "url": null, "metadata": null} -{"id": "9bb6aa4088254365b8abe8a9cc91e27b", "timestamp": "2024-11-27 17:24:57", "name": "assistant", "content": "############################Result Parsed#############################", "role": "assistant", "url": null, "metadata": null} -{"id": "79d20e9269294802bf9e62e148dc48b3", "timestamp": "2024-11-27 17:24:57", "name": "assistant", "content": "{'thought': \"The student's answer seems close, but let's verify if 13 guesses align with the binary search principle applied to the range 1 to 4000.\", 'speak': '实际上,我们可以用公式来确认一下:在二分查找中,最坏情况下所需的猜测次数可以通过 log2(N) 来计算。你可以尝试计算一下 log2(4000) 的值,看看结果。', 'function': '[]'}", "role": "assistant", "url": null, "metadata": null} -{"id": "7d7cc7f0a5e04b54a83d456828f0affd", "timestamp": "2024-11-27 17:24:57", "name": "assistant", "content": "################################Speak#################################", "role": "assistant", "url": null, "metadata": null} -{"id": "2d574fd3ce9a4aaa87d11fdc476086fc", "timestamp": "2024-11-27 17:24:57", "name": "assistant", "content": {"thought": "The student's answer seems close, but let's verify if 13 guesses align with the binary search principle applied to the range 1 to 4000.", "speak": "实际上,我们可以用公式来确认一下:在二分查找中,最坏情况下所需的猜测次数可以通过 log2(N) 来计算。你可以尝试计算一下 log2(4000) 的值,看看结果。", "function": "[]"}, "role": "assistant", "url": null, "metadata": null} -{"id": "8a2bb250dd364dd9a0d96affe1af502a", "timestamp": "2024-11-27 17:25:48", "name": "assistant", "content": "##################### ITER 1, STEP 1: REASONING ######################", "role": "assistant", "url": null, "metadata": null} -{"id": "3ced3f42ebbb484ab7a4594a818dc10e", "timestamp": "2024-11-27 17:25:48", "name": "system", "content": "###Global Info:###- User is user_e6e87b0c-efed-4293-82f9-1454b14d6617- User's total study time is 00:02:04- User's current chapter study time is 00:02:04- Activated file path: - Activated file content (current editing 10 lines): ``````- Last five action:workspaceFolders\n\n\n- File tree: [{'name': '.config', 'type': 'file'}, {'name': 'binarySearch.py', 'type': 'file'}]", "role": "system", "url": null, "metadata": null} -{"id": "fb5060e3f13e448bb8b299f18b9f7c1d", "timestamp": "2024-11-27 17:25:48", "name": "system", "content": "## Tool Functions:\nThe following tool functions are available in the format of\n```\n{index}. {function name}: {function description}\n{argument1 name} ({argument type}): {argument description}\n{argument2 name} ({argument type}): {argument description}\n...\n```\n\n1. record: Call it to save some important info for other chapters. Like file path, function call example.\n\tcontent (string): The content to be recorded.\n2. next_chapter: Call it to go to next chapter.\n", "role": "system", "url": null, "metadata": null} -{"id": "e8c2bcf48c1b4404a29cb45fd46d3963", "timestamp": "2024-11-27 17:25:48", "name": "system", "content": "Respond a JSON dictionary in a markdown's fenced code block as follows:\n```json\n{\"thought\": \"what you thought\", \"speak\": \"what you speak\", \"function\": \"[{\\\"name\\\": \\\"{function name}\\\", \\\"arguments\\\": {\\\"{argument1 name}\\\": xxx, \\\"{argument2 name}\\\": xxx}}]\"}\n```\n ####", "role": "system", "url": null, "metadata": null} -{"id": "e592258c523f47d6987611d26a5a8255", "timestamp": "2024-11-27 17:25:48", "name": "assistant", "content": "################################Prompt################################", "role": "assistant", "url": null, "metadata": null} -{"id": "1839d640d43541008227db69f8d8a70b", "timestamp": "2024-11-27 17:25:48", "name": "assistant", "content": "log2(4000)结果是12,确实 这12次意味着将答案备选区缩小到只有1个,再猜一次才能得到最后答案,因此是13!", "role": "assistant", "url": null, "metadata": null} -{"id": "8da158b6f7b44601bb1263efe50e73bc", "timestamp": "2024-11-27 17:25:53", "name": "assistant", "content": "############################Result Parsed#############################", "role": "assistant", "url": null, "metadata": null} -{"id": "44ecc1939f3248609874a1c5d86bd72d", "timestamp": "2024-11-27 17:25:53", "name": "assistant", "content": "{'thought': 'The student has correctly understood the binary search concept and the calculation of guesses needed. They are ready to move to the next chapter.', 'speak': '你说得对,确实是13次。很棒!现在你准备好继续学习下一个章节了吗?', 'function': '[{\"name\": \"next_chapter\", \"arguments\": {}}]'}", "role": "assistant", "url": null, "metadata": null} -{"id": "8fcaf6bf63574025af87c9897c973fd3", "timestamp": "2024-11-27 17:25:53", "name": "assistant", "content": "################################Speak#################################", "role": "assistant", "url": null, "metadata": null} -{"id": "91c24aeb15554e3893c3b3ab0537fdcc", "timestamp": "2024-11-27 17:25:53", "name": "assistant", "content": {"thought": "The student has correctly understood the binary search concept and the calculation of guesses needed. They are ready to move to the next chapter.", "speak": "你说得对,确实是13次。很棒!现在你准备好继续学习下一个章节了吗?", "function": "[{\"name\": \"next_chapter\", \"arguments\": {}}]"}, "role": "assistant", "url": null, "metadata": null} -{"id": "ce0a3f5460b341999cda364d2345f1b8", "timestamp": "2024-11-27 17:26:14", "name": "assistant", "content": "##################### ITER 1, STEP 1: REASONING ######################", "role": "assistant", "url": null, "metadata": null} -{"id": "d6074e31413a4e15bd060f1a087c214e", "timestamp": "2024-11-27 17:26:14", "name": "system", "content": "###Global Info:###- User is user_e6e87b0c-efed-4293-82f9-1454b14d6617- User's total study time is 00:02:30- User's current chapter study time is 00:02:30- Activated file path: - Activated file content (current editing 10 lines): ``````- Last five action:workspaceFolders\n\n\n- File tree: [{'name': '.config', 'type': 'file'}, {'name': 'binarySearch.py', 'type': 'file'}]", "role": "system", "url": null, "metadata": null} -{"id": "323c5480e3f74e4ba41e57c2b6af1a53", "timestamp": "2024-11-27 17:26:14", "name": "system", "content": "## Tool Functions:\nThe following tool functions are available in the format of\n```\n{index}. {function name}: {function description}\n{argument1 name} ({argument type}): {argument description}\n{argument2 name} ({argument type}): {argument description}\n...\n```\n\n1. record: Call it to save some important info for other chapters. Like file path, function call example.\n\tcontent (string): The content to be recorded.\n2. next_chapter: Call it to go to next chapter.\n", "role": "system", "url": null, "metadata": null} -{"id": "c95ba7061e3e4bc2b7c13bbca4f9267a", "timestamp": "2024-11-27 17:26:14", "name": "system", "content": "Respond a JSON dictionary in a markdown's fenced code block as follows:\n```json\n{\"thought\": \"what you thought\", \"speak\": \"what you speak\", \"function\": \"[{\\\"name\\\": \\\"{function name}\\\", \\\"arguments\\\": {\\\"{argument1 name}\\\": xxx, \\\"{argument2 name}\\\": xxx}}]\"}\n```\n ####", "role": "system", "url": null, "metadata": null} -{"id": "37bbae3ffc214da2b9e06b432f714d00", "timestamp": "2024-11-27 17:26:14", "name": "assistant", "content": "################################Prompt################################", "role": "assistant", "url": null, "metadata": null} -{"id": "186f14170bf349c8a886dacd8470db34", "timestamp": "2024-11-27 17:26:14", "name": "assistant", "content": "是的!进入下一章!", "role": "assistant", "url": null, "metadata": null} -{"id": "e3877dd6911d4f12a97e01e896c4f100", "timestamp": "2024-11-27 17:26:17", "name": "assistant", "content": "############################Result Parsed#############################", "role": "assistant", "url": null, "metadata": null} -{"id": "81e65f2e91724fcdaa348076234cc744", "timestamp": "2024-11-27 17:26:17", "name": "assistant", "content": "{'thought': 'The student is ready to move to the next chapter, which focuses on implementing binary search.', 'speak': '好的,我们进入下一章!在这一章中,我们将尝试实现二分查找的代码。', 'function': '[{\"name\": \"next_chapter\", \"arguments\": {}}]'}", "role": "assistant", "url": null, "metadata": null} -{"id": "77301e3961814bb7a0b0ba2561ff227b", "timestamp": "2024-11-27 17:26:17", "name": "assistant", "content": "################################Speak#################################", "role": "assistant", "url": null, "metadata": null} -{"id": "b655fe870fa84099ada2caf77234dcfc", "timestamp": "2024-11-27 17:26:17", "name": "assistant", "content": {"thought": "The student is ready to move to the next chapter, which focuses on implementing binary search.", "speak": "好的,我们进入下一章!在这一章中,我们将尝试实现二分查找的代码。", "function": "[{\"name\": \"next_chapter\", \"arguments\": {}}]"}, "role": "assistant", "url": null, "metadata": null} -{"id": "30bf214c3a6b4454abafa9039b032940", "timestamp": "2024-11-27 17:26:48", "name": "assistant", "content": "##################### ITER 1, STEP 1: REASONING ######################", "role": "assistant", "url": null, "metadata": null} -{"id": "eb7b773dc8b242a38a45b4987f79da78", "timestamp": "2024-11-27 17:26:48", "name": "system", "content": "###Global Info:###- User is user_e6e87b0c-efed-4293-82f9-1454b14d6617- User's total study time is 00:03:04- User's current chapter study time is 00:03:04- Activated file path: - Activated file content (current editing 10 lines): ``````- Last five action:workspaceFolders\n\n\npaste\n/mnt/c/CAKE/vscode/cake/binary_search/binarySearch.py\n\nedit\n\n\n- File tree: [{'name': '.config', 'type': 'file'}, {'name': 'binarySearch.py', 'type': 'file'}]", "role": "system", "url": null, "metadata": null} -{"id": "29e1de0687264405997a16c425c2738d", "timestamp": "2024-11-27 17:26:48", "name": "system", "content": "## Tool Functions:\nThe following tool functions are available in the format of\n```\n{index}. {function name}: {function description}\n{argument1 name} ({argument type}): {argument description}\n{argument2 name} ({argument type}): {argument description}\n...\n```\n\n1. record: Call it to save some important info for other chapters. Like file path, function call example.\n\tcontent (string): The content to be recorded.\n2. next_chapter: Call it to go to next chapter.\n", "role": "system", "url": null, "metadata": null} -{"id": "bb48da0e78e242948fd4c1d89ae99ad6", "timestamp": "2024-11-27 17:26:48", "name": "system", "content": "Respond a JSON dictionary in a markdown's fenced code block as follows:\n```json\n{\"thought\": \"what you thought\", \"speak\": \"what you speak\", \"function\": \"[{\\\"name\\\": \\\"{function name}\\\", \\\"arguments\\\": {\\\"{argument1 name}\\\": xxx, \\\"{argument2 name}\\\": xxx}}]\"}\n```\n ####", "role": "system", "url": null, "metadata": null} -{"id": "935ab227030c4cc8afdebd1e3714fb85", "timestamp": "2024-11-27 17:26:48", "name": "assistant", "content": "################################Prompt################################", "role": "assistant", "url": null, "metadata": null} -{"id": "b2ec38839ed04e3bbd964d03ab63d083", "timestamp": "2024-11-27 17:26:48", "name": "assistant", "content": "我已经写了一些代码了,下面该怎么写呢?", "role": "assistant", "url": null, "metadata": null} -{"id": "214494925be74f5a8feef2dd2a4d902d", "timestamp": "2024-11-27 17:26:53", "name": "assistant", "content": "############################Result Parsed#############################", "role": "assistant", "url": null, "metadata": null} -{"id": "ef02f135e174439aaf091f563c99bc11", "timestamp": "2024-11-27 17:26:53", "name": "assistant", "content": "{'thought': 'The student is in the code implementation phase for binary search and needs guidance on how to proceed with their code.', 'speak': '好的,我们来完成二分查找的代码!首先,请确保你有一个有序数组,然后编写一个函数来实现二分查找。你可以定义函数的输入为数组和要查找的目标值。展示一下你写的代码内容,我们可以一起做进一步的修改。', 'function': '[]'}", "role": "assistant", "url": null, "metadata": null} -{"id": "4d6fb90990d74a4b9d0b50ec7050a4f1", "timestamp": "2024-11-27 17:26:53", "name": "assistant", "content": "################################Speak#################################", "role": "assistant", "url": null, "metadata": null} -{"id": "4cfd04e1adc641ae94a945908b682a34", "timestamp": "2024-11-27 17:26:53", "name": "assistant", "content": {"thought": "The student is in the code implementation phase for binary search and needs guidance on how to proceed with their code.", "speak": "好的,我们来完成二分查找的代码!首先,请确保你有一个有序数组,然后编写一个函数来实现二分查找。你可以定义函数的输入为数组和要查找的目标值。展示一下你写的代码内容,我们可以一起做进一步的修改。", "function": "[]"}, "role": "assistant", "url": null, "metadata": null} diff --git a/Html/runs/run_20241127-172320_f1kjx7/logging.log b/Html/runs/run_20241127-172320_f1kjx7/logging.log deleted file mode 100644 index 0648642..0000000 --- a/Html/runs/run_20241127-172320_f1kjx7/logging.log +++ /dev/null @@ -1,161 +0,0 @@ -2024-11-27 17:23:26.905 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: openai_cfg -2024-11-27 17:23:33.245 | INFO | agentscope.models.model:__init__:201 - Initialize model by configuration [openai_cfg] -2024-11-27 17:23:33.260 | WARNING | agentscope.models.openai_model:__init__:83 - fail to get max_length for gpt-4o-mini: 'Model [gpt-4o-mini] not found in OPENAI_MAX_LENGTH. The last updated date is 20231212' -2024-11-27 17:23:33.261 | INFO | agentscope.utils.monitor:register_budget:609 - set budget None to gpt-4o-mini -2024-11-27 17:23:33.262 | WARNING | agentscope.utils.monitor:register_budget:639 - Calculate budgets for model [gpt-4o-mini] is not supported -2024-11-27 17:23:33.276 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.call_counter] to SqliteMonitor with unit [times] and quota [None] -2024-11-27 17:23:33.299 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.prompt_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-27 17:23:33.320 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.completion_tokens] to SqliteMonitor with unit [token] and quota [None] -2024-11-27 17:23:33.343 | INFO | agentscope.utils.monitor:register:417 - Register metric [gpt-4o-mini.total_tokens] to SqliteMonitor with unit [token] and quota [None] -assistant: ##################### ITER 1, STEP 1: REASONING ###################### -system: ###Global Info:###- User is user_e6e87b0c-efed-4293-82f9-1454b14d6617- User's total study time is 00:00:19- User's current chapter study time is 00:00:19- Activated file path: - Activated file content (current editing 10 lines): ``````- Last five action:workspaceFolders - - -- File tree: [{'name': '.config', 'type': 'file'}, {'name': 'binarySearch.py', 'type': 'file'}] -system: ## Tool Functions: -The following tool functions are available in the format of -``` -{index}. {function name}: {function description} -{argument1 name} ({argument type}): {argument description} -{argument2 name} ({argument type}): {argument description} -... -``` - -1. record: Call it to save some important info for other chapters. Like file path, function call example. - content (string): The content to be recorded. -2. next_chapter: Call it to go to next chapter. - -system: Respond a JSON dictionary in a markdown's fenced code block as follows: -```json -{"thought": "what you thought", "speak": "what you speak", "function": "[{\"name\": \"{function name}\", \"arguments\": {\"{argument1 name}\": xxx, \"{argument2 name}\": xxx}}]"} -``` - #### -assistant: ################################Prompt################################ -assistant: hi -assistant: ############################Result Parsed############################# -assistant: {'thought': 'The student should try to calculate the number of guesses needed for the range 1 to 4000 using binary search principles.', 'speak': '可以试着计算一下,从1到4000这个区间最坏情况下需要猜测几次?', 'function': '[]'} -assistant: ################################Speak################################# -assistant: {'thought': 'The student should try to calculate the number of guesses needed for the range 1 to 4000 using binary search principles.', 'speak': '可以试着计算一下,从1到4000这个区间最坏情况下需要猜测几次?', 'function': '[]'} -assistant: ##################### ITER 1, STEP 1: REASONING ###################### -system: ###Global Info:###- User is user_e6e87b0c-efed-4293-82f9-1454b14d6617- User's total study time is 00:01:09- User's current chapter study time is 00:01:09- Activated file path: - Activated file content (current editing 10 lines): ``````- Last five action:workspaceFolders - - -- File tree: [{'name': '.config', 'type': 'file'}, {'name': 'binarySearch.py', 'type': 'file'}] -system: ## Tool Functions: -The following tool functions are available in the format of -``` -{index}. {function name}: {function description} -{argument1 name} ({argument type}): {argument description} -{argument2 name} ({argument type}): {argument description} -... -``` - -1. record: Call it to save some important info for other chapters. Like file path, function call example. - content (string): The content to be recorded. -2. next_chapter: Call it to go to next chapter. - -system: Respond a JSON dictionary in a markdown's fenced code block as follows: -```json -{"thought": "what you thought", "speak": "what you speak", "function": "[{\"name\": \"{function name}\", \"arguments\": {\"{argument1 name}\": xxx, \"{argument2 name}\": xxx}}]"} -``` - #### -assistant: ################################Prompt################################ -assistant: 我觉得应该是13次 - -assistant: ############################Result Parsed############################# -assistant: {'thought': "The student's answer seems close, but let's verify if 13 guesses align with the binary search principle applied to the range 1 to 4000.", 'speak': '实际上,我们可以用公式来确认一下:在二分查找中,最坏情况下所需的猜测次数可以通过 log2(N) 来计算。你可以尝试计算一下 log2(4000) 的值,看看结果。', 'function': '[]'} -assistant: ################################Speak################################# -assistant: {'thought': "The student's answer seems close, but let's verify if 13 guesses align with the binary search principle applied to the range 1 to 4000.", 'speak': '实际上,我们可以用公式来确认一下:在二分查找中,最坏情况下所需的猜测次数可以通过 log2(N) 来计算。你可以尝试计算一下 log2(4000) 的值,看看结果。', 'function': '[]'} -assistant: ##################### ITER 1, STEP 1: REASONING ###################### -system: ###Global Info:###- User is user_e6e87b0c-efed-4293-82f9-1454b14d6617- User's total study time is 00:02:04- User's current chapter study time is 00:02:04- Activated file path: - Activated file content (current editing 10 lines): ``````- Last five action:workspaceFolders - - -- File tree: [{'name': '.config', 'type': 'file'}, {'name': 'binarySearch.py', 'type': 'file'}] -system: ## Tool Functions: -The following tool functions are available in the format of -``` -{index}. {function name}: {function description} -{argument1 name} ({argument type}): {argument description} -{argument2 name} ({argument type}): {argument description} -... -``` - -1. record: Call it to save some important info for other chapters. Like file path, function call example. - content (string): The content to be recorded. -2. next_chapter: Call it to go to next chapter. - -system: Respond a JSON dictionary in a markdown's fenced code block as follows: -```json -{"thought": "what you thought", "speak": "what you speak", "function": "[{\"name\": \"{function name}\", \"arguments\": {\"{argument1 name}\": xxx, \"{argument2 name}\": xxx}}]"} -``` - #### -assistant: ################################Prompt################################ -assistant: log2(4000)结果是12,确实 这12次意味着将答案备选区缩小到只有1个,再猜一次才能得到最后答案,因此是13! -assistant: ############################Result Parsed############################# -assistant: {'thought': 'The student has correctly understood the binary search concept and the calculation of guesses needed. They are ready to move to the next chapter.', 'speak': '你说得对,确实是13次。很棒!现在你准备好继续学习下一个章节了吗?', 'function': '[{"name": "next_chapter", "arguments": {}}]'} -assistant: ################################Speak################################# -assistant: {'thought': 'The student has correctly understood the binary search concept and the calculation of guesses needed. They are ready to move to the next chapter.', 'speak': '你说得对,确实是13次。很棒!现在你准备好继续学习下一个章节了吗?', 'function': '[{"name": "next_chapter", "arguments": {}}]'} -assistant: ##################### ITER 1, STEP 1: REASONING ###################### -system: ###Global Info:###- User is user_e6e87b0c-efed-4293-82f9-1454b14d6617- User's total study time is 00:02:30- User's current chapter study time is 00:02:30- Activated file path: - Activated file content (current editing 10 lines): ``````- Last five action:workspaceFolders - - -- File tree: [{'name': '.config', 'type': 'file'}, {'name': 'binarySearch.py', 'type': 'file'}] -system: ## Tool Functions: -The following tool functions are available in the format of -``` -{index}. {function name}: {function description} -{argument1 name} ({argument type}): {argument description} -{argument2 name} ({argument type}): {argument description} -... -``` - -1. record: Call it to save some important info for other chapters. Like file path, function call example. - content (string): The content to be recorded. -2. next_chapter: Call it to go to next chapter. - -system: Respond a JSON dictionary in a markdown's fenced code block as follows: -```json -{"thought": "what you thought", "speak": "what you speak", "function": "[{\"name\": \"{function name}\", \"arguments\": {\"{argument1 name}\": xxx, \"{argument2 name}\": xxx}}]"} -``` - #### -assistant: ################################Prompt################################ -assistant: 是的!进入下一章! -assistant: ############################Result Parsed############################# -assistant: {'thought': 'The student is ready to move to the next chapter, which focuses on implementing binary search.', 'speak': '好的,我们进入下一章!在这一章中,我们将尝试实现二分查找的代码。', 'function': '[{"name": "next_chapter", "arguments": {}}]'} -assistant: ################################Speak################################# -assistant: {'thought': 'The student is ready to move to the next chapter, which focuses on implementing binary search.', 'speak': '好的,我们进入下一章!在这一章中,我们将尝试实现二分查找的代码。', 'function': '[{"name": "next_chapter", "arguments": {}}]'} -assistant: ##################### ITER 1, STEP 1: REASONING ###################### -system: ###Global Info:###- User is user_e6e87b0c-efed-4293-82f9-1454b14d6617- User's total study time is 00:03:04- User's current chapter study time is 00:03:04- Activated file path: - Activated file content (current editing 10 lines): ``````- Last five action:workspaceFolders - - -paste -/mnt/c/CAKE/vscode/cake/binary_search/binarySearch.py - -edit - - -- File tree: [{'name': '.config', 'type': 'file'}, {'name': 'binarySearch.py', 'type': 'file'}] -system: ## Tool Functions: -The following tool functions are available in the format of -``` -{index}. {function name}: {function description} -{argument1 name} ({argument type}): {argument description} -{argument2 name} ({argument type}): {argument description} -... -``` - -1. record: Call it to save some important info for other chapters. Like file path, function call example. - content (string): The content to be recorded. -2. next_chapter: Call it to go to next chapter. - -system: Respond a JSON dictionary in a markdown's fenced code block as follows: -```json -{"thought": "what you thought", "speak": "what you speak", "function": "[{\"name\": \"{function name}\", \"arguments\": {\"{argument1 name}\": xxx, \"{argument2 name}\": xxx}}]"} -``` - #### -assistant: ################################Prompt################################ -assistant: 我已经写了一些代码了,下面该怎么写呢? -assistant: ############################Result Parsed############################# -assistant: {'thought': 'The student is in the code implementation phase for binary search and needs guidance on how to proceed with their code.', 'speak': '好的,我们来完成二分查找的代码!首先,请确保你有一个有序数组,然后编写一个函数来实现二分查找。你可以定义函数的输入为数组和要查找的目标值。展示一下你写的代码内容,我们可以一起做进一步的修改。', 'function': '[]'} -assistant: ################################Speak################################# -assistant: {'thought': 'The student is in the code implementation phase for binary search and needs guidance on how to proceed with their code.', 'speak': '好的,我们来完成二分查找的代码!首先,请确保你有一个有序数组,然后编写一个函数来实现二分查找。你可以定义函数的输入为数组和要查找的目标值。展示一下你写的代码内容,我们可以一起做进一步的修改。', 'function': '[]'}