Spaces:
Sleeping
Sleeping
File size: 671 Bytes
7257069 ef93755 7257069 ef93755 7257069 ef93755 7257069 ef93755 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | """
SecureCodeEnv - CodeGraph Serializer
Converts CodeGraph to JSON-serializable dict for API responses.
"""
from codegraph.graph import CodeGraph
def serialize_graph(graph: CodeGraph) -> dict:
"""Serialize CodeGraph to a clean JSON-compatible dict."""
components_dict = {}
for name, comp in graph.components.items():
components_dict[name] = comp.to_dict()
return {
"components": components_dict,
"conventions": graph.conventions,
"dependencies": graph.dependencies,
"episode_seed": graph.episode_seed,
"component_count": len(graph.components),
"context_prompt": graph.to_context_prompt(),
}
|