Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

automatically detect pydantic models and instantiate them #119

Merged
merged 4 commits into from
Dec 1, 2023

Conversation

rgbkrk
Copy link
Owner

@rgbkrk rgbkrk commented Nov 30, 2023

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)

@rgbkrk rgbkrk merged commit 1ffc573 into main Dec 1, 2023
8 checks passed
@rgbkrk rgbkrk deleted the automatic-model-creation branch December 1, 2023 00:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant