motleycrew.utils.structured_output_with_retries

Functions

structured_output_with_retries(schema, ...)

Use MotleyCrew agent with retries to extract structured output.

motleycrew.utils.structured_output_with_retries.structured_output_with_retries(schema: ~typing.Type[~pydantic.main.BaseModel], prompt: str, input_messages: ~typing.List[~langchain_core.messages.human.HumanMessage] | dict, language_model: ~langchain_core.language_models.base.BaseLanguageModel | None = None, post_process: ~typing.Callable[[~pydantic.main.BaseModel], ~pydantic.main.BaseModel] = <function <lambda>>) BaseModel

Use MotleyCrew agent with retries to extract structured output.

Parameters:
  • schema – The Pydantic model to extract

  • prompt – Instructions

  • input_messages – List of messages containing the image and text

  • language_model – The language model to use

Returns:

An instance of the schema with extracted data