
    dh$v                     <   S r SSKrSSKrSSKJrJr  SSKJr  SSKJ	r	J
r
JrJrJrJrJrJrJrJr  SSKJrJr  SSKJr  SSKJrJrJr  SS	KJrJrJrJ r J!r!J"r"J#r#J$r$J%r%  SS
K&J'r'  SSK(J)r)J*r*  SSK+J,r,J-r-J.r.  SSK/J0r0J1r1J2r2  SSK3J4r4  SSK5J6r6J7r7  SSK8J9r9  SSK:J;r;  SSK<J=r=J>r>J?r?J@r@JArA  \R                  " \C5      rD\S\	S\ES\ES\	S\4
S j5       rF\S\	S\ES\ES\	S\
4
S j5       rGS\S\\E\	4   4S jrHS\\E\	4   S\4S jrIS\\E\	4   S\\    S\ 4S jrJ " S  S!\5      rKg)"z#Wrapper around Minimax chat models.    N)asynccontextmanagercontextmanager)
itemgetter)
AnyAsyncIteratorCallableDictIteratorListOptionalSequenceTypeUnion)AsyncCallbackManagerForLLMRunCallbackManagerForLLMRun)LanguageModelInput)BaseChatModelagenerate_from_streamgenerate_from_stream)		AIMessageAIMessageChunkBaseMessageBaseMessageChunkChatMessageChatMessageChunkHumanMessageSystemMessageToolMessage)OutputParserLike)JsonOutputKeyToolsParserPydanticToolsParser)ChatGenerationChatGenerationChunk
ChatResult)RunnableRunnableMapRunnablePassthrough)BaseTool)convert_to_secret_strget_from_dict_or_env)convert_to_openai_tool)
get_fields)	BaseModel
ConfigDictField	SecretStrmodel_validatorclientmethodurlkwargsreturnc              +      #    SSK Jn  U R                  " X40 UD6 nU" U5      v   SSS5        g! , (       d  f       g= f7f)zContext manager for connecting to an SSE stream.

Args:
    client: The httpx client.
    method: The HTTP method.
    url: The URL to connect to.
    kwargs: Additional keyword arguments to pass to the client.

Yields:
    An EventSource object.
r   EventSourceN	httpx_sser9   streamr2   r3   r4   r5   r9   responses         _/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/chat_models/minimax.pyconnect_httpx_sser@   ?   s3      &	v	-f	-(## 
.	-	-s   A0	A
>Ac                   #    SSK Jn  U R                  " X40 UD6 ISh  vN nU" U5      7v   SSS5      ISh  vN   g N  N! , ISh  vN  (       d  f       g= f7f)zAsync context manager for connecting to an SSE stream.

Args:
    client: The httpx client.
    method: The HTTP method.
    url: The URL to connect to.
    kwargs: Additional keyword arguments to pass to the client.

Yields:
    An EventSource object.
r   r8   Nr:   r=   s         r?   aconnect_httpx_sserB   R   s?      &}}V3F33x(## 433333sA   AAAAAAAAAAAAmessagec                    [        U [        5      (       a  SU R                  S.nU$ [        U [        5      (       a+  SU R                  U R                  R                  S5      S.nU$ [        U [        5      (       a  SU R                  S.nU$ [        U [        5      (       aI  SU R                  U R                  U R                  =(       d    U R                  R                  S5      S	.nU$ [        S
U R                  R                   S35      e)z%Convert a LangChain messages to Dict.userrolecontent	assistant
tool_calls)rG   rH   rJ   systemtoolname)rG   rH   tool_call_idrM   zGot unknown type 'z'.)
isinstancer   rH   r   additional_kwargsgetr   r   rN   rM   	TypeError	__class____name__)rC   message_dicts     r?   _convert_message_to_dictrV   g   s     '<(( &7??C$ # 
GY	'	'!3377E
   
