storage

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bolt

type Bolt struct {
	DB *bolt.DB
}

Bolt provides a BoltDB key-value storage implementation of storage interfaces. It handles database operations for storing and retrieving source documents.

func NewBolt

func NewBolt(path string) (Bolt, error)

NewBolt creates a new BoltDB client connection with the provided file path. It returns an initialized Bolt struct and any error encountered during database setup. The function ensures that required buckets exist in the database.

func (Bolt) KVSource

func (b Bolt) KVSource(id string) (golightrag.Source, error)

KVSource retrieves a source document by ID from the BoltDB database. It returns the found source or an error if the source doesn't exist or if the query fails.

func (Bolt) KVUpsertSources

func (b Bolt) KVUpsertSources(sources []golightrag.Source) error

KVUpsertSources creates or updates multiple source documents in the BoltDB database. It returns an error if any database operation fails during the process.

type Chromem

type Chromem struct {
	EntitiesColl      *chromem.Collection
	RelationshipsColl *chromem.Collection
	// contains filtered or unexported fields
}

Chromem provides a vector storage implementation using ChromeM database. It handles operations for storing and retrieving vector-based entities and relationships with semantic search capabilities.

func NewChromem

func NewChromem(dbPath string, topK int, embeddingFunc EmbeddingFunc) (Chromem, error)

NewChromem creates a new ChromeM client with the provided parameters. It returns an initialized Chromem struct and any error encountered during setup. The dbPath parameter specifies where to persist the database, topK defines the number of results to return in queries, and embeddingFunc provides the vector embedding capability.

func (Chromem) VectorQueryEntity

func (c Chromem) VectorQueryEntity(keywords string) ([]string, error)

VectorQueryEntity performs a semantic search for entities based on the provided keywords. It returns a slice of matching entity names and any error encountered during the operation.

func (Chromem) VectorQueryRelationship

func (c Chromem) VectorQueryRelationship(keywords string) ([][2]string, error)

VectorQueryRelationship performs a semantic search for relationships based on the provided keywords. It returns a slice of source-target entity pairs and any error encountered during the operation.

func (Chromem) VectorUpsertEntity

func (c Chromem) VectorUpsertEntity(name, content string) error

VectorUpsertEntity creates or updates an entity with vector embedding based on its content. It returns an error if the database operation fails.

func (Chromem) VectorUpsertRelationship

func (c Chromem) VectorUpsertRelationship(source, target, content string) error

VectorUpsertRelationship creates or updates a relationship with vector embedding based on its content. It returns an error if the database operation fails.

type EmbeddingFunc added in v0.1.2

type EmbeddingFunc func(ctx context.Context, text string) ([]float32, error)

EmbeddingFunc is a function type for embedding text into a vector.

type Milvus added in v0.1.2

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

Milvus provides a vector storage implementation using Milvus database. It handles operations for storing and retrieving vector-based entities and relationships with semantic search capabilities.

The Close() method should be called when done to properly release resources.

func NewMilvus added in v0.1.2

func NewMilvus(config *milvusclient.ClientConfig, topK, vectorDim int, embeddingFunc EmbeddingFunc) (Milvus, error)

NewMilvus creates a new Milvus client with the provided parameters. It returns an initialized Milvus struct and any error encountered during setup.

func (Milvus) Close added in v0.1.2

func (m Milvus) Close(ctx context.Context) error

Close closes the connection to Milvus.

func (Milvus) VectorQueryEntity added in v0.1.2

func (m Milvus) VectorQueryEntity(keywords string) ([]string, error)

VectorQueryEntity performs a semantic search for entities based on the provided keywords.

func (Milvus) VectorQueryRelationship added in v0.1.2

func (m Milvus) VectorQueryRelationship(keywords string) ([][2]string, error)

VectorQueryRelationship performs a semantic search for relationships based on the provided keywords.

func (Milvus) VectorUpsertEntity added in v0.1.2

func (m Milvus) VectorUpsertEntity(name, content string) error

VectorUpsertEntity creates or updates an entity with vector embedding based on its content.

