def create_response_model(chain: Chain, prefix: str = None) -> BaseModel:
    """Create a pydantic response model for a LangChain instance.

    Args:
        chain: A LangChain instance.
        prefix: A prefix for the model name.
    """
    response_fields = {}

    for key in chain.output_keys:
        # TODO: add support for other output key types
        # based on demand
        if key == "source_documents":
            response_fields[key] = (list[Document], ...)
        else:
            response_fields[key] = (str, ...)

    prefix = prefix or chain.__class__.__name__

    return create_model(f"{prefix}Response", **response_fields)
Create a pydantic response model for a LangChain instance.

    Args:
        chain: A LangChain instance.
        prefix: A prefix for the model name.
    
lanarky/adapters/langchain/utils.py