graph

package
v0.0.0-...-1f1a93d Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

NemesisBot - AI agent License: MIT Copyright (c) 2026 NemesisBot contributors

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	StoragePath string // directory for JSONL files
}

Config holds knowledge graph store configuration.

type Entity

type Entity struct {
	Name       string            `json:"name"`
	Type       string            `json:"type"` // person, place, thing, concept
	Properties map[string]string `json:"properties,omitempty"`
	CreatedAt  time.Time         `json:"created_at"`
}

Entity represents a node in the knowledge graph.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store implements a simple knowledge graph backed by JSONL files.

func NewStore

func NewStore(cfg Config) (*Store, error)

NewStore creates a new graph store, loads existing data from disk.

func (*Store) AddEntity

func (s *Store) AddEntity(ctx context.Context, entity *Entity) error

AddEntity adds or updates an entity in the knowledge graph.

func (*Store) AddTriple

func (s *Store) AddTriple(ctx context.Context, triple *Triple) error

AddTriple adds a relationship triple to the knowledge graph.

func (*Store) Close

func (s *Store) Close() error

Close releases resources.

func (*Store) DeleteEntity

func (s *Store) DeleteEntity(ctx context.Context, name string) error

DeleteEntity removes an entity and all triples that reference it.

func (*Store) EntityCount

func (s *Store) EntityCount() int

EntityCount returns the number of entities stored.

func (*Store) GetEntity

func (s *Store) GetEntity(ctx context.Context, name string) (*Entity, error)

GetEntity retrieves an entity by name (case-insensitive).

func (*Store) GetRelated

func (s *Store) GetRelated(ctx context.Context, entityName string, depth int) ([]*Triple, error)

GetRelated returns all relationships within depth hops of the named entity using BFS.

func (*Store) Query

func (s *Store) Query(ctx context.Context, subject, predicate, object string) ([]*Triple, error)

Query searches for triples matching the given subject, predicate, and/or object. Empty strings act as wildcards.

func (*Store) Search

func (s *Store) Search(ctx context.Context, query string, limit int) ([]*Triple, error)

Search performs a case-insensitive text search across triples' subject, predicate, and object fields.

func (*Store) TripleCount

func (s *Store) TripleCount() int

TripleCount returns the number of triples stored.

type Triple

type Triple struct {
	Subject    string            `json:"subject"`
	Predicate  string            `json:"predicate"`
	Object     string            `json:"object"`
	Metadata   map[string]string `json:"metadata,omitempty"`
	Confidence float64           `json:"confidence"`
	CreatedAt  time.Time         `json:"created_at"`
}

Triple represents a subject-predicate-object relationship in the knowledge graph.

Jump to

Keyboard shortcuts

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