Function createExtractionChainFromZod

  • Function that creates an extraction chain from a Zod schema. It converts the Zod schema to a JSON schema using zod-to-json-schema before creating the extraction chain.

    Parameters

    • schema: ZodObject<any, any, any, any, {}>

      The Zod schema which extracted data should match

    • llm: BaseChatModel<BaseFunctionCallOptions, AIMessageChunk>

      Must be a ChatOpenAI or AnthropicFunctions model that supports function calling.

    Returns LLMChain<object, BaseChatModel<BaseFunctionCallOptions, AIMessageChunk>>

    A LLMChain instance configured to return data matching the schema.