-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgraph.go
144 lines (125 loc) · 3.76 KB
/
graph.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
// This file was auto-generated by Fern from our API Definition.
package zep
import (
json "encoding/json"
fmt "fmt"
internal "github.com/getzep/zep-go/v2/internal"
)
type AddDataRequest struct {
Data *string `json:"data,omitempty" url:"-"`
GroupID *string `json:"group_id,omitempty" url:"-"`
Type *GraphDataType `json:"type,omitempty" url:"-"`
UserID *string `json:"user_id,omitempty" url:"-"`
}
type GraphSearchQuery struct {
// Node to rerank around for node distance reranking
CenterNodeUUID *string `json:"center_node_uuid,omitempty" url:"-"`
// one of user_id or group_id must be provided
GroupID *string `json:"group_id,omitempty" url:"-"`
// The maximum number of facts to retrieve. Defaults to 10. Limited to 50.
Limit *int `json:"limit,omitempty" url:"-"`
// minimum similarity score for a result to be returned
MinScore *float64 `json:"min_score,omitempty" url:"-"`
// weighting for maximal marginal relevance
MmrLambda *float64 `json:"mmr_lambda,omitempty" url:"-"`
// The string to search for (required)
Query string `json:"query" url:"-"`
// Defaults to RRF
Reranker *Reranker `json:"reranker,omitempty" url:"-"`
// Defaults to Edges. Communities will be added in the future.
Scope *GraphSearchScope `json:"scope,omitempty" url:"-"`
// one of user_id or group_id must be provided
UserID *string `json:"user_id,omitempty" url:"-"`
}
type GraphSearchResults struct {
Edges []*EntityEdge `json:"edges,omitempty" url:"edges,omitempty"`
Nodes []*EntityNode `json:"nodes,omitempty" url:"nodes,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (g *GraphSearchResults) GetEdges() []*EntityEdge {
if g == nil {
return nil
}
return g.Edges
}
func (g *GraphSearchResults) GetNodes() []*EntityNode {
if g == nil {
return nil
}
return g.Nodes
}
func (g *GraphSearchResults) GetExtraProperties() map[string]interface{} {
return g.extraProperties
}
func (g *GraphSearchResults) UnmarshalJSON(data []byte) error {
type unmarshaler GraphSearchResults
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*g = GraphSearchResults(value)
extraProperties, err := internal.ExtractExtraProperties(data, *g)
if err != nil {
return err
}
g.extraProperties = extraProperties
g.rawJSON = json.RawMessage(data)
return nil
}
func (g *GraphSearchResults) String() string {
if len(g.rawJSON) > 0 {
if value, err := internal.StringifyJSON(g.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(g); err == nil {
return value
}
return fmt.Sprintf("%#v", g)
}
type GraphSearchScope string
const (
GraphSearchScopeEdges GraphSearchScope = "edges"
GraphSearchScopeNodes GraphSearchScope = "nodes"
)
func NewGraphSearchScopeFromString(s string) (GraphSearchScope, error) {
switch s {
case "edges":
return GraphSearchScopeEdges, nil
case "nodes":
return GraphSearchScopeNodes, nil
}
var t GraphSearchScope
return "", fmt.Errorf("%s is not a valid %T", s, t)
}
func (g GraphSearchScope) Ptr() *GraphSearchScope {
return &g
}
type Reranker string
const (
RerankerRrf Reranker = "rrf"
RerankerMmr Reranker = "mmr"
RerankerNodeDistance Reranker = "node_distance"
RerankerEpisodeMentions Reranker = "episode_mentions"
RerankerCrossEncoder Reranker = "cross_encoder"
)
func NewRerankerFromString(s string) (Reranker, error) {
switch s {
case "rrf":
return RerankerRrf, nil
case "mmr":
return RerankerMmr, nil
case "node_distance":
return RerankerNodeDistance, nil
case "episode_mentions":
return RerankerEpisodeMentions, nil
case "cross_encoder":
return RerankerCrossEncoder, nil
}
var t Reranker
return "", fmt.Errorf("%s is not a valid %T", s, t)
}
func (r Reranker) Ptr() *Reranker {
return &r
}