Files
letta-server/letta/functions/function_sets/files.py
2025-06-13 16:24:59 -07:00

60 lines
1.9 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) -> str:
"""
Grep tool to search files across data sources with 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.
Returns:
str: Matching lines or 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.")