-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode.go
47 lines (33 loc) · 1.35 KB
/
node.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package llamaindexgo
import "context"
// Node represents a node in the graph
type Node interface {
// ID returns the unique identifier of the node
ID() string
// Content returns the raw content of the node
Content() []byte
// Metadata returns the associated metadata of the node
Metadata() map[string]any
// Text returns the text value of the node
// If the node does not have a text value, it returns an error
Text() (string, error)
// Embedding returns the embedding value of the node
// If the node does not have an embedding, it returns an error
Embedding() ([]float, error)
// ParentID returns the unique identifier of the parent node
// return an empty string if the node does not have a parent
ParentID() (string, error)
// ChildrenIDs returns the unique identifiers of the children nodes
// return an empty slice if the node does not have children
ChildrenIDs() ([]string, error)
}
type Tokenizer func(ctx context.Context, text string) ([]string, error)
// NodeParser generates Nodes from Documents
type NodeParser interface {
// GetNodesFromDocuments returns a list of Nodes from the given list of Documents
GetNodesFromDocuments(ctx context.Context, docs []Node) ([]Node, error)
}
type TextSplitter interface {
SplitText(ctx context.Context, text string) ([]string, error)
SplitTexts(ctx context.Context, texts []string) ([]string, error)
}