def compile_chain_factory(endpoint: Callable[..., Any]):
    """Compile a LangChain instance factory function.

    Args:
        endpoint: LangChain instance factory function.
    """
    try:
        chain = endpoint()
    except TypeError:
        raise TypeError("set default values for all factory endpoint parameters")

    if not isinstance(chain, Chain):
        raise TypeError("factory endpoint must return a Chain instance")
    return chain
Compile a LangChain instance factory function.

    Args:
        endpoint: LangChain instance factory function.
    
lanarky/adapters/langchain/utils.py