Files
knowledge-graph-agent/backend/models/graph.go
T

48 lines
1.6 KiB
Go

package models
type Node struct {
ID string `json:"id"`
Label string `json:"label"`
Type string `json:"type,omitempty"`
Properties map[string]interface{} `json:"properties,omitempty"`
X float64 `json:"x,omitempty"`
Y float64 `json:"y,omitempty"`
Style map[string]interface{} `json:"style,omitempty"`
}
type Edge struct {
ID string `json:"id"`
Source string `json:"source"`
Target string `json:"target"`
Label string `json:"label,omitempty"`
Type string `json:"type,omitempty"`
Properties map[string]interface{} `json:"properties,omitempty"`
Style map[string]interface{} `json:"style,omitempty"`
}
type GraphData struct {
Nodes []Node `json:"nodes"`
Edges []Edge `json:"edges"`
}
// SimpleNode 简化版节点结构,仅保留核心信息,适合 LLM 处理
type SimpleNode struct {
ID string `json:"id" example:"1"`
Label string `json:"label" example:"人工智能"`
Type string `json:"type,omitempty" example:"概念"`
}
// SimpleEdge 简化版边结构,仅保留核心信息,适合 LLM 处理
type SimpleEdge struct {
Source string `json:"source" example:"1"`
Target string `json:"target" example:"2"`
Type string `json:"type,omitempty" example:"CONTAINS"`
Label string `json:"label,omitempty" example:"包含"`
}
// SimpleGraphData 简化版图数据,适合 LLM 处理
type SimpleGraphData struct {
Nodes []SimpleNode `json:"nodes"`
Edges []SimpleEdge `json:"edges"`
}