G]	+	+ (W__E  
G[	)	)#00LLIG$=$=$A$A&$I	
  ,W->->-G-G,HKLL    dctc                     U R                  S5      nU R                  SS5      nUS:X  a$  0 nU R                  SS5      nUb  XCS'   [        X#S9$ [        XS9$ )	z$Convert a dict to LangChain message.rG   rH    rI   rJ   NrH   rP   rF   )rQ   r   r   )rX   rG   rH   rP   rJ   s        r?   _convert_dict_to_messager\      sa    776?Dggi$G{WW\40
!.8l+NND22rW   default_classc                     U R                  S5      nU R                  SS5      n0 nU R                  SS 5      nUb  XTS'   US:X  d
  U[        :X  a	  [        X4S9$ U(       d
  U[        :X  a	  [        X2S9$ U" US	9$ )
NrG   rH   rZ   	tool_callrJ   rI   r[   )rH   rG   )rH   )rQ   r   r   )rX   r]   rG   rH   rP   rJ   s         r?   _convert_delta_to_message_chunkr`      s     776?Dggi$Gd+J*4,'{m~=gSS} 00;;))rW   c                     ^  \ rS rSr% Sr\S\\\4   4S j5       r	\S\4S j5       r
\S\\\4   4S j5       rSr\\S'   S	r\\S
'    Sr\\S'    Sr\\S'    Sr\\S'    \" \S9r\\\4   \S'    \" SSS9r\\S'   \" SSS9r\\   \S'    \" SS9r\\S'    Sr\\S'    \" SS9r\ " S S!9\!S"\S\4S# j5       5       r"S$\#\\$4   S\%4S% jr& S:S&\'\(   S'\S(\S\\\4   4S) jjr)\*S*\\\4   SS4S+ j5       r+   S;S&\'\(   S,\\'\      S-\\,   S.\\   S(\S\%4S/ jjr-  S<S&\'\(   S,\\'\      S-\\,   S(\S\.\/   4
S0 jjr0   S;S&\'\(   S,\\'\      S-\\1   S.\\   S(\S\%4S1 jjr2  S<S&\'\(   S,\\'\      S-\\1   S(\S\3\/   4
S2 jjr4S3\5\#\\\4   \6\$   \7\84      S(\S\9\:\(4   4U 4S4 jjr;SS5.S6\#\\6\$   4   S7\S(\S\9\:\#\\$4   4   4S8 jjr<S9r=U =r>$ )=MiniMaxChat   u  MiniMax chat model integration.

Setup:
    To use, you should have the environment variable``MINIMAX_API_KEY`` set with
your API KEY.

    .. code-block:: bash

        export MINIMAX_API_KEY="your-api-key"

Key init args — completion params:
    model: Optional[str]
        Name of MiniMax model to use.
    max_tokens: Optional[int]
        Max number of tokens to generate.
    temperature: Optional[float]
        Sampling temperature.
    top_p: Optional[float]
        Total probability mass of tokens to consider at each step.
    streaming: Optional[bool]
         Whether to stream the results or not.

Key init args — client params:
    api_key: Optional[str]
        MiniMax API key. If not passed in will be read from env var MINIMAX_API_KEY.
    base_url: Optional[str]
        Base URL for API requests.

See full list of supported init args and their descriptions in the params section.

Instantiate:
    .. code-block:: python

        from langchain_community.chat_models import MiniMaxChat

        chat = MiniMaxChat(
            api_key=api_key,
            model='abab6.5-chat',
            # temperature=...,
            # other params...
        )

Invoke:
    .. code-block:: python

        messages = [
            ("system", "你是一名专业的翻译家，可以将用户的中文翻译为英文。"),
            ("human", "我喜欢编程。"),
        ]
        chat.invoke(messages)

    .. code-block:: python

        AIMessage(
            content='I enjoy programming.',
            response_metadata={
                'token_usage': {'total_tokens': 48},
                'model_name': 'abab6.5-chat',
                'finish_reason': 'stop'
            },
            id='run-42d62ba6-5dc1-4e16-98dc-f72708a4162d-0'
        )

Stream:
    .. code-block:: python

        for chunk in chat.stream(messages):
            print(chunk)

    .. code-block:: python

        content='I' id='run-a5837c45-4aaa-4f64-9ab4-2679bbd55522'
        content=' enjoy programming.' response_metadata={'finish_reason': 'stop'} id='run-a5837c45-4aaa-4f64-9ab4-2679bbd55522'

    .. code-block:: python

        stream = chat.stream(messages)
        full = next(stream)
        for chunk in stream:
            full += chunk
        full

    .. code-block:: python

        AIMessageChunk(
            content='I enjoy programming.',
            response_metadata={'finish_reason': 'stop'},
            id='run-01aed0a0-61c4-4709-be22-c6d8b17155d6'
        )

Async:
    .. code-block:: python

        await chat.ainvoke(messages)

        # stream
        # async for chunk in chat.astream(messages):
        #     print(chunk)

        # batch
        # await chat.abatch([messages])

    .. code-block:: python

        AIMessage(
            content='I enjoy programming.',
            response_metadata={
                'token_usage': {'total_tokens': 48},
                'model_name': 'abab6.5-chat',
                'finish_reason': 'stop'
            },
            id='run-c263b6f1-1736-4ece-a895-055c26b3436f-0'
        )

Tool calling:
    .. code-block:: python

        from pydantic import BaseModel, Field


        class GetWeather(BaseModel):
            '''Get the current weather in a given location'''

            location: str = Field(
                ..., description="The city and state, e.g. San Francisco, CA"
            )


        class GetPopulation(BaseModel):
            '''Get the current population in a given location'''

            location: str = Field(
                ..., description="The city and state, e.g. San Francisco, CA"
            )

        chat_with_tools = chat.bind_tools([GetWeather, GetPopulation])
        ai_msg = chat_with_tools.invoke(
            "Which city is hotter today and which is bigger: LA or NY?"
        )
        ai_msg.tool_calls

    .. code-block:: python

        [
            {
                'name': 'GetWeather',
                'args': {'location': 'LA'},
                'id': 'call_function_2140449382',
                'type': 'tool_call'
            }
        ]

Structured output:
    .. code-block:: python

        from typing import Optional

        from pydantic import BaseModel, Field


        class Joke(BaseModel):
            '''Joke to tell user.'''
            setup: str = Field(description="The setup of the joke")
            punchline: str = Field(description="The punchline to the joke")
            rating: Optional[int] = Field(description="How funny the joke is, from 1 to 10")


        structured_chat = chat.with_structured_output(Joke)
        structured_chat.invoke("Tell me a joke about cats")

    .. code-block:: python

        Joke(
            setup='Why do cats have nine lives?',
            punchline='Because they are so cute and cuddly!',
            rating=None
        )

Response metadata
    .. code-block:: python

        ai_msg = chat.invoke(messages)
        ai_msg.response_metadata

    .. code-block:: python

        {'token_usage': {'total_tokens': 48},
         'model_name': 'abab6.5-chat',
         'finish_reason': 'stop'}

r6   c                 :    0 SU R                   0EU R                  E$ )zGet the identifying parameters.model)re   _default_paramsselfs    r?   _identifying_paramsMiniMaxChat._identifying_params_  s$     A7DJJ'@4+?+?@@rW   c                     g)zReturn type of llm.minimax rg   s    r?   	_llm_typeMiniMaxChat._llm_typed  s     rW   c                 x    U R                   U R                  U R                  U R                  S.U R                  E$ )z2Get the default parameters for calling OpenAI API.)re   
max_tokenstemperaturetop_p)re   rq   rr   rs   model_kwargsrg   s    r?   rf   MiniMaxChat._default_paramsi  s<     ZZ//++ZZ	

 
 	
rW   N_clientzabab6.5s-chatre      rq   gffffff?rr   gffffff?rs   )default_factoryrt   z3https://api.minimaxi.chat/v1/text/chatcompletion_v2base_url)defaultaliasminimax_api_hostgroup_idminimax_group_idapi_key)r{   minimax_api_keyF	streamingT)populate_by_namebefore)modevaluesc                     [        [        USS/S5      5      US'   [        U 5      R                  5        VVs0 sH   u  p#UR                  c  M  X#R                  _M"     nnnUR                  U5        [        USS/SUS   5      US'   U$ s  snnf )z?Validate that api key and python package exists in environment.r   r   MINIMAX_API_KEYr|   ry   MINIMAX_API_HOST)r)   r*   r,   itemsrz   update)clsr   rM   fielddefault_valuess        r?   validate_environment MiniMaxChat.validate_environment  s     %: "I.!%
 !  *#446
6}}  D--6 	 

 	f% &:,-.	&
!" 
s   B
B
r>   c                 8   / n[        U[        5      (       d  UR                  5       nUS    HA  n[        US   5      n[        UR                  S5      S9nUR	                  [        XES95        MC     UR                  S0 5      nUU R                  S.n[        X'S9$ )	NchoicesrC   finish_reason)r   rC   generation_infousage)token_usage
model_name)generations
llm_output)rO   dictr\   rQ   appendr"   re   r$   )rh   r>   r   resrC   r   r   r   s           r?   _create_chat_resultMiniMaxChat._create_chat_result  s    (D))}}HI&C.s9~>G"1IJOwP ' ll7B/&**

 kIIrW   messages	is_streamr5   c                     U Vs/ sH  n[        U5      PM     nnU R                  nXVS'   U R                  UR                  S0 5      5        UR                  " S0 UD6  U(       a  SUS'   U$ s  snf )z#Create API request body parameters.r   toolsTr<   rm   )rV   rf   _reformat_function_parametersrQ   r   )rh   r   r   r5   mmessage_dictspayloads          r?   _create_payload_parameters&MiniMaxChat._create_payload_parameters  sr     ?GGh1!4hG&&+
**6::gr+BC   $GH Hs   A,	tools_argc                     U  HM  nUS   S:X  d  M  [        US   S   [        5      (       a  M+  [        R                  " US   S   5      US   S'   MO     g)z,Reformat the function parameters to strings.typefunction
parametersN)rO   strjsondumps)r   tool_args     r?   r   )MiniMaxChat._reformat_function_parameters  s]     "H:-j$\2C7 7 6:ZZZ(66$\2	 "rW   stoprun_managerr<   c                 x   U(       d  [        S5      eUb  UOU R                  nU(       a   U R                  " U4X#S.UD6n[        U5      $ U R                  " U40 UD6nSn	U R
                  b  U R
                  R                  5       n	SU	 3SS.n
SSKnUR                  U
S	S
9 nUR                  U R                  US9nUR                  5         SSS5        WR                  5       nSU;   a   SUS   ;   a  US   S   S:X  a  [        S5      eU R                  UR                  5       5      $ ! , (       d  f       Nc= f)a  Generate next turn in the conversation.
Args:
    messages: The history of the conversation as a list of messages. Code chat
        does not support context.
    stop: The list of stop words (optional).
    run_manager: The CallbackManager for LLM run, it's not used at the moment.
    stream: Whether to stream the results or not.

Returns:
    The ChatResult that contains outputs generated by the model.

Raises:
    ValueError: if the last message in the list is not from human.
:You should provide at least one message to start the chat!Nr   r   rZ   Bearer application/jsonAuthorizationzContent-Typer   <   headerstimeoutr   	base_resp
status_msgzinvalid api keyzInvalid API Key Provided)
ValueErrorr   _streamr   r   r   get_secret_valuehttpxClientpostr|   raise_for_statusr   	Exceptionr   )rh   r   r   r   r<   r5   r   stream_iterr   r   r   r   r2   r>   final_responses                  r?   	_generateMiniMaxChat._generate  sI   , L  %0Fdnn	,,#@FK (4411(EfE+**;;=G&wi0.
 	\\'2\6&{{4#8#8w{GH%%' 7 ">){ ;;{+L9=NN677''88 76s   #+D++
D9c              +     #    U R                   " U4SS0UD6nSnU R                  b  U R                  R                  5       nSU 3SS.nSSKnUR	                  US	S
9 n	[        U	SU R                  US9 n
U
R                  5        H  n[        R                  " UR                  5      n[        US   5      S:X  a  M7  US   S   n[        US   [        5      nUR                  SS5      nUb  SU0OSn[        XS9nU(       a  UR!                  UR"                  US9  Uv   Uc  M    O   SSS5        SSS5        g! , (       d  f       N= f! , (       d  f       g= f7f)z#Stream the chat response in chunks.r   TrZ   Nr   r   r   r   r   r   POSTr   r   deltar   r   chunk)r   r   r   r   r   r@   r|   iter_sser   loadsdatalenr`   r   rQ   r#   on_llm_new_tokentextrh   r   r   r   r5   r   r   r   r   r2   event_sourcesser   choicer   r   s                   r?   r   MiniMaxChat._stream  sl     11(UdUfU+**;;=G&wi0.
 	\\'2\6&" 5 5G'002C JJsxx0E5+,1 "9-a0F;wE %+JJ$EM )4 )-8! $
 0 %E ##44UZZu4MK$0/ 3 76  76s=   AEE4B-D:%D:)E1	E:
E	E
EEc                 v  #    U(       d  [        S5      eUb  UOU R                  nU(       a(  U R                  " U4X#S.UD6n[        U5      I S h  vN $ U R                  " U40 UD6nSn	U R
                  b  U R
                  R                  5       n	SU	 3SS.n
SS KnUR                  U
SS	9 IS h  vN nUR                  U R                  US
9I S h  vN nUR                  5         S S S 5      IS h  vN   U R                  WR                  5       5      $  N Ng NG N)! , IS h  vN  (       d  f       N>= f7f)Nr   r   rZ   r   r   r   r   r   r   r   )r   r   _astreamr   r   r   r   r   AsyncClientr   r|   r   r   r   )rh   r   r   r   r<   r5   r   r   r   r   r   r   r2   r>   s                 r?   
_agenerateMiniMaxChat._agenerate:  s1     L  %0Fdnn	--#@FK /{;;;11(EfE+**;;=G&wi0.
 	$$Wb$AAV#[[)>)>W[MMH%%' BA ''88 < BM BAAAsm   AD9DA D91D2D95DDD(D93D4$D9D9DD9D6%D(&D62D9c                V  #    U R                   " U4SS0UD6nSnU R                  b  U R                  R                  5       nSU 3SS.nSS KnUR	                  USS	9 IS h  vN n	[        U	S
