Ë
    ´ŒjA  ã                   óÎ   — d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZmZ d dlmZ d d	lmZ d d
lmZ eeeeef      gee	   f   Zedœdedee   dededef
d„Zy)é    )ÚSequence)ÚCallable)ÚAgentAction)ÚBaseLanguageModel)ÚBaseMessage)ÚChatPromptTemplate)ÚRunnableÚRunnablePassthrough)ÚBaseTool)Úformat_to_tool_messages)ÚToolsAgentOutputParser)Úmessage_formatterÚllmÚtoolsÚpromptr   Úreturnc                ó4  ‡— dhj                  |j                  t        |j                  «      z   «      }|rd|› �}t	        |«      ‚t        | d«      sd}t	        |«      ‚| j                  |«      }t        j                  ˆfd„¬«      |z  |z  t        «       z  S )a.	  Create an agent that uses tools.

    Args:
        llm: LLM to use as the agent.
        tools: Tools this agent has access to.
        prompt: The prompt to use. See Prompt section below for more on the expected
            input variables.
        message_formatter: Formatter function to convert (AgentAction, tool output)
            tuples into FunctionMessages.

    Returns:
        A Runnable sequence representing an agent. It takes as input all the same input
        variables as the prompt passed in does. It returns as output either an
        AgentAction or AgentFinish.

    Example:

        .. code-block:: python

            from langchain.agents import AgentExecutor, create_tool_calling_agent, tool
            from langchain_anthropic import ChatAnthropic
            from langchain_core.prompts import ChatPromptTemplate

            prompt = ChatPromptTemplate.from_messages(
                [
                    ("system", "You are a helpful assistant"),
                    ("placeholder", "{chat_history}"),
                    ("human", "{input}"),
                    ("placeholder", "{agent_scratchpad}"),
                ]
            )
            model = ChatAnthropic(model="claude-3-opus-20240229")

            @tool
            def magic_function(input: int) -> int:
                """Applies a magic function to an input."""
                return input + 2

            tools = [magic_function]

            agent = create_tool_calling_agent(model, tools, prompt)
            agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)

            agent_executor.invoke({"input": "what is the value of magic_function(3)?"})

            # Using with chat history
            from langchain_core.messages import AIMessage, HumanMessage
            agent_executor.invoke(
                {
                    "input": "what's my name?",
                    "chat_history": [
                        HumanMessage(content="hi! my name is bob"),
                        AIMessage(content="Hello Bob! How can I assist you today?"),
                    ],
                }
            )

    Prompt:

        The agent prompt must have an `agent_scratchpad` key that is a
            ``MessagesPlaceholder``. Intermediate agent actions and tool output
            messages will be passed in here.
    Úagent_scratchpadz#Prompt missing required variables: Ú
bind_toolszGThis function requires a bind_tools() method be implemented on the LLM.c                 ó   •—  ‰| d   «      S )NÚintermediate_steps© )Úxr   s    €úr/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/langchain/agents/tool_calling_agent/base.pyÚ<lambda>z+create_tool_calling_agent.<locals>.<lambda>i   s   ø€ Ñ'8¸Ð;OÑ9PÔ'Qó    )r   )
Ú
differenceÚinput_variablesÚlistÚpartial_variablesÚ
ValueErrorÚhasattrr   r
   Úassignr   )r   r   r   r   Úmissing_varsÚmsgÚllm_with_toolss      `   r   Úcreate_tool_calling_agentr'      sµ   ø€ ðL 'Ð'×2Ñ2Ø×Ñ¤ f×&>Ñ&>Ó!?Ñ?ó€Lñ Ø3°L°>ÐBˆÜ˜‹oÐä�3˜Ô%ØWˆÜØó
ð 	
ð —^‘^ EÓ*€Nô 	×"Ñ"ÛQô	
ð ñ	ð ñ		ô
 !Ó
"ñ	#ðr   N)Úcollections.abcr   Útypingr   Úlangchain_core.agentsr   Úlangchain_core.language_modelsr   Úlangchain_core.messagesr   Úlangchain_core.prompts.chatr   Úlangchain_core.runnablesr	   r
   Úlangchain_core.toolsr   Ú(langchain.agents.format_scratchpad.toolsr   Ú%langchain.agents.output_parsers.toolsr   ÚtupleÚstrr   ÚMessageFormatterr'   r   r   r   Ú<module>r5      s“   ðÝ $Ý å -Ý <Ý /Ý :ß BÝ )õõ Ià˜X e¨K¸Ð,<Ñ&=Ñ>Ð?ÀÀkÑARÐRÑSÐ ð +Bò[Ø	ð[à�HÑð[ð ð[ð
 (ð[ð ô[r   