file_search.py — langchain Source File
Architecture documentation for file_search.py, a python file in the langchain codebase. 10 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR b1c845f0_034f_02e0_9e00_d934b4cbf29e["file_search.py"] 6981cd94_29a7_1048_c996_e1c505576216["fnmatch"] b1c845f0_034f_02e0_9e00_d934b4cbf29e --> 6981cd94_29a7_1048_c996_e1c505576216 7025b240_fdc3_cf68_b72f_f41dac94566b["json"] b1c845f0_034f_02e0_9e00_d934b4cbf29e --> 7025b240_fdc3_cf68_b72f_f41dac94566b 67ec3255_645e_8b6e_1eff_1eb3c648ed95["re"] b1c845f0_034f_02e0_9e00_d934b4cbf29e --> 67ec3255_645e_8b6e_1eff_1eb3c648ed95 f02b765e_0b79_f1fa_161f_0492d5c24a46["subprocess"] b1c845f0_034f_02e0_9e00_d934b4cbf29e --> f02b765e_0b79_f1fa_161f_0492d5c24a46 69e1d8cc_6173_dcd0_bfdf_2132d8e1ce56["contextlib"] b1c845f0_034f_02e0_9e00_d934b4cbf29e --> 69e1d8cc_6173_dcd0_bfdf_2132d8e1ce56 af34f08b_0ede_2b87_0db6_983d74ed0249["datetime"] b1c845f0_034f_02e0_9e00_d934b4cbf29e --> af34f08b_0ede_2b87_0db6_983d74ed0249 b6ee5de5_719a_eeb5_1e11_e9c63bc22ef8["pathlib"] b1c845f0_034f_02e0_9e00_d934b4cbf29e --> b6ee5de5_719a_eeb5_1e11_e9c63bc22ef8 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] b1c845f0_034f_02e0_9e00_d934b4cbf29e --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 43d88577_548b_2248_b01b_7987bae85dcc["langchain_core.tools"] b1c845f0_034f_02e0_9e00_d934b4cbf29e --> 43d88577_548b_2248_b01b_7987bae85dcc 50acc543_e5f0_2162_cf07_c2bf50723e0c["langchain.agents.middleware.types"] b1c845f0_034f_02e0_9e00_d934b4cbf29e --> 50acc543_e5f0_2162_cf07_c2bf50723e0c style b1c845f0_034f_02e0_9e00_d934b4cbf29e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""File search middleware for Anthropic text editor and memory tools.
This module provides Glob and Grep search tools that operate on files stored
in state or filesystem.
"""
from __future__ import annotations
import fnmatch
import json
import re
import subprocess
from contextlib import suppress
from datetime import datetime, timezone
from pathlib import Path
from typing import Literal
from langchain_core.tools import tool
from langchain.agents.middleware.types import AgentMiddleware, AgentState, ContextT, ResponseT
def _expand_include_patterns(pattern: str) -> list[str] | None:
"""Expand brace patterns like `*.{py,pyi}` into a list of globs."""
if "}" in pattern and "{" not in pattern:
return None
expanded: list[str] = []
def _expand(current: str) -> None:
start = current.find("{")
if start == -1:
expanded.append(current)
return
end = current.find("}", start)
if end == -1:
raise ValueError
prefix = current[:start]
suffix = current[end + 1 :]
inner = current[start + 1 : end]
if not inner:
raise ValueError
for option in inner.split(","):
_expand(prefix + option + suffix)
try:
_expand(pattern)
except ValueError:
return None
return expanded
def _is_valid_include_pattern(pattern: str) -> bool:
"""Validate glob pattern used for include filters."""
if not pattern:
return False
// ... (328 more lines)
Domain
Subdomains
Classes
Dependencies
- contextlib
- datetime
- fnmatch
- json
- langchain.agents.middleware.types
- langchain_core.tools
- pathlib
- re
- subprocess
- typing
Source
Frequently Asked Questions
What does file_search.py do?
file_search.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, MessageSchema subdomain.
What functions are defined in file_search.py?
file_search.py defines 3 function(s): _expand_include_patterns, _is_valid_include_pattern, _match_include_pattern.
What does file_search.py depend on?
file_search.py imports 10 module(s): contextlib, datetime, fnmatch, json, langchain.agents.middleware.types, langchain_core.tools, pathlib, re, and 2 more.
Where is file_search.py in the architecture?
file_search.py is located at libs/langchain_v1/langchain/agents/middleware/file_search.py (domain: CoreAbstractions, subdomain: MessageSchema, directory: libs/langchain_v1/langchain/agents/middleware).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free