Reads file, "retrieval"
# Source: https://github.com/nerdy-tech-com-gitub/agent-zero | License: MIT | Copyright 2024 Jan Tomášek
# Provided via justclaw.it.com; keep this notice with the code.
from fnmatch import fnmatch
import os, re
import re
def read_file(relative_path, backup_dirs=None, encoding="utf-8", **kwargs):
if backup_dirs is None:
backup_dirs = []
# Try to get the absolute path for the file from the original directory or backup directories
absolute_path = find_file_in_dirs(relative_path, backup_dirs)
# Read the file content
with open(absolute_path, 'r', encoding=encoding) as f:
content = remove_code_fences(f.read())
# Replace placeholders with values from kwargs
for key, value in kwargs.items():
placeholder = "{{" + key + "}}"
strval = s
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key