graph

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package graph implements the graph.neo4j module and associated steps.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GraphModuleSchemas

func GraphModuleSchemas() []sdk.ModuleSchemaData

GraphModuleSchemas returns schema metadata for all graph module types.

func NewGraphExtractEntitiesLLMStep

func NewGraphExtractEntitiesLLMStep(name string, _ map[string]any) (sdk.StepInstance, error)

NewGraphExtractEntitiesLLMStep creates a new step.graph_extract_entities_llm instance.

func NewGraphExtractEntitiesStep

func NewGraphExtractEntitiesStep(name string, _ map[string]any) (sdk.StepInstance, error)

NewGraphExtractEntitiesStep creates a new step.graph_extract_entities instance.

func NewGraphImportStep

func NewGraphImportStep(name string, _ map[string]any) (sdk.StepInstance, error)

NewGraphImportStep creates a new step.graph_import instance.

func NewGraphLinkStep

func NewGraphLinkStep(name string, _ map[string]any) (sdk.StepInstance, error)

NewGraphLinkStep creates a new step.graph_link instance.

func NewGraphQueryStep

func NewGraphQueryStep(name string, _ map[string]any) (sdk.StepInstance, error)

NewGraphQueryStep creates a new step.graph_query instance.

func NewGraphWriteStep

func NewGraphWriteStep(name string, _ map[string]any) (sdk.StepInstance, error)

NewGraphWriteStep creates a new step.graph_write instance.

func NewNeo4jModule

func NewNeo4jModule(name string, config map[string]any) (sdk.ModuleInstance, error)

NewNeo4jModule creates a new graph.neo4j module.

func RegisterNeo4jModule

func RegisterNeo4jModule(name string, m *Neo4jModule) error

RegisterNeo4jModule registers a Neo4jModule under the given name.

func UnregisterNeo4jModule

func UnregisterNeo4jModule(name string)

UnregisterNeo4jModule removes a registered Neo4jModule.

Types

type Entity

type Entity struct {
	Type  string `json:"type"`
	Value string `json:"value"`
	Start int    `json:"start"`
	End   int    `json:"end"`
}

Entity represents an extracted entity from text.

type GraphResult

type GraphResult interface {
	Next(ctx context.Context) bool
	Record() *neo4j.Record
	Err() error
}

GraphResult is a narrow interface over neo4j.ResultWithContext for testability.

type GraphSession

type GraphSession interface {
	Run(ctx context.Context, cypher string, params map[string]any) (GraphResult, error)
	Close(ctx context.Context) error
}

GraphSession is a narrow interface over neo4j.SessionWithContext for testability.

type LLMClient

type LLMClient interface {
	ExtractEntities(ctx context.Context, text string, types []string) ([]LLMEntity, error)
}

LLMClient is the interface for LLM-based entity extraction.

func NewClaudeClient

func NewClaudeClient(apiKey, model string) LLMClient

NewClaudeClient creates an LLM client backed by the Anthropic Messages API.

func NewOpenAIClient

func NewOpenAIClient(apiKey, model string) LLMClient

NewOpenAIClient creates an LLM client backed by the OpenAI Chat Completions API.

type LLMEntity

type LLMEntity struct {
	Type       string  `json:"type"`
	Value      string  `json:"value"`
	Context    string  `json:"context"`
	Confidence float64 `json:"confidence"`
}

LLMEntity is an entity extracted by an LLM.

type Neo4jConfig

type Neo4jConfig struct {
	URI                          string        `json:"uri"                          yaml:"uri"`
	Database                     string        `json:"database"                     yaml:"database"`
	Username                     string        `json:"username"                     yaml:"username"`
	Password                     string        `json:"password"                     yaml:"password"`
	MaxConnectionPoolSize        int           `json:"maxConnectionPoolSize"        yaml:"maxConnectionPoolSize"`
	ConnectionAcquisitionTimeout time.Duration `json:"connectionAcquisitionTimeout" yaml:"connectionAcquisitionTimeout"`
}

Neo4jConfig holds configuration for the graph.neo4j module.

type Neo4jDriver

type Neo4jDriver interface {
	NewSession(ctx context.Context, config neo4j.SessionConfig) GraphSession
	VerifyConnectivity(ctx context.Context) error
	Close(ctx context.Context) error
}

Neo4jDriver is a narrow interface over neo4j.DriverWithContext for testability.

type Neo4jModule

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

Neo4jModule implements the graph.neo4j module.

func LookupNeo4jModule

func LookupNeo4jModule(name string) (*Neo4jModule, error)

LookupNeo4jModule returns the registered Neo4jModule by name.

func NewNeo4jModuleForTest

func NewNeo4jModuleForTest(name string, driver Neo4jDriver) *Neo4jModule

NewNeo4jModuleForTest creates a Neo4jModule with an injected driver for integration testing.

func (*Neo4jModule) ExecuteCypher

func (m *Neo4jModule) ExecuteCypher(ctx context.Context, cypher string, params map[string]any) ([]map[string]any, error)

ExecuteCypher runs a Cypher query and returns all rows as maps.

func (*Neo4jModule) Init

func (m *Neo4jModule) Init() error

Init validates configuration.

func (*Neo4jModule) Start

func (m *Neo4jModule) Start(ctx context.Context) error

Start creates the driver and verifies connectivity.

func (*Neo4jModule) Stop

func (m *Neo4jModule) Stop(ctx context.Context) error

Stop closes the driver and unregisters the module.

Jump to

Keyboard shortcuts

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