Remove unused JSON loading and serialization methods from PromptBuilder
This commit is contained in:
parent
dc2e2b4ed2
commit
889c1f2791
@ -1,8 +1,7 @@
|
|||||||
class PromptBuilder {
|
class PromptBuilder {
|
||||||
final String clientId;
|
final String clientId;
|
||||||
final Map<String, dynamic> _nodes = {};
|
final Map<String, dynamic> _nodes = {};
|
||||||
final Map<String, Map<String, String>> _outputToNode =
|
final Map<String, Map<String, String>> _outputToNode = {};
|
||||||
{}; // Maps output tags to node IDs
|
|
||||||
int _nodeIdCounter = 1;
|
int _nodeIdCounter = 1;
|
||||||
|
|
||||||
PromptBuilder({required this.clientId});
|
PromptBuilder({required this.clientId});
|
||||||
@ -391,37 +390,4 @@ class PromptBuilder {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Loads nodes from a JSON map
|
|
||||||
void loadFromJson(Map<String, dynamic> json) {
|
|
||||||
_nodes.clear();
|
|
||||||
_outputToNode.clear();
|
|
||||||
|
|
||||||
json.forEach((nodeId, nodeData) {
|
|
||||||
_nodes[nodeId] = nodeData;
|
|
||||||
|
|
||||||
// Register outputs of this node
|
|
||||||
final classType = nodeData["class_type"];
|
|
||||||
final defaultOutputs = _getDefaultOutputs(classType);
|
|
||||||
for (var i = 0; i < defaultOutputs.length; i++) {
|
|
||||||
final outputTag = nodeData["_meta"]?["outputTags"]
|
|
||||||
?[defaultOutputs[i]] ??
|
|
||||||
defaultOutputs[i];
|
|
||||||
_outputToNode[outputTag] = {
|
|
||||||
"nodeId": nodeId,
|
|
||||||
"outputIndex": i.toString()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Update the node ID counter to avoid collisions
|
|
||||||
_nodeIdCounter =
|
|
||||||
_nodes.keys.map(int.parse).fold(0, (max, id) => id > max ? id : max) +
|
|
||||||
1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Converts the current nodes to a JSON map
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
return Map<String, dynamic>.from(_nodes);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user