func (Milvus) VectorUpsertRelationship added in v0.1.2

func (m Milvus) VectorUpsertRelationship(source, target, content string) error

VectorUpsertRelationship creates or updates a relationship with vector embedding based on its content.

type Neo4J

type Neo4J struct {
	Client neo4j.DriverWithContext
}

Neo4J provides a Neo4j graph database implementation of storage interfaces. It handles database connections and operations for storing and retrieving graph entities and relationships.

func NewNeo4J

func NewNeo4J(target, user, password string) (Neo4J, error)

NewNeo4J creates a new Neo4j client connection with the provided connection parameters. It returns an initialized Neo4J struct and any error encountered during connection setup. The returned Neo4J instance must be closed with Close() when no longer needed to free up resources.

func (Neo4J) Close

func (n Neo4J) Close(ctx context.Context) error

Close terminates the connection to the Neo4j database. It returns any error encountered during the closing operation.

func (Neo4J) GraphCountEntitiesRelationships

func (n Neo4J) GraphCountEntitiesRelationships(names []string) (map[string]int, error)

GraphCountEntitiesRelationships counts the number of relationships for multiple entities. It returns a map of entity names to their relationship counts.

func (Neo4J) GraphEntities

func (n Neo4J) GraphEntities(names []string) (map[string]golightrag.GraphEntity, error)

GraphEntities retrieves multiple graph entities by their names from the Neo4j database. It returns a map of entity names to GraphEntity objects, or an error if the query fails.

func (Neo4J) GraphEntity

func (n Neo4J) GraphEntity(name string) (golightrag.GraphEntity, error)

GraphEntity retrieves a graph entity by name from the Neo4j database. It returns the found entity or an error if the entity doesn't exist or if the query fails.

func (Neo4J) GraphRelatedEntities

func (n Neo4J) GraphRelatedEntities(names []string) (map[string][]golightrag.GraphEntity, error)

GraphRelatedEntities retrieves all entities related to multiple input entities. It returns a map of entity names to slices of related GraphEntity objects.

func (Neo4J) GraphRelationship

func (n Neo4J) GraphRelationship(sourceEntity, targetEntity string) (golightrag.GraphRelationship, error)

GraphRelationship retrieves a relationship between two entities from the Neo4j database. It returns the found relationship or an error if the relationship doesn't exist or if the query fails.

func (Neo4J) GraphRelationships

func (n Neo4J) GraphRelationships(pairs [][2]string) (map[string]golightrag.GraphRelationship, error)

GraphRelationships retrieves multiple relationships between entity pairs from the Neo4j database. It returns a map where the key is "sourceEntity-targetEntity" and the value is the GraphRelationship.

func (Neo4J) GraphUpsertEntity

func (n Neo4J) GraphUpsertEntity(entity golightrag.GraphEntity) error

GraphUpsertEntity creates or updates an entity in the Neo4j graph database. It returns an error if the database operation fails.

func (Neo4J) GraphUpsertRelationship

func (n Neo4J) GraphUpsertRelationship(relationship golightrag.GraphRelationship) error

GraphUpsertRelationship creates or updates a relationship between two entities in the Neo4j graph database. It returns an error if the database operation fails.

type Redis added in v0.1.2

type Redis struct {
	Client *redis.Client
}

Redis provides a Redis key-value storage implementation of storage interfaces. It handles database operations for storing and retrieving source documents.

func NewRedis added in v0.1.2

func NewRedis(addr, password string, db int) (Redis, error)

NewRedis creates a new Redis client connection with the provided configuration. It returns an initialized Redis struct and any error encountered during connection setup.

func (Redis) KVSource added in v0.1.2

func (r Redis) KVSource(id string) (golightrag.Source, error)

KVSource retrieves a source document by ID from the Redis database. It returns the found source or an error if the source doesn't exist or if the query fails.

func (Redis) KVUpsertSources added in v0.1.2

func (r Redis) KVUpsertSources(sources []golightrag.Source) error

KVUpsertSources creates or updates multiple source documents in the Redis database. It returns an error if any database operation fails during the process.

Jump to

Keyboard shortcuts

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