Merge branch 'mgx_ops' into swe_editer

This commit is contained in:
seeker-jie 2024-08-29 18:03:47 +08:00
commit b394fed52b
58 changed files with 2003 additions and 1372 deletions

View file

@ -581,20 +581,20 @@ def read_json_file(json_file: str, encoding: str = "utf-8") -> list[Any]:
def handle_unknown_serialization(x: Any) -> str:
"""For `to_jsonable_python` debug, unknown values will be logged instead of raising an exception."""
"""For `to_jsonable_python` debug, get more detail about the x."""
if inspect.ismethod(x):
logger.error(f"Method: {x.__self__.__class__.__name__}.{x.__func__.__name__}")
tip = f"Cannot serialize method '{x.__func__.__name__}' of class '{x.__self__.__class__.__name__}'"
elif inspect.isfunction(x):
logger.error(f"Function: {x.__name__}")
tip = f"Cannot serialize function '{x.__name__}'"
elif hasattr(x, "__class__"):
logger.error(f"Instance of: {x.__class__.__name__}")
tip = f"Cannot serialize instance of '{x.__class__.__name__}'"
elif hasattr(x, "__name__"):
logger.error(f"Class or module: {x.__name__}")
tip = f"Cannot serialize class or module '{x.__name__}'"
else:
logger.error(f"Unknown type: {type(x)}")
tip = f"Cannot serialize object of type '{type(x).__name__}'"
return f"<Unserializable {type(x).__name__} object>"
raise TypeError(tip)
def write_json_file(json_file: str, data: Any, encoding: str = "utf-8", indent: int = 4, use_fallback: bool = False):

View file

@ -38,7 +38,7 @@ async def mermaid_to_file(
Returns:
int: 0 if the conversion is successful, -1 if the conversion fails.
"""
suffixes = suffixes or ["png"]
suffixes = suffixes or ["svg"]
# Write the Mermaid code to a temporary file
config = config if config else Config.default()
dir_name = os.path.dirname(output_file_without_suffix)

View file

@ -189,7 +189,7 @@ class OmniParseClient:
# Do not verify if only byte data is provided
return
file_ext = Path(verify_file_path).suffix
file_ext = Path(verify_file_path).suffix.lower()
if file_ext not in allowed_file_extensions:
raise ValueError(f"Not allowed {file_ext} File extension must be one of {allowed_file_extensions}")