Documentation
¶
Index ¶
Constants ¶
const ( EntityPerson = "person" EntityOrg = "organization" EntityStandard = "standard" EntityClause = "clause" EntityConcept = "concept" EntityTerm = "term" EntityRegulation = "regulation" )
Entity type constants used during extraction and storage.
const ( RelReferences = "references" RelDefines = "defines" RelAmends = "amends" RelRequires = "requires" RelContradicts = "contradicts" RelSupersedes = "supersedes" )
Relation type constants used during extraction and storage.
Variables ¶
This section is empty.
Functions ¶
func DetectCommunities ¶
DetectCommunities runs community detection on the entity graph. Level-0 communities are connected components. Components larger than minComponentSplit are further split using greedy modularity optimisation and stored as level-1 communities.
func SummarizeCommunities ¶
func SummarizeCommunities(ctx context.Context, s *store.Store, chat llm.Provider, communities []store.Community) error
SummarizeCommunities uses the LLM to generate a natural-language summary for each community based on its member entities. Summaries are generated concurrently (up to 8 at a time) and individual failures are logged but do not abort the entire operation.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder constructs the knowledge graph from document chunks.
func NewBuilder ¶
NewBuilder creates a new graph builder.
type ExtractedEntity ¶
type ExtractedEntity struct {
Name string `json:"name"`
Type string `json:"type"`
Description string `json:"description"`
NameEN string `json:"name_en"`
}
ExtractedEntity is what the LLM returns from entity extraction.
type ExtractedRelationship ¶
type ExtractedRelationship struct {
Source string `json:"source"`
Target string `json:"target"`
RelationType string `json:"relation_type"`
Description string `json:"description"`
Weight float64 `json:"weight"`
}
ExtractedRelationship is what the LLM returns from relationship extraction.
type ExtractionResult ¶
type ExtractionResult struct {
Entities []ExtractedEntity `json:"entities"`
Relationships []ExtractedRelationship `json:"relationships"`
}
ExtractionResult holds the LLM's structured output for a chunk.
type TraversalResult ¶
TraversalResult contains entities and chunks found via graph traversal.
func Traverse ¶
func Traverse(ctx context.Context, s *store.Store, queryEntities []string, maxDepth int) (*TraversalResult, error)
Traverse finds entities matching query terms and follows relationships to discover related chunks. Uses BFS with configurable depth.
queryEntities are entity names (case-insensitive lookup). The traversal walks outgoing and incoming relationships up to maxDepth hops, collecting all entity IDs and their associated chunk IDs.