Ë
    ´Œjž  ã                   ó~   — d dl Z d dlmZ d dlmZ d dlmZmZmZ d dl	m
Z
 de
dedefd	„Zd
eeeef      dee   fd„Zy)é    N)ÚSequence)ÚAgentAction)Ú	AIMessageÚBaseMessageÚToolMessage)ÚToolAgentActionÚagent_actionÚobservationÚreturnc                 óÔ   — t        |t        «      s	 t        j                  |d¬«      }n|}t        | j                  |d| j                  i¬«      S # t        $ r t        |«      }Y Œ:w xY w)ak  Convert agent action and observation into a tool message.

    Args:
        agent_action: the tool invocation request from the agent.
        observation: the result of the tool invocation.
    Returns:
        ToolMessage that corresponds to the original tool invocation.

    Raises:
        ValueError: if the observation cannot be converted to a string.
    F)Úensure_asciiÚname)Útool_call_idÚcontentÚadditional_kwargs)Ú
isinstanceÚstrÚjsonÚdumpsÚ	Exceptionr   r   Útool)r	   r
   r   s      úr/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/langchain/agents/format_scratchpad/tools.pyÚ_create_tool_messager      sl   € ô �k¤3Ô'ð	'Ü—j‘j ¸5ÔA‰Gð ˆÜØ!×.Ñ.ØØ! <×#4Ñ#4Ð5ôð øô	 ò 	'Ü˜+Ó&ŠGð	'ús   ’A ÁA'Á&A'Úintermediate_stepsc                 ó"  — g }| D ]‚  \  }}t        |t        «      rHg t        |j                  «      ¢t	        ||«      ‘}|j                  |D �cg c]	  }||vsŒ|‘Œ c}«       Œ^|j                  t        |j                  ¬«      «       Œ„ |S c c}w )zöConvert (AgentAction, tool output) tuples into ToolMessages.

    Args:
        intermediate_steps: Steps the LLM has taken to date, along with observations.

    Returns:
        list of messages to send to the LLM for the next prediction.

    )r   )	r   r   ÚlistÚmessage_logr   ÚextendÚappendr   Úlog)r   Úmessagesr	   r
   Únew_messagesÚnews         r   Úformat_to_tool_messagesr$   +   s“   € ð €HÛ%7Ñ!ˆ�kÜ�l¤OÔ4ðÜ�l×.Ñ.Ó/ðä$ \°;Ó?ðˆLð �O‰O©LÓP©L S¸CÀxÒ<OšS¨LÑPÕQà�O‰OœI¨l×.>Ñ.>Ô?Õ@ð &8ð €Oùò Qs   Á	B
ÁB
)r   Úcollections.abcr   Úlangchain_core.agentsr   Úlangchain_core.messagesr   r   r   Ú%langchain.agents.output_parsers.toolsr   r   r   Útupler   r$   © ó    r   Ú<module>r,      sf   ðÛ Ý $å -÷ñ õ BðØ!ðàðð óð:Ø   {°CÐ'7Ñ!8Ñ9ðà	ˆ+Ñôr+   