MCPcopy Index your code
hub / github.com/OpenBMB/ChatDev / create_folder

Function create_folder

functions/function_calling/file.py:238–266  ·  view source on GitHub ↗

Create a directory tree under the workspace.

(
    path: Annotated[str, ParamMeta(description="Workspace-relative folder path")],
    *,
    parents: Annotated[bool, ParamMeta(description="Create missing parent directories")]
    = True,
    exist_ok: Annotated[bool, ParamMeta(description="Do not raise if folder already exists")]
    = True,
    _context: Dict[str, Any] | None = None,
)

Source from the content-addressed store, hash-verified

236
237
238def create_folder(
239 path: Annotated[str, ParamMeta(description="Workspace-relative folder path")],
240 *,
241 parents: Annotated[bool, ParamMeta(description="Create missing parent directories")]
242 = True,
243 exist_ok: Annotated[bool, ParamMeta(description="Do not raise if folder already exists")]
244 = True,
245 _context: Dict[str, Any] | None = None,
246) -> Dict[str, Any]:
247 """Create a directory tree under the workspace."""
248
249 if not path:
250 raise ValueError("path must be provided")
251 _check_attachments_not_modified(path)
252
253 ctx = FileToolContext(_context)
254 target = ctx.resolve_under_workspace(path)
255
256 if target.exists() and not target.is_dir():
257 raise ValueError("Target exists and is not a directory")
258
259 previously_exists = target.exists()
260 target.mkdir(parents=parents, exist_ok=exist_ok)
261
262 return {
263 "path": ctx.to_workspace_relative(target),
264 "absolute_path": str(target),
265 "created": not previously_exists,
266 }
267
268
269def delete_path(

Callers

nothing calls this directly

Calls 5

to_workspace_relativeMethod · 0.95
ParamMetaClass · 0.90
FileToolContextClass · 0.85

Tested by

no test coverage detected