🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
feat: merge mgx_ops
莘权 马fc703a6930b0
diff --cc metagpt/utils/common.pyindex 2cfd56e1e,def127fc9..8e8bccf2d--- a/metagpt/utils/common.py+++ b/metagpt/utils/common.py@@@ -1121,21 -1120,23 +1121,43 @@@ def log_time(method)return timeit_wrapper_async if iscoroutinefunction(method) else timeit_wrapper+async def check_http_endpoint(url: str, timeout: int = 3) -> bool:+ """+ Checks the status of an HTTP endpoint.++ Args:+ url (str): The URL of the HTTP endpoint to check.+ timeout (int, optional): The timeout in seconds for the HTTP request. Defaults to 3.++ Returns:+ bool: True if the endpoint is online and responding with a 200 status code, False otherwise.+ """+ async with aiohttp.ClientSession() as session:+ try:+ async with session.get(url, timeout=timeout) as response:+ return response.status == 200+ except Exception as e:+ print(f"Error accessing the endpoint {url}: {e}")+ return False+++++ def rectify_pathname(path: Union[str, Path], default_filename: str) -> Path:+ """+ Rectifies the given path to ensure a valid output file path.++ If the given `path` is a directory, it creates the directory (if it doesn't exist) and appends the `default_filename` to it. If the `path` is a file path, it creates the parent directory (if it doesn't exist) and returns the `path`.++ Args:+ path (Union[str, Path]): The input path, which can be a string or a `Path` object.+ default_filename (str): The default filename to use if the `path` is a directory.++ Returns:+ Path: The rectified output path.+ """+ output_pathname = Path(path)+ if output_pathname.is_dir():+ output_pathname.mkdir(parents=True, exist_ok=True)+ output_pathname = output_pathname / default_filename+ else:+ output_pathname.parent.mkdir(parents=True, exist_ok=True)+ return output_pathname