This attempts to instantiate pydantic models when seen as arguments. No more having to do this workaround:
def visualize_knowledge_graph(kg: KnowledgeGraph, comment: str = "Knowledge Graph"):
"""Visualizes a knowledge graph using graphviz."""
# Hack around by detecting when `kg` should be converted from a dict to a proper model
if isinstance(kg, dict):
kg = KnowledgeGraph(**kg)
dot = Digraph(comment=comment)
This attempts to instantiate pydantic models when seen as arguments. No more having to do this workaround: