diff --git a/lightrag/types.py b/lightrag/types.py
index 9c8e0099..d2670ddc 100644
--- a/lightrag/types.py
+++ b/lightrag/types.py
@@ -1,5 +1,5 @@
from pydantic import BaseModel
-from typing import List, Dict, Any
+from typing import List, Dict, Any, Optional
class GPTKeywordExtractionFormat(BaseModel):
@@ -15,7 +15,7 @@ class KnowledgeGraphNode(BaseModel):
class KnowledgeGraphEdge(BaseModel):
id: str
- type: str
+ type: Optional[str]
source: str # id of source node
target: str # id of target node
properties: Dict[str, Any] # anything else goes here
diff --git a/lightrag_webui/src/components/PropertiesView.tsx b/lightrag_webui/src/components/PropertiesView.tsx
index 078420e6..dec80460 100644
--- a/lightrag_webui/src/components/PropertiesView.tsx
+++ b/lightrag_webui/src/components/PropertiesView.tsx
@@ -200,7 +200,7 @@ const EdgePropertiesView = ({ edge }: { edge: EdgeType }) => {
-
+ {edge.type &&
}
{
}
for (const edge of graph.edges) {
- if (!edge.id || !edge.source || !edge.target || !edge.type || !edge.properties) {
+ if (!edge.id || !edge.source || !edge.target) {
return false
}
}
@@ -88,6 +88,14 @@ const fetchGraph = async (label: string) => {
if (source !== undefined && source !== undefined) {
const sourceNode = rawData.nodes[source]
const targetNode = rawData.nodes[target]
+ if (!sourceNode) {
+ console.error(`Source node ${edge.source} is undefined`)
+ continue
+ }
+ if (!targetNode) {
+ console.error(`Target node ${edge.target} is undefined`)
+ continue
+ }
sourceNode.degree += 1
targetNode.degree += 1
}
@@ -146,7 +154,7 @@ const createSigmaGraph = (rawGraph: RawGraph | null) => {
for (const rawEdge of rawGraph?.edges ?? []) {
rawEdge.dynamicId = graph.addDirectedEdge(rawEdge.source, rawEdge.target, {
- label: rawEdge.type
+ label: rawEdge.type || undefined
})
}
diff --git a/lightrag_webui/src/stores/graph.ts b/lightrag_webui/src/stores/graph.ts
index b78e9bf8..b7c2120c 100644
--- a/lightrag_webui/src/stores/graph.ts
+++ b/lightrag_webui/src/stores/graph.ts
@@ -19,7 +19,7 @@ export type RawEdgeType = {
id: string
source: string
target: string
- type: string
+ type?: string
properties: Record
dynamicId: string