index • AI Agent SDK
index: Index a directory or file for knowledge retrieval.
index
Method
</div>
This is a method of the Knowledge class in the knowledge module.
Index a directory or file for knowledge retrieval.
Supports incremental indexing – only changed files are re-indexed.
Signature
def index(path: str, incremental: bool, force: bool, include_glob: list, exclude_glob: list, user_id: str, agent_id: str, run_id: str) -> AnyParameters
ParamField
strDirectory or file path to index
ParamField
boolIf True, only index changed files (default: True)
ParamField
boolIf True, re-index all files regardless of changes
ParamField
listList of glob patterns to include (e.g., [“.py”, “.md”])
ParamField
listList of glob patterns to exclude (e.g., [“.log”, “test_“])
ParamField
strOptional user ID for scoping
ParamField
strOptional agent ID for scoping
ParamField
strOptional run ID for scoping
Returns
ResponseField
AnyIndexResult with indexing statistics
Uses
time_module.timeIndexResultisfiledirnameos.makedirsFileTrackertracker.loadIgnoreMatcher.from_directoryisdiros.walk
Source
View on GitHubpraisonaiagents/knowledge/knowledge.py at line 859