This commit is contained in:
CakeCN
2024-12-03 16:21:19 +08:00
commit 4198ca63b1
975 changed files with 333413 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
{
"project": "QqF4e6",
"name": "3qsnbb",
"run_id": "run_20241126-192000_3qsnbb",
"timestamp": "2024-11-26 19:20:00",
"pid": 7205
}

Binary file not shown.

View File

@@ -0,0 +1,214 @@
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('/<filename>-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>
<head>
<style>
img {{
max-width: 100%;
height: auto;
}}
</style>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/5.2.0/github-markdown.min.css">
</head>
<body>
{html_content}
</body>
</html>
"""
# 保存 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/<path:filename>')
def serve_static(filename):
return send_from_directory(STATIC_DIR, filename)
'''
Vscode
'''
@app.route('/desktop/<user_id>/<path>')
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)

View File

@@ -0,0 +1,76 @@
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}"

View File

@@ -0,0 +1,45 @@
{"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}

View File

@@ -0,0 +1,135 @@
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": {}}]'}