Skip to main content

index

Method
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) -> Any

Parameters

path
str
required
Directory or file path to index
incremental
bool
default:"True"
If True, only index changed files (default: True)
force
bool
default:"False"
If True, re-index all files regardless of changes
include_glob
list
List of glob patterns to include (e.g., [“.py”, “.md”])
exclude_glob
list
List of glob patterns to exclude (e.g., [“.log”, “test_”])
user_id
str
Optional user ID for scoping
agent_id
str
Optional agent ID for scoping
run_id
str
Optional run ID for scoping

Returns

Returns
Any
IndexResult with indexing statistics

Uses

  • time_module.time
  • IndexResult
  • isfile
  • dirname
  • os.makedirs
  • FileTracker
  • tracker.load
  • IgnoreMatcher.from_directory
  • isdir
  • os.walk

Source

View on GitHub

praisonaiagents/knowledge/knowledge.py at line 827