def compile_openai_resource_factory(endpoint: Callable[..., Any]) -> OpenAIResource:
    """Compile an OpenAI resource factory function.

    Args:
        endpoint: openai resource factory function.

    Returns:
        An OpenAIResource instance.
    """
    try:
        resource = endpoint()
    except TypeError:
        raise TypeError("set default values for all factory endpoint parameters")

    if not isinstance(resource, OpenAIResource):
        raise TypeError("factory endpoint must return a LanarkyOpenAIResource instance")
    return resource
Compile an OpenAI resource factory function.

    Args:
        endpoint: openai resource factory function.

    Returns:
        An OpenAIResource instance.
    
lanarky/adapters/openai/utils.py