Files
letta-server/letta/functions/function_sets/files.py
2025-06-20 13:36:54 -07:00

67 lines
2.2 KiB
Python

from typing import TYPE_CHECKING, List, Optional, Tuple
if TYPE_CHECKING:
from letta.schemas.agent import AgentState
from letta.schemas.file import FileMetadata
async def open_file(agent_state: "AgentState", file_name: str, view_range: Optional[Tuple[int, int]]) -> str:
"""
Open the file with name `file_name` and load the contents into files section in core memory.
Args:
file_name (str): Name of the file to view. Required.
view_range (Optional[Tuple[int, int]]): Optional tuple indicating range to view.
Returns:
str: A status message
"""
raise NotImplementedError("Tool not implemented. Please contact the Letta team.")
async def close_file(agent_state: "AgentState", file_name: str) -> str:
"""
Close file with name `file_name` in files section in core memory.
Args:
file_name (str): Name of the file to close.
Returns:
str: A status message
"""
raise NotImplementedError("Tool not implemented. Please contact the Letta team.")
async def grep(
agent_state: "AgentState",
pattern: str,
include: Optional[str] = None,
context_lines: Optional[int] = 3,
) -> str:
"""
Grep tool to search files across data sources using a keyword or regex pattern.
Args:
pattern (str): Keyword or regex pattern to search within file contents.
include (Optional[str]): Optional keyword or regex pattern to filter filenames to include in the search.
context_lines (Optional[int]): Number of lines of context to show before and after each match.
Equivalent to `-C` in grep. Defaults to 3.
Returns:
str: Matching lines with optional surrounding context or a summary output.
"""
raise NotImplementedError("Tool not implemented. Please contact the Letta team.")
async def search_files(agent_state: "AgentState", query: str) -> List["FileMetadata"]:
"""
Get list of most relevant files across all data sources using embedding search.
Args:
query (str): The search query.
Returns:
List[FileMetadata]: List of matching files.
"""
raise NotImplementedError("Tool not implemented. Please contact the Letta team.")