Merge branch 'dev' into dev_make_tools

This commit is contained in:
刘棒棒 2023-12-21 10:36:13 +08:00
commit d72b457c83
7 changed files with 316 additions and 62 deletions

View file

@ -46,9 +46,12 @@ class ExecuteCode(ABC):
class ExecutePyCode(ExecuteCode, Action):
"""execute code, return result to llm, and display it."""
def __init__(self, name: str = "python_executor", context=None, llm=None):
def __init__(self, name: str = "python_executor", context=None, llm=None, nb=None):
super().__init__(name, context, llm)
self.nb = nbformat.v4.new_notebook()
if nb is None:
self.nb = nbformat.v4.new_notebook()
else:
self.nb = nb
self.nb_client = NotebookClient(self.nb)
self.console = Console()
self.interaction = "ipython" if self.is_ipython() else "terminal"

View file

@ -210,6 +210,8 @@ class WriteCodeWithTools(BaseWriteAnalysisCode):
module_name=module_name,
tool_catalog=tool_catalog,
)
else:
prompt = GENERATE_CODE_PROMPT.format(
user_requirement=plan.goal,

View file

@ -106,7 +106,7 @@ class WriteCodeSteps(Action):
def process_task(task):
task_dict = task.dict()
# ptask = {k: task_dict[k] for k in task_dict if k in select_task_keys }
ptask = f"task_id_{task_dict['task_id']}:{task_dict['instruction']}\n"
ptask = f"task_id_{task_dict['task_id']}:{task_dict['instruction']}"
return ptask