Iragent
This project is about using agents as simple as possible with small and large language models
Loading...
Searching...
No Matches
iragent.models.KnowledgeGraphBuilder Class Reference

Public Member Functions

 __init__ (self, embedding_model, int chunk_size=128, int chunk_overlap=32, index_dir="./vector_store/")
 
 build_index_from_markdown (self, str dir_path, bool strip_markdown=True, bool recursive=True)
 
 build_index_from_texts (self, list[str] texts)
 
 save_index (self)
 
 load_index (self)
 
List[str] search (self, str query, int k)
 

Public Attributes

 embedding_model = embedding_model
 
 index_path = os.path.join(index_dir, "faiss_index.index")
 
 index_dir = index_dir
 
 docs_path = os.path.join(index_dir, "faiss_index.index.docs")
 
 index = None
 
list document = []
 
 faiss = faiss
 
 chunk_size = chunk_size
 
 chunk_overlap = chunk_overlap
 

Protected Member Functions

list[str] _chunker (self, str text)
 
list[str] _read_markdown_and_chunk (self, str dir_path, bool strip_markdown=True, bool recursive=True)
 
np.ndarray _normalize (self, np.ndarray vectors)
 

Constructor & Destructor Documentation

◆ __init__()

iragent.models.KnowledgeGraphBuilder.__init__ ( self,
embedding_model,
int chunk_size = 128,
int chunk_overlap = 32,
index_dir = "./vector_store/" )

Member Function Documentation

◆ _chunker()

list[str] iragent.models.KnowledgeGraphBuilder._chunker ( self,
str text )
protected
Splits text into overlapping chunks based on token count.

Args:
    text: The input text to split.
    max_tokens: Maximum tokens per chunk.
    overlap: Number of tokens to overlap between chunks.
    model_name: Model name for tokenizer compatibility.

Returns:
    List of text chunks.

◆ _normalize()

np.ndarray iragent.models.KnowledgeGraphBuilder._normalize ( self,
np.ndarray vectors )
protected

◆ _read_markdown_and_chunk()

list[str] iragent.models.KnowledgeGraphBuilder._read_markdown_and_chunk ( self,
str dir_path,
bool strip_markdown = True,
bool recursive = True )
protected

◆ build_index_from_markdown()

iragent.models.KnowledgeGraphBuilder.build_index_from_markdown ( self,
str dir_path,
bool strip_markdown = True,
bool recursive = True )

◆ build_index_from_texts()

iragent.models.KnowledgeGraphBuilder.build_index_from_texts ( self,
list[str] texts )
Create a FAISS index from a list of texts

◆ load_index()

iragent.models.KnowledgeGraphBuilder.load_index ( self)
Load FAISS index from disk

◆ save_index()

iragent.models.KnowledgeGraphBuilder.save_index ( self)

◆ search()

List[str] iragent.models.KnowledgeGraphBuilder.search ( self,
str query,
int k )
Search for nearest neighbors, this function get query: str and k:int as input. 

Member Data Documentation

◆ chunk_overlap

iragent.models.KnowledgeGraphBuilder.chunk_overlap = chunk_overlap

◆ chunk_size

iragent.models.KnowledgeGraphBuilder.chunk_size = chunk_size

◆ docs_path

iragent.models.KnowledgeGraphBuilder.docs_path = os.path.join(index_dir, "faiss_index.index.docs")

◆ document

list iragent.models.KnowledgeGraphBuilder.document = []

◆ embedding_model

iragent.models.KnowledgeGraphBuilder.embedding_model = embedding_model

◆ faiss

iragent.models.KnowledgeGraphBuilder.faiss = faiss

◆ index

iragent.models.KnowledgeGraphBuilder.index = None

◆ index_dir

iragent.models.KnowledgeGraphBuilder.index_dir = index_dir

◆ index_path

iragent.models.KnowledgeGraphBuilder.index_path = os.path.join(index_dir, "faiss_index.index")

The documentation for this class was generated from the following file: