rgbkrk / chatlab

⚡️🧪 Fast LLM Tool Calling Experimentation, big and smol
https://chatlab.dev
Other
138 stars 12 forks source link

automatically detect pydantic models and instantiate them #119

Closed rgbkrk closed 11 months ago

rgbkrk commented 11 months ago

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)