memory

package
v0.96.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

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.

type Relation

type Relation struct {
	From         string `json:"from"`
	To           string `json:"to"`
	RelationType string `json:"relationType"`
}

Relation represents a directed edge between two entities.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL