_format_grep_results() — langchain Function Reference
Architecture documentation for the _format_grep_results() function in file_search.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD dd8bd3f3_4ef2_0063_3646_d8a083bd6388["_format_grep_results()"] c970c63b_27bf_364e_6a46_1e5cc38ce38f["FilesystemFileSearchMiddleware"] dd8bd3f3_4ef2_0063_3646_d8a083bd6388 -->|defined in| c970c63b_27bf_364e_6a46_1e5cc38ce38f 99cb0385_d25f_ae58_a625_e8187615e060["__init__()"] 99cb0385_d25f_ae58_a625_e8187615e060 -->|calls| dd8bd3f3_4ef2_0063_3646_d8a083bd6388 style dd8bd3f3_4ef2_0063_3646_d8a083bd6388 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/langchain/agents/middleware/file_search.py lines 356–382
def _format_grep_results(
results: dict[str, list[tuple[int, str]]],
output_mode: str,
) -> str:
"""Format grep results based on output mode."""
if output_mode == "files_with_matches":
# Just return file paths
return "\n".join(sorted(results.keys()))
if output_mode == "content":
# Return file:line:content format
lines = []
for file_path in sorted(results.keys()):
for line_num, line in results[file_path]:
lines.append(f"{file_path}:{line_num}:{line}")
return "\n".join(lines)
if output_mode == "count":
# Return file:count format
lines = []
for file_path in sorted(results.keys()):
count = len(results[file_path])
lines.append(f"{file_path}:{count}")
return "\n".join(lines)
# Default to files_with_matches
return "\n".join(sorted(results.keys()))
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does _format_grep_results() do?
_format_grep_results() is a function in the langchain codebase, defined in libs/langchain_v1/langchain/agents/middleware/file_search.py.
Where is _format_grep_results() defined?
_format_grep_results() is defined in libs/langchain_v1/langchain/agents/middleware/file_search.py at line 356.
What calls _format_grep_results()?
_format_grep_results() is called by 1 function(s): __init__.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free