feat(rnd): Add node metadata on Agent Server Node object (#7237)

This commit is contained in:
Zamil Majdy
2024-06-21 20:50:50 +04:00
committed by GitHub
parent 210d7738b9
commit d9226888b2
2 changed files with 6 additions and 0 deletions

View File

@@ -15,6 +15,7 @@ class Node(BaseDbModel):
# TODO: Make it `dict[str, list[str]]`, output can be connected to multiple blocks.
# Other option is to use an edge-list, but it will complicate the rest code.
output_nodes: dict[str, str] = {} # dict[output_name, node_id]
metadata: dict[str, Any] = {}
@staticmethod
def from_db(node: AgentNode):
@@ -27,6 +28,7 @@ class Node(BaseDbModel):
input_default=json.loads(node.constantInput),
input_nodes={v.sinkName: v.agentNodeSourceId for v in node.Input or []},
output_nodes={v.sourceName: v.agentNodeSinkId for v in node.Output or []},
metadata=json.loads(node.metadata),
)
def connect(self, node: "Node", source_name: str, sink_name: str):
@@ -133,6 +135,7 @@ async def create_graph(graph: Graph) -> Graph:
"agentBlockId": node.block_id,
"agentGraphId": graph.id,
"constantInput": json.dumps(node.input_default),
"metadata": json.dumps(node.metadata),
}) for node in graph.nodes
])

View File

@@ -37,6 +37,9 @@ model AgentNode {
// JSON serialized dict[str, str] containing predefined input values.
constantInput String @default("{}")
// JSON serialized dict[str, str] containing the node metadata.
metadata String @default("{}")
ExecutionHistory AgentNodeExecution[]
}