Documentation
¶
Index ¶
- type Entity
- type KnowledgeBase
- func (k KnowledgeBase) AddObservations(observations []Observation) ([]Observation, error)
- func (k KnowledgeBase) CreateEntities(entities []Entity) ([]Entity, error)
- func (k KnowledgeBase) CreateRelations(relations []Relation) ([]Relation, error)
- func (k KnowledgeBase) DeleteEntities(entityNames []string) error
- func (k KnowledgeBase) DeleteObservations(deletions []Observation) error
- func (k KnowledgeBase) DeleteRelations(relations []Relation) error
- func (k KnowledgeBase) OpenNodes(names []string) (KnowledgeGraph, error)
- func (kb KnowledgeBase) ReadGraph() (*KnowledgeGraph, error)
- func (k KnowledgeBase) SearchNodes(query string) (KnowledgeGraph, error)
- type KnowledgeGraph
- type Observation
- type Relation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entity ¶
type Entity struct {
Name string `json:"name"`
EntityType string `json:"entityType"`
Observations []string `json:"observations"`
}
Entity represents a knowledge graph node with observations.
type KnowledgeBase ¶
type KnowledgeBase struct {
// contains filtered or unexported fields
}
KnowledgeBase manages entities and relations with persistent storage.
func NewKnowlegeBase ¶
func NewKnowlegeBase(path string) *KnowledgeBase
func (KnowledgeBase) AddObservations ¶
func (k KnowledgeBase) AddObservations(observations []Observation) ([]Observation, error)
AddObservations appends new observations to existing entities. It returns the new observations that were actually added.
func (KnowledgeBase) CreateEntities ¶
func (k KnowledgeBase) CreateEntities(entities []Entity) ([]Entity, error)
CreateEntities adds new entities to the graph, skipping duplicates by name. It returns the new entities that were actually added.
func (KnowledgeBase) CreateRelations ¶
func (k KnowledgeBase) CreateRelations(relations []Relation) ([]Relation, error)
CreateRelations adds new relations to the graph, skipping exact duplicates. It returns the new relations that were actually added.
func (KnowledgeBase) DeleteEntities ¶
func (k KnowledgeBase) DeleteEntities(entityNames []string) error
DeleteEntities removes entities and their associated relations.
func (KnowledgeBase) DeleteObservations ¶
func (k KnowledgeBase) DeleteObservations(deletions []Observation) error
DeleteObservations removes specific observations from entities.
func (KnowledgeBase) DeleteRelations ¶
func (k KnowledgeBase) DeleteRelations(relations []Relation) error
DeleteRelations removes specific relations from the graph.
func (KnowledgeBase) OpenNodes ¶
func (k KnowledgeBase) OpenNodes(names []string) (KnowledgeGraph, error)
OpenNodes returns entities with specified names and their interconnecting relations.
func (KnowledgeBase) ReadGraph ¶
func (kb KnowledgeBase) ReadGraph() (*KnowledgeGraph, error)
func (KnowledgeBase) SearchNodes ¶
func (k KnowledgeBase) SearchNodes(query string) (KnowledgeGraph, error)
SearchNodes filters entities and relations matching the query string.
type KnowledgeGraph ¶
type KnowledgeGraph struct {
Entities []Entity `json:"entities"`
Relations []Relation `json:"relations"`
}
KnowledgeGraph represents the complete graph structure.
type Observation ¶
type Observation struct {
EntityName string `json:"entityName"`
Contents []string `json:"contents"`
Observations []string `json:"observations,omitempty"` // Used for deletion operations
}
Observation contains facts about an entity.