Home / Function/ from_llm_and_tools() — langchain Function Reference

from_llm_and_tools() — langchain Function Reference

Architecture documentation for the from_llm_and_tools() function in base.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  c9b66245_954d_d2ee_4fd7_d5d2d86134a7["from_llm_and_tools()"]
  b444f628_93a3_fafc_0827_7b9ca1eef67c["OpenAIFunctionsAgent"]
  c9b66245_954d_d2ee_4fd7_d5d2d86134a7 -->|defined in| b444f628_93a3_fafc_0827_7b9ca1eef67c
  da808fef_77ef_b187_cb58_925f7766ebac["create_prompt()"]
  c9b66245_954d_d2ee_4fd7_d5d2d86134a7 -->|calls| da808fef_77ef_b187_cb58_925f7766ebac
  style c9b66245_954d_d2ee_4fd7_d5d2d86134a7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/agents/openai_functions_agent/base.py lines 249–284

    def from_llm_and_tools(
        cls,
        llm: BaseLanguageModel,
        tools: Sequence[BaseTool],
        callback_manager: BaseCallbackManager | None = None,
        extra_prompt_messages: list[BaseMessagePromptTemplate] | None = None,
        system_message: SystemMessage | None = _NOT_SET,  # type: ignore[assignment]
        **kwargs: Any,
    ) -> BaseSingleActionAgent:
        """Construct an agent from an LLM and tools.

        Args:
            llm: The LLM to use as the agent.
            tools: The tools to use.
            callback_manager: The callback manager to use.
            extra_prompt_messages: Extra prompt messages to use.
            system_message: The system message to use.
                Defaults to a default system message.
            kwargs: Additional parameters to pass to the agent.
        """
        system_message_ = (
            system_message
            if system_message is not _NOT_SET
            else SystemMessage(content="You are a helpful AI assistant.")
        )
        prompt = cls.create_prompt(
            extra_prompt_messages=extra_prompt_messages,
            system_message=system_message_,
        )
        return cls(
            llm=llm,
            prompt=prompt,
            tools=tools,
            callback_manager=callback_manager,
            **kwargs,
        )

Subdomains

Frequently Asked Questions

What does from_llm_and_tools() do?
from_llm_and_tools() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/agents/openai_functions_agent/base.py.
Where is from_llm_and_tools() defined?
from_llm_and_tools() is defined in libs/langchain/langchain_classic/agents/openai_functions_agent/base.py at line 249.
What does from_llm_and_tools() call?
from_llm_and_tools() calls 1 function(s): create_prompt.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free