
    AhB              
           S SK Jr  S SKJr  S SKJr  S SKJr  S SKJ	r	  S SK
Jr  S SKJr  S SKJr  S	r\" S
SSSS9\4S\\\\      \\   4   S\S\S\4S jj5       rg)    )Union)
deprecated)BaseLanguageModel)PydanticToolsParser)ChatPromptTemplate)Runnable)#convert_pydantic_to_openai_function)	BaseModelzExtract and save the relevant entities mentioned in the following passage together with their properties.

If a property is not present and is not required in the function parameters, do not include it in the output.z0.1.14a|  LangChain has introduced a method called `with_structured_output` thatis available on ChatModels capable of tool calling.You can read more about the method here: <https://python.langchain.com/docs/modules/model_io/chat/structured_output/>. Please follow our extraction use case documentation for more guidelineson how to do information extraction with LLMs.<https://python.langchain.com/docs/use_cases/extraction/>. with_structured_output does not currently support a list of pydantic schemas. If this is a blocker or if you notice other issues, please provide feedback here:<https://github.com/langchain-ai/langchain/discussions/18154>z1.0a)  
            from pydantic import BaseModel, Field
            from langchain_anthropic import ChatAnthropic

            class Joke(BaseModel):
                setup: str = Field(description="The setup of the joke")
                punchline: str = Field(description="The punchline to the joke")

            # Or any other chat model that supports tools.
            # Please reference to to the documentation of structured_output
            # to see an up to date list of which models support
            # with_structured_output.
            model = ChatAnthropic(model="claude-3-opus-20240229", temperature=0)
            structured_llm = model.with_structured_output(Joke)
            structured_llm.invoke("Tell me a joke about cats.
                Make sure to call the Joke function.")
            )sincemessageremovalalternativepydantic_schemasllmsystem_messagereturnc                    [        U [        5      (       d  U /n [        R                  " SU4S/5      nU  Vs/ sH  n[	        U5      PM     nnU Vs/ sH  nSUS.PM
     nnUR                  US9nX8-  [        U S9-  $ s  snf s  snf )a#  Creates a chain that extracts information from a passage.

Args:
    pydantic_schemas: The schema of the entities to extract.
    llm: The language model to use.
    system_message: The system message to use for extraction.

Returns:
    A runnable that extracts information from a passage.
system)userz{input}function)typer   )tools)
isinstancelistr   from_messagesr	   bindr   )	r   r   r   promptp	functionsdr   models	            `/var/www/html/shao/venv/lib/python3.13/site-packages/langchain/chains/openai_tools/extraction.py create_extraction_chain_pydanticr#      s    f &--,---~&	
F BRRAQA4Q7AQIR:CD)Qja0)EDHH5H!E>/6FGGG SDs   A>BN)typingr   langchain_core._apir   langchain_core.language_modelsr   *langchain_core.output_parsers.openai_toolsr   langchain_core.promptsr   langchain_core.runnablesr   %langchain_core.utils.function_callingr	   pydanticr
   _EXTRACTION_TEMPLATEr   r   strr#        r"   <module>r0      s     * < J 5 - U q  

	H 	##N /HDi14	?BCH	H H 	HI#HHr/   