mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-02 14:45:17 +02:00
Update test for action node & Modify extenv (self reflection)
This commit is contained in:
parent
32211ff5f2
commit
a1b0faacf4
5 changed files with 159 additions and 33 deletions
|
|
@ -25,7 +25,7 @@ import sys
|
|||
import traceback
|
||||
import typing
|
||||
from pathlib import Path
|
||||
from typing import Any, List, Tuple, Union
|
||||
from typing import Any, List, Tuple, Union, Callable
|
||||
|
||||
import aiofiles
|
||||
import loguru
|
||||
|
|
@ -214,7 +214,7 @@ class OutputParser:
|
|||
|
||||
if start_index != -1 and end_index != -1:
|
||||
# Extract the structure part
|
||||
structure_text = text[start_index : end_index + 1]
|
||||
structure_text = text[start_index: end_index + 1]
|
||||
|
||||
try:
|
||||
# Attempt to convert the text to a Python data type using ast.literal_eval
|
||||
|
|
@ -337,6 +337,14 @@ def print_members(module, indent=0):
|
|||
print(f"{prefix}Method: {name}")
|
||||
|
||||
|
||||
def get_function_schema(func: Callable) -> dict[str, Union[dict, Any, str]]:
|
||||
sig = inspect.signature(func)
|
||||
parameters = sig.parameters
|
||||
return_type = sig.return_annotation
|
||||
param_schema = {name: parameter.annotation for name, parameter in parameters.items()}
|
||||
return {"input_params": param_schema, "return_type": return_type, "func_desc": func.__doc__, "func": func}
|
||||
|
||||
|
||||
def parse_recipient(text):
|
||||
# FIXME: use ActionNode instead.
|
||||
pattern = r"## Send To:\s*([A-Za-z]+)\s*?" # hard code for now
|
||||
|
|
@ -594,6 +602,10 @@ def list_files(root: str | Path) -> List[Path]:
|
|||
return files
|
||||
|
||||
|
||||
def is_coroutine_func(func: Callable) -> bool:
|
||||
return inspect.iscoroutinefunction(func)
|
||||
|
||||
|
||||
def encode_image(image_path: Path, encoding: str = "utf-8") -> str:
|
||||
with open(str(image_path), "rb") as image_file:
|
||||
return base64.b64encode(image_file.read()).decode(encoding)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue