diff --git a/AlgoriAgent/__pycache__/__init__.cpython-310.pyc b/AlgoriAgent/__pycache__/__init__.cpython-310.pyc index 6000a78..65ba710 100644 Binary files a/AlgoriAgent/__pycache__/__init__.cpython-310.pyc and b/AlgoriAgent/__pycache__/__init__.cpython-310.pyc differ diff --git a/AlgoriAgent/projects/algoriAgent/__pycache__/agent_manager.cpython-310.pyc b/AlgoriAgent/projects/algoriAgent/__pycache__/agent_manager.cpython-310.pyc index ac596df..f76d2bd 100644 Binary files a/AlgoriAgent/projects/algoriAgent/__pycache__/agent_manager.cpython-310.pyc and b/AlgoriAgent/projects/algoriAgent/__pycache__/agent_manager.cpython-310.pyc differ diff --git a/AlgoriAgent/projects/algoriAgent/agent/__pycache__/__init__.cpython-310.pyc b/AlgoriAgent/projects/algoriAgent/agent/__pycache__/__init__.cpython-310.pyc index 3415652..b7372b7 100644 Binary files a/AlgoriAgent/projects/algoriAgent/agent/__pycache__/__init__.cpython-310.pyc and b/AlgoriAgent/projects/algoriAgent/agent/__pycache__/__init__.cpython-310.pyc differ diff --git a/AlgoriAgent/projects/algoriAgent/agent/__pycache__/algori_agent.cpython-310.pyc b/AlgoriAgent/projects/algoriAgent/agent/__pycache__/algori_agent.cpython-310.pyc index a5e1a54..145ae3a 100644 Binary files a/AlgoriAgent/projects/algoriAgent/agent/__pycache__/algori_agent.cpython-310.pyc and b/AlgoriAgent/projects/algoriAgent/agent/__pycache__/algori_agent.cpython-310.pyc differ diff --git a/AlgoriAgent/projects/algoriAgent/agent/__pycache__/flex_service_toolkit.cpython-310.pyc b/AlgoriAgent/projects/algoriAgent/agent/__pycache__/flex_service_toolkit.cpython-310.pyc index 0104194..d9d8f26 100644 Binary files a/AlgoriAgent/projects/algoriAgent/agent/__pycache__/flex_service_toolkit.cpython-310.pyc and b/AlgoriAgent/projects/algoriAgent/agent/__pycache__/flex_service_toolkit.cpython-310.pyc differ diff --git a/AlgoriAgent/projects/algoriAgent/agent/algori_agent.py b/AlgoriAgent/projects/algoriAgent/agent/algori_agent.py index 2575519..4a0f3ea 100644 --- a/AlgoriAgent/projects/algoriAgent/agent/algori_agent.py +++ b/AlgoriAgent/projects/algoriAgent/agent/algori_agent.py @@ -1,476 +1,576 @@ -# -*- coding: utf-8 -*- -"""An agent class that implements the ReAct algorithm. The agent will reason -and act iteratively to solve problems. More details can be found in the paper -https://arxiv.org/abs/2210.03629. -""" -from typing import Any, Callable, Optional, Union, Sequence - -from loguru import logger -from agent.flex_service_toolkit import FlexServiceToolkit -from agentscope.exception import ResponseParsingError, FunctionCallError -from agentscope.agents import AgentBase -from agentscope.memory.temporary_memory import TemporaryMemory -from agentscope.message import Msg -from agentscope.parsers import MarkdownJsonDictParser -from agentscope.service.service_toolkit import ServiceFunction -from agentscope.service import ( - ServiceToolkit, - ServiceResponse, - ServiceExecStatus, -) -import json - - -# 这个INSTRUCTION_PROMPT 交给免费Agent进行使用,不包含评测与得分标准,但是会在没有自己注释的大段代码或复制粘贴代码是,通知学生进入一次理解性测试。 -INSTRUCTION_PROMPT = """## Your Role: -You are a powerful AI agent to teach student computer algorithm, you are to company a student to learn algorithm or solve problems. - -## What You Should Do: -0. You MUST follow the teaching instructions made by human teacher with several chapters, ONLY focus on one chapter at a time. -1. Student may ask you some questions, DONT answer the question directly or completely, instead, based on context (like student's code) to answer only one step forward. -2. Each chapter in teaching instruction will specifically guide what to teach to student, follow the instruction. -3. System will gather student's infomation sometimes, you neet to analyze student's learning statement from student's history codes, call the necessary function we he is stuck. - -## Note: -1. Fully understand the tool functions and their arguments before using them. -2. Make sure the types and values of the arguments you provided to the tool functions are correct. -3. Don't take things for granted. For example, where you are, what's the time now, etc. You can try to use the tool functions to get information. -4. If the function execution fails, you should analyze the error and try to solve it. -5. Remember to decide whether the student's question or idea is regarding about current chapter, if not, you should not awnser and ask the student to focus on the chapter. - -## Resources: -1. The tool functions you can use. -2. The context, including the student's code, and teaching instructions. -""" # noqa -CHAPTER_FINISH = 0 -CHAPTER_FOCUS = 1 -CHAPTER_LATTER = 2 -CHAPTER_FAILED = 3 - -class Chapter(): - def __init__(self, No = 1, focus = 2,title="", chapter = "", chapter_prompt = "", score_prompt = "", append_tools : Callable[..., Any] = None) -> None: - self.No = No - self.focus = focus - self.chapter = chapter - self.append_tools = append_tools - self.memory = None - def GetChapter(self): - if self.focus == CHAPTER_FINISH: f = "(Finished Chapter)" - elif self.focus == CHAPTER_FOCUS: f = "(Your Now Chapter)" - elif self.focus == CHAPTER_LATTER: f = "(Ignore for Latter Chapter)" - elif self.focus == CHAPTER_FAILED: f = "(Failed Chapter)" - return f"{f} Chapter {self.No}: {self.chapter}" - - def Finished(self, successful: bool = True): - if successful: self.focus = 0 - else: self.focus = 3 - - def Focus(self): - self.focus = 1 - -def record(content: str, name: str): - """Call it to save some important info for other chapters. Like file path, function call example. - - Args: - content (`str`): The content to be recorded. - name (`str`): The name of the agent to record. - Returns: - None - """ - ChapterChainAgent.Instance[name].memory.add(Msg( - "assistant", content, role="assistant" - )) - ChapterChainAgent.Instance[name].chapter_memory.add(Msg( - "assistant", "I recorded globally: "+content, role="assistant" - )) - status = ServiceExecStatus.SUCCESS - return ServiceResponse(status, None) - -def next_chapter(name: str): - """Call it to go to next chapter. - - Args: - name (`str`): The name of the agent to go to next chapter. - - Returns: - None - """ - try: - ChapterChainAgent.Instance[name].next_chapter() - except: - status = ServiceExecStatus.ERROR - return ServiceResponse(status, "Failed to go to next chapter. name '"+name+"' not found in ChapterChainAgent.Instance") - - status = ServiceExecStatus.SUCCESS - return ServiceResponse(status, None) - - - -class ChapterChainAgent(AgentBase): - """An agent class to preform chapter chain algorithm. - Project will be split to some chapters chained. - Each chapter will haave a main objective, having its own tools, and holding its own context. - """ - Instance = {} - def __init__( - self, - name: str, - model_config_name: str, - service_toolkit: FlexServiceToolkit = None, - sys_prompt: str = "You're a helpful assistant.", - max_iters: int = 10, - verbose: bool = True, - chapter_chain: Sequence[Chapter] = None, - stop_when_one_CHAPTER_failed: bool = True, - **kwargs: Any, - ) -> None: - """ - Args: - name (`str`): - The name of the agent. - sys_prompt (`str`): - The system prompt of the agent. - model_config_name (`str`): - The name of the model config, which is used to load model from - configuration. - service_toolkit (`ServiceToolkit`): - A `ServiceToolkit` object that contains the tool functions. - max_iters (`int`, defaults to `10`): - The maximum number of iterations of each chapter. - verbose (`bool`, defaults to `True`): - Whether to print the detailed information during reasoning and - acting steps. If `False`, only the content in speak field will - be print out. - chapter_chain (`Sequence[str]`): - The chapter chain to be performed. If None, the agent will add a - init chapter to construct the chapter chain. - """ - super().__init__( - name=name, - sys_prompt=sys_prompt, - model_config_name=model_config_name, - ) - - # TODO: To compatible with the old version, which will be deprecated - # soon - if "tools" in kwargs: - logger.warning( - "The argument `tools` will be deprecated soon. " - "Please use `service_toolkit` instead. Example refers to " - "https://github.com/modelscope/agentscope/blob/main/" - "examples/conversation_with_react_agent/code/" - "conversation_with_react_agent.py", - ) - - service_funcs = {} - for func, json_schema in kwargs["tools"]: - name = json_schema["function"]["name"] - service_funcs[name] = ServiceFunction( - name=name, - original_func=func, - processed_func=func, - json_schema=json_schema, - ) - - if service_toolkit is None: - service_toolkit = FlexServiceToolkit() - service_toolkit.service_funcs = service_funcs - else: - service_toolkit.service_funcs.update(service_funcs) - - elif service_toolkit is None: - raise ValueError( - "The argument `service_toolkit` is required to initialize " - "the ReActAgent.", - ) - - service_toolkit.add(record,name=name) - service_toolkit.add(next_chapter,name=name) - - self.service_toolkit = service_toolkit - self.service_toolkit.agent = self - self.verbose = verbose - self.max_iters = max_iters - - if not sys_prompt.endswith("\n"): - sys_prompt = sys_prompt + "\n" - - self.sys_prompt = "\n".join( - [ - # The brief intro of the role and target - sys_prompt.format(name=self.name), - # The detailed instruction prompt for the agent - INSTRUCTION_PROMPT, - ], - ) - - - # This memory is used to store all useful memory with the chapter chain switching - #self.memory_on_chain = TemporaryMemory() - self.memory.add(Msg("system", self.sys_prompt, role="system")) - self.chapter_memory = TemporaryMemory() - - # Initialize a parser object to formulate the response from the model - self.parser = MarkdownJsonDictParser( - content_hint={ - "thought": "what you thought", - "speak": "what you speak", - "function": service_toolkit.tools_calling_format, - }, - required_keys=["thought", "speak", "function"], - # Only print the speak field when verbose is False - keys_to_content=True if self.verbose else "speak", - ) - - - self.chapter_chain = chapter_chain - - self.chapter_chain_now = 0 - self.finish_now_chapter = False - - self.stop_when_one_CHAPTER_failed = stop_when_one_CHAPTER_failed - - - ChapterChainAgent.Instance[name] = self - - def chapter_chain_to_memory(self): - mem = "##The Chapter Chain##\n" - for chapter in self.chapter_chain: - mem+=chapter.GetChapter()+"\n" - mem+="\n" - mem+= "Remember your now chapter is "+ self.chapter_chain[self.chapter_chain_now].GetChapter()+"\n" - return Msg("system", mem, role="system") - - def _has_unfinished_chapter(self): - for chapter in self.chapter_chain: - if chapter.focus == CHAPTER_LATTER or chapter.focus == CHAPTER_FOCUS: - return True - return False - def next_chapter(self, successful: bool = True): - if self.chapter_chain[self.chapter_chain_now].append_tools is not None: - for callable_tools in self.chapter_chain[self.chapter_chain_now].append_tools: - self.service_toolkit.Remove(callable_tools) - - self.chapter_chain[self.chapter_chain_now].Finished(successful) - - for i in range(len(self.chapter_chain)): - if self.chapter_chain[i].focus == 2: - self.chapter_chain[i].Focus() - if self.chapter_chain[i].append_tools is not None: - for callable_tools in self.chapter_chain[i].append_tools: - self.service_toolkit.add(callable_tools) - self.chapter_chain_now = i - return - - def add_chapters_after(self, CHAPTER_No, chapters: Sequence[Chapter]): - for i in range(len(self.chapter_chain)): - if self.chapter_chain[i].No == CHAPTER_No: - for j in range(len(chapters)): - CHAPTER_to_insert = Chapter(No = CHAPTER_No + j + 1, chapter = chapters[j], focus = 2, append_tools= - self.chapter_chain[self.chapter_chain_now].append_tools) - self.chapter_chain.insert(i+1+j, CHAPTER_to_insert) - for j in range(i+len(chapters), len(self.chapter_chain)): - self.chapter_chain[j].No += len(chapters) - break - def reply(self, x: Optional[Union[Msg, Sequence[Msg]]] = None, user_backboard:str = "") -> Msg: - if self.chapter_memory.size() == 0: - - self.chapter_chain[self.chapter_chain_now].memory = self.chapter_memory - for msg in self.memory.get_memory(): - self.chapter_memory.add(msg) - self.chapter_memory.add(self.chapter_chain_to_memory()) - - self.chapter_memory.add(x) - - - for _ in range(1): - # Step 1: Thought - if self.verbose: - self.speak(f" ITER {_+1}, STEP 1: REASONING ".center(70, "#")) - - # Prepare hint to remind model what the response format is - # Won't be recorded in memory to save tokens - backboard_hint_msg = Msg( - "system", - user_backboard, - role="system", - echo=self.verbose, - ) - tools_hint_msg = Msg( - "system", - self.service_toolkit.tools_instruction, - role="system", - echo=self.verbose, - ) - hint_msg = Msg( - "system", - self.parser.format_instruction+"\n ####", - role="system", - echo=self.verbose, - ) - - prompt = self.model.format(self.chapter_memory.get_memory(), - backboard_hint_msg, - # The instruction prompt for tools - tools_hint_msg, - hint_msg) - print("*********************************************************************") - print(prompt) - if self.verbose: - self.speak(f"Prompt".center(70, "#")) - self.speak(str(self.chapter_memory.get_memory()[-1].content)) - # print(prompt) - - try: - res = self.model( - prompt, - parse_func=self.parser.parse, - max_retries=1, - ) - - - if self.verbose: - self.speak(f"Result Parsed".center(70, "#")) - self.speak(str(res.parsed)) - print(res.parsed) - - self.chapter_memory.add( - Msg( - self.name, - self.parser.to_memory(res.parsed), - "assistant", - ), - ) - - # Print out the response - msg_returned = Msg( - self.name, - self.parser.to_content(res.parsed), - "assistant", - ) - if self.verbose: - self.speak(f"Speak".center(70, "#")) - print(msg_returned) - self.speak(msg_returned) - return msg_returned - - if self.verbose: - self.speak(f"Function".center(70, "#")) - self.speak(str(res.parsed["function"])) - print(res.parsed["function"]) - - arg_function = res.parsed["function"] - if ( - isinstance(arg_function, str) - and arg_function in ["[]", ""] - or isinstance(arg_function, list) - and len(arg_function) == 0 - ): - # Only the speak field is exposed to users or other agents - continue - - # Only catch the response parsing error and expose runtime - # errors to developers for debugging - except ResponseParsingError as e: - # Print out raw response from models for developers to debug - response_msg = Msg(self.name, e.raw_response, "assistant") - self.speak(response_msg) - - # Re-correct by model itself - error_msg = Msg("system", str(e), "system") - self.speak(error_msg) - - self.chapter_memory.add([response_msg, error_msg]) - - # Skip acting step to re-correct the response - continue - - # 2. Acting - if self.verbose: - self.speak(f" ITER {_+1}, STEP 2: ACTING ".center(70, "#")) - - # Parse, check and execute the tool functions in service toolkit - try: - - - - execute_results = self.service_toolkit.parse_and_call_func( - res.parsed["function"], - ) - # 在这里补充任务结束行动 - if self.finish_now_chapter: - self.finish_now_chapter = False - hint_msg = Msg( - "system", - "You have finished your own chapter." - "Now generate a reply by summarizing the current " - "situation. Remember this summary will be recorded in global memory. Make sure keep important information.", - role="system", - echo=self.verbose, - ) - - # Generate a reply by summarizing the current situation - prompt = self.model.format(self.chapter_memory.get_memory(), hint_msg) - res = self.model(prompt) - res_msg = Msg(self.name, res.text, "assistant") - self.memory.add(res_msg) - self.speak(res_msg) - self.next_chapter(successful=True) - self.success_own_chapter = True - break - - # Note: Observing the execution results and generate response - # are finished in the next reasoning step. We just put the - # execution results into memory, and wait for the next loop - # to generate response. - - # Record execution results into memory as system message - msg_res = Msg("system", execute_results, "system") - self.speak(msg_res) - self.chapter_memory.add(msg_res) - - except FunctionCallError as e: - # Catch the function calling error that can be handled by - # the model - error_msg = Msg("system", str(e), "system") - self.speak(error_msg) - self.chapter_memory.add(error_msg) - continue - - except Exception as e: - # Catch the function calling error that can not be handled - error_msg = Msg("system", str(e), "system") - self.speak(error_msg) - self.chapter_memory.add(error_msg) - continue - - - - - def GetProcess(self): - process = [] - t = {} - t['topic'] = "Global Memory" - mems = [] - for msg in self.memory.get_memory(): - mems.append(msg.serialize()) - - t['memory'] = "$MEMORYMEMORY$".join(mems) - t['finish'] = "True" - ts = f"{t['topic']}$TOPICTOPIC${t['memory']}$TOPICTOPIC${t['finish']}" - process.append(ts) - for chapter in self.chapter_chain: - t = {} - t['topic'] = f'Chapter {chapter.No}' - mems = [] - if chapter.memory is not None: - for msg in self.memory.get_memory(): - mems.append(msg.serialize()) - t['memory'] = "$MEMORYMEMORY$".join(mems) - t['finish'] = "True" if chapter.focus == CHAPTER_FINISH else "False" - ts = f"{t['topic']}$TOPICTOPIC${t['memory']}$TOPICTOPIC${t['finish']}" - process.append(ts) - - returnString = "" - returnString = "$TASKTASK$".join(process) - return returnString +# -*- coding: utf-8 -*- +"""An agent class that implements the ReAct algorithm. The agent will reason +and act iteratively to solve problems. More details can be found in the paper +https://arxiv.org/abs/2210.03629. +""" +from typing import Any, Callable, Optional, Union, Sequence + +from loguru import logger +from agent.flex_service_toolkit import FlexServiceToolkit +from agentscope.exception import ResponseParsingError, FunctionCallError +from agentscope.agents import AgentBase +from agentscope.memory.temporary_memory import TemporaryMemory +from agentscope.message import Msg +from agentscope.parsers import MarkdownJsonDictParser +from agentscope.service.service_toolkit import ServiceFunction +from agentscope.service import ( + ServiceToolkit, + ServiceResponse, + ServiceExecStatus, +) +import json +from AlgoriAgent.projects.algoriAgent.agent.score_agent import ScoreAgent +from AlgoriAgent.projects.algoriAgent.agent.total_score_agent import TotalScoreAgent + +import re + + + + +# 这个INSTRUCTION_PROMPT 交给免费Agent进行使用,不包含评测与得分标准,但是会在没有自己注释的大段代码或复制粘贴代码是,通知学生进入一次理解性测试。 +INSTRUCTION_PROMPT_EN = """## Your Role: +You need to help the student learn algorithms, verify the learning process, ensure that the student understands the current chapter's content, and then guide the student to the next chapter. + +## What You Should Do: +0. You MUST follow the teaching instructions made by human teacher with several chapters, ONLY focus on one chapter at a time. +1. Student may ask you some questions, DONT answer the question directly or completely, instead, based on context (like student's code) to answer only one step forward. +2. Each chapter in teaching instruction will specifically guide what to teach to student, follow the instruction. +3. System will gather student's infomation sometimes, you neet to analyze student's learning statement from student's history codes, call the necessary function we he is stuck. + +## Note: +1. Fully understand the tool functions and their arguments before using them. +2. Make sure the types and values of the arguments you provided to the tool functions are correct. +3. Don't take things for granted. For example, where you are, what's the time now, etc. You can try to use the tool functions to get information. +4. If the function execution fails, you should analyze the error and try to solve it. +5. Remember to decide whether the student's question or idea is regarding about current chapter, if not, you should not awnser and ask the student to focus on the chapter. + +## Resources: +1. The tool functions you can use. +2. The context, including the student's code, and teaching instructions. +""" # noqa +INSTRUCTION_PROMPT_CN = """## 你的角色: +你需要帮助学生学习算法,检验学习过程,确保学生理解当前章节的内容后,带领学生进入下一章 + +## 你需要做的: +0. 你必须根据老师提供的教学大纲,按照章节顺序,依次学习。 +1. 学生可能会提出一些问题,你无需回答问题,而是根据上下文(比如学生自己的代码)来分析,并给出一步的解决方案。 +2. 教学大纲中会指明每个章节的学习目标,你按照目标学习。 +3. 系统会occasionally gather学生信息,你需要分析学生学习记录,调用必要的函数。 + +## 注意事项: +1. 确保使用工具函数时,提供的参数类型和值是正确的。 +2. 不要太相信自己,例如,当前位置,当前时间等,你可以尝试使用工具函数获取信息。 +3. 如果函数执行失败,你需要分析错误并尝试解决。 +4. 确保学生提出的问题或想法是否与当前章节相关,如果不相关,你应答并提醒学生关注当前章节。 + +## 资源: +1. 你可以使用的工具函数。 +2. 上下文,包括学生的代码,和教学大纲。 +""" + + +LANGUAGE_HINT_EN = "Use English to reply" +LANGUAGE_HINT_CN = "使用中文回复" + + + +CHAPTER_FINISH = 0 +CHAPTER_FOCUS = 1 +CHAPTER_LATTER = 2 +CHAPTER_FAILED = 3 + +class Chapter(): + + def __init__(self, course_id, lesson_id, No = 1, focus = 2,title="", chapter = "", chapter_prompt = "", + score_prompt = "", append_tools : list[Callable[..., Any], dict] = None) -> None: + ''' + No : 序号 + focus : 0: Finished, 1: Focus, 2: Latter, 3: Failed + title : 子章节标题 + chapter : 教案子章节内容 + chapter_prompt : 教案的提示 + score_prompt : 评测标准 + append_tools : 追加工具函数 + ''' + self.No = No + self.focus = focus + self.chapter = chapter + self.chapter_prompt = chapter_prompt + self.score_prompt = score_prompt + self.append_tools = append_tools + self.memory = None + self.title =title + self.course_id = course_id + self.lesson_id = lesson_id + + + def GetChapter(self): + if self.focus == CHAPTER_FINISH: f = "(Finished Chapter)" + elif self.focus == CHAPTER_FOCUS: f = "(Your Now Chapter)" + elif self.focus == CHAPTER_LATTER: f = "(Ignore for Latter Chapter)" + elif self.focus == CHAPTER_FAILED: f = "(Failed Chapter)" + # des = f"{f} Chapter {self.No}: {self.chapter if self.focus else 'Hidden for further study.'}" + des = f"{f} Chapter {self.No}: " + if self.focus == CHAPTER_FINISH or self.focus == CHAPTER_FAILED: des += 'Hidden due to finished.' + if self.focus == CHAPTER_LATTER: des += 'Hidden for further study.' + if self.focus == CHAPTER_FOCUS: + des+=self.chapter + des+='\n' + des+='Here are some concrete instructions:\n' + des+=self.chapter_prompt+'\n' + + return des + + def Finished(self, successful: bool = True): + if successful: self.focus = 0 + else: self.focus = 3 + + def Focus(self): + self.focus = 1 + +def record(content: str, name: str): + """Call it to save some important info for other chapters. Like file path, function call example. + + Args: + content (`str`): The content to be recorded. + name (`str`): The name of the agent to record. + Returns: + None + """ + ChapterChainAgent.Instance[name].memory.add(Msg( + "assistant", content, role="assistant" + )) + ChapterChainAgent.Instance[name].chapter_memory.add(Msg( + "assistant", "I recorded globally: "+content, role="assistant" + )) + status = ServiceExecStatus.SUCCESS + return ServiceResponse(status, None) + +def next_chapter(name: str): + """Call it to go to next chapter. + + Args: + name (`str`): The name of the agent to go to next chapter. + + Returns: + message (`str`): The result of the operation. + """ + res="" + try: + print(ChapterChainAgent.Instance) + print(name in ChapterChainAgent.Instance) + res = ChapterChainAgent.Instance[name].next_chapter() + except Exception as e: + status = ServiceExecStatus.ERROR + return ServiceResponse(status, str(e)) + + status = ServiceExecStatus.SUCCESS + return ServiceResponse(status, res) + +from AlgoriAgent.projects.algoriAgent.tools.file_tools import file_tools + +class ChapterChainAgent(AgentBase): + """An agent class to preform chapter chain algorithm. + Project will be split to some chapters chained. + Each chapter will haave a main objective, having its own tools, and holding its own context. + """ + Instance = {} + def __init__( + self, + name: str, + model_config_name: str, + service_toolkit: FlexServiceToolkit = None, + sys_prompt: str = "You're a helpful assistant.", + max_iters: int = 10, + verbose: bool = True, + chapter_chain: Sequence[Chapter] = None, + stop_when_one_CHAPTER_failed: bool = True, + root_path: str = ".", + **kwargs: Any, + ) -> None: + """ + Args: + name (`str`): + The name of the agent. + sys_prompt (`str`): + The system prompt of the agent. + model_config_name (`str`): + The name of the model config, which is used to load model from + configuration. + service_toolkit (`ServiceToolkit`): + A `ServiceToolkit` object that contains the tool functions. + max_iters (`int`, defaults to `10`): + The maximum number of iterations of each chapter. + verbose (`bool`, defaults to `True`): + Whether to print the detailed information during reasoning and + acting steps. If `False`, only the content in speak field will + be print out. + chapter_chain (`Sequence[str]`): + The chapter chain to be performed. If None, the agent will add a + init chapter to construct the chapter chain. + """ + super().__init__( + name=name, + sys_prompt=sys_prompt, + model_config_name=model_config_name, + ) + self.model_config_name = model_config_name + # TODO: To compatible with the old version, which will be deprecated + # soon + self.name=name + if "tools" in kwargs: + logger.warning( + "The argument `tools` will be deprecated soon. " + "Please use `service_toolkit` instead. Example refers to " + "https://github.com/modelscope/agentscope/blob/main/" + "examples/conversation_with_react_agent/code/" + "conversation_with_react_agent.py", + ) + + service_funcs = {} + for func, json_schema in kwargs["tools"]: + name = json_schema["function"]["name"] + service_funcs[name] = ServiceFunction( + name=name, + original_func=func, + processed_func=func, + json_schema=json_schema, + ) + + if service_toolkit is None: + service_toolkit = FlexServiceToolkit() + service_toolkit.service_funcs = service_funcs + else: + service_toolkit.service_funcs.update(service_funcs) + + elif service_toolkit is None: + raise ValueError( + "The argument `service_toolkit` is required to initialize " + "the ReActAgent.", + ) + + service_toolkit.add(record,name=name) + service_toolkit.add(next_chapter,name=name) + for tool in file_tools: + service_toolkit.add(tool, root_path=root_path) + + self.service_toolkit = service_toolkit + self.service_toolkit.agent = self + self.verbose = verbose + self.max_iters = max_iters + + if not sys_prompt.endswith("\n"): + sys_prompt = sys_prompt + "\n" + + self.sys_prompt = "\n".join( + [ + # The brief intro of the role and target + sys_prompt.format(name=self.name), + # The detailed instruction prompt for the agent + INSTRUCTION_PROMPT_CN, + ], + ) + + + # This memory is used to store all useful memory with the chapter chain switching + #self.memory_on_chain = TemporaryMemory() + self.memory.add(Msg("system", self.sys_prompt, role="system")) + self.chapter_memory = TemporaryMemory() + + # Initialize a parser object to formulate the response from the model + self.parser = MarkdownJsonDictParser( + content_hint={ + "thought": "what you thought", + "speak": "what you speak", + "function": service_toolkit.tools_calling_format, + }, + required_keys=["thought", "speak", "function"], + # Only print the speak field when verbose is False + keys_to_content=True if self.verbose else "speak", + ) + self.language_hint = LANGUAGE_HINT_CN + + self.chapter_chain = chapter_chain + + self.chapter_chain_now = 0 + self.finish_now_chapter = False + + self.stop_when_one_CHAPTER_failed = stop_when_one_CHAPTER_failed + + + ChapterChainAgent.Instance[name] = self + self.agent_manager = None + self.root_path = root_path + + def chapter_chain_to_memory(self): + mem = "##The Chapter Chain##\n" + for chapter in self.chapter_chain: + if (chapter.focus == CHAPTER_FOCUS or chapter.focus == CHAPTER_FINISH): + mem+=chapter.GetChapter()+"\n" + mem+="\n" + # mem+= "Remember your now chapter is "+ self.chapter_chain[self.chapter_chain_now].GetChapter()+"\n" + return Msg("system", mem, role="system") + + def _has_unfinished_chapter(self): + for chapter in self.chapter_chain: + if chapter.focus == CHAPTER_LATTER or chapter.focus == CHAPTER_FOCUS: + return True + return False + def next_chapter(self, successful: bool = True): + if self.chapter_chain[self.chapter_chain_now].append_tools is not None or len(self.chapter_chain[self.chapter_chain_now].append_tools)==0: + for callable_tools, args in self.chapter_chain[self.chapter_chain_now].append_tools: + self.service_toolkit.Remove(callable_tools) + + self.chapter_chain[self.chapter_chain_now].Finished(successful) + try: + score_agent = ScoreAgent(name=self.name, model_config_name=self.model_config_name, memory=self.chapter_memory, + chapter_score_prompt=self.chapter_chain[self.chapter_chain_now].score_prompt, + service_toolkit=self.service_toolkit, sys_prompt="", max_iters=self.max_iters, verbose=self.verbose) + res = score_agent.reply() + + total_score_agent = TotalScoreAgent(name=self.name, model_config_name=self.model_config_name, input=res['content']['speak'], + service_toolkit=self.service_toolkit, sys_prompt="", max_iters=self.max_iters, verbose=self.verbose) + score = total_score_agent.reply() + + except Exception as e: + print("=*="*50) + print(e) + self.agent_manager.message_pass(self, "chapter_score", json.dumps({'chapter_id':self.chapter_chain_now+1, 'data':res})) + self.agent_manager.save_chapter_memory(self,self.chapter_chain[self.chapter_chain_now].course_id, self.chapter_chain[self.chapter_chain_now].lesson_id, + self.chapter_chain[self.chapter_chain_now].title, self.chapter_memory.export(to_mem = True), + score, is_rebuttal=False) + self.chapter_memory = TemporaryMemory() + self.agent_manager.message_pass(self, "next_chapter","") + self.agent_manager.system_message("进入下一节") + + for i in range(len(self.chapter_chain)): + if self.chapter_chain[i].focus == CHAPTER_LATTER: + self.chapter_chain[i].Focus() + if self.chapter_chain[i].append_tools is not None and len(self.chapter_chain[i].append_tools) > 0: + for callable_tools, args in self.chapter_chain[i].append_tools: + print("add tools:", callable_tools) + print("args:", args) + args['root_path'] = self.root_path + self.service_toolkit.add(callable_tools, **args) + self.chapter_chain_now = i + return "成功进入下一章" + # 找不到章节 + return "学生完成了本课所有章节,已经没有下一章了!" + + def add_chapters_after(self, CHAPTER_No, chapters: Sequence[Chapter]): + for i in range(len(self.chapter_chain)): + if self.chapter_chain[i].No == CHAPTER_No: + for j in range(len(chapters)): + CHAPTER_to_insert = Chapter(No = CHAPTER_No + j + 1, chapter = chapters[j], focus = 2, append_tools= + self.chapter_chain[self.chapter_chain_now].append_tools) + self.chapter_chain.insert(i+1+j, CHAPTER_to_insert) + for j in range(i+len(chapters), len(self.chapter_chain)): + self.chapter_chain[j].No += len(chapters) + break + def reply(self, x: Optional[Union[Msg, Sequence[Msg]]] = None, user_backboard:str = "") -> Msg: + if self.chapter_memory.size() <= 1: + self.chapter_chain[self.chapter_chain_now].memory = self.chapter_memory + for msg in self.memory.get_memory(): + self.chapter_memory.add(msg) + self.chapter_memory.add(self.chapter_chain_to_memory()) + + self.chapter_memory.add(x) + + + for _ in range(self.max_iters): + # Step 1: Thought + if self.verbose: + self.speak(f" ITER {_+1}, STEP 1: REASONING ".center(70, "#")) + + # Prepare hint to remind model what the response format is + # Won't be recorded in memory to save tokens + backboard_hint_msg = Msg( + "system", + user_backboard, + role="system", + echo=self.verbose, + ) + tools_hint_msg = Msg( + "system", + self.service_toolkit.tools_instruction, + role="system", + echo=self.verbose, + ) + hint_msg = Msg( + "system", + self.parser.format_instruction+"\n ####" + "!!"+ self.language_hint +"!!", + role="system", + echo=self.verbose, + ) + prompt = self.model.format(self.chapter_memory.get_memory(), + backboard_hint_msg, + # The instruction prompt for tools + tools_hint_msg, + hint_msg) + if self.verbose: + self.speak(f"Prompt".center(70, "#")) + self.speak(str(prompt)) + + try: + if self.verbose: + self.speak(f"API Trigger".center(70, "#")) + res = self.model( + prompt, + parse_func=self.parser.parse, + max_retries=2, + ###################### + ) + + if self.verbose: + self.speak(f"Result Parsed".center(70, "#")) + self.speak(str(res.parsed)) + print(res.parsed) + + self.chapter_memory.add( + Msg( + self.name, + self.parser.to_memory(res.parsed), + "assistant", + ), + ) + + # Print out the response + msg_returned = Msg( + self.name, + self.parser.to_content(res.parsed), + "assistant", + ) + if self.verbose: + self.speak(f"Speak".center(70, "#")) + print(msg_returned) + self.speak(msg_returned) + return msg_returned + + + if self.verbose: + self.speak(f"Function".center(70, "#")) + self.speak(str(res.parsed["function"])) + print(res.parsed["function"]) + + arg_function = res.parsed["function"] + if ( + isinstance(arg_function, str) + and arg_function in ["[]", ""] + or isinstance(arg_function, list) + and len(arg_function) == 0 + ): + # Only the speak field is exposed to users or other agents + continue + + # Only catch the response parsing error and expose runtime + # errors to developers for debugging + except ResponseParsingError as e: + # Print out raw response from models for developers to debug + response_msg = Msg(self.name, e.raw_response, "assistant") + self.speak(response_msg) + + # Re-correct by model itself + error_msg = Msg("system", str(e), "system") + self.speak(error_msg) + + self.chapter_memory.add([response_msg, error_msg]) + + + + def function_call(self, parsed_function) -> Msg: + if self.verbose: + self.speak(f"ACTING ".center(70, "#")) + print(str(parsed_function)) + + # Parse, check and execute the tool functions in service toolkit + try: + execute_results = self.service_toolkit.parse_and_call_func( + parsed_function# res.parsed["function"], + ) + # 在这里补充任务结束行动 + if self.finish_now_chapter: self.finish() + + + # Note: Observing the execution results and generate response + # are finished in the next reasoning step. We just put the + # execution results into memory, and wait for the next loop + # to generate response. + + # Record execution results into memory as system message + msg_res = Msg("system", execute_results, "system") + self.speak(msg_res) + self.chapter_memory.add(msg_res) + pattern = r"\[RESULT\]: (.*)" + match = re.search(pattern, msg_res['content']) + result_content='正则匹配失败' + if match: + result_content = match.group(1) + res = self.reply(Msg(name='system', content="命令执行结果如上,请总结并引导学生进行下一步操作", role="system")) + + self.agent_manager.system_message(parsed_function['name'] + "执行" + ("成功" if "[STATUS]: SUCCESS" in str(msg_res['content']) else "失败") + ",结果为:" + result_content) + self.agent_manager.message_pass(self, "message", res.content['speak']) + + except FunctionCallError as e: + # Catch the function calling error that can be handled by + # the model + error_msg = Msg("system", str(e), "system") + self.speak(error_msg) + self.chapter_memory.add(error_msg) + + except Exception as e: + # Catch the function calling error that can not be handled + error_msg = Msg("system", str(e), "system") + self.speak(error_msg) + self.chapter_memory.add(error_msg) + + def finish(self): + self.finish_now_chapter = False + hint_msg = Msg( + "system", + "You have finished your now chapter." + "Now generate a reply by summarizing the current " + "situation. Remember this summary will be recorded in global memory. Make sure keep important information.", + role="system", + echo=self.verbose, + ) + + # Generate a reply by summarizing the current situation + prompt = self.model.format(self.chapter_memory.get_memory(), hint_msg) + res = self.model(prompt) + res_msg = Msg(self.name, res.text, "assistant") + self.memory.add(res_msg) + self.speak(res_msg) + self.next_chapter(successful=True) + self.success_own_chapter = True + + def change_language(self, language): + if(language == "zh"):self.language_hint = LANGUAGE_HINT_CN + if(language == "en"):self.language_hint = LANGUAGE_HINT_EN + + def GetProcess(self): + process = [] + t = {} + t['topic'] = "Global Memory" + mems = [] + for msg in self.memory.get_memory(): + mems.append(msg.serialize()) + + t['memory'] = "$MEMORYMEMORY$".join(mems) + t['finish'] = "True" + ts = f"{t['topic']}$TOPICTOPIC${t['memory']}$TOPICTOPIC${t['finish']}" + process.append(ts) + for chapter in self.chapter_chain: + t = {} + t['topic'] = f'Chapter {chapter.No}' + mems = [] + if chapter.memory is not None: + for msg in self.memory.get_memory(): + mems.append(msg.serialize()) + t['memory'] = "$MEMORYMEMORY$".join(mems) + t['finish'] = "True" if chapter.focus == CHAPTER_FINISH else "False" + ts = f"{t['topic']}$TOPICTOPIC${t['memory']}$TOPICTOPIC${t['finish']}" + process.append(ts) + + returnString = "" + returnString = "$TASKTASK$".join(process) + return returnString diff --git a/AlgoriAgent/projects/algoriAgent/agent/score_agent.py b/AlgoriAgent/projects/algoriAgent/agent/score_agent.py new file mode 100644 index 0000000..67997bb --- /dev/null +++ b/AlgoriAgent/projects/algoriAgent/agent/score_agent.py @@ -0,0 +1,180 @@ + +from typing import Any, Callable, Optional, Union, Sequence + +from loguru import logger +from agent.flex_service_toolkit import FlexServiceToolkit +from agentscope.exception import ResponseParsingError, FunctionCallError +from agentscope.agents import AgentBase +from agentscope.memory.temporary_memory import TemporaryMemory +from agentscope.message import Msg +from agentscope.parsers import MarkdownJsonDictParser +from agentscope.service.service_toolkit import ServiceFunction +from agentscope.service import ( + ServiceToolkit, + ServiceResponse, + ServiceExecStatus, +) +import json + + +INSTRUCTION_SCORE_PROMPT_CN = """ +你是一名经验丰富的算法课程评分专家,你的任务是:基于学生对一个章节的学习日志、对话流,按照指定的评分标准进行评分。 +但是不同于普通老师,为了提高得分的区分度,你需要作为一名非常挑剔的专家,根据评分标准仔细挑剔学生的学习日志,并给出评分报告。 + +重要的挑剔点: +1. 存在错误的概念理解 +2. 存在矛盾的概念理解 +3. 存在不清晰、不连贯的概念表达 +4. 其他你认为可以挑剔的地方 + +下面是学生的整个学习日志和对话流: +""" + +CHAPTER_HINT_CN =""" +上面就是学生的整个学习日志和对话流,请进行下面的各条章节评分标准进行挑剔与评分。 +""" + +RESPONSE_HINT_CN = """ +你的返回必须包含: +对于每条章节评分标准,报告学生的得分以及挑剔的结果。 +例如: +``` +{'评分标准1': {'得分': 8, '挑剔报告': '答案正确,但对于xxx概念表述有误'} +} +``` +""" + +INSTRUCTION_SCORE_PROMPT_EN = """ +You are a experienced algorithm course scoring expert, your task is to: Based on the students' learning logs and dialogues, score them according to the specified scoring standard. +But unlike a normal teacher, to improve the distinction of the score, you need to be a very critical expert, carefully pick out the students' learning logs according to the scoring standard and give a score report. + +The important points to pick out: +1. There are errors in the concept understanding +2. There are contradictions in the concept understanding +3. There are unclear, incoherent concept expressions +4. Other places you think can be picked out +Below is the students' entire learning log and dialogue: +""" + +CHAPTER_HINT_EN = """ +Above is the students' entire learning log and dialogue, please pick out according to the following chapter scoring standard and score them. +""" + +RESPONSE_HINT_EN=""" +Your response must contain: +For each chapter scoring standard, report the students' score and pick out the results. +For example: +``` +{'Score standard 1': {'Score': 8, 'Pick out report': 'The answer is correct, but for the xxx concept expression is wrong'} +} +``` +""" + + +class ScoreAgent(AgentBase): + """ + ScoreAgent is a agent that can score students' learning logs. + """ + def __init__(self, name: str, model_config_name: str, memory: TemporaryMemory, + chapter_score_prompt: str, + service_toolkit: ServiceToolkit, + sys_prompt: str = "You're a helpful assistant.", + max_iters: int = 5, + verbose: bool = True, + **kwargs): + self.service_toolkit = service_toolkit + super().__init__( + name=name, + sys_prompt=sys_prompt, + model_config_name=model_config_name, + ) + self.max_iters = max_iters + self.verbose = verbose + if not sys_prompt.endswith("\n"): + sys_prompt = sys_prompt + "\n" + + self.sys_prompt = "\n".join( + [ + # The brief intro of the role and target + sys_prompt.format(name=self.name), + # The detailed instruction prompt for the agent + INSTRUCTION_SCORE_PROMPT_CN, + ], + ) + self.memory = TemporaryMemory() + self.memory.add(Msg("system", self.sys_prompt, role="system")) + + self.memory.add(memory.get_memory()) + + self.memory.add(Msg("system", CHAPTER_HINT_CN, role="system")) + + self.memory.add(Msg("system", chapter_score_prompt, role="system")) + + self.memory.add(Msg("system", RESPONSE_HINT_CN, role="system")) + + self.parser = MarkdownJsonDictParser( + content_hint={ + "thought": "what you thought", + "speak": "actual response in correct format mentioned above", + }, + required_keys=["thought", "speak"], + # Only print the speak field when verbose is False + keys_to_content=True if self.verbose else "speak", + ) + + def reply(self, x = None, user_backboard = ""): + for _ in range(self.max_iters): + if self.verbose: + self.speak(f" ITER {_+1} ".center(70, "#")) + try: + + hint_msg = Msg( + "system", + self.parser.format_instruction+"\n", + role="system", + echo=self.verbose, + ) + prompt = self.model.format(self.memory.get_memory(),hint_msg + ) + if self.verbose: + self.speak(f"API Trigger".center(70, "#")) + self.speak(str(prompt)) + res = self.model( + prompt, + parse_func=self.parser.parse, + max_retries=2, + ###################### + ) + + if self.verbose: + self.speak(f"Result Parsed".center(70, "#")) + self.speak(str(res.parsed)) + print(res.parsed) + self.memory.add( + Msg( + self.name, + self.parser.to_memory(res.parsed), + "assistant", + ), + ) + msg_returned = Msg( + self.name, + self.parser.to_content(res.parsed), + "assistant", + ) + return msg_returned + except ResponseParsingError as e: + # Print out raw response from models for developers to debug + response_msg = Msg(self.name, e.raw_response, "assistant") + self.speak(response_msg) + # Re-correct by model itself + error_msg = Msg("system", str(e), "system") + self.speak(error_msg) + self.memory.add([response_msg, error_msg]) + except Exception as e: + self.speak(f"Error: {e}".center(70, "#")) + self.speak(f"Retrying".center(70, "#")) + continue + + return Msg(self.name, "Error: Max iterations reached", "assistant") + diff --git a/AlgoriAgent/projects/algoriAgent/agent/total_score_agent.py b/AlgoriAgent/projects/algoriAgent/agent/total_score_agent.py new file mode 100644 index 0000000..26ce77c --- /dev/null +++ b/AlgoriAgent/projects/algoriAgent/agent/total_score_agent.py @@ -0,0 +1,152 @@ + +from typing import Any, Callable, Optional, Union, Sequence + +from loguru import logger +from agent.flex_service_toolkit import FlexServiceToolkit +from agentscope.exception import ResponseParsingError, FunctionCallError +from agentscope.agents import AgentBase +from agentscope.memory.temporary_memory import TemporaryMemory +from agentscope.message import Msg +from agentscope.parsers import MarkdownJsonDictParser +from agentscope.service.service_toolkit import ServiceFunction +from agentscope.service import ( + ServiceToolkit, + ServiceResponse, + ServiceExecStatus, +) +import json + + +INSTRUCTION_TOTAL_SCORE_PROMPT_CN = """ +你是一名精通文件处理的专家,你的本次任务非常简单,给你一段由其他老师给出的评分评价,你需要从中提取每一条标准下的得分,并计算总分,返回总分即可。 +""" + + +RESPONSE_TOTAL_SCORE_HINT_CN = """ +你的返回必须包含且仅包含一个整数,表示得分。 +例如: +输入: +``` +{'评分标准1': {'得分': 8, '挑剔报告': '答案正确,但对于xxx概念表述有误'}, + '评分标准2': {'得分': 3, '挑剔报告': '答案错误,对于xxx概念理解完全错误,导致回答有误'} +} +``` +输出: +11 +下面是真正的输入: +""" + +INSTRUCTION_TOTAL_SCORE_PROMPT_EN = """ +You are an expert in file processing. Your task is very simple. You will be given a segment of evaluation comments provided by another teacher. You need to extract the scores for each criterion and calculate the total score, returning only the total score. +""" + + +RESPONSE_TOTAL_SCORE_HINT_EN=""" +Your return must contain and only contain an integer representing the score. For example: +Input: +``` +{'Criterion 1': {'Score': 8, 'Critical Report': 'The answer is correct, but there is a mistake in the explanation of the xxx concept'}, + 'Criterion 2': {'Score': 3, 'Critical Report': 'The answer is incorrect, with a complete misunderstanding of the xxx concept, leading to an incorrect response'} +} +``` +Output: +``` +{'output': 11} +``` +Below is the actual input: +""" + + +class TotalScoreAgent(AgentBase): + """ + TotalScoreAgent is a agent that can gather students' all score. + """ + def __init__(self, name: str, model_config_name: str, input: str, + service_toolkit: ServiceToolkit, + sys_prompt: str = "You're a helpful assistant.", + max_iters: int = 5, + verbose: bool = True, + **kwargs): + self.service_toolkit = service_toolkit + super().__init__( + name=name, + sys_prompt=sys_prompt, + model_config_name=model_config_name, + ) + self.max_iters = max_iters + self.verbose = verbose + if not sys_prompt.endswith("\n"): + sys_prompt = sys_prompt + "\n" + + self.sys_prompt = "\n".join( + [ + # The brief intro of the role and target + sys_prompt.format(name=self.name), + # The detailed instruction prompt for the agent + INSTRUCTION_TOTAL_SCORE_PROMPT_CN, + RESPONSE_TOTAL_SCORE_HINT_CN + ], + ) + self.memory = TemporaryMemory() + self.memory.add(Msg("system", self.sys_prompt, role="system")) + + self.memory.add(Msg("User", input, role="system")) + self.parser = MarkdownJsonDictParser( + content_hint={ + "output": "total score", + }, + required_keys=["output"], + # Only print the speak field when verbose is False + keys_to_content=True if self.verbose else "speak", + ) + + def reply(self, x = None, user_backboard = ""): + for _ in range(self.max_iters): + if self.verbose: + self.speak(f" ITER {_+1} ".center(70, "#")) + try: + + hint_msg = Msg( + "system", + self.parser.format_instruction+"\n", + role="system", + echo=self.verbose, + ) + prompt = self.model.format(self.memory.get_memory(),hint_msg + ) + if self.verbose: + self.speak(f"API Trigger".center(70, "#")) + self.speak(str(prompt)) + res = self.model( + prompt, + parse_func=self.parser.parse, + max_retries=2, + ###################### + ) + + print('====-======-=====') + + return res.parsed['output'] + + + if self.verbose: + self.speak(f"Result Parsed".center(70, "#")) + self.speak(str(res)) + print(res) + + return res + except ResponseParsingError as e: + # Print out raw response from models for developers to debug + response_msg = Msg(self.name, e.raw_response, "assistant") + self.speak(response_msg) + # Re-correct by model itself + error_msg = Msg("system", str(e), "system") + self.speak(error_msg) + self.memory.add([response_msg, error_msg]) + except Exception as e: + self.speak(f"Error: {e}".center(70, "#")) + self.speak(f"Retrying".center(70, "#")) + continue + + return Msg(self.name, "Error: Max iterations reached", "assistant") + diff --git a/AlgoriAgent/projects/algoriAgent/agent_manager.py b/AlgoriAgent/projects/algoriAgent/agent_manager.py index 128e80b..a2f35bd 100644 --- a/AlgoriAgent/projects/algoriAgent/agent_manager.py +++ b/AlgoriAgent/projects/algoriAgent/agent_manager.py @@ -1,235 +1,329 @@ -import sys -import os -current_directory = os.path.dirname(os.path.abspath(__file__)) -sys.path.append(current_directory) - -import agentscope -from agentscope.message import Msg -import os -import asyncio -import threading -import json - -from agent.flex_service_toolkit import * -from AlgoriAgent.projects.algoriAgent.agent.algori_agent import * - -from agentscope.service import ( - ServiceToolkit, - ServiceResponse, - ServiceExecStatus, -) -import configparser - -config = configparser.ConfigParser() -config.read('config.ini') -openai_api_key = config['Global']['api_key'] - - - -OPENAI_CFG_DICT = { - "config_name": "openai_cfg", # 此配置的名称,必须保证唯一 - "model_type": "openai_chat", # 模型类型 - "model_name": "gpt-4o-mini", # 模型名称 - #"model_name": "gpt-4", # 模型名称 - #"model_name": "llama3", - - "api_key": openai_api_key, # OpenAI API key. 如果没有设置,将使用环境变量中的 OPENAI_API_KEY - - "client_args": { - "base_url": config['Global']['base_chat_url'] - }, - -} - -import uuid -from AlgoriAgent.projects.algoriAgent.tools.judge_tools import judge -EMPTY_CHAPTER_CHAIN = [ Chapter(1, CHAPTER_FOCUS, "本章是未打开某个具体章节时的默认章节。", "处于本章节时不会有任何章节跳转。请作为一名经验丰富的算法教师,回答用户的问题。") ] - -def tool_name_to_tool(tool_name_list): - tools = [] - for tool_name in tool_name_list: - if tool_name == "": - continue - if tool_name == "judge": - tools.append(judge) - - return tools - -class AgentManager: - def __init__(self): - - agentscope.init(model_configs=[OPENAI_CFG_DICT])#, studio_url="http://0.0.0.0:5000") - self.agents = {} - - def new_agent(self, markdown:str, markdown_prompt:str, score_prompt:str, id = None): - ''' - markdown: 教案的markdown文件内容 - markdown_prompt: 教案的prompt的markdown文件内容 - score_prompt: 评分的prompt的markdown文件内容 - 根据3个教案的prompt,生成一个agent,返回agent的id与agent - ''' - markdown_list = markdown.split("\n") - markdown_prompt_list = markdown_prompt.split("\n") - score_prompt_list = score_prompt.split("\n") - # 获取 H1 标题 - title = "" - for line in markdown_list: - if line.startswith("# "): - title = line[2:] - break - - # 对于 H3 标题 构造每一个 Chapter - # 首先找到所有的 H3 标题 - chapter_dict = {} - chapter_sequence = [] - for line in markdown_list: - if line.startswith("### "): - chapter_name = line[4:] - chapter_dict[chapter_name] = {} - chapter_sequence.append(chapter_name) - # 将 H3 标题 和 其对应的内容 构造成一个 Chapter - - h3_name = "" - content = "" - for i in range(len(markdown_list)): - if markdown_list[i].startswith("### "): - if(h3_name != ""): - chapter_dict[h3_name]["markdown"] = content - h3_name = markdown_list[i][4:] - content = "" - continue - if h3_name != "": - content += markdown_list[i]+"\n" - if(h3_name != ""): - chapter_dict[h3_name]["markdown"] = content - - - h3_name = "" - content = "" - require_tools = [] - for i in range(len(markdown_prompt_list)): - if markdown_prompt_list[i].startswith("### "): - if(h3_name != ""): - chapter_dict[h3_name]["markdown_prompt"] = content - chapter_dict[h3_name]["require_tools"] = tool_name_to_tool(require_tools) - h3_name = markdown_prompt_list[i][4:] - content = "" - continue - - if h3_name != "": - if markdown_prompt_list[i].startswith("_require_tools"): - require_tools.append(markdown_prompt_list[i].split("=")[1].strip()) - continue - content += markdown_prompt_list[i]+"\n" - if(h3_name != ""): - chapter_dict[h3_name]["markdown_prompt"] = content - chapter_dict[h3_name]["require_tools"] = tool_name_to_tool(require_tools) - - - h3_name = "" - content = "" - for i in range(len(score_prompt_list)): - if score_prompt_list[i].startswith("### "): - if(h3_name != ""): - chapter_dict[h3_name]["score_prompt"] = content - h3_name = score_prompt_list[i][4:] - content = "" - continue - - if h3_name != "": - content += score_prompt_list[i]+"\n" - if(h3_name != ""): - chapter_dict[h3_name]["score_prompt"] = content - - - chapter_chain = [] - No = 1 - print (chapter_dict) - for chapter_name in chapter_sequence: - chapter_chain.append(Chapter(No, CHAPTER_LATTER, title, chapter_dict[chapter_name]["markdown"], chapter_dict[chapter_name]["markdown_prompt"], chapter_dict[chapter_name]["score_prompt"],chapter_dict[chapter_name]["require_tools"])) - No+=1 - chapter_chain[0].Focus() - - - # Prepare the tools for the agent - service_toolkit = FlexServiceToolkit() - # for tool_function in unity_function_list: - # service_toolkit.add(tool_function) - agent = ChapterChainAgent( - name="assistant", - model_config_name="openai_cfg", - verbose=True, - service_toolkit=service_toolkit, - max_iters=5, - chapter_chain=chapter_chain - ) - self.agents[id] = agent - return id, agent - - - - def new_agent_with_chain(self, chapter_chain = None, id = None): - ''' - - ''' - if chapter_chain is None: - chapter_chain = EMPTY_CHAPTER_CHAIN - - # Prepare the tools for the agent - service_toolkit = FlexServiceToolkit() - # for tool_function in unity_function_list: - # service_toolkit.add(tool_function) - agent = ChapterChainAgent( - name="assistant", - model_config_name="openai_cfg", - verbose=True, - service_toolkit=service_toolkit, - max_iters=5, - chapter_chain=EMPTY_CHAPTER_CHAIN - ) - if id is None: id = uuid.uuid4() - self.agents[id] = agent - return id, agent - - - def get_agent(self, id=None): - ''' - 如果在get agent之前没有new agent,并用id进行访问,就返回一个章节链为空的agent - ''' - if id: - if id in self.agents: - return self.agents[id] - self.agents[id] = self.new_agent(id)[1] - else: - id = str(uuid.uuid4()) - self.agents[id] = self.new_agent()[1] - return id, self.agents[id] - - - def invoke(self,id, query, user_backboard): - msg = Msg("user", query, role="user") - return self.agents[id](msg, user_backboard = user_backboard) - - -import time -if __name__ == '__main__': - # tool_demo = ToolDemo("Lava") - # response = tool_demo.invoke("I want such a Gurouce, when use it, it will be thrown and fly towards the mouse position for a short time, and stop. And will damage Enemy who step on it. I call it Lava Gurouce.") - # print(response) - # Start the WebSocket server in a separate thread - manager = AgentManager() - id, agent = manager.new_agent() - - # Main thread logic - try: - # Your code that might be interrupted - while True: - input_data = input("用户:") - print(manager.invoke(id, input_data)) - - except KeyboardInterrupt: - print("Process interrupted by user.") - # You can add any cleanup code here if needed - finally: - print("Exiting program.") - # Code to run before the program exits +import sys +import os +current_directory = os.path.dirname(os.path.abspath(__file__)) +sys.path.append(current_directory) +from flask_socketio import SocketIO, join_room, emit, Namespace +import agentscope +from agentscope.message import Msg +import os +import asyncio +import threading +import json + +from agent.flex_service_toolkit import * +from AlgoriAgent.projects.algoriAgent.agent.algori_agent import * + +from agentscope.service import ( + ServiceToolkit, + ServiceResponse, + ServiceExecStatus, +) +import configparser + +config = configparser.ConfigParser() +config.read('config.ini') +openai_api_key = config['Global']['api_key'] + + + +OPENAI_CFG_DICT = { + "config_name": "openai_cfg", # 此配置的名称,必须保证唯一 + "model_type": "openai_chat", # 模型类型 + "model_name": "gpt-4o-mini", # 模型名称 + #"model_name": "gpt-4", # 模型名称 + #"model_name": "llama3", + "api_key": openai_api_key, # OpenAI API key. 如果没有设置,将使用环境变量中的 OPENAI_API_KEY + + "client_args": { + "base_url": config['Global']['base_chat_url'] + }, + +} + +import uuid +from AlgoriAgent.projects.algoriAgent.tools.judge_tools import judge +EMPTY_CHAPTER_CHAIN = [ Chapter(1, CHAPTER_FOCUS, "本章是未打开某个具体章节时的默认章节。", "处于本章节时不会有任何章节跳转。请作为一名经验丰富的算法教师,回答用户的问题。") ] + +def tool_name_to_tool(tool_name_list): + tools = [] + for tool_name in tool_name_list: + if tool_name == "": + continue + if tool_name == "judge": + tools.append(judge) + + return tools + +def tool_name_to_tool_with_args(tool_name_list, tool_args_list) -> list[tuple[Callable, dict]]: + tools = [] + for tool_name, tool_args in zip(tool_name_list, tool_args_list): + if tool_name == "": + continue + if tool_name == "judge": + tools.append((judge, {"course_id": tool_args[0], "lesson_id": tool_args[1], "name": tool_args[2]})) + + return tools +class AgentManager: + def __init__(self,max_iter = 5, app=None, socketio=None): + + agentscope.init(model_configs=[OPENAI_CFG_DICT])#, studio_url="http://0.0.0.0:5000") + self.agents = {} + self.max_iter = max_iter + self.agent_to_id = {} + self.app = app + self.socketio = socketio + def new_agent(self, course_id, lesson_id, markdown:str, markdown_prompt:str, score_prompt:str, id = "Defult Assistant", root_path="."): + ''' + markdown: 教案的markdown文件内容 + markdown_prompt: 教案的prompt的markdown文件内容 + score_prompt: 评分的prompt的markdown文件内容 + 根据3个教案的prompt,生成一个agent,返回agent的id与agent + ''' + markdown_list = markdown.split("\n") + markdown_prompt_list = markdown_prompt.split("\n") + score_prompt_list = score_prompt.split("\n") + # 获取 H1 标题 + title = "" + for line in markdown_list: + if line.startswith("# "): + title = line[2:] + break + + # 对于 H3 标题 构造每一个 Chapter + # 首先找到所有的 H3 标题 + chapter_dict = {} + chapter_sequence = [] + for line in markdown_list: + if line.startswith("### "): + chapter_name = line[4:] + chapter_dict[chapter_name] = {} + chapter_sequence.append(chapter_name) + # 将 H3 标题 和 其对应的内容 构造成一个 Chapter + + h3_name = "" + content = "" + for i in range(len(markdown_list)): + if markdown_list[i].startswith("### "): + if(h3_name != ""): + chapter_dict[h3_name]["markdown"] = content + h3_name = markdown_list[i][4:] + content = "" + continue + if h3_name != "": + content += markdown_list[i]+"\n" + if(h3_name != ""): + chapter_dict[h3_name]["markdown"] = content + + + h3_name = "" + content = "" + require_tools = [] + require_tools_args = [] + for i in range(len(markdown_prompt_list)): + if markdown_prompt_list[i].startswith("### "): + if(h3_name != ""): + chapter_dict[h3_name]["markdown_prompt"] = content + chapter_dict[h3_name]["require_tools"] = tool_name_to_tool_with_args(require_tools, require_tools_args) + h3_name = markdown_prompt_list[i][4:] + content = "" + require_tools=[] + require_tools_args = [] + continue + + if h3_name != "": + if markdown_prompt_list[i].startswith("_require_tools"): + require_tools.append(markdown_prompt_list[i].split("=")[1].strip().split(",")[0]) + require_tools_args.append((markdown_prompt_list[i].split("=")[1].strip().split(",")[1:])) + continue + content += markdown_prompt_list[i]+"\n" + if(h3_name != ""): + chapter_dict[h3_name]["markdown_prompt"] = content + chapter_dict[h3_name]["require_tools"] = tool_name_to_tool_with_args(require_tools, require_tools_args) + + + h3_name = "" + content = "" + for i in range(len(score_prompt_list)): + if score_prompt_list[i].startswith("### "): + if(h3_name != ""): + chapter_dict[h3_name]["score_prompt"] = content + h3_name = score_prompt_list[i][4:] + content = "" + continue + + if h3_name != "": + content += score_prompt_list[i]+"\n" + if(h3_name != ""): + chapter_dict[h3_name]["score_prompt"] = content + + + chapter_chain = [] + No = 1 + print (chapter_dict) + for chapter_name in chapter_sequence: + chapter_chain.append(Chapter(course_id, lesson_id, No, CHAPTER_LATTER, chapter_name, chapter_dict[chapter_name]["markdown"], chapter_dict[chapter_name]["markdown_prompt"], chapter_dict[chapter_name]["score_prompt"],chapter_dict[chapter_name]["require_tools"])) + No+=1 + chapter_chain[0].Focus() + + + # Prepare the tools for the agent + service_toolkit = FlexServiceToolkit() + # for tool_function in unity_function_list: + # service_toolkit.add(tool_function) + agent = ChapterChainAgent( + name=id, + model_config_name="openai_cfg", + verbose=True, + service_toolkit=service_toolkit, + max_iters=5, + chapter_chain=chapter_chain, + root_path = root_path, + ) + self.agents[id] = agent + self.agent_to_id[agent] = id + agent.agent_manager = self + return id, agent + + def message_pass(self, agent, messagetype, message): + id = self.agent_to_id[agent] + print("message_pass", id, messagetype, message) + with self.app.app_context(): + try: + self.socketio.emit(messagetype, message, room=id, namespace='/agent') + except Exception as e: + print("message_pass",e) + + def system_message(self, message): + with self.app.app_context(): + try: + self.socketio.emit('system_message', message, room=id, namespace='/agent') + except Exception as e: + print("ERROR: system_message",e) + + + def save_chapter_memory(self, agent,course_id, lesson_id, subchapter_title, mem_list, score, is_rebuttal): + id = self.agent_to_id[agent] + self.app.my_function.save_chapter_memory(id, course_id, lesson_id, subchapter_title, mem_list, score, is_rebuttal) + + + def new_agent_with_chain(self, chapter_chain = None, id = None): + if chapter_chain is None: + chapter_chain = EMPTY_CHAPTER_CHAIN + + # Prepare the tools for the agent + service_toolkit = FlexServiceToolkit() + # for tool_function in unity_function_list: + # service_toolkit.add(tool_function) + agent = ChapterChainAgent( + name="assistant", + model_config_name="openai_cfg", + verbose=True, + service_toolkit=service_toolkit, + max_iters=5, + chapter_chain=EMPTY_CHAPTER_CHAIN + ) + if id is None: id = uuid.uuid4() + self.agents[id] = agent + return id, agent + + + def get_agent(self, id=None): + ''' + 如果在get agent之前没有new agent,并用id进行访问,就返回一个章节链为空的agent + ''' + if id: + if id in self.agents: + return self.agents[id] + self.agents[id] = self.new_agent(id)[1] + else: + id = str(uuid.uuid4()) + self.agents[id] = self.new_agent()[1] + return id, self.agents[id] + + + def invoke(self,id, query, user_backboard, reset=False): + msg = Msg("user", query, role="user") + agent = self.agents[id] + res = agent(msg, user_backboard=user_backboard) + return res + # 暂时取消生成器的写法 + # 假设 agent 是一个生成器 + # if reset or not hasattr(agent, '_generator'): + # agent._generator = agent(msg, user_backboard=user_backboard) + + # try: + # response = next(agent._generator) + # yield response + # except StopIteration: + # return + + def function_call(self, id, arg_function): + agent = self.agents[id] + return agent.function_call(arg_function) + + def change_language(self, id, language): + agent = self.agents[id] + agent.change_language(language) + + def sample_judge(self, id, bb): + agent = self.agents[id] + + with self.app.app_context(): + try: + print(bb.get_active_file_reletive_path()) + assert bb is not None and bb.active_file_path != "" , "no path specified" + if bb.get_active_file_reletive_path().endswith(".py"): + self.socketio.emit('terminal', {'data': f"python {bb.get_active_file_reletive_path()}"}, room=id, namespace='/vscode') + self.socketio.emit('system_message', "代码试运行尚在建设,推荐直接通过命令行执行!", room=id, namespace='/agent') + else: + self.socketio.emit('system_message', "代码试运行尚仅支持python文件", room=id, namespace='/agent') + except Exception as e: + print(e) + if (str(e) == "no path specified"): + self.socketio.emit("system_message", "未加载IDE文件同步,请尝试重新打开IDE文件或刷新页面,并确保插件已连接", room=id, namespace='/agent') + + def judge(self, id, bb): + agent = self.agents[id] + with self.app.app_context(): + try: + if (agent.chapter_chain[agent.chapter_chain_now].append_tools is not None and len(agent.chapter_chain[agent.chapter_chain_now].append_tools)): + for tool, tool_kwargs in agent.chapter_chain[agent.chapter_chain_now].append_tools: + if tool.__name__ == "judge": + print(bb.get_active_file_reletive_path()) + assert bb is not None and bb.active_file_path != "" , "no path specified" + if bb.get_active_file_reletive_path().endswith(".py"): + # self.socketio.emit('terminal', {'data': f"python {bb.get_active_file_reletive_path()}"}, room=id, namespace='/vscode') + self.socketio.emit('system_message', "代码评测中,请稍后", room=id, namespace='/agent') + agent.function_call({'name':'judge','arguments':{'filepath': bb.get_active_file_reletive_path()}}) + else: + self.socketio.emit('system_message', "代码评测尚仅支持python文件", room=id, namespace='/agent') + + else: + with self.app.app_context(): + self.socketio.emit("system_message", "本章学习无需评测", room=id, namespace='/agent') + else: + with self.app.app_context(): + self.socketio.emit("system_message", "本章学习无需评测", room=id, namespace='/agent') + except Exception as e: + if (str(e) == "no path specified"): + self.socketio.emit("system_message", "未加载IDE文件同步,请尝试重新打开IDE文件或刷新页面,并确保插件已连接", room=id, namespace='/agent') + + +import time +if __name__ == '__main__': + manager = AgentManager() + id, agent = manager.new_agent() + + # Main thread logic + try: + # Your code that might be interrupted + while True: + input_data = input("用户:") + print(manager.invoke(id, input_data)) + + except KeyboardInterrupt: + print("Process interrupted by user.") + # You can add any cleanup code here if needed + finally: + print("Exiting program.") + # Code to run before the program exits diff --git a/AlgoriAgent/projects/algoriAgent/tools/__pycache__/__init__.cpython-310.pyc b/AlgoriAgent/projects/algoriAgent/tools/__pycache__/__init__.cpython-310.pyc index 36bf43a..bdca170 100644 Binary files a/AlgoriAgent/projects/algoriAgent/tools/__pycache__/__init__.cpython-310.pyc and b/AlgoriAgent/projects/algoriAgent/tools/__pycache__/__init__.cpython-310.pyc differ diff --git a/AlgoriAgent/projects/algoriAgent/tools/__pycache__/judge_tools.cpython-310.pyc b/AlgoriAgent/projects/algoriAgent/tools/__pycache__/judge_tools.cpython-310.pyc index 2cb7089..c90bb77 100644 Binary files a/AlgoriAgent/projects/algoriAgent/tools/__pycache__/judge_tools.cpython-310.pyc and b/AlgoriAgent/projects/algoriAgent/tools/__pycache__/judge_tools.cpython-310.pyc differ diff --git a/AlgoriAgent/projects/algoriAgent/tools/file_tools.py b/AlgoriAgent/projects/algoriAgent/tools/file_tools.py new file mode 100644 index 0000000..1bd232e --- /dev/null +++ b/AlgoriAgent/projects/algoriAgent/tools/file_tools.py @@ -0,0 +1,54 @@ +from agentscope.service.service_toolkit import ServiceFunction +from agentscope.service import ( + ServiceToolkit, + ServiceResponse, + ServiceExecStatus, +) +import os +def read_file(filepath:str, root_path:str): + """Read the file and return the content. Remember use 'judge' function if you want to judge file, instead of this function. + + Args: + filepath (`str`): The path to the file. + root_path (`str`): The root path of now student's workspace. + + Returns: + content (`str`): The content of the file. + """ + # 从books/code_tests/name/中获取所有.in文件 + + filepath = os.path.join('..', root_path, filepath) + try: + with open(filepath, 'r') as f: + content = f.read() + except Exception as e: + status = ServiceExecStatus.ERROR + content = str(e) + return ServiceResponse(status, (content)) + + status = ServiceExecStatus.SUCCESS + return ServiceResponse(status, ('```\n'+content+'```\n')) + + +def write_file(filepath:str, content:str, root_path:str): + """Write content to the file. + + Args: + filepath (`str`): The path to the file. + content (`str`): The content to be written to the file. + root_path (`str`): The root path of now student's workspace. + + Returns: + None. + """ + filepath = os.path.join('..', root_path, filepath) + try: + with open(filepath, 'w') as f: + f.write(content) + except Exception as e: + status = ServiceExecStatus.ERROR + return ServiceResponse(status, None) + status = ServiceExecStatus.SUCCESS + return ServiceResponse(status, None) + +file_tools = [read_file, write_file] \ No newline at end of file diff --git a/AlgoriAgent/projects/algoriAgent/tools/judge_tools.py b/AlgoriAgent/projects/algoriAgent/tools/judge_tools.py index 5b7ce5b..c434540 100644 --- a/AlgoriAgent/projects/algoriAgent/tools/judge_tools.py +++ b/AlgoriAgent/projects/algoriAgent/tools/judge_tools.py @@ -1,64 +1,78 @@ -from agentscope.service.service_toolkit import ServiceFunction -from agentscope.service import ( - ServiceToolkit, - ServiceResponse, - ServiceExecStatus, -) -import os -def judge(filepath:str, name: str): - """Call this method to judge the student's solution after they have completed the problem. - - Args: - filepath (`str`): The path to the file containing the student's solution. - name (`str`): The name of the problem. - - Returns: - Report `tuple(int,str)`: The report of the student's solution. - """ - # 从books/code_tests/name/中获取所有.in文件 - - directory = 'books/code_tests/'+name - # 如果目录不存在,报错 - if not os.path.exists(directory): - status = ServiceExecStatus.FAILED - return ServiceResponse(status, f"The name {name} is not found.") - files = os.listdir(directory) - in_files = [file for file in files if file.endswith('.in')] - save_dir = os.path.dirname(filepath) - Report = "" - passed_num=0 - failed_num=0 - for file in in_files: - os.remove(os.path.join(save_dir, f"_{name}.out")) - cmd = "cat " + os.path.join(directory, file) + " | " + "python " + filepath +" > " + os.path.join(save_dir, f"_{name}.out") - os.system(cmd) - # 比较结果 - re = "" - if compare_file(os.path.join(save_dir, f"_{name}.out"), os.path.join(directory, file.replace(".in", ".out"))): - re = "Passed {file}" - passed_num += 1 - else: - re = "Failed {file}" - failed_num += 1 - Report = Report + re + "\n" - os.remove(os.path.join(save_dir, f"_{name}.out")) - score = int (100 * passed_num / (passed_num + failed_num)) - - - - status = ServiceExecStatus.SUCCESS - return ServiceResponse(status, (Report, score)) - - -def compare_file(path1:str, path2:str): - """ - Compare two files and return true if they are the same. - """ - with open(path1, 'r') as f1, open(path2, 'r') as f2: - # 逐行比较 - for line1, line2 in zip(f1, f2): - if line1.strip() != line2.strip(): - return False - return True - +from agentscope.service.service_toolkit import ServiceFunction +from agentscope.service import ( + ServiceToolkit, + ServiceResponse, + ServiceExecStatus, +) +import os +def judge(filepath:str, name: str, course_id: str, lesson_id: str, root_path:str): + """Call this method to judge the student's solution after they have completed the problem. + + Args: + filepath (`str`): The path to the file containing the student's solution. + name (`str`): The name of the problem. + course_id (`str`): The id of the course. + lesson_id (`str`): The id of the lesson. + root_path (`str`): The root path of the user's workspace project. + + Returns: + Report `tuple(int,str)`: The report of the student's solution. + """ + # 从books/code_tests/name/中获取所有.in文件 + + directory = 'books/code_tests/'+course_id+'/'+name + # 如果目录不存在,报错 + if not os.path.exists(directory): + status = ServiceExecStatus.FAILED + return ServiceResponse(status, f"The name {name} is not found.") + files = os.listdir(directory) + in_files = [file for file in files if file.endswith('.in')] + save_dir = root_path + Report = "" + passed_num=0 + failed_num=0 + erroroutput = "" + exceptoutput="" + for file in in_files: + file_path = os.path.join(save_dir, f"_{name}.out") + if os.path.exists(file_path): + os.remove(file_path) + with open(file_path, 'w') as ff: + ff.write("") + + cmd = "cat " + os.path.join(directory, file) + " | " + "python " + os.path.join(root_path, filepath) +" > " + os.path.join(save_dir, f"_{name}.out") + os.system(cmd) + # 比较结果 + re = "" + if compare_file(os.path.join(save_dir, f"_{name}.out"), os.path.join(directory, file.replace(".in", ".out"))): + re = f"Passed {file}" + passed_num += 1 + else: + re = f"Failed {file}" + failed_num += 1 + with open(os.path.join(directory, file.replace(".in", ".out")),'r') as f: exceptoutput = f.read() + with open(os.path.join(save_dir, f"_{name}.out"),'r') as f: erroroutput = f.read() + Report = Report + re + "\n" + os.remove(os.path.join(save_dir, f"_{name}.out")) + score = int (100 * passed_num / (passed_num + failed_num)) + + + + status = ServiceExecStatus.SUCCESS + return ServiceResponse(status, (score, f"评测得分为 {score}, 在 {passed_num + failed_num} 个测试用例中通过了 {passed_num}个。最后一个错误样例期望输出:'{exceptoutput}',但你的输出:'{erroroutput}")) + + +def compare_file(path1:str, path2:str): + """ + Compare two files and return true if they are the same. + """ + with open(path1, 'r') as f1, open(path2, 'r') as f2: + # 逐行比较 + print('-------------------COMPARE-------------------------') + for line1, line2 in zip(f1, f2): + print(line1.strip(), "||",line2.strip()) + if line1.strip() != line2.strip(): + return False + return True + judge_tools = [judge] \ No newline at end of file diff --git a/AlgoriAgent/src/agentscope/__pycache__/__init__.cpython-310.pyc b/AlgoriAgent/src/agentscope/__pycache__/__init__.cpython-310.pyc index 92a3bf9..40f996a 100644 Binary files a/AlgoriAgent/src/agentscope/__pycache__/__init__.cpython-310.pyc and b/AlgoriAgent/src/agentscope/__pycache__/__init__.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/__pycache__/_init.cpython-310.pyc b/AlgoriAgent/src/agentscope/__pycache__/_init.cpython-310.pyc index 1db3ab8..80b4292 100644 Binary files a/AlgoriAgent/src/agentscope/__pycache__/_init.cpython-310.pyc and b/AlgoriAgent/src/agentscope/__pycache__/_init.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/__pycache__/_runtime.cpython-310.pyc b/AlgoriAgent/src/agentscope/__pycache__/_runtime.cpython-310.pyc index d69bbf2..0795868 100644 Binary files a/AlgoriAgent/src/agentscope/__pycache__/_runtime.cpython-310.pyc and b/AlgoriAgent/src/agentscope/__pycache__/_runtime.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/__pycache__/_version.cpython-310.pyc b/AlgoriAgent/src/agentscope/__pycache__/_version.cpython-310.pyc index 06773cc..413879d 100644 Binary files a/AlgoriAgent/src/agentscope/__pycache__/_version.cpython-310.pyc and b/AlgoriAgent/src/agentscope/__pycache__/_version.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/__pycache__/constants.cpython-310.pyc b/AlgoriAgent/src/agentscope/__pycache__/constants.cpython-310.pyc index 3d462ca..6c56bec 100644 Binary files a/AlgoriAgent/src/agentscope/__pycache__/constants.cpython-310.pyc and b/AlgoriAgent/src/agentscope/__pycache__/constants.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/__pycache__/exception.cpython-310.pyc b/AlgoriAgent/src/agentscope/__pycache__/exception.cpython-310.pyc index f32c39c..63925d5 100644 Binary files a/AlgoriAgent/src/agentscope/__pycache__/exception.cpython-310.pyc and b/AlgoriAgent/src/agentscope/__pycache__/exception.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/__pycache__/file_manager.cpython-310.pyc b/AlgoriAgent/src/agentscope/__pycache__/file_manager.cpython-310.pyc index a6699ea..8ad297a 100644 Binary files a/AlgoriAgent/src/agentscope/__pycache__/file_manager.cpython-310.pyc and b/AlgoriAgent/src/agentscope/__pycache__/file_manager.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/__pycache__/logging.cpython-310.pyc b/AlgoriAgent/src/agentscope/__pycache__/logging.cpython-310.pyc index 9c2ee62..c007dff 100644 Binary files a/AlgoriAgent/src/agentscope/__pycache__/logging.cpython-310.pyc and b/AlgoriAgent/src/agentscope/__pycache__/logging.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/__pycache__/message.cpython-310.pyc b/AlgoriAgent/src/agentscope/__pycache__/message.cpython-310.pyc index b26e810..1871fb5 100644 Binary files a/AlgoriAgent/src/agentscope/__pycache__/message.cpython-310.pyc and b/AlgoriAgent/src/agentscope/__pycache__/message.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/__pycache__/msghub.cpython-310.pyc b/AlgoriAgent/src/agentscope/__pycache__/msghub.cpython-310.pyc index b8379f6..375997f 100644 Binary files a/AlgoriAgent/src/agentscope/__pycache__/msghub.cpython-310.pyc and b/AlgoriAgent/src/agentscope/__pycache__/msghub.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/agents/__pycache__/__init__.cpython-310.pyc b/AlgoriAgent/src/agentscope/agents/__pycache__/__init__.cpython-310.pyc index 70a678c..b372256 100644 Binary files a/AlgoriAgent/src/agentscope/agents/__pycache__/__init__.cpython-310.pyc and b/AlgoriAgent/src/agentscope/agents/__pycache__/__init__.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/agents/__pycache__/agent.cpython-310.pyc b/AlgoriAgent/src/agentscope/agents/__pycache__/agent.cpython-310.pyc index d044bd5..b2de94e 100644 Binary files a/AlgoriAgent/src/agentscope/agents/__pycache__/agent.cpython-310.pyc and b/AlgoriAgent/src/agentscope/agents/__pycache__/agent.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/agents/__pycache__/dialog_agent.cpython-310.pyc b/AlgoriAgent/src/agentscope/agents/__pycache__/dialog_agent.cpython-310.pyc index 87a5af9..d9bd920 100644 Binary files a/AlgoriAgent/src/agentscope/agents/__pycache__/dialog_agent.cpython-310.pyc and b/AlgoriAgent/src/agentscope/agents/__pycache__/dialog_agent.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/agents/__pycache__/dict_dialog_agent.cpython-310.pyc b/AlgoriAgent/src/agentscope/agents/__pycache__/dict_dialog_agent.cpython-310.pyc index 1e592ac..6ad5b3b 100644 Binary files a/AlgoriAgent/src/agentscope/agents/__pycache__/dict_dialog_agent.cpython-310.pyc and b/AlgoriAgent/src/agentscope/agents/__pycache__/dict_dialog_agent.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/agents/__pycache__/operator.cpython-310.pyc b/AlgoriAgent/src/agentscope/agents/__pycache__/operator.cpython-310.pyc index d077370..873f5f3 100644 Binary files a/AlgoriAgent/src/agentscope/agents/__pycache__/operator.cpython-310.pyc and b/AlgoriAgent/src/agentscope/agents/__pycache__/operator.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/agents/__pycache__/rag_agent.cpython-310.pyc b/AlgoriAgent/src/agentscope/agents/__pycache__/rag_agent.cpython-310.pyc index 3cf0dfc..5fabaaf 100644 Binary files a/AlgoriAgent/src/agentscope/agents/__pycache__/rag_agent.cpython-310.pyc and b/AlgoriAgent/src/agentscope/agents/__pycache__/rag_agent.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/agents/__pycache__/react_agent.cpython-310.pyc b/AlgoriAgent/src/agentscope/agents/__pycache__/react_agent.cpython-310.pyc index dff44f6..8823671 100644 Binary files a/AlgoriAgent/src/agentscope/agents/__pycache__/react_agent.cpython-310.pyc and b/AlgoriAgent/src/agentscope/agents/__pycache__/react_agent.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/agents/__pycache__/rpc_agent.cpython-310.pyc b/AlgoriAgent/src/agentscope/agents/__pycache__/rpc_agent.cpython-310.pyc index 9c9b69a..17a3287 100644 Binary files a/AlgoriAgent/src/agentscope/agents/__pycache__/rpc_agent.cpython-310.pyc and b/AlgoriAgent/src/agentscope/agents/__pycache__/rpc_agent.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/agents/__pycache__/text_to_image_agent.cpython-310.pyc b/AlgoriAgent/src/agentscope/agents/__pycache__/text_to_image_agent.cpython-310.pyc index edec4cd..35efa0a 100644 Binary files a/AlgoriAgent/src/agentscope/agents/__pycache__/text_to_image_agent.cpython-310.pyc and b/AlgoriAgent/src/agentscope/agents/__pycache__/text_to_image_agent.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/agents/__pycache__/user_agent.cpython-310.pyc b/AlgoriAgent/src/agentscope/agents/__pycache__/user_agent.cpython-310.pyc index dbf9653..0352247 100644 Binary files a/AlgoriAgent/src/agentscope/agents/__pycache__/user_agent.cpython-310.pyc and b/AlgoriAgent/src/agentscope/agents/__pycache__/user_agent.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/memory/__pycache__/__init__.cpython-310.pyc b/AlgoriAgent/src/agentscope/memory/__pycache__/__init__.cpython-310.pyc index dbc3eb9..f6d8505 100644 Binary files a/AlgoriAgent/src/agentscope/memory/__pycache__/__init__.cpython-310.pyc and b/AlgoriAgent/src/agentscope/memory/__pycache__/__init__.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/memory/__pycache__/memory.cpython-310.pyc b/AlgoriAgent/src/agentscope/memory/__pycache__/memory.cpython-310.pyc index 6021c86..df244a2 100644 Binary files a/AlgoriAgent/src/agentscope/memory/__pycache__/memory.cpython-310.pyc and b/AlgoriAgent/src/agentscope/memory/__pycache__/memory.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/memory/__pycache__/temporary_memory.cpython-310.pyc b/AlgoriAgent/src/agentscope/memory/__pycache__/temporary_memory.cpython-310.pyc index 892b46b..02f360b 100644 Binary files a/AlgoriAgent/src/agentscope/memory/__pycache__/temporary_memory.cpython-310.pyc and b/AlgoriAgent/src/agentscope/memory/__pycache__/temporary_memory.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/models/__pycache__/__init__.cpython-310.pyc b/AlgoriAgent/src/agentscope/models/__pycache__/__init__.cpython-310.pyc index f084595..8f715aa 100644 Binary files a/AlgoriAgent/src/agentscope/models/__pycache__/__init__.cpython-310.pyc and b/AlgoriAgent/src/agentscope/models/__pycache__/__init__.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/models/__pycache__/config.cpython-310.pyc b/AlgoriAgent/src/agentscope/models/__pycache__/config.cpython-310.pyc index 317c2de..be0fc05 100644 Binary files a/AlgoriAgent/src/agentscope/models/__pycache__/config.cpython-310.pyc and b/AlgoriAgent/src/agentscope/models/__pycache__/config.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/models/__pycache__/dashscope_model.cpython-310.pyc b/AlgoriAgent/src/agentscope/models/__pycache__/dashscope_model.cpython-310.pyc index d96a15c..a823dfc 100644 Binary files a/AlgoriAgent/src/agentscope/models/__pycache__/dashscope_model.cpython-310.pyc and b/AlgoriAgent/src/agentscope/models/__pycache__/dashscope_model.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/models/__pycache__/gemini_model.cpython-310.pyc b/AlgoriAgent/src/agentscope/models/__pycache__/gemini_model.cpython-310.pyc index 6f8884b..39a3040 100644 Binary files a/AlgoriAgent/src/agentscope/models/__pycache__/gemini_model.cpython-310.pyc and b/AlgoriAgent/src/agentscope/models/__pycache__/gemini_model.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/models/__pycache__/litellm_model.cpython-310.pyc b/AlgoriAgent/src/agentscope/models/__pycache__/litellm_model.cpython-310.pyc index 34e7155..ac51971 100644 Binary files a/AlgoriAgent/src/agentscope/models/__pycache__/litellm_model.cpython-310.pyc and b/AlgoriAgent/src/agentscope/models/__pycache__/litellm_model.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/models/__pycache__/model.cpython-310.pyc b/AlgoriAgent/src/agentscope/models/__pycache__/model.cpython-310.pyc index f5dc171..d17ee41 100644 Binary files a/AlgoriAgent/src/agentscope/models/__pycache__/model.cpython-310.pyc and b/AlgoriAgent/src/agentscope/models/__pycache__/model.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/models/__pycache__/ollama_model.cpython-310.pyc b/AlgoriAgent/src/agentscope/models/__pycache__/ollama_model.cpython-310.pyc index cc86f6b..6f7ea7a 100644 Binary files a/AlgoriAgent/src/agentscope/models/__pycache__/ollama_model.cpython-310.pyc and b/AlgoriAgent/src/agentscope/models/__pycache__/ollama_model.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/models/__pycache__/openai_model.cpython-310.pyc b/AlgoriAgent/src/agentscope/models/__pycache__/openai_model.cpython-310.pyc index 1a116d4..b9e2f94 100644 Binary files a/AlgoriAgent/src/agentscope/models/__pycache__/openai_model.cpython-310.pyc and b/AlgoriAgent/src/agentscope/models/__pycache__/openai_model.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/models/__pycache__/post_model.cpython-310.pyc b/AlgoriAgent/src/agentscope/models/__pycache__/post_model.cpython-310.pyc index d3c2c86..2c6c4f1 100644 Binary files a/AlgoriAgent/src/agentscope/models/__pycache__/post_model.cpython-310.pyc and b/AlgoriAgent/src/agentscope/models/__pycache__/post_model.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/models/__pycache__/response.cpython-310.pyc b/AlgoriAgent/src/agentscope/models/__pycache__/response.cpython-310.pyc index 00b10fc..579c346 100644 Binary files a/AlgoriAgent/src/agentscope/models/__pycache__/response.cpython-310.pyc and b/AlgoriAgent/src/agentscope/models/__pycache__/response.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/models/__pycache__/zhipu_model.cpython-310.pyc b/AlgoriAgent/src/agentscope/models/__pycache__/zhipu_model.cpython-310.pyc index b92c18e..bf695a7 100644 Binary files a/AlgoriAgent/src/agentscope/models/__pycache__/zhipu_model.cpython-310.pyc and b/AlgoriAgent/src/agentscope/models/__pycache__/zhipu_model.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/parsers/__pycache__/__init__.cpython-310.pyc b/AlgoriAgent/src/agentscope/parsers/__pycache__/__init__.cpython-310.pyc index fb58c2c..7e7365b 100644 Binary files a/AlgoriAgent/src/agentscope/parsers/__pycache__/__init__.cpython-310.pyc and b/AlgoriAgent/src/agentscope/parsers/__pycache__/__init__.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/parsers/__pycache__/code_block_parser.cpython-310.pyc b/AlgoriAgent/src/agentscope/parsers/__pycache__/code_block_parser.cpython-310.pyc index 3dc7d15..eea1722 100644 Binary files a/AlgoriAgent/src/agentscope/parsers/__pycache__/code_block_parser.cpython-310.pyc and b/AlgoriAgent/src/agentscope/parsers/__pycache__/code_block_parser.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/parsers/__pycache__/json_object_parser.cpython-310.pyc b/AlgoriAgent/src/agentscope/parsers/__pycache__/json_object_parser.cpython-310.pyc index 103c93e..e33a08a 100644 Binary files a/AlgoriAgent/src/agentscope/parsers/__pycache__/json_object_parser.cpython-310.pyc and b/AlgoriAgent/src/agentscope/parsers/__pycache__/json_object_parser.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/parsers/__pycache__/parser_base.cpython-310.pyc b/AlgoriAgent/src/agentscope/parsers/__pycache__/parser_base.cpython-310.pyc index 82465d0..37ddcdb 100644 Binary files a/AlgoriAgent/src/agentscope/parsers/__pycache__/parser_base.cpython-310.pyc and b/AlgoriAgent/src/agentscope/parsers/__pycache__/parser_base.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/parsers/__pycache__/tagged_content_parser.cpython-310.pyc b/AlgoriAgent/src/agentscope/parsers/__pycache__/tagged_content_parser.cpython-310.pyc index 984987e..3f4909b 100644 Binary files a/AlgoriAgent/src/agentscope/parsers/__pycache__/tagged_content_parser.cpython-310.pyc and b/AlgoriAgent/src/agentscope/parsers/__pycache__/tagged_content_parser.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/pipelines/__pycache__/__init__.cpython-310.pyc b/AlgoriAgent/src/agentscope/pipelines/__pycache__/__init__.cpython-310.pyc index aa2ce8c..6f22c33 100644 Binary files a/AlgoriAgent/src/agentscope/pipelines/__pycache__/__init__.cpython-310.pyc and b/AlgoriAgent/src/agentscope/pipelines/__pycache__/__init__.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/pipelines/__pycache__/functional.cpython-310.pyc b/AlgoriAgent/src/agentscope/pipelines/__pycache__/functional.cpython-310.pyc index 3fbd44f..c93d697 100644 Binary files a/AlgoriAgent/src/agentscope/pipelines/__pycache__/functional.cpython-310.pyc and b/AlgoriAgent/src/agentscope/pipelines/__pycache__/functional.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/pipelines/__pycache__/pipeline.cpython-310.pyc b/AlgoriAgent/src/agentscope/pipelines/__pycache__/pipeline.cpython-310.pyc index 1f23b72..c44fae9 100644 Binary files a/AlgoriAgent/src/agentscope/pipelines/__pycache__/pipeline.cpython-310.pyc and b/AlgoriAgent/src/agentscope/pipelines/__pycache__/pipeline.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/prompt/__pycache__/__init__.cpython-310.pyc b/AlgoriAgent/src/agentscope/prompt/__pycache__/__init__.cpython-310.pyc index 58e63a7..4c4fbb4 100644 Binary files a/AlgoriAgent/src/agentscope/prompt/__pycache__/__init__.cpython-310.pyc and b/AlgoriAgent/src/agentscope/prompt/__pycache__/__init__.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/prompt/__pycache__/_prompt_comparer.cpython-310.pyc b/AlgoriAgent/src/agentscope/prompt/__pycache__/_prompt_comparer.cpython-310.pyc index 4aaba5b..a560539 100644 Binary files a/AlgoriAgent/src/agentscope/prompt/__pycache__/_prompt_comparer.cpython-310.pyc and b/AlgoriAgent/src/agentscope/prompt/__pycache__/_prompt_comparer.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/prompt/__pycache__/_prompt_engine.cpython-310.pyc b/AlgoriAgent/src/agentscope/prompt/__pycache__/_prompt_engine.cpython-310.pyc index 48c176d..f7e1abb 100644 Binary files a/AlgoriAgent/src/agentscope/prompt/__pycache__/_prompt_engine.cpython-310.pyc and b/AlgoriAgent/src/agentscope/prompt/__pycache__/_prompt_engine.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/prompt/__pycache__/_prompt_generator_base.cpython-310.pyc b/AlgoriAgent/src/agentscope/prompt/__pycache__/_prompt_generator_base.cpython-310.pyc index d8d1a35..a8ed295 100644 Binary files a/AlgoriAgent/src/agentscope/prompt/__pycache__/_prompt_generator_base.cpython-310.pyc and b/AlgoriAgent/src/agentscope/prompt/__pycache__/_prompt_generator_base.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/prompt/__pycache__/_prompt_generator_en.cpython-310.pyc b/AlgoriAgent/src/agentscope/prompt/__pycache__/_prompt_generator_en.cpython-310.pyc index 590f2a6..3632cd9 100644 Binary files a/AlgoriAgent/src/agentscope/prompt/__pycache__/_prompt_generator_en.cpython-310.pyc and b/AlgoriAgent/src/agentscope/prompt/__pycache__/_prompt_generator_en.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/prompt/__pycache__/_prompt_generator_zh.cpython-310.pyc b/AlgoriAgent/src/agentscope/prompt/__pycache__/_prompt_generator_zh.cpython-310.pyc index bd64985..0f34626 100644 Binary files a/AlgoriAgent/src/agentscope/prompt/__pycache__/_prompt_generator_zh.cpython-310.pyc and b/AlgoriAgent/src/agentscope/prompt/__pycache__/_prompt_generator_zh.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/prompt/__pycache__/_prompt_optimizer.cpython-310.pyc b/AlgoriAgent/src/agentscope/prompt/__pycache__/_prompt_optimizer.cpython-310.pyc index 0395ce6..178d371 100644 Binary files a/AlgoriAgent/src/agentscope/prompt/__pycache__/_prompt_optimizer.cpython-310.pyc and b/AlgoriAgent/src/agentscope/prompt/__pycache__/_prompt_optimizer.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/prompt/__pycache__/_prompt_utils.cpython-310.pyc b/AlgoriAgent/src/agentscope/prompt/__pycache__/_prompt_utils.cpython-310.pyc index 21b27e3..d4c9f27 100644 Binary files a/AlgoriAgent/src/agentscope/prompt/__pycache__/_prompt_utils.cpython-310.pyc and b/AlgoriAgent/src/agentscope/prompt/__pycache__/_prompt_utils.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/rag/__pycache__/__init__.cpython-310.pyc b/AlgoriAgent/src/agentscope/rag/__pycache__/__init__.cpython-310.pyc index 7d4481b..1db4bd3 100644 Binary files a/AlgoriAgent/src/agentscope/rag/__pycache__/__init__.cpython-310.pyc and b/AlgoriAgent/src/agentscope/rag/__pycache__/__init__.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/rag/__pycache__/knowledge.cpython-310.pyc b/AlgoriAgent/src/agentscope/rag/__pycache__/knowledge.cpython-310.pyc index e2bd247..78b45ff 100644 Binary files a/AlgoriAgent/src/agentscope/rag/__pycache__/knowledge.cpython-310.pyc and b/AlgoriAgent/src/agentscope/rag/__pycache__/knowledge.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/rag/__pycache__/knowledge_bank.cpython-310.pyc b/AlgoriAgent/src/agentscope/rag/__pycache__/knowledge_bank.cpython-310.pyc index 285707e..f6d6162 100644 Binary files a/AlgoriAgent/src/agentscope/rag/__pycache__/knowledge_bank.cpython-310.pyc and b/AlgoriAgent/src/agentscope/rag/__pycache__/knowledge_bank.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/rag/__pycache__/llama_index_knowledge.cpython-310.pyc b/AlgoriAgent/src/agentscope/rag/__pycache__/llama_index_knowledge.cpython-310.pyc index 7f85c37..29458f2 100644 Binary files a/AlgoriAgent/src/agentscope/rag/__pycache__/llama_index_knowledge.cpython-310.pyc and b/AlgoriAgent/src/agentscope/rag/__pycache__/llama_index_knowledge.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/rpc/__pycache__/__init__.cpython-310.pyc b/AlgoriAgent/src/agentscope/rpc/__pycache__/__init__.cpython-310.pyc index dd6478e..a8b69c0 100644 Binary files a/AlgoriAgent/src/agentscope/rpc/__pycache__/__init__.cpython-310.pyc and b/AlgoriAgent/src/agentscope/rpc/__pycache__/__init__.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/rpc/__pycache__/rpc_agent_client.cpython-310.pyc b/AlgoriAgent/src/agentscope/rpc/__pycache__/rpc_agent_client.cpython-310.pyc index a3ad980..80eca09 100644 Binary files a/AlgoriAgent/src/agentscope/rpc/__pycache__/rpc_agent_client.cpython-310.pyc and b/AlgoriAgent/src/agentscope/rpc/__pycache__/rpc_agent_client.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/rpc/__pycache__/rpc_agent_pb2.cpython-310.pyc b/AlgoriAgent/src/agentscope/rpc/__pycache__/rpc_agent_pb2.cpython-310.pyc index 5fef677..ff95202 100644 Binary files a/AlgoriAgent/src/agentscope/rpc/__pycache__/rpc_agent_pb2.cpython-310.pyc and b/AlgoriAgent/src/agentscope/rpc/__pycache__/rpc_agent_pb2.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/rpc/__pycache__/rpc_agent_pb2_grpc.cpython-310.pyc b/AlgoriAgent/src/agentscope/rpc/__pycache__/rpc_agent_pb2_grpc.cpython-310.pyc index 35ccdf1..5eefddc 100644 Binary files a/AlgoriAgent/src/agentscope/rpc/__pycache__/rpc_agent_pb2_grpc.cpython-310.pyc and b/AlgoriAgent/src/agentscope/rpc/__pycache__/rpc_agent_pb2_grpc.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/server/__pycache__/__init__.cpython-310.pyc b/AlgoriAgent/src/agentscope/server/__pycache__/__init__.cpython-310.pyc index 699d07a..13a9ff9 100644 Binary files a/AlgoriAgent/src/agentscope/server/__pycache__/__init__.cpython-310.pyc and b/AlgoriAgent/src/agentscope/server/__pycache__/__init__.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/server/__pycache__/launcher.cpython-310.pyc b/AlgoriAgent/src/agentscope/server/__pycache__/launcher.cpython-310.pyc index 562999c..c81a470 100644 Binary files a/AlgoriAgent/src/agentscope/server/__pycache__/launcher.cpython-310.pyc and b/AlgoriAgent/src/agentscope/server/__pycache__/launcher.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/server/__pycache__/servicer.cpython-310.pyc b/AlgoriAgent/src/agentscope/server/__pycache__/servicer.cpython-310.pyc index 61a343c..be43460 100644 Binary files a/AlgoriAgent/src/agentscope/server/__pycache__/servicer.cpython-310.pyc and b/AlgoriAgent/src/agentscope/server/__pycache__/servicer.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/service/__pycache__/__init__.cpython-310.pyc b/AlgoriAgent/src/agentscope/service/__pycache__/__init__.cpython-310.pyc index 5e4fcf1..b520b32 100644 Binary files a/AlgoriAgent/src/agentscope/service/__pycache__/__init__.cpython-310.pyc and b/AlgoriAgent/src/agentscope/service/__pycache__/__init__.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/service/__pycache__/service_response.cpython-310.pyc b/AlgoriAgent/src/agentscope/service/__pycache__/service_response.cpython-310.pyc index 10faaee..ad786ec 100644 Binary files a/AlgoriAgent/src/agentscope/service/__pycache__/service_response.cpython-310.pyc and b/AlgoriAgent/src/agentscope/service/__pycache__/service_response.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/service/__pycache__/service_status.cpython-310.pyc b/AlgoriAgent/src/agentscope/service/__pycache__/service_status.cpython-310.pyc index e0c8fac..6f11438 100644 Binary files a/AlgoriAgent/src/agentscope/service/__pycache__/service_status.cpython-310.pyc and b/AlgoriAgent/src/agentscope/service/__pycache__/service_status.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/service/__pycache__/service_toolkit.cpython-310.pyc b/AlgoriAgent/src/agentscope/service/__pycache__/service_toolkit.cpython-310.pyc index c3807f3..c8c371d 100644 Binary files a/AlgoriAgent/src/agentscope/service/__pycache__/service_toolkit.cpython-310.pyc and b/AlgoriAgent/src/agentscope/service/__pycache__/service_toolkit.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/service/execute_code/__pycache__/__init__.cpython-310.pyc b/AlgoriAgent/src/agentscope/service/execute_code/__pycache__/__init__.cpython-310.pyc index 23734c9..5af3fce 100644 Binary files a/AlgoriAgent/src/agentscope/service/execute_code/__pycache__/__init__.cpython-310.pyc and b/AlgoriAgent/src/agentscope/service/execute_code/__pycache__/__init__.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/service/execute_code/__pycache__/exec_python.cpython-310.pyc b/AlgoriAgent/src/agentscope/service/execute_code/__pycache__/exec_python.cpython-310.pyc index aeaad9b..881ab68 100644 Binary files a/AlgoriAgent/src/agentscope/service/execute_code/__pycache__/exec_python.cpython-310.pyc and b/AlgoriAgent/src/agentscope/service/execute_code/__pycache__/exec_python.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/service/execute_code/__pycache__/exec_shell.cpython-310.pyc b/AlgoriAgent/src/agentscope/service/execute_code/__pycache__/exec_shell.cpython-310.pyc index 01e8585..1ff3dfd 100644 Binary files a/AlgoriAgent/src/agentscope/service/execute_code/__pycache__/exec_shell.cpython-310.pyc and b/AlgoriAgent/src/agentscope/service/execute_code/__pycache__/exec_shell.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/service/file/__pycache__/__init__.cpython-310.pyc b/AlgoriAgent/src/agentscope/service/file/__pycache__/__init__.cpython-310.pyc index 5c01c4c..d57333d 100644 Binary files a/AlgoriAgent/src/agentscope/service/file/__pycache__/__init__.cpython-310.pyc and b/AlgoriAgent/src/agentscope/service/file/__pycache__/__init__.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/service/file/__pycache__/common.cpython-310.pyc b/AlgoriAgent/src/agentscope/service/file/__pycache__/common.cpython-310.pyc index ea84156..169b58d 100644 Binary files a/AlgoriAgent/src/agentscope/service/file/__pycache__/common.cpython-310.pyc and b/AlgoriAgent/src/agentscope/service/file/__pycache__/common.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/service/file/__pycache__/json.cpython-310.pyc b/AlgoriAgent/src/agentscope/service/file/__pycache__/json.cpython-310.pyc index ea5afa6..493c103 100644 Binary files a/AlgoriAgent/src/agentscope/service/file/__pycache__/json.cpython-310.pyc and b/AlgoriAgent/src/agentscope/service/file/__pycache__/json.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/service/file/__pycache__/text.cpython-310.pyc b/AlgoriAgent/src/agentscope/service/file/__pycache__/text.cpython-310.pyc index e2b3c54..7278043 100644 Binary files a/AlgoriAgent/src/agentscope/service/file/__pycache__/text.cpython-310.pyc and b/AlgoriAgent/src/agentscope/service/file/__pycache__/text.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/service/multi_modality/__pycache__/__init__.cpython-310.pyc b/AlgoriAgent/src/agentscope/service/multi_modality/__pycache__/__init__.cpython-310.pyc index b1ae235..e234712 100644 Binary files a/AlgoriAgent/src/agentscope/service/multi_modality/__pycache__/__init__.cpython-310.pyc and b/AlgoriAgent/src/agentscope/service/multi_modality/__pycache__/__init__.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/service/multi_modality/__pycache__/dashscope_services.cpython-310.pyc b/AlgoriAgent/src/agentscope/service/multi_modality/__pycache__/dashscope_services.cpython-310.pyc index d4cba67..73e7d98 100644 Binary files a/AlgoriAgent/src/agentscope/service/multi_modality/__pycache__/dashscope_services.cpython-310.pyc and b/AlgoriAgent/src/agentscope/service/multi_modality/__pycache__/dashscope_services.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/service/multi_modality/__pycache__/openai_services.cpython-310.pyc b/AlgoriAgent/src/agentscope/service/multi_modality/__pycache__/openai_services.cpython-310.pyc index 9f02834..950604f 100644 Binary files a/AlgoriAgent/src/agentscope/service/multi_modality/__pycache__/openai_services.cpython-310.pyc and b/AlgoriAgent/src/agentscope/service/multi_modality/__pycache__/openai_services.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/service/retrieval/__pycache__/__init__.cpython-310.pyc b/AlgoriAgent/src/agentscope/service/retrieval/__pycache__/__init__.cpython-310.pyc index 06d3974..5cbde55 100644 Binary files a/AlgoriAgent/src/agentscope/service/retrieval/__pycache__/__init__.cpython-310.pyc and b/AlgoriAgent/src/agentscope/service/retrieval/__pycache__/__init__.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/service/retrieval/__pycache__/retrieval_from_list.cpython-310.pyc b/AlgoriAgent/src/agentscope/service/retrieval/__pycache__/retrieval_from_list.cpython-310.pyc index ad061c7..629ff64 100644 Binary files a/AlgoriAgent/src/agentscope/service/retrieval/__pycache__/retrieval_from_list.cpython-310.pyc and b/AlgoriAgent/src/agentscope/service/retrieval/__pycache__/retrieval_from_list.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/service/retrieval/__pycache__/similarity.cpython-310.pyc b/AlgoriAgent/src/agentscope/service/retrieval/__pycache__/similarity.cpython-310.pyc index a2728d8..af49e8a 100644 Binary files a/AlgoriAgent/src/agentscope/service/retrieval/__pycache__/similarity.cpython-310.pyc and b/AlgoriAgent/src/agentscope/service/retrieval/__pycache__/similarity.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/service/sql_query/__pycache__/__init__.cpython-310.pyc b/AlgoriAgent/src/agentscope/service/sql_query/__pycache__/__init__.cpython-310.pyc index 4e90583..1bd3de8 100644 Binary files a/AlgoriAgent/src/agentscope/service/sql_query/__pycache__/__init__.cpython-310.pyc and b/AlgoriAgent/src/agentscope/service/sql_query/__pycache__/__init__.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/service/sql_query/__pycache__/mongodb.cpython-310.pyc b/AlgoriAgent/src/agentscope/service/sql_query/__pycache__/mongodb.cpython-310.pyc index 8ee0f14..b871810 100644 Binary files a/AlgoriAgent/src/agentscope/service/sql_query/__pycache__/mongodb.cpython-310.pyc and b/AlgoriAgent/src/agentscope/service/sql_query/__pycache__/mongodb.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/service/sql_query/__pycache__/mysql.cpython-310.pyc b/AlgoriAgent/src/agentscope/service/sql_query/__pycache__/mysql.cpython-310.pyc index 1edf15d..5c53b77 100644 Binary files a/AlgoriAgent/src/agentscope/service/sql_query/__pycache__/mysql.cpython-310.pyc and b/AlgoriAgent/src/agentscope/service/sql_query/__pycache__/mysql.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/service/sql_query/__pycache__/sqlite.cpython-310.pyc b/AlgoriAgent/src/agentscope/service/sql_query/__pycache__/sqlite.cpython-310.pyc index e8611b7..d383fa2 100644 Binary files a/AlgoriAgent/src/agentscope/service/sql_query/__pycache__/sqlite.cpython-310.pyc and b/AlgoriAgent/src/agentscope/service/sql_query/__pycache__/sqlite.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/service/text_processing/__pycache__/__init__.cpython-310.pyc b/AlgoriAgent/src/agentscope/service/text_processing/__pycache__/__init__.cpython-310.pyc index 1643d73..16cfbb9 100644 Binary files a/AlgoriAgent/src/agentscope/service/text_processing/__pycache__/__init__.cpython-310.pyc and b/AlgoriAgent/src/agentscope/service/text_processing/__pycache__/__init__.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/service/text_processing/__pycache__/summarization.cpython-310.pyc b/AlgoriAgent/src/agentscope/service/text_processing/__pycache__/summarization.cpython-310.pyc index 043ba7c..1646d7a 100644 Binary files a/AlgoriAgent/src/agentscope/service/text_processing/__pycache__/summarization.cpython-310.pyc and b/AlgoriAgent/src/agentscope/service/text_processing/__pycache__/summarization.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/service/web/__pycache__/__init__.cpython-310.pyc b/AlgoriAgent/src/agentscope/service/web/__pycache__/__init__.cpython-310.pyc index de27a57..c8b7c90 100644 Binary files a/AlgoriAgent/src/agentscope/service/web/__pycache__/__init__.cpython-310.pyc and b/AlgoriAgent/src/agentscope/service/web/__pycache__/__init__.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/service/web/__pycache__/arxiv.cpython-310.pyc b/AlgoriAgent/src/agentscope/service/web/__pycache__/arxiv.cpython-310.pyc index 9bc5c29..62660ac 100644 Binary files a/AlgoriAgent/src/agentscope/service/web/__pycache__/arxiv.cpython-310.pyc and b/AlgoriAgent/src/agentscope/service/web/__pycache__/arxiv.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/service/web/__pycache__/dblp.cpython-310.pyc b/AlgoriAgent/src/agentscope/service/web/__pycache__/dblp.cpython-310.pyc index dd842f0..cbab202 100644 Binary files a/AlgoriAgent/src/agentscope/service/web/__pycache__/dblp.cpython-310.pyc and b/AlgoriAgent/src/agentscope/service/web/__pycache__/dblp.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/service/web/__pycache__/download.cpython-310.pyc b/AlgoriAgent/src/agentscope/service/web/__pycache__/download.cpython-310.pyc index 76df274..905d353 100644 Binary files a/AlgoriAgent/src/agentscope/service/web/__pycache__/download.cpython-310.pyc and b/AlgoriAgent/src/agentscope/service/web/__pycache__/download.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/service/web/__pycache__/search.cpython-310.pyc b/AlgoriAgent/src/agentscope/service/web/__pycache__/search.cpython-310.pyc index 518a9c8..eeae27f 100644 Binary files a/AlgoriAgent/src/agentscope/service/web/__pycache__/search.cpython-310.pyc and b/AlgoriAgent/src/agentscope/service/web/__pycache__/search.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/service/web/__pycache__/web_digest.cpython-310.pyc b/AlgoriAgent/src/agentscope/service/web/__pycache__/web_digest.cpython-310.pyc index 1bf30bf..2253c05 100644 Binary files a/AlgoriAgent/src/agentscope/service/web/__pycache__/web_digest.cpython-310.pyc and b/AlgoriAgent/src/agentscope/service/web/__pycache__/web_digest.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/studio/__pycache__/__init__.cpython-310.pyc b/AlgoriAgent/src/agentscope/studio/__pycache__/__init__.cpython-310.pyc index 0ad271a..c54571c 100644 Binary files a/AlgoriAgent/src/agentscope/studio/__pycache__/__init__.cpython-310.pyc and b/AlgoriAgent/src/agentscope/studio/__pycache__/__init__.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/studio/__pycache__/_app.cpython-310.pyc b/AlgoriAgent/src/agentscope/studio/__pycache__/_app.cpython-310.pyc index 6f8d1c5..9f62786 100644 Binary files a/AlgoriAgent/src/agentscope/studio/__pycache__/_app.cpython-310.pyc and b/AlgoriAgent/src/agentscope/studio/__pycache__/_app.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/studio/__pycache__/_client.cpython-310.pyc b/AlgoriAgent/src/agentscope/studio/__pycache__/_client.cpython-310.pyc index 27f7564..794aff7 100644 Binary files a/AlgoriAgent/src/agentscope/studio/__pycache__/_client.cpython-310.pyc and b/AlgoriAgent/src/agentscope/studio/__pycache__/_client.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/utils/__pycache__/__init__.cpython-310.pyc b/AlgoriAgent/src/agentscope/utils/__pycache__/__init__.cpython-310.pyc index 60c0b41..a09358d 100644 Binary files a/AlgoriAgent/src/agentscope/utils/__pycache__/__init__.cpython-310.pyc and b/AlgoriAgent/src/agentscope/utils/__pycache__/__init__.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/utils/__pycache__/common.cpython-310.pyc b/AlgoriAgent/src/agentscope/utils/__pycache__/common.cpython-310.pyc index 088aa7c..d138979 100644 Binary files a/AlgoriAgent/src/agentscope/utils/__pycache__/common.cpython-310.pyc and b/AlgoriAgent/src/agentscope/utils/__pycache__/common.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/utils/__pycache__/monitor.cpython-310.pyc b/AlgoriAgent/src/agentscope/utils/__pycache__/monitor.cpython-310.pyc index c400b93..6cea868 100644 Binary files a/AlgoriAgent/src/agentscope/utils/__pycache__/monitor.cpython-310.pyc and b/AlgoriAgent/src/agentscope/utils/__pycache__/monitor.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/utils/__pycache__/token_utils.cpython-310.pyc b/AlgoriAgent/src/agentscope/utils/__pycache__/token_utils.cpython-310.pyc index 686b04c..670e645 100644 Binary files a/AlgoriAgent/src/agentscope/utils/__pycache__/token_utils.cpython-310.pyc and b/AlgoriAgent/src/agentscope/utils/__pycache__/token_utils.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/utils/__pycache__/tools.cpython-310.pyc b/AlgoriAgent/src/agentscope/utils/__pycache__/tools.cpython-310.pyc index 0300872..ffdddb7 100644 Binary files a/AlgoriAgent/src/agentscope/utils/__pycache__/tools.cpython-310.pyc and b/AlgoriAgent/src/agentscope/utils/__pycache__/tools.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/web/__pycache__/__init__.cpython-310.pyc b/AlgoriAgent/src/agentscope/web/__pycache__/__init__.cpython-310.pyc index d69998c..57e5535 100644 Binary files a/AlgoriAgent/src/agentscope/web/__pycache__/__init__.cpython-310.pyc and b/AlgoriAgent/src/agentscope/web/__pycache__/__init__.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/web/gradio/__pycache__/__init__.cpython-310.pyc b/AlgoriAgent/src/agentscope/web/gradio/__pycache__/__init__.cpython-310.pyc index 2db016a..9d35ab5 100644 Binary files a/AlgoriAgent/src/agentscope/web/gradio/__pycache__/__init__.cpython-310.pyc and b/AlgoriAgent/src/agentscope/web/gradio/__pycache__/__init__.cpython-310.pyc differ diff --git a/AlgoriAgent/src/agentscope/web/gradio/__pycache__/utils.cpython-310.pyc b/AlgoriAgent/src/agentscope/web/gradio/__pycache__/utils.cpython-310.pyc index 87aefe1..21ceeb3 100644 Binary files a/AlgoriAgent/src/agentscope/web/gradio/__pycache__/utils.cpython-310.pyc and b/AlgoriAgent/src/agentscope/web/gradio/__pycache__/utils.cpython-310.pyc differ diff --git a/Html/__pycache__/backboardManager.cpython-310.pyc b/Html/__pycache__/backboardManager.cpython-310.pyc index b26aeca..638913c 100644 Binary files a/Html/__pycache__/backboardManager.cpython-310.pyc and b/Html/__pycache__/backboardManager.cpython-310.pyc differ diff --git a/Html/app.py b/Html/app.py index 4cb1ab0..529e251 100644 --- a/Html/app.py +++ b/Html/app.py @@ -58,11 +58,13 @@ class VSCodeNamespace(Namespace): dataconfig = data['config'] user_id = dataconfig.get('user_id') path = dataconfig.get('path') + course_id = dataconfig.get('course_id') + lesson_id = dataconfig.get('chapter_id') print(f"User {user_id} connected with path: {path}") useruuid = username2uuid[user_id] join_room(useruuid, namespace='/vscode') if backboard_manager.get_backboard(useruuid) == None: - backboard_manager.add_backboard(useruuid, path) + backboard_manager.add_backboard(useruuid,user_id, course_id, lesson_id, path) def on_message(self, data): @@ -98,7 +100,20 @@ def realtime_response(config, realtime_action): assert type(file_path) == str bb.pasted_file_path = file_path bb.pasted_content = realtime_action['content'] + bb.active_file_path = file_path + with open(f"{file_path}") as f: + bb.active_file_content = f.read() + + if realtime_action['type'] == 'fileEdit': + file_path = realtime_action['filePath'] + assert type(file_path) == str + bb.active_file_path = file_path + with open(f"{file_path}") as f: + bb.active_file_content = f.read() + + + print("config"+str(config)) print("realtime_action"+str(realtime_action)) @@ -131,10 +146,11 @@ class AgentNamespace(Namespace): markdown = fmd.read() markdown_prompts = fmdp.read() score_prompts = fsp.read() - user_uuid, agent = agent_manager.new_agent(course_id, chapter_id, markdown, markdown_prompts, score_prompts, id=user_uuid, root_path=f'{user}/{course_id}/{chapter_id}') + user_uuid, agent = agent_manager.new_agent(course_id, chapter_id, markdown, markdown_prompts, score_prompts, id=user_uuid, + root_path=f'../../study/{user}/{course_id}/{chapter_id}') print(user_uuid) join_room(user_uuid, namespace='/agent') # 将该用户加入以user_id为名的room - backboard_manager.add_backboard(user_uuid, chapter_id) + backboard_manager.add_backboard(user_uuid, user, course_id, chapter_id, root_path=f'../../study/{user}/{course_id}/{chapter_id}') def on_language(self, language): id = session.get('user_id') @@ -150,23 +166,23 @@ class AgentNamespace(Namespace): res = agent_manager.invoke(id, data['data'], backboard_manager.get_backboard(id).get_info_prompt()) print('=*='*20) print(res.content) - reply = f"AI: {res.content['speak']}" + reply = f"{res.content['speak']}" with app.app_context(): emit('message',reply, room=id, namespace='/agent') emit('request_function',res.content['function'], room=id, namespace='/agent') - # for res in agent_manager.invoke(id, data, backboard_manager.get_backboard(id).get_info_prompt(), reset=True): - # print('=*='*20) - # print(res.content) - # if ('speak' in res.content): - # reply = f"AI: {res.content['speak']}" - # with app.app_context(): emit('message',reply, room=id, namespace='/agent') - # if ('function' in res.content): - # functions = res.content['function'] - # if functions is None: break - # if len(functions)==0:break + if data['type'] == 'function': agent_manager.function_call(id, data['data']) + def on_initiative(self,data): + print("User active function call") + user_id = session['user_id'] + if data['name'] == 'sample_judge': + agent_manager.sample_judge(user_id, backboard_manager.get_backboard(user_id)) + if data['name'] == 'judge': + agent_manager.judge(user_id, backboard_manager.get_backboard(user_id)) + + def on_disconnect(self,data): print("VSCode client disconnected") @@ -358,7 +374,7 @@ def dashboard(): for course_id in user_id2UserClass[user_id].select_course: course_brief_info = course_list.get_course_brief_info(course_id, load_course_from_json(course_id, course_data_dir = COURSE_DATA_DIR)) user_course_data.append(course_brief_info) - return render_template('dashboard.html',user_data = json.dumps(user_id2UserClass[user_id].__json__()), user_course_data = json.dumps(user_course_data)) + return render_template('dashboard.html',user_data = user_id2UserClass[user_id].to_json_without_dialog(), user_course_data = json.dumps(user_course_data)) ''' Course diff --git a/Html/backboardManager.py b/Html/backboardManager.py index 7ebfe2d..1777f8d 100644 --- a/Html/backboardManager.py +++ b/Html/backboardManager.py @@ -2,27 +2,15 @@ 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] - - - +import os class Backboard: - def __init__(self, user_id, folder): + def __init__(self, user_id, username, course_id, lesson_id, root_path): self.user_id = user_id - self.folder = folder + self.username = username + self.course_id = course_id + self.lesson_id = lesson_id + self.root_path = root_path self.create_time = time.time() self.enter_chapter_time = time.time() self.history = [] @@ -48,12 +36,12 @@ class Backboard: f"- User's total study time is {self.get_deltatime_mmss(self.create_time, time.time())}{endl}" f"- User's current chapter study time is {self.get_deltatime_mmss(self.enter_chapter_time, time.time())}{endl}" f"- Activated file path: {self.active_file_path}{endl}" - f"- Activated file content (current editing 10 lines): {endl}" f"```{endl}" f"{self.active_file_content[-10:]}{endl}" f"```{endl}" f"- Last five action:{five_history}{endl}" f"- File tree: {self.file_tree}{endl}") + # f"- Activated file content (current editing 10 lines): {endl}" def add_history(self, realtime_action): if(realtime_action['type']=='config'):return if len(self.history)!=0: @@ -72,3 +60,21 @@ class Backboard: return f"{hours:02d}:{minutes:02d}:{seconds:02d}" + def get_active_file_reletive_path(self): + relative_path = os.path.relpath(self.active_file_path, self.root_path) + return relative_path + + + +class BackBoardManager: + def __init__(self): + self.backboards = {} # user_id: Backboard + + def add_backboard(self, user_id, username, course_id, lesson_id, root_path): + self.backboards[user_id] = Backboard(user_id,username, course_id, lesson_id, root_path) + + def get_backboard(self, user_id) -> Backboard: + return self.backboards[user_id] + + + diff --git a/Html/db/data/course/CS101.json b/Html/db/data/course/CS101.json index 8135c4a..5c7ba5e 100644 --- a/Html/db/data/course/CS101.json +++ b/Html/db/data/course/CS101.json @@ -2,7 +2,7 @@ "course_id": "CS101", "course_name": "Computer Science 101", "course_auther": "John Doe", - "course_img_path": "/static/image/algorithm/book_cover.png", + "course_img_path": "/static/image/CS101/CS101.png", "description":"这个老师很懒,没有写介绍", "lessons": [ { @@ -11,7 +11,7 @@ "markdown": "This is the introduction lesson.", "markdown_prompt": "What is Computer Science?", "score_prompt": "Please provide an overview of CS.", - "lesson_img_path": "/static/image/algorithm/book_cover.png" + "lesson_img_path": "/static/image/CS101/CS101.png" }, { "lesson_id": "L002", @@ -19,7 +19,7 @@ "markdown": "In this lesson, we cover Data Structures.", "markdown_prompt": "What is an array?", "score_prompt": "Explain how linked lists work.", - "lesson_img_path": "/static/image/algorithm/book_cover.png" + "lesson_img_path": "/static/image/CS101/CS101.png" } ] } diff --git a/Html/db/data/course/course_list.json b/Html/db/data/course/course_list.json index 9f695a2..5988d99 100644 --- a/Html/db/data/course/course_list.json +++ b/Html/db/data/course/course_list.json @@ -3,7 +3,7 @@ "course_id": "CS101", "course_name": "Computer Science 101", "course_description":"这个老师很懒,没有写介绍", - "course_img_path": "/static/image/algorithm/book_cover.png", + "course_img_path": "/static/image/CS101/CS101.png", "course_create_date": "2023-01-01", "course_update_data": "2023-01-01"}, @@ -19,7 +19,7 @@ "course_id": "data-structure", "course_name": "数据结构", "course_description":"这个老师很懒,没有写介绍", - "course_img_path": "/static/image/algorithm/book_cover.png", + "course_img_path": "/static/image/data-structure/book_cover-data-structure.png", "course_create_date": "2023-01-01", "course_update_data": "2023-01-01"} } \ No newline at end of file diff --git a/Html/db/data/course/data-structure.json b/Html/db/data/course/data-structure.json index ce96ac9..b1326b8 100644 --- a/Html/db/data/course/data-structure.json +++ b/Html/db/data/course/data-structure.json @@ -2,7 +2,7 @@ "course_id": "data-structure", "course_name": "data-structure", "course_auther": "Chao Peng", - "course_img_path": "/static/image/algorithm/book_cover.png", + "course_img_path": "/static/image/data-structure/book_cover-data-structure.png", "description":"这个老师很懒,没有写介绍", "lessons": [ { @@ -11,7 +11,7 @@ "markdown": "This is the introduction lesson.", "markdown_prompt": "What is Data structure?", "score_prompt": "Please provide an overview of CS.", - "lesson_img_path": "/static/image/algorithm/book_cover.png" + "lesson_img_path": "/static/image/data-structure/book_cover-data-structure.png" }, { "lesson_id": "L002", @@ -19,7 +19,7 @@ "markdown": "In this lesson, we cover Data Structures.", "markdown_prompt": "What is an array?", "score_prompt": "Explain how linked lists work.", - "lesson_img_path": "/static/image/algorithm/book_cover.png" + "lesson_img_path": "/static/image/data-structure/book_cover-data-structure.png" } ] } diff --git a/Html/db/data/user/cake.json b/Html/db/data/user/cake.json index 67e05bf..354c128 100644 --- a/Html/db/data/user/cake.json +++ b/Html/db/data/user/cake.json @@ -15,17 +15,17 @@ "title": "\u5f15\u5165", "dialog": [ { - "id": "0b26417b9a4a41c3a86a63e96ac279f7", - "timestamp": "2025-01-01 01:40:36", + "id": "c22798c82f664930aa74a06834e4310a", + "timestamp": "2025-01-01 18:47:30", "name": "system", - "content": "You're a helpful assistant.\n\n## \u4f60\u7684\u89d2\u8272\uff1a\n\u4f60\u9700\u8981\u5e2e\u52a9\u5b66\u751f\u5b66\u4e60\u7b97\u6cd5\uff0c\u5b8c\u6210\u7279\u5b9a\u7684\u7f16\u7a0b\u4efb\u52a1\u3002\n\n## \u4f60\u9700\u8981\u505a\u7684\uff1a\n0. \u4f60\u5fc5\u987b\u6839\u636e\u8001\u5e08\u63d0\u4f9b\u7684\u6559\u5b66\u5927\u7eb2\uff0c\u6309\u7167\u7ae0\u8282\u987a\u5e8f\uff0c\u4f9d\u6b21\u5b66\u4e60\u3002\n1. \u5b66\u751f\u53ef\u80fd\u4f1a\u63d0\u51fa\u4e00\u4e9b\u95ee\u9898\uff0c\u4f60\u65e0\u9700\u56de\u7b54\u95ee\u9898\uff0c\u800c\u662f\u6839\u636e\u4e0a\u4e0b\u6587\uff08\u6bd4\u5982\u5b66\u751f\u81ea\u5df1\u7684\u4ee3\u7801\uff09\u6765\u5206\u6790\uff0c\u5e76\u7ed9\u51fa\u4e00\u6b65\u7684\u89e3\u51b3\u65b9\u6848\u3002\n2. \u6559\u5b66\u5927\u7eb2\u4e2d\u4f1a\u6307\u660e\u6bcf\u4e2a\u7ae0\u8282\u7684\u5b66\u4e60\u76ee\u6807\uff0c\u4f60\u6309\u7167\u76ee\u6807\u5b66\u4e60\u3002\n3. \u7cfb\u7edf\u4f1aoccasionally gather\u5b66\u751f\u4fe1\u606f\uff0c\u4f60\u9700\u8981\u5206\u6790\u5b66\u751f\u5b66\u4e60\u8bb0\u5f55\uff0c\u8c03\u7528\u5fc5\u8981\u7684\u51fd\u6570\u3002\n\n## \u6ce8\u610f\u4e8b\u9879\uff1a\n1. \u786e\u4fdd\u4f7f\u7528\u5de5\u5177\u51fd\u6570\u65f6\uff0c\u63d0\u4f9b\u7684\u53c2\u6570\u7c7b\u578b\u548c\u503c\u662f\u6b63\u786e\u7684\u3002\n2. \u4e0d\u8981\u592a\u76f8\u4fe1\u81ea\u5df1\uff0c\u4f8b\u5982\uff0c\u5f53\u524d\u4f4d\u7f6e\uff0c\u5f53\u524d\u65f6\u95f4\u7b49\uff0c\u4f60\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528\u5de5\u5177\u51fd\u6570\u83b7\u53d6\u4fe1\u606f\u3002\n3. \u5982\u679c\u51fd\u6570\u6267\u884c\u5931\u8d25\uff0c\u4f60\u9700\u8981\u5206\u6790\u9519\u8bef\u5e76\u5c1d\u8bd5\u89e3\u51b3\u3002\n4. \u786e\u4fdd\u5b66\u751f\u63d0\u51fa\u7684\u95ee\u9898\u6216\u60f3\u6cd5\u662f\u5426\u4e0e\u5f53\u524d\u7ae0\u8282\u76f8\u5173\uff0c\u5982\u679c\u4e0d\u76f8\u5173\uff0c\u4f60\u5e94\u7b54\u5e76\u63d0\u9192\u5b66\u751f\u5173\u6ce8\u5f53\u524d\u7ae0\u8282\u3002\n\n## \u8d44\u6e90\uff1a\n1. \u4f60\u53ef\u4ee5\u4f7f\u7528\u7684\u5de5\u5177\u51fd\u6570\u3002\n2. \u4e0a\u4e0b\u6587\uff0c\u5305\u62ec\u5b66\u751f\u7684\u4ee3\u7801\uff0c\u548c\u6559\u5b66\u5927\u7eb2\u3002\n", + "content": "You're a helpful assistant.\n\n## \u4f60\u7684\u89d2\u8272\uff1a\n\u4f60\u9700\u8981\u5e2e\u52a9\u5b66\u751f\u5b66\u4e60\u7b97\u6cd5\uff0c\u68c0\u9a8c\u5b66\u4e60\u8fc7\u7a0b\uff0c\u786e\u4fdd\u5b66\u751f\u7406\u89e3\u5f53\u524d\u7ae0\u8282\u7684\u5185\u5bb9\u540e\uff0c\u5e26\u9886\u5b66\u751f\u8fdb\u5165\u4e0b\u4e00\u7ae0\n\n## \u4f60\u9700\u8981\u505a\u7684\uff1a\n0. \u4f60\u5fc5\u987b\u6839\u636e\u8001\u5e08\u63d0\u4f9b\u7684\u6559\u5b66\u5927\u7eb2\uff0c\u6309\u7167\u7ae0\u8282\u987a\u5e8f\uff0c\u4f9d\u6b21\u5b66\u4e60\u3002\n1. \u5b66\u751f\u53ef\u80fd\u4f1a\u63d0\u51fa\u4e00\u4e9b\u95ee\u9898\uff0c\u4f60\u65e0\u9700\u56de\u7b54\u95ee\u9898\uff0c\u800c\u662f\u6839\u636e\u4e0a\u4e0b\u6587\uff08\u6bd4\u5982\u5b66\u751f\u81ea\u5df1\u7684\u4ee3\u7801\uff09\u6765\u5206\u6790\uff0c\u5e76\u7ed9\u51fa\u4e00\u6b65\u7684\u89e3\u51b3\u65b9\u6848\u3002\n2. \u6559\u5b66\u5927\u7eb2\u4e2d\u4f1a\u6307\u660e\u6bcf\u4e2a\u7ae0\u8282\u7684\u5b66\u4e60\u76ee\u6807\uff0c\u4f60\u6309\u7167\u76ee\u6807\u5b66\u4e60\u3002\n3. \u7cfb\u7edf\u4f1aoccasionally gather\u5b66\u751f\u4fe1\u606f\uff0c\u4f60\u9700\u8981\u5206\u6790\u5b66\u751f\u5b66\u4e60\u8bb0\u5f55\uff0c\u8c03\u7528\u5fc5\u8981\u7684\u51fd\u6570\u3002\n\n## \u6ce8\u610f\u4e8b\u9879\uff1a\n1. \u786e\u4fdd\u4f7f\u7528\u5de5\u5177\u51fd\u6570\u65f6\uff0c\u63d0\u4f9b\u7684\u53c2\u6570\u7c7b\u578b\u548c\u503c\u662f\u6b63\u786e\u7684\u3002\n2. \u4e0d\u8981\u592a\u76f8\u4fe1\u81ea\u5df1\uff0c\u4f8b\u5982\uff0c\u5f53\u524d\u4f4d\u7f6e\uff0c\u5f53\u524d\u65f6\u95f4\u7b49\uff0c\u4f60\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528\u5de5\u5177\u51fd\u6570\u83b7\u53d6\u4fe1\u606f\u3002\n3. \u5982\u679c\u51fd\u6570\u6267\u884c\u5931\u8d25\uff0c\u4f60\u9700\u8981\u5206\u6790\u9519\u8bef\u5e76\u5c1d\u8bd5\u89e3\u51b3\u3002\n4. \u786e\u4fdd\u5b66\u751f\u63d0\u51fa\u7684\u95ee\u9898\u6216\u60f3\u6cd5\u662f\u5426\u4e0e\u5f53\u524d\u7ae0\u8282\u76f8\u5173\uff0c\u5982\u679c\u4e0d\u76f8\u5173\uff0c\u4f60\u5e94\u7b54\u5e76\u63d0\u9192\u5b66\u751f\u5173\u6ce8\u5f53\u524d\u7ae0\u8282\u3002\n\n## \u8d44\u6e90\uff1a\n1. \u4f60\u53ef\u4ee5\u4f7f\u7528\u7684\u5de5\u5177\u51fd\u6570\u3002\n2. \u4e0a\u4e0b\u6587\uff0c\u5305\u62ec\u5b66\u751f\u7684\u4ee3\u7801\uff0c\u548c\u6559\u5b66\u5927\u7eb2\u3002\n", "role": "system", "url": null, "metadata": null }, { - "id": "461938c9265547c9bd0187ece94d659d", - "timestamp": "2025-01-01 01:40:43", + "id": "b5f28da4edf74912878f3b0092f8db2f", + "timestamp": "2025-01-01 18:47:42", "name": "system", "content": "##The Chapter Chain##\n(Your Now Chapter) Chapter 1: \n\u4e8c\u5206\u662f\u4e00\u4e2a\u5f88\u7b80\u5355\u57fa\u7840\uff0c\u4f46\u5f88\u91cd\u8981\u7684\u77e5\u8bc6\u70b9\uff0c\u4e3a\u4ee5\u540e\u8bb8\u591a\u9ad8\u7ea7\u7684\u6570\u636e\u7ed3\u6784\u4e0e\u7b97\u6cd5\u94fa\u57ab\u3002\n\n\u4e0b\u9762\u662f\u4e00\u4e2a\u7528\u4e8c\u5206\u7684\u7b80\u5355\u573a\u666f\uff1a\n\n\u5047\u8bbe\u5c0f\u660e\u4ece0\u52301000\u4e4b\u95f4\u9009\u62e9\u4e86\u4e00\u4e2a\u6570\u5b57\u4f46\u4e0d\u544a\u8bc9\u4f60\uff0c\u4f60\u53ef\u4ee5\u4e0d\u65ad\u731c\u6d4b\u8fd9\u4e2a\u6570\uff0c\u6bcf\u6b21\u731c\u6d4b\u5c0f\u660e\u4f1a\u544a\u77e5\u4f60\u7684\u731c\u6d4b\u5f97\u8fc7\u5927\u8fd8\u662f\u8fc7\u5c0f\uff0c\u95ee\u6700\u591a\u51e0\u6b21\u5c31\u4e00\u5b9a\u80fd\u731c\u4e2d\uff1f\n\n\u7b54\u6848\u662f\u5229\u7528\u4e8c\u5206\u67e5\u627e\u7684\u539f\u7406\uff0c\u731c\u6d4b11\u6b21\u5373\u53ef\u3002\n\n1. \u5bf9\u4e8e0\u52301000\u7684\u7b54\u6848\u5907\u9009\u533a\uff0c\u731c\u6d4b\u4e2d\u4f4d\u6570500\uff0c\u5047\u8bbe\u8fc7\u5c0f\uff0c\n2. \u5219\u5bf9\u4e8e501\u52301000\u7684\u7b54\u6848\u5907\u9009\u533a\uff0c\u731c\u6d4b750\uff0c\u5047\u8bbe\u8fc7\u5927\n3. \u5219\u5bf9\u4e8e501\u5230749\u7684\u7b54\u6848\u5907\u9009\u533a\uff0c\u731c\u6d4b625\uff0c\u5047\u8bbe\u8fc7\u5c0f\uff0c\n4. \u5219\u5bf9\u4e8e626\u5230749\u533a\u95f4......\n5. \uff08688-749\uff09\n6. \uff08718-749\uff09\n7. \uff08734-749\uff09\n8. \uff08742-749\uff09\n9. \uff08746-749\uff09\n10. \uff08748-749\uff09\n11. \uff08749-749\uff09\n\n\u5728\u6700\u5dee\u7684\u60c5\u51b5\u4e0b\uff0c\u7b2c11\u6b21\u7684\u7b54\u6848\u5907\u9009\u533a\u5c31\u4e00\u5b9a\u957f\u5ea6\u4e3a1\u4e86\uff0c\u4e5f\u5c31\u662f\u5fc5\u7136\u662f\u7b54\u6848\u3002\n\n\u56e0\u6b64\u5982\u679c\u5e8f\u5217\u662f\u6709\u5e8f\u7684\uff0c\u5c31\u53ef\u4ee5\u901a\u8fc7\u4e8c\u5206\u67e5\u627e\u5feb\u901f\u5b9a\u4f4d\u6240\u9700\u8981\u7684\u6570\u636e\u3002\n\n#### \u601d\u8003\u9898\uff08\u8be2\u95eeAgent\u4ee5\u5b66\u4e60\u8ba1\u7b97\u65b9\u6cd5\uff0c\u6216\u9a8c\u8bc1\u4f60\u7684\u7b54\u6848\uff09\n\n\u5bf9\u4e8e\u4e0a\u9762\u90a3\u4e2a\u9898\u76ee\uff0c\u5982\u679c\u95ee\u9898\u533a\u95f4\u662f1\u52304000\uff0c\u6700\u5dee\u60c5\u51b5\u4e0b\u9700\u8981\u731c\u6d4b\u51e0\u6b21\uff1f\n\n\nHere are some concrete instructions:\n\n\u672c\u5c0f\u8282\u8fdb\u884c\u4e8c\u5206\u67e5\u627e\u7684\u5f15\u5165\uff0c\u9996\u5148\u5e2e\u52a9\u5b66\u751f\u7406\u89e3\u6559\u6848\u5f15\u5165\u7ae0\u8282\u7684\u6545\u4e8b\u3002\n\n\u786e\u4fdd\u5b66\u751f\u7406\u89e3\u4e86\u5f15\u5165\u540e\uff0c\u5728\u8fdb\u884c\u601d\u8003\u9898\u3002\n\n\u5982\u679c\u4e0d\u8fdb\u884c\u601d\u8003\u9898\uff0c\u5219\u8be2\u95ee\u4e00\u4e0b\u662f\u5426\u4e0d\u8fdb\u884c\u601d\u8003\u9898\uff0c\u786e\u8ba4\u540e\u8fdb\u5165\u4e0b\u4e00\u8282\u3002\n\n\u5982\u679c\u8fdb\u884c\u601d\u8003\u9898\uff0c\u544a\u77e5\u5b66\u751f\u8ba1\u7b97\u65b9\u6cd5\u5e76\u9a8c\u8bc1\u7b54\u6848\uff08\u7b54\u6848\u662f13\u6b21\uff09\n\n\u8ba1\u7b97\u65b9\u6cd5\uff1a\n\n4000\u662f\u521d\u59cb\u7b54\u6848\u533a\u95f4\u957f\u5ea6\uff0c\u6bcf\u6b21\u8be2\u95ee\u80fd\u591f\u6392\u9664\u4e00\u534a\u7684\u533a\u95f4\uff0c\u5f53\u533a\u95f4\u957f\u5ea6\u5c0f\u4e8e\u7b49\u4e8e1\u65f6\uff0c\u518d\u8fdb\u884c\u4e00\u6b21\u731c\u6d4b\u5c31\u4e00\u5b9a\u662f\u7b54\u6848\u3002\n\n4000\u4e0d\u65ad\u9664\u4ee52\uff0c\u966412\u6b21\u5c31\u5c0f\u4e8e\u7b49\u4e8e1\u4e86\uff0c\u518d\u52a0\u4e00\u6b21\u5c31\u4e00\u5b9a\u662f\u7b54\u6848\u3002\u6700\u540e\u662f12+1=13\u6b21\u3002\n\n\uff08\u6bd44000\u5927\u7684\u6700\u5c0f2\u7684\u6b21\u65b9\u6570\uff0c4096\u5c31\u662f2\u768412\u6b21\u65b9\uff0c\u8fd9\u91cc\u768412\u5c31\u662f\u7b54\u6848\u4e2d\u768412\uff0c\u6216\u8005\u5199\u4f5c\"\u4e0a\u53d6\u6574(log2(4000))\")\n\n\u8be2\u95ee\u5b66\u751f\uff0c\u5f53\u5b66\u751f\u544a\u77e5\u7406\u89e3\u540e\uff0c\u8fdb\u5165\u4e0b\u4e00\u8282\u3002\n\n\n\n\n", "role": "system", @@ -33,8 +33,8 @@ "metadata": null }, { - "id": "4d63161cb43344d79a2a27abde4a4439", - "timestamp": "2025-01-01 01:40:43", + "id": "23ac775d2b6446368059bba9636ffbdf", + "timestamp": "2025-01-01 18:47:42", "name": "user", "content": "\u7b54\u6848\u662f13\uff0clog2 4000+1", "role": "user", @@ -42,12 +42,12 @@ "metadata": null }, { - "id": "af2e4a0d68f34e61b977ee54f72acf63", - "timestamp": "2025-01-01 01:40:46", - "name": "user_342ee332-16c3-4722-a7aa-fd020088aba1", + "id": "50dc4cfcf0bd4eb7a47d818f5d7456ac", + "timestamp": "2025-01-01 18:47:45", + "name": "user_4eb13cc2-52ab-4281-ad32-83f1ccccadf7", "content": { - "thought": "\u5b66\u751f\u7406\u89e3\u4e86\u601d\u8003\u9898\u7684\u7b54\u6848\uff0c\u4e0b\u4e00\u6b65\u8fdb\u5165\u4e0b\u4e00\u8282\u3002", - "speak": "\u597d\u7684\uff0c\u4f60\u7684\u8ba1\u7b97\u65b9\u6cd5\u662f\u6b63\u786e\u7684\uff0c\u6700\u5dee\u60c5\u51b5\u4e0b\u9700\u8981\u731c\u6d4b13\u6b21\u3002\u6211\u4eec\u73b0\u5728\u53ef\u4ee5\u8fdb\u5165\u4e0b\u4e00\u8282\u3002", + "thought": "\u5b66\u751f\u5df2\u7ecf\u7406\u89e3\u4e86\u4e8c\u5206\u67e5\u627e\u7684\u601d\u8003\u9898\u548c\u8ba1\u7b97\u65b9\u6cd5\uff0c\u786e\u8ba4\u53ef\u4ee5\u8fdb\u5165\u4e0b\u4e00\u7ae0\u3002", + "speak": "\u4f60\u5df2\u7ecf\u7406\u89e3\u4e86\u8fd9\u4e2a\u95ee\u9898\u7684\u8ba1\u7b97\u65b9\u6cd5\uff0c\u7b54\u6848\u662f13\u6b21\u3002\u6211\u4eec\u53ef\u4ee5\u8fdb\u5165\u4e0b\u4e00\u8282\u5417\uff1f", "function": "[{\"name\": \"next_chapter\", \"arguments\": {}}]" }, "role": "assistant", @@ -58,6 +58,290 @@ "score": 10, "is_rebuttal": false, "rebuttal_score": 0 + }, + { + "title": "\u7ec3\u4e60\uff1a\u4e8c\u5206\u67e5\u627e", + "dialog": [ + { + "id": "ee78b4c3bc194a57b447eb6409bafd1f", + "timestamp": "2025-01-01 18:47:50", + "name": "system", + "content": "1. Execute function next_chapter\n [ARGUMENTS]:\n \n [STATUS]: SUCCESS\n [RESULT]: \u6210\u529f\u8fdb\u5165\u4e0b\u4e00\u7ae0\n", + "role": "system", + "url": null, + "metadata": null + }, + { + "id": "c22798c82f664930aa74a06834e4310a", + "timestamp": "2025-01-01 18:47:30", + "name": "system", + "content": "You're a helpful assistant.\n\n## \u4f60\u7684\u89d2\u8272\uff1a\n\u4f60\u9700\u8981\u5e2e\u52a9\u5b66\u751f\u5b66\u4e60\u7b97\u6cd5\uff0c\u68c0\u9a8c\u5b66\u4e60\u8fc7\u7a0b\uff0c\u786e\u4fdd\u5b66\u751f\u7406\u89e3\u5f53\u524d\u7ae0\u8282\u7684\u5185\u5bb9\u540e\uff0c\u5e26\u9886\u5b66\u751f\u8fdb\u5165\u4e0b\u4e00\u7ae0\n\n## \u4f60\u9700\u8981\u505a\u7684\uff1a\n0. \u4f60\u5fc5\u987b\u6839\u636e\u8001\u5e08\u63d0\u4f9b\u7684\u6559\u5b66\u5927\u7eb2\uff0c\u6309\u7167\u7ae0\u8282\u987a\u5e8f\uff0c\u4f9d\u6b21\u5b66\u4e60\u3002\n1. \u5b66\u751f\u53ef\u80fd\u4f1a\u63d0\u51fa\u4e00\u4e9b\u95ee\u9898\uff0c\u4f60\u65e0\u9700\u56de\u7b54\u95ee\u9898\uff0c\u800c\u662f\u6839\u636e\u4e0a\u4e0b\u6587\uff08\u6bd4\u5982\u5b66\u751f\u81ea\u5df1\u7684\u4ee3\u7801\uff09\u6765\u5206\u6790\uff0c\u5e76\u7ed9\u51fa\u4e00\u6b65\u7684\u89e3\u51b3\u65b9\u6848\u3002\n2. \u6559\u5b66\u5927\u7eb2\u4e2d\u4f1a\u6307\u660e\u6bcf\u4e2a\u7ae0\u8282\u7684\u5b66\u4e60\u76ee\u6807\uff0c\u4f60\u6309\u7167\u76ee\u6807\u5b66\u4e60\u3002\n3. \u7cfb\u7edf\u4f1aoccasionally gather\u5b66\u751f\u4fe1\u606f\uff0c\u4f60\u9700\u8981\u5206\u6790\u5b66\u751f\u5b66\u4e60\u8bb0\u5f55\uff0c\u8c03\u7528\u5fc5\u8981\u7684\u51fd\u6570\u3002\n\n## \u6ce8\u610f\u4e8b\u9879\uff1a\n1. \u786e\u4fdd\u4f7f\u7528\u5de5\u5177\u51fd\u6570\u65f6\uff0c\u63d0\u4f9b\u7684\u53c2\u6570\u7c7b\u578b\u548c\u503c\u662f\u6b63\u786e\u7684\u3002\n2. \u4e0d\u8981\u592a\u76f8\u4fe1\u81ea\u5df1\uff0c\u4f8b\u5982\uff0c\u5f53\u524d\u4f4d\u7f6e\uff0c\u5f53\u524d\u65f6\u95f4\u7b49\uff0c\u4f60\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528\u5de5\u5177\u51fd\u6570\u83b7\u53d6\u4fe1\u606f\u3002\n3. \u5982\u679c\u51fd\u6570\u6267\u884c\u5931\u8d25\uff0c\u4f60\u9700\u8981\u5206\u6790\u9519\u8bef\u5e76\u5c1d\u8bd5\u89e3\u51b3\u3002\n4. \u786e\u4fdd\u5b66\u751f\u63d0\u51fa\u7684\u95ee\u9898\u6216\u60f3\u6cd5\u662f\u5426\u4e0e\u5f53\u524d\u7ae0\u8282\u76f8\u5173\uff0c\u5982\u679c\u4e0d\u76f8\u5173\uff0c\u4f60\u5e94\u7b54\u5e76\u63d0\u9192\u5b66\u751f\u5173\u6ce8\u5f53\u524d\u7ae0\u8282\u3002\n\n## \u8d44\u6e90\uff1a\n1. \u4f60\u53ef\u4ee5\u4f7f\u7528\u7684\u5de5\u5177\u51fd\u6570\u3002\n2. \u4e0a\u4e0b\u6587\uff0c\u5305\u62ec\u5b66\u751f\u7684\u4ee3\u7801\uff0c\u548c\u6559\u5b66\u5927\u7eb2\u3002\n", + "role": "system", + "url": null, + "metadata": null + }, + { + "id": "f7a18a7080aa4dc7a4d8feb584d04e3d", + "timestamp": "2025-01-01 18:47:50", + "name": "system", + "content": "##The Chapter Chain##\n(Finished Chapter) Chapter 1: Hidden due to finished.\n(Your Now Chapter) Chapter 2: \n\u8bd5\u8bd5\u5bf9\u4e8e\u4e0b\u9762\u7684\u9898\u76ee\uff0c\u7528\u4ee3\u7801\u5b9e\u73b0\u4e00\u4e0b\u4e8c\u5206\u67e5\u627e\u3002\n\n#### \u9898\u76ee\uff1a\u6709\u5e8f\u6570\u7ec4\u5bfb\u5740\n\n\u7ed9\u51fa\u4e00\u4e2a\u957f\u5ea6\u4e3an\u7684\u6709\u5e8f\u6570\u7ec4\uff08\u4ece\u5c0f\u5230\u5927\uff09\uff0c\u6709q\u6b21\u8be2\u95ee\uff0c\u5bf9\u4e8e\u6bcf\u6b21\u8be2\u95ee\uff0c\u8f93\u51fa\u6307\u5b9a\u6570\u5728\u6570\u7ec4\u4e2d\u7684\u4e0b\u6807\u3002\u5982\u679c\u4e0d\u5b58\u5728\u5219\u8f93\u51fa-1\u3002\n\n##### \u8f93\u5165\n\n\u7b2c\u4e00\u884c\u4e00\u4e2a\u6574\u6570n\u3002(1<=n<=10^5)\n\n\u7b2c\u4e8c\u884cn\u4e2a\u7528\u7a7a\u683c\u5206\u5f00\u7684\u6574\u6570ai\u3002(0<=ai<=10^8)\n\n\u7b2c\u4e09\u884c\u4e00\u4e2a\u6574\u6570q\uff0c\u8868\u793a\u8be2\u95ee\u7684\u6b21\u6570\u3002(1<=q<=10^4)\n\n\u540eq\u884c\uff0c\u6bcf\u884c\u4e00\u4e2a\u6574\u6570b\uff0c\u8868\u793a\u8be2\u95ee\u7684\u6570\u3002(0<=b<=10^8)\n\n##### \u8f93\u51fa\n\nq\u884c\uff0c\u6bcf\u884c\u4e00\u4e2a\u6574\u6570\uff0c\u5bf9\u5e94\u6bcf\u6b21\u8be2\u95ee\u7684\u8fd4\u56de\u7ed3\u679c\u3002\n\n##### \u63d0\u793a\uff1a\n\n\u5b8c\u6210\u4ee3\u7801\u540e\uff0c\u901a\u77e5Agent\u8fdb\u884c\u8bc4\u6d4b\u3002\n\n\u5982\u679c\u4f60\u8fd8\u4e0d\u5b8c\u5168\u4f1a\u8fd9\u4e2a\u7b97\u6cd5\uff0c\u8be2\u95eeAgent\u83b7\u53d6\u63d0\u793a\u5e76\u8fdb\u884c\u5b66\u4e60\u3002\n\n\nHere are some concrete instructions:\n\n\u5982\u679c\u5b66\u751f\u5728\u5b9e\u73b0\u7684\u8fc7\u7a0b\u4e2d\u9047\u5230\u95ee\u9898\uff0c\u4e0d\u8981\u76f4\u63a5\u544a\u77e5\u5b8c\u6574\u4ee3\u7801\u5982\u4f55\u7f16\u5199\uff0c\u8be2\u95ee\u5176\u5f53\u524d\u9047\u5230\u7684\u662f\u4ec0\u4e48\u95ee\u9898\uff0c\u5e76\u5e2e\u52a9\u5b66\u751f\u4e00\u6b65\u6b65\u5b8c\u6210\u9898\u76ee\u3002\n\n\u5b9e\u73b0\u4ee3\u7801\u540e\uff0c\u5168\u90e8\u901a\u8fc7\u6d4b\u8bd5\u6570\u636e\u540e\u624d\u53ef\u4ee5\u8fdb\u5165\u4e0b\u4e00\u8282\u3002\n\n\u672c\u4f53\u6d4b\u8bd5\u70b9\u6587\u4ef6\u5939\u540d `twice_split\u3002`\n\n\n\n\n\n", + "role": "system", + "url": null, + "metadata": null + }, + { + "id": "55a91eb47a8e4f6a90f72c5b8adb62e7", + "timestamp": "2025-01-01 18:47:50", + "name": "system", + "content": "\u547d\u4ee4\u6267\u884c\u7ed3\u679c\u5982\u4e0a\uff0c\u8bf7\u603b\u7ed3\u5e76\u5f15\u5bfc\u5b66\u751f\u8fdb\u884c\u4e0b\u4e00\u6b65\u64cd\u4f5c", + "role": "system", + "url": null, + "metadata": null + }, + { + "id": "ddace8fbc1ca47dca894c3329b140a9f", + "timestamp": "2025-01-01 18:47:52", + "name": "user_4eb13cc2-52ab-4281-ad32-83f1ccccadf7", + "content": { + "thought": "\u5b66\u751f\u9700\u8981\u5b9e\u73b0\u4e8c\u5206\u67e5\u627e\uff0c\u5e76\u5728\u5b9e\u73b0\u8fc7\u7a0b\u4e2d\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u95ee\u9898\u3002\u6211\u5e94\u8be5\u5f15\u5bfc\u4ed6\u4eec\u9010\u6b65\u5b8c\u6210\u8fd9\u4e2a\u7b97\u6cd5\u3002", + "speak": "\u8bf7\u5148\u5c1d\u8bd5\u5b9e\u73b0\u4e8c\u5206\u67e5\u627e\u7684\u903b\u8f91\u3002\u5982\u679c\u5728\u5b9e\u73b0\u8fc7\u7a0b\u4e2d\u9047\u5230\u95ee\u9898\uff0c\u53ef\u4ee5\u544a\u8bc9\u6211\u5177\u4f53\u662f\u4ec0\u4e48\u95ee\u9898\uff0c\u6211\u4f1a\u5e2e\u52a9\u4f60\u89e3\u51b3\u3002", + "function": [] + }, + "role": "assistant", + "url": null, + "metadata": null + }, + { + "id": "c742b1c3777d424e88f528e7240fa481", + "timestamp": "2025-01-01 18:48:29", + "name": "system", + "content": "1. Execute function judge\n [ARGUMENTS]:\n filepath: main.py\n [STATUS]: SUCCESS\n [RESULT]: (0, '\u8bc4\u6d4b\u5f97\u5206\u4e3a 0, \u5728 40 \u4e2a\u6d4b\u8bd5\u7528\u4f8b\u4e2d\u901a\u8fc7\u4e86 0\u4e2a\u3002')\n", + "role": "system", + "url": null, + "metadata": null + }, + { + "id": "0719f0912285479aaf2b2d40fa02ac98", + "timestamp": "2025-01-01 18:48:29", + "name": "system", + "content": "\u547d\u4ee4\u6267\u884c\u7ed3\u679c\u5982\u4e0a\uff0c\u8bf7\u603b\u7ed3\u5e76\u5f15\u5bfc\u5b66\u751f\u8fdb\u884c\u4e0b\u4e00\u6b65\u64cd\u4f5c", + "role": "system", + "url": null, + "metadata": null + }, + { + "id": "5518c0618077410ab32a36ecba13a3fa", + "timestamp": "2025-01-01 18:48:31", + "name": "user_4eb13cc2-52ab-4281-ad32-83f1ccccadf7", + "content": { + "thought": "\u5b66\u751f\u7684\u4e8c\u5206\u67e5\u627e\u5b9e\u73b0\u6ca1\u6709\u901a\u8fc7\u4efb\u4f55\u6d4b\u8bd5\u7528\u4f8b\uff0c\u8bf4\u660e\u4ee3\u7801\u53ef\u80fd\u5b58\u5728\u903b\u8f91\u9519\u8bef\u3002", + "speak": "\u4f60\u7684\u4ee3\u7801\u5728\u8bc4\u6d4b\u4e2d\u6ca1\u6709\u901a\u8fc7\u4efb\u4f55\u6d4b\u8bd5\u7528\u4f8b\uff0c\u53ef\u80fd\u5b58\u5728\u4e00\u4e9b\u95ee\u9898\u3002\u8bf7\u4ed4\u7ec6\u68c0\u67e5\u4f60\u7684\u4e8c\u5206\u67e5\u627e\u5b9e\u73b0\uff0c\u7279\u522b\u662f\u8fb9\u754c\u6761\u4ef6\u548c\u8fd4\u56de\u503c\u7684\u90e8\u5206\u3002\u9700\u8981\u5e2e\u52a9\u7684\u8bdd\uff0c\u53ef\u4ee5\u544a\u8bc9\u6211\u4f60\u9047\u5230\u7684\u5177\u4f53\u95ee\u9898\u3002", + "function": [] + }, + "role": "assistant", + "url": null, + "metadata": null + }, + { + "id": "4b186d3f172a4d3aaeb2481e43817922", + "timestamp": "2025-01-01 18:48:49", + "name": "user", + "content": "\u8bf7\u67e5\u770b\u6211\u7684\u4ee3\u7801\uff0c\u95ee\u9898\u5728\u4e8e\u54ea\u91cc\u5462\uff1f", + "role": "user", + "url": null, + "metadata": null + }, + { + "id": "351ace31a7984d13ab1ec11151c0aefe", + "timestamp": "2025-01-01 18:48:52", + "name": "user_4eb13cc2-52ab-4281-ad32-83f1ccccadf7", + "content": { + "thought": "\u9700\u8981\u67e5\u770b\u5b66\u751f\u7684\u4ee3\u7801\uff0c\u4ee5\u5e2e\u52a9\u4ed6\u4eec\u89e3\u51b3\u95ee\u9898\u3002", + "speak": "\u8ba9\u6211\u5148\u67e5\u770b\u4f60\u7684\u4ee3\u7801\u5185\u5bb9\uff0c\u7136\u540e\u6211\u4f1a\u7ed9\u51fa\u5177\u4f53\u7684\u53cd\u9988\u548c\u5efa\u8bae\u3002", + "function": [ + { + "name": "read_file", + "arguments": { + "filepath": "/home/caikecheng/algoAgent/study/cake/algorithm/binary_search/main.py" + } + } + ] + }, + "role": "assistant", + "url": null, + "metadata": null + }, + { + "id": "71da76256284416cbd6e19a62355d507", + "timestamp": "2025-01-01 18:48:53", + "name": "system", + "content": "1. Execute function read_file\n [ARGUMENTS]:\n filepath: /home/caikecheng/algoAgent/study/cake/algorithm/binary_search/main.py\n [STATUS]: SUCCESS\n [RESULT]: ```\ndef binary_search(arr, target):\n left, right = 0, len(arr) - 1\n while left <= right:\n mid = left + (right - left) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n return -1\n\nif __name__ == '__main__':\n sorted_array = list(map(int, input(\"\u8f93\u5165\u6570\u636e\").split()))\n target_value = int(input())\n result = binary_search(sorted_array, target_value)\n print(result)```\n\n", + "role": "system", + "url": null, + "metadata": null + }, + { + "id": "a7b7256bddbc4b51a0828578008fa1fc", + "timestamp": "2025-01-01 18:48:53", + "name": "system", + "content": "\u547d\u4ee4\u6267\u884c\u7ed3\u679c\u5982\u4e0a\uff0c\u8bf7\u603b\u7ed3\u5e76\u5f15\u5bfc\u5b66\u751f\u8fdb\u884c\u4e0b\u4e00\u6b65\u64cd\u4f5c", + "role": "system", + "url": null, + "metadata": null + }, + { + "id": "b2ee66aabdeb40709c5c884df6f268cb", + "timestamp": "2025-01-01 18:48:55", + "name": "user_4eb13cc2-52ab-4281-ad32-83f1ccccadf7", + "content": { + "thought": "\u5b66\u751f\u7684\u4ee3\u7801\u5b9e\u73b0\u4e86\u4e8c\u5206\u67e5\u627e\u7684\u529f\u80fd\uff0c\u4f46\u5728\u8bfb\u53d6\u8f93\u5165\u548c\u6267\u884c\u591a\u6b21\u67e5\u8be2\u65f6\u8fd8\u6709\u95ee\u9898\u3002", + "speak": "\u4f60\u7684\u4e8c\u5206\u67e5\u627e\u51fd\u6570\u662f\u6b63\u786e\u7684\uff0c\u4f46\u5728\u4e3b\u7a0b\u5e8f\u4e2d\u4f60\u53ea\u8bfb\u53d6\u4e86\u4e00\u6b21\u8f93\u5165\uff0c\u4e14\u6ca1\u6709\u8fdb\u884c\u591a\u6b21\u67e5\u8be2\u5904\u7406\u3002\u4f60\u9700\u8981\u5148\u8bfb\u53d6\u6709\u5e8f\u6570\u7ec4\u7684\u957f\u5ea6\uff0c\u518d\u8bfb\u53d6\u6570\u7ec4\u5143\u7d20\uff0c\u63a5\u7740\u8bfb\u53d6\u67e5\u8be2\u6b21\u6570\u5e76\u5bf9\u6bcf\u4e2a\u67e5\u8be2\u8fdb\u884c\u5904\u7406\u3002\u8bf7\u5c1d\u8bd5\u4fee\u6539\u4f60\u7684\u4ee3\u7801\u4ee5\u652f\u6301\u591a\u4e2a\u67e5\u8be2\uff0c\u5e76\u786e\u4fdd\u8f93\u51fa\u6bcf\u6b21\u67e5\u8be2\u7684\u7ed3\u679c\u3002", + "function": [] + }, + "role": "assistant", + "url": null, + "metadata": null + }, + { + "id": "6fb06d9423464751999e735993fc7603", + "timestamp": "2025-01-01 18:49:19", + "name": "user", + "content": "\u6211\u5df2\u7ecf\u4fee\u6539\u4e86\uff0c\u8bf7\u518d\u8bc4\u6d4b\u4e00\u4e0b", + "role": "user", + "url": null, + "metadata": null + }, + { + "id": "4017e2d8ca9e4458bb44861e9899ba6b", + "timestamp": "2025-01-01 18:49:22", + "name": "user_4eb13cc2-52ab-4281-ad32-83f1ccccadf7", + "content": { + "thought": "\u5b66\u751f\u5df2\u7ecf\u505a\u4e86\u4fee\u6539\uff0c\u73b0\u5728\u9700\u8981\u5bf9\u4ed6\u4eec\u7684\u4ee3\u7801\u8fdb\u884c\u91cd\u65b0\u8bc4\u6d4b\u3002", + "speak": "\u597d\u7684\uff0c\u8ba9\u6211\u6765\u8bc4\u6d4b\u4f60\u7684\u4ee3\u7801\uff0c\u770b\u770b\u5b83\u662f\u5426\u80fd\u901a\u8fc7\u6d4b\u8bd5\u7528\u4f8b\u3002", + "function": [ + { + "name": "judge", + "arguments": { + "filepath": "/home/caikecheng/algoAgent/study/cake/algorithm/binary_search/main.py" + } + } + ] + }, + "role": "assistant", + "url": null, + "metadata": null + }, + { + "id": "b38cd9699d2e41169237621858ca32e5", + "timestamp": "2025-01-01 18:49:23", + "name": "system", + "content": "1. Execute function judge\n [ARGUMENTS]:\n filepath: /home/caikecheng/algoAgent/study/cake/algorithm/binary_search/main.py\n [STATUS]: SUCCESS\n [RESULT]: (100, '\u8bc4\u6d4b\u5f97\u5206\u4e3a 100, \u5728 40 \u4e2a\u6d4b\u8bd5\u7528\u4f8b\u4e2d\u901a\u8fc7\u4e86 40\u4e2a\u3002')\n", + "role": "system", + "url": null, + "metadata": null + }, + { + "id": "d39f4b43f0024a7eb14d8b760d847be5", + "timestamp": "2025-01-01 18:49:23", + "name": "system", + "content": "\u547d\u4ee4\u6267\u884c\u7ed3\u679c\u5982\u4e0a\uff0c\u8bf7\u603b\u7ed3\u5e76\u5f15\u5bfc\u5b66\u751f\u8fdb\u884c\u4e0b\u4e00\u6b65\u64cd\u4f5c", + "role": "system", + "url": null, + "metadata": null + }, + { + "id": "8192e17189b446978c6f1576d68942b1", + "timestamp": "2025-01-01 18:49:25", + "name": "user_4eb13cc2-52ab-4281-ad32-83f1ccccadf7", + "content": { + "thought": "\u5b66\u751f\u7684\u4ee3\u7801\u5df2\u7ecf\u6210\u529f\u901a\u8fc7\u4e86\u6240\u6709\u6d4b\u8bd5\u7528\u4f8b\uff0c\u8bf4\u660e\u4ed6\u4eec\u7684\u5b9e\u73b0\u662f\u6b63\u786e\u7684\u3002", + "speak": "\u606d\u559c\u4f60\uff01\u4f60\u7684\u4ee3\u7801\u5728\u8bc4\u6d4b\u4e2d\u5df2\u7ecf\u901a\u8fc7\u4e86\u6240\u6709\u6d4b\u8bd5\u7528\u4f8b\u3002\u73b0\u5728\u6211\u4eec\u53ef\u4ee5\u8fdb\u5165\u4e0b\u4e00\u7ae0\u5b66\u4e60\u65b0\u7684\u5185\u5bb9\u4e86\u3002", + "function": [ + { + "name": "next_chapter", + "arguments": {} + } + ] + }, + "role": "assistant", + "url": null, + "metadata": null + }, + { + "id": "be629f2384b0456bba664a6ec6aa550c", + "timestamp": "2025-01-01 18:49:32", + "name": "user", + "content": "\u8fdb\u5165\u4e0b\u4e00\u7ae0", + "role": "user", + "url": null, + "metadata": null + }, + { + "id": "7c508c59ded24fd6bf3fd7731c6c626e", + "timestamp": "2025-01-01 18:49:34", + "name": "user_4eb13cc2-52ab-4281-ad32-83f1ccccadf7", + "content": { + "thought": "\u6210\u529f\u8fdb\u5165\u4e0b\u4e00\u7ae0\uff0c\u63a5\u4e0b\u6765\u5b66\u751f\u5c06\u5b66\u4e60\u65b0\u7684\u5185\u5bb9\u3002", + "speak": "\u6211\u4eec\u5df2\u7ecf\u6210\u529f\u8fdb\u5165\u4e0b\u4e00\u7ae0\u3002\u8bf7\u51c6\u5907\u597d\u5b66\u4e60\u63a5\u4e0b\u6765\u7684\u7b97\u6cd5\u5185\u5bb9\uff01", + "function": [] + }, + "role": "assistant", + "url": null, + "metadata": null + }, + { + "id": "1fd1633a4e8540ab94952833e4b39ec8", + "timestamp": "2025-01-01 18:49:44", + "name": "user", + "content": "\u8fdb\u5165\u4e0b\u4e00\u7ae0", + "role": "user", + "url": null, + "metadata": null + }, + { + "id": "5964823bd2584d44ae8a3cbff51986c9", + "timestamp": "2025-01-01 18:49:46", + "name": "user_4eb13cc2-52ab-4281-ad32-83f1ccccadf7", + "content": { + "thought": "\u5df2\u7ecf\u8fdb\u5165\u4e0b\u4e00\u7ae0\uff0c\u5b66\u751f\u51c6\u5907\u5b66\u4e60\u65b0\u7684\u5185\u5bb9\u3002", + "speak": "\u6211\u4eec\u73b0\u5728\u5df2\u7ecf\u8fdb\u5165\u4e86\u4e0b\u4e00\u7ae0\uff0c\u8bf7\u51c6\u5907\u597d\u63a5\u53d7\u65b0\u7684\u7b97\u6cd5\u6311\u6218\uff01", + "function": [] + }, + "role": "assistant", + "url": null, + "metadata": null + }, + { + "id": "b4e1e59bf45640acb8d2c30bd46446b9", + "timestamp": "2025-01-01 18:49:55", + "name": "user", + "content": "\u8c03\u7528next_chapter\u547d\u4ee4", + "role": "user", + "url": null, + "metadata": null + }, + { + "id": "4547da79875d4e7fac620dd1c4001027", + "timestamp": "2025-01-01 18:49:57", + "name": "user_4eb13cc2-52ab-4281-ad32-83f1ccccadf7", + "content": { + "thought": "\u5b66\u751f\u8bf7\u6c42\u8fdb\u5165\u4e0b\u4e00\u7ae0\uff0c\u73b0\u5728\u9700\u8981\u6267\u884c\u76f8\u5173\u547d\u4ee4\u3002", + "speak": "\u6211\u5c06\u5e26\u4f60\u8fdb\u5165\u4e0b\u4e00\u7ae0\uff0c\u8bf7\u7a0d\u7b49\u3002", + "function": [ + { + "name": "next_chapter", + "arguments": {} + } + ] + }, + "role": "assistant", + "url": null, + "metadata": null + } + ], + "score": 35, + "is_rebuttal": false, + "rebuttal_score": 0 } ], "binary_search" diff --git a/Html/db/user.py b/Html/db/user.py index c389fc8..5ceb16b 100644 --- a/Html/db/user.py +++ b/Html/db/user.py @@ -2,7 +2,7 @@ import os # Example usage: import json from datetime import datetime - +import copy LOCAL_USER_DATA_DIR = "data/user/" # only use locally, not for other .py files class User: @@ -88,6 +88,19 @@ class User: 'course_process_dict': self.course_process_dict } + def to_json_without_dialog(self): + course_dict = copy.deepcopy(self.course_process_dict) + for course_id in course_dict.keys(): + for lep,lid in course_dict[course_id]['lesson_processs']: + for chapter_info in lep: + chapter_info['dialog']=[] + return json.dumps({ + 'user_id': self.user_id, + 'select_course': self.select_course, + 'head_icon': self.head_icon, + 'course_process_dict': course_dict + }, indent=1) + def to_json(self): return json.dumps(self.__json__(), indent=4) diff --git a/Html/static/css/desktop.css b/Html/static/css/desktop.css index 1694649..eb5d5fc 100644 --- a/Html/static/css/desktop.css +++ b/Html/static/css/desktop.css @@ -211,3 +211,88 @@ max-width: 200px; } +.button { + display: flex; + align-items: center; + padding: 15px; + border-bottom: 1px solid #eee; + cursor: pointer; + transition: background-color 0.3s ease; +} +.button:hover { + background-color: #f0f0f0; +} +.close-button { + width: auto; + height: auto; + text-align: center; + padding: 5px; + padding-bottom: 2px; + padding-top: 2px; + border-radius: 5px; +} +/* 新增的侧边工具栏样式 */ +.sidebar-tools { + position: fixed; + top: 50%; + transform: translateY(-50%); + right: -250px; /* 初始隐藏 */ + width: 250px; + background-color: #fff; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); + border-radius: 10px 0 0 10px; + transition: right 0.3s ease-in-out; + z-index: 1000; +} +.sidebar-tools.open { + right: 0; +} +.sidebar-tools .tool-button { + display: flex; + align-items: center; + padding: 15px; + border-bottom: 1px solid #eee; + cursor: pointer; + transition: background-color 0.3s ease; +} +.sidebar-tools .tool-button:hover { + background-color: #f0f0f0; +} +.sidebar-tools .tool-button .icon { + width: 30px; + height: 30px; + margin-right: 10px; + background-color: #007bff; + border-radius: 5px; + display: flex; + align-items: center; + justify-content: center; + color: #fff; +} +.sidebar-tools .tool-button .description { + flex-grow: 1; +} +.toggle-button { + position: fixed; + top: 50%; + transform: translateY(-50%); + right: -10px; /* 初始隐藏 */ + width: 50px; + height: 50px; + background-color: #007bff; + border-radius: 50%; + display: flex; + align-items: center; + justify-content: center; + color: #fff; + cursor: pointer; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); + transition: right 0.3s ease-in-out; + z-index: 1001; +} +.toggle-button.open { + right: 250px; +} +.toggle-button .icon { + font-size: 20px; +} \ No newline at end of file diff --git a/Html/static/image/CS101/CS101.png b/Html/static/image/CS101/CS101.png new file mode 100644 index 0000000..b529ce4 Binary files /dev/null and b/Html/static/image/CS101/CS101.png differ diff --git a/Html/static/image/data-structure/book_cover-data-structure.png b/Html/static/image/data-structure/book_cover-data-structure.png new file mode 100644 index 0000000..db5d916 Binary files /dev/null and b/Html/static/image/data-structure/book_cover-data-structure.png differ diff --git a/Html/static/js/chatbox.js b/Html/static/js/chatbox.js index b6b492b..35612c4 100644 --- a/Html/static/js/chatbox.js +++ b/Html/static/js/chatbox.js @@ -1,5 +1,6 @@ var socket; +let system_message_idx=0 document.addEventListener('DOMContentLoaded', function() { data = window.appData; console.log(data); @@ -12,7 +13,7 @@ document.addEventListener('DOMContentLoaded', function() { socket.on('message', function(data) { // 显示服务器的回复消息 const serverMessage = document.createElement('div'); - serverMessage.innerHTML = `
`; + serverMessage.innerHTML = ``; document.getElementById('chatbox').appendChild(serverMessage); // 滚动到最新消息 @@ -32,7 +33,7 @@ document.addEventListener('DOMContentLoaded', function() { approveButton.innerText = '批准'; approveButton.data = element; approveButton.style.width = '100%'; - approveButton.style.maxHeight = '30px'; + approveButton.style.borderRadius = '4px'; approveButton.onclick = function(event) { console.log(element) socket.emit('message', JSON.stringify({type:'function', data:element})); @@ -65,7 +66,33 @@ document.addEventListener('DOMContentLoaded', function() { document.getElementById('chatbox').appendChild(scoreMessage); document.getElementById('chatbox').scrollTop = document.getElementById('chatbox').scrollHeight; }) - + socket.on('system_message',function(data){ + console.log(data) + let systemMessage = document.createElement('div'); + systemMessage.className = 'chat-message server-message'; + let closeButton = document.createElement('button'); + closeButton.className = 'close-button'; // 可以根据需要添加样式类 + closeButton.innerHTML = '×'; // 关闭按钮的文本内容 + closeButton.style.marginRight = '10px'; // 可选:设置关闭按钮的右边距 + + systemMessage.appendChild(closeButton); + systemMessage.innerHTML += `系统提示: ${data}`; + systemMessage.id = 'system_message_'+system_message_idx; + system_message_idx+=1 + document.getElementById('chatbox').appendChild(systemMessage); + document.getElementById('chatbox').scrollTop = document.getElementById('chatbox').scrollHeight; + $('.close-button').on('click', function(event) { + $(this).css({ + 'background-color': 'gray', + 'color': 'white', // 可选:设置文字颜色为白色,以便更清晰地显示 + 'border': 'none' // 可选:去掉边框 + }); + $(this).parent().remove(); + }); + setTimeout(function() { + $(systemMessage.id).remove(); + }, 5000); // 5000 毫秒 = 5 秒 + }) }); @@ -106,7 +133,9 @@ chineseRadio.addEventListener('change', function() { }); - +function sendInitiativeFunctionCall(function_name){ + socket.emit('initiative', {'name': function_name}); +} // 发送消息 function sendMessage() { const input = document.getElementById('messageInput').value; diff --git a/Html/templates/desktop.html b/Html/templates/desktop.html index 3a115df..accf0ef 100644 --- a/Html/templates/desktop.html +++ b/Html/templates/desktop.html @@ -14,6 +14,7 @@ +