_list_directory() — langchain Function Reference
Architecture documentation for the _list_directory() function in anthropic_tools.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 19486b37_2ea2_1132_8eb1_d4def5f50de0["_list_directory()"] 19f1d717_5fcb_e619_f4a8_c2fc5a4421aa["anthropic_tools.py"] 19486b37_2ea2_1132_8eb1_d4def5f50de0 -->|defined in| 19f1d717_5fcb_e619_f4a8_c2fc5a4421aa f2bf3aba_56f3_0a65_e91d_2e98b4adca69["_handle_view()"] f2bf3aba_56f3_0a65_e91d_2e98b4adca69 -->|calls| 19486b37_2ea2_1132_8eb1_d4def5f50de0 style 19486b37_2ea2_1132_8eb1_d4def5f50de0 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/anthropic/langchain_anthropic/middleware/anthropic_tools.py lines 134–156
def _list_directory(files: dict[str, FileData], path: str) -> list[str]:
"""List files in a directory.
Args:
files: Files `dict`.
path: Normalized directory path.
Returns:
Sorted list of file paths in the directory.
"""
# Ensure path ends with / for directory matching
dir_path = path if path.endswith("/") else f"{path}/"
matching_files = []
for file_path in files:
if file_path.startswith(dir_path):
# Get relative path from directory
relative = file_path[len(dir_path) :]
# Only include direct children (no subdirectories)
if "/" not in relative:
matching_files.append(file_path)
return sorted(matching_files)
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does _list_directory() do?
_list_directory() is a function in the langchain codebase, defined in libs/partners/anthropic/langchain_anthropic/middleware/anthropic_tools.py.
Where is _list_directory() defined?
_list_directory() is defined in libs/partners/anthropic/langchain_anthropic/middleware/anthropic_tools.py at line 134.
What calls _list_directory()?
_list_directory() is called by 1 function(s): _handle_view.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free