fix: use the supported Zep node-edge method

This commit is contained in:
666ghj 2026-07-22 20:08:18 +08:00
parent aa6abf3e39
commit 0d8c23a3c2
2 changed files with 45 additions and 2 deletions

View File

@ -192,7 +192,7 @@ class ZepEntityReader:
try:
# 使用重试机制调用Zep API
edges = self._call_with_retry(
func=lambda: self.client.graph.node.get_entity_edges(node_uuid=node_uuid),
func=lambda: self.client.graph.node.get_edges(node_uuid=node_uuid),
operation_name=f"获取节点边(node={node_uuid[:8]}...)"
)
@ -434,4 +434,3 @@ class ZepEntityReader:
)
return result.entities

View File

@ -0,0 +1,44 @@
from types import SimpleNamespace
from app.services.zep_entity_reader import ZepEntityReader
from zep_cloud.graph.node.client import NodeClient
def test_pinned_zep_sdk_exposes_get_edges_not_get_entity_edges():
assert hasattr(NodeClient, "get_edges")
assert not hasattr(NodeClient, "get_entity_edges")
def test_get_node_edges_uses_the_supported_sdk_method():
calls = []
class NodeApi:
def get_edges(self, *, node_uuid):
calls.append(node_uuid)
return [SimpleNamespace(
uuid_="edge-1",
name="KNOWS",
fact="Alice knows Bob",
source_node_uuid="node-1",
target_node_uuid="node-2",
attributes={"since": "2024"},
)]
class GraphApi:
node = NodeApi()
class Client:
graph = GraphApi()
reader = object.__new__(ZepEntityReader)
reader.client = Client()
assert reader.get_node_edges("node-1") == [{
"uuid": "edge-1",
"name": "KNOWS",
"fact": "Alice knows Bob",
"source_node_uuid": "node-1",
"target_node_uuid": "node-2",
"attributes": {"since": "2024"},
}]
assert calls == ["node-1"]