U R                  US9 IS h  vN n
U
R                  5         S h  vN n[        R                  " UR                  5      n[        US   5      S:X  a  M=  US   S   n[        US   [        5      nUR                  SS 5      nUb  SU0OS n[        XS9nU(       a"  UR!                  UR"                  US9I S h  vN   U7v   Uc  M    S S S 5      IS h  vN   S S S 5      IS h  vN   g  GN N N N7
 N, N ! , IS h  vN  (       d  f       N5= f N,! , IS h  vN  (       d  f       g = f7f)Nr   TrZ   r   r   r   r   r   r   r   r   r   r   r   r   r   )r   r   r   r   r   rB   r|   	aiter_sser   r   r   r   r`   r   rQ   r#   r   r   r   s                   r?   r   MiniMaxChat._astream[  s     11(UdUfU+**;;=G&wi0.
 	$$Wb$AAV) 5 5G !-!7!7!9 # JJsxx0E5+,1 "9-a0F;wE %+JJ$EM )4 )-8! $
 0 %E #)::5::U:SSSK$05  BAA& T' ":    BAAAs   AF)!E&"F)%F E)FE3E/E+
E/BE35E-
6
E3E3FE1FF) F!F))F+E/-E3/E31F3F
	9E<:F
	FF)F&FF&"F)r   c                 f   > U Vs/ sH  n[        U5      PM     nn[        TU ]  " SSU0UD6$ s  snf )a  Bind tool-like objects to this chat model.

Args:
    tools: A list of tool definitions to bind to this chat model.
        Can be a dictionary, pydantic model, callable, or BaseTool. Pydantic
        models, callables, and BaseTools will be automatically converted to
        their schema dictionary representation.
    **kwargs: Any additional parameters to pass to the
        :class: `~langchain.runnable.Runnable` constructor.
r   rm   )r+   superbind)rh   r   r5   rL   formatted_toolsrS   s        r?   
bind_toolsMiniMaxChat.bind_tools  s>      EJJED1$7EJw|</<V<< Ks   .)include_rawschemar   c                   U(       a  [        SU 35      e[        U[        5      =(       a    [        U[        5      nU R                  U/5      nU(       a  [        U/SS9nO[        U5      S   S   n[        USS9nU(       aT  [        R                  " [        S5      U-  S S	9n[        R                  " S
 S9n	UR                  U	/SS9n
[        US9U
-  $ XV-  $ )a  Model wrapper that returns outputs formatted to match the given schema.

Args:
    schema: The output schema as a dict or a Pydantic class. If a Pydantic class
        then the model output will be an object of that class. If a dict then
        the model output will be a dict. With a Pydantic class the returned
        attributes will be validated, whereas with a dict they will not be. If
        `method` is "function_calling" and `schema` is a dict, then the dict
        must match the OpenAI function-calling spec.
    include_raw: If False then only the parsed structured output is returned. If
        an error occurs during model output parsing it will be raised. If True
        then both the raw model response (a BaseMessage) and the parsed model
        response will be returned. If an error occurs during output parsing it
        will be caught and returned as well. The final output is always a dict
        with keys "raw", "parsed", and "parsing_error".

Returns:
    A Runnable that takes any ChatModel input and returns as output:

        If include_raw is True then a dict with keys:
            raw: BaseMessage
            parsed: Optional[_DictOrPydantic]
            parsing_error: Optional[BaseException]

        If include_raw is False then just _DictOrPydantic is returned,
        where _DictOrPydantic depends on the schema:

        If schema is a Pydantic class then _DictOrPydantic is the Pydantic
            class.

        If schema is a dict then _DictOrPydantic is a dict.

Example: Function-calling, Pydantic schema (method="function_calling", include_raw=False):
    .. code-block:: python

        from langchain_community.chat_models import MiniMaxChat
        from pydantic import BaseModel

        class AnswerWithJustification(BaseModel):
            '''An answer to the user question along with justification for the answer.'''
            answer: str
            justification: str

        llm = MiniMaxChat()
        structured_llm = llm.with_structured_output(AnswerWithJustification)

        structured_llm.invoke("What weighs more a pound of bricks or a pound of feathers")

        # -> AnswerWithJustification(
        #     answer='A pound of bricks and a pound of feathers weigh the same.',
        #     justification='The weight of the feathers is much less dense than the weight of the bricks, but since both weigh one pound, they weigh the same.'
        # )

Example: Function-calling, Pydantic schema (method="function_calling", include_raw=True):
    .. code-block:: python

        from langchain_community.chat_models import MiniMaxChat
        from pydantic import BaseModel

        class AnswerWithJustification(BaseModel):
            '''An answer to the user question along with justification for the answer.'''
            answer: str
            justification: str

        llm = MiniMaxChat()
        structured_llm = llm.with_structured_output(AnswerWithJustification, include_raw=True)

        structured_llm.invoke("What weighs more a pound of bricks or a pound of feathers")

        # -> {
        #     'raw': AIMessage(content='', additional_kwargs={'tool_calls': [{'id': 'call_function_8953642285', 'type': 'function', 'function': {'name': 'AnswerWithJustification', 'arguments': '{"answer": "A pound of bricks and a pound of feathers weigh the same.", "justification": "The weight of the feathers is much less dense than the weight of the bricks, but since both weigh one pound, they weigh the same."}'}}]}, response_metadata={'token_usage': {'total_tokens': 257}, 'model_name': 'abab6.5-chat', 'finish_reason': 'tool_calls'}, id='run-d897e037-2796-49f5-847e-f9f69dd390db-0', tool_calls=[{'name': 'AnswerWithJustification', 'args': {'answer': 'A pound of bricks and a pound of feathers weigh the same.', 'justification': 'The weight of the feathers is much less dense than the weight of the bricks, but since both weigh one pound, they weigh the same.'}, 'id': 'call_function_8953642285', 'type': 'tool_call'}]),
        #     'parsed': AnswerWithJustification(answer='A pound of bricks and a pound of feathers weigh the same.', justification='The weight of the feathers is much less dense than the weight of the bricks, but since both weigh one pound, they weigh the same.'),
        #     'parsing_error': None
        # }

Example: Function-calling, dict schema (method="function_calling", include_raw=False):
    .. code-block:: python

        from langchain_community.chat_models import MiniMaxChat
        from pydantic import BaseModel
        from langchain_core.utils.function_calling import convert_to_openai_tool

        class AnswerWithJustification(BaseModel):
            '''An answer to the user question along with justification for the answer.'''
            answer: str
            justification: str

        dict_schema = convert_to_openai_tool(AnswerWithJustification)
        llm = MiniMaxChat()
        structured_llm = llm.with_structured_output(dict_schema)

        structured_llm.invoke("What weighs more a pound of bricks or a pound of feathers")

        # -> {
        #     'answer': 'A pound of bricks and a pound of feathers both weigh the same, which is a pound.',
        #     'justification': 'The difference is that bricks are much denser than feathers, so a pound of bricks will take up much less space than a pound of feathers.'
        # }
zReceived unsupported arguments T)r   first_tool_onlyr   rM   )key_namer   rawc                     g Nrm   _s    r?   <lambda>4MiniMaxChat.with_structured_output.<locals>.<lambda>  s    RVrW   )parsedparsing_errorc                     g r   rm   r   s    r?   r   r     s    drW   )r   r   )exception_key)r   )r   rO   r   
issubclassr-   r   r!   r+   r    r'   assignr   with_fallbacksr&   )rh   r   r   r5   is_pydantic_schemallmoutput_parserr   parser_assignparser_noneparser_with_fallbacks              r?   with_structured_output"MiniMaxChat.with_structured_output  s    R >vhGHH'5W*VY:Woovh'.Ah $/M
 .f5jA&IH4!4M /66!%(=8M .44NKK#0#?#?_ $@ $  3'*>>>&&rW   rm   )F)NNN)NN)?rT   
__module____qualname____firstlineno____doc__propertyr	   r   r   ri   rn   rf   rv   __annotations__re   rq   intrr   floatrs   r/   r   rt   r|   r~   r   r   r0   r   boolr.   model_configr1   classmethodr   r   r-   r$   r   r   r   r   staticmethodr   r   r   r
   r#   r   r   r   r   r   r   r   r   r(   r%   r   r   r  __static_attributes____classcell__)rS   s   @r?   rb   rb      s   ~@ AT#s(^ A A 3   
c3h 
 
 GS E3 JAKQE5D#(#>L$sCx.>V!EZc  ',D
&KhsmKJ!&Y!7OY7It/L (#$ 3   $4JE$	/,B Jz J$ >C[)6:NQ	c3h  c3h D   %):>!%49{#49 tCy!49 67	49
 49 49 
49r %):>	-{#- tCy!- 67	-
 - 
%	&-d %)?C!%9{#9 tCy!9 ;<	9
 9 9 
9H %)?C	,{#, tCy!, ;<	,
 , 
*	+,\=d38nd9oxQRS= = 
$k1	2	=. "	B'dDO+,B' 	B'
 B' 
$eD)O&<<	=B' B'rW   rb   )Lr  r   logging
contextlibr   r   operatorr   typingr   r   r   r	   r
   r   r   r   r   r   langchain_core.callbacksr   r   langchain_core.language_modelsr   *langchain_core.language_models.chat_modelsr   r   r   langchain_core.messagesr   r   r   r   r   r   r   r   r   "langchain_core.output_parsers.baser   *langchain_core.output_parsers.openai_toolsr    r!   langchain_core.outputsr"   r#   r$   langchain_core.runnablesr%   r&   r'   langchain_core.toolsr(   langchain_core.utilsr)   r*   %langchain_core.utils.function_callingr+   langchain_core.utils.pydanticr,   pydanticr-   r.   r/   r0   r1   	getLoggerrT   loggerr   r@   rB   rV   r\   r`   rb   rm   rW   r?   <module>r)     sj   )   :    > 

 
 
 @ S R O O ) L H 4  
		8	$ $c $3 $S $C $H $ $$ $$$#&$25$$ $(k d38n 2
3$sCx. 
3[ 
3*	c3h*(,-=(>**"@
'- @
'rW   