mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-12 09:12:38 +02:00
refine naming and some details
This commit is contained in:
parent
e85f749031
commit
b1da79c714
19 changed files with 190 additions and 201 deletions
|
|
@ -352,7 +352,7 @@ def parse_recipient(text):
|
|||
return ""
|
||||
|
||||
|
||||
def create_func_config(func_schema: dict) -> dict:
|
||||
def create_func_call_config(func_schema: dict) -> dict:
|
||||
"""Create new function call config"""
|
||||
tools = [{"type": "function", "function": func_schema}]
|
||||
tool_choice = {"type": "function", "function": {"name": func_schema["name"]}}
|
||||
|
|
@ -362,7 +362,7 @@ def create_func_config(func_schema: dict) -> dict:
|
|||
}
|
||||
|
||||
|
||||
def remove_comments(code_str):
|
||||
def remove_comments(code_str: str) -> str:
|
||||
"""Remove comments from code."""
|
||||
pattern = r"(\".*?\"|\'.*?\')|(\#.*?$)"
|
||||
|
||||
|
|
|
|||
|
|
@ -10,12 +10,13 @@ import nbformat
|
|||
|
||||
from metagpt.const import DATA_PATH
|
||||
from metagpt.roles.role import Role
|
||||
from metagpt.utils.common import read_json_file
|
||||
from metagpt.utils.save_code import save_code_file
|
||||
|
||||
|
||||
def load_history(save_dir: str = ""):
|
||||
"""
|
||||
Load history from the specified save directory.
|
||||
Load plan and code execution history from the specified save directory.
|
||||
|
||||
Args:
|
||||
save_dir (str): The directory from which to load the history.
|
||||
|
|
@ -26,14 +27,14 @@ def load_history(save_dir: str = ""):
|
|||
|
||||
plan_path = Path(save_dir) / "plan.json"
|
||||
nb_path = Path(save_dir) / "history_nb" / "code.ipynb"
|
||||
plan = json.load(open(plan_path, "r", encoding="utf-8"))
|
||||
plan = read_json_file(plan_path)
|
||||
nb = nbformat.read(open(nb_path, "r", encoding="utf-8"), as_version=nbformat.NO_CONVERT)
|
||||
return plan, nb
|
||||
|
||||
|
||||
def save_history(role: Role, save_dir: str = ""):
|
||||
"""
|
||||
Save history to the specified directory.
|
||||
Save plan and code execution history to the specified directory.
|
||||
|
||||
Args:
|
||||
role (Role): The role containing the plan and execute_code attributes.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue