Skip to content

Commit

Permalink
feat(rnd): Add node metadata on Agent Server Node object (Significant…
Browse files Browse the repository at this point in the history
  • Loading branch information
majdyz authored Jun 21, 2024
1 parent 210d773 commit d922688
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions rnd/autogpt_server/autogpt_server/data/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -27,6 +28,7 @@ def from_db(node: AgentNode):
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):
Expand Down Expand Up @@ -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
])

Expand Down
3 changes: 3 additions & 0 deletions rnd/autogpt_server/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
}

Expand Down

0 comments on commit d922688

Please sign in to comment.