Documentation
¶
Index ¶
- func TriplesToGraph(triples []Triple) ([]*Entity, []*Relation)
- type Entity
- type EntityStore
- type InMemoryGraph
- func (g *InMemoryGraph) FindEntities(_ context.Context, query string, limit int) ([]*Entity, error)
- func (g *InMemoryGraph) GetEntity(_ context.Context, id string) (*Entity, error)
- func (g *InMemoryGraph) GetNeighbors(_ context.Context, entityID string, depth int) ([]*Entity, []*Relation, error)
- func (g *InMemoryGraph) GetRelations(_ context.Context, entityID string) ([]*Relation, error)
- func (g *InMemoryGraph) Stats() (entityCount, relationCount int)
- func (g *InMemoryGraph) UpsertEntity(_ context.Context, entity *Entity) error
- func (g *InMemoryGraph) UpsertRelation(_ context.Context, rel *Relation) error
- type Relation
- type Triple
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TriplesToGraph ¶
TriplesToGraph converts extracted triples into entities and relations.
Types ¶
type Entity ¶
type Entity struct {
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"` // person | project | technology | concept | file | decision
MemoryIDs []string `json:"memory_ids"`
Metadata map[string]any `json:"metadata,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Entity represents a named concept extracted from memories.
type EntityStore ¶
type EntityStore interface {
UpsertEntity(ctx context.Context, entity *Entity) error
GetEntity(ctx context.Context, id string) (*Entity, error)
FindEntities(ctx context.Context, query string, limit int) ([]*Entity, error)
UpsertRelation(ctx context.Context, rel *Relation) error
GetRelations(ctx context.Context, entityID string) ([]*Relation, error)
GetNeighbors(ctx context.Context, entityID string, depth int) ([]*Entity, []*Relation, error)
}
EntityStore defines the persistence interface for entities and relations.
type InMemoryGraph ¶
type InMemoryGraph struct {
// contains filtered or unexported fields
}
InMemoryGraph is a basic in-memory knowledge graph for MVP.
func NewInMemoryGraph ¶
func NewInMemoryGraph() *InMemoryGraph
func (*InMemoryGraph) FindEntities ¶
func (*InMemoryGraph) GetNeighbors ¶
func (*InMemoryGraph) GetRelations ¶
func (*InMemoryGraph) Stats ¶
func (g *InMemoryGraph) Stats() (entityCount, relationCount int)
Stats returns graph statistics.
func (*InMemoryGraph) UpsertEntity ¶
func (g *InMemoryGraph) UpsertEntity(_ context.Context, entity *Entity) error
func (*InMemoryGraph) UpsertRelation ¶
func (g *InMemoryGraph) UpsertRelation(_ context.Context, rel *Relation) error
type Relation ¶
type Relation struct {
ID string `json:"id"`
FromID string `json:"from_id"`
ToID string `json:"to_id"`
Type string `json:"type"` // uses | depends_on | created_by | related_to | supersedes | part_of
Weight float64 `json:"weight"`
MemoryIDs []string `json:"memory_ids"`
CreatedAt time.Time `json:"created_at"`
}
Relation represents a directed edge between two entities.
type Triple ¶
type Triple struct {
Subject string `json:"subject"`
Predicate string `json:"predicate"`
Object string `json:"object"`
MemoryID string `json:"memory_id"`
}
Triple is a subject-predicate-object extracted from text.
func ExtractTriples ¶
ExtractTriples extracts subject-predicate-object triples from text content. Uses simple pattern matching for MVP; can be upgraded to LLM-based extraction later.
Click to show internal directories.
Click to hide internal directories.