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
  b23ba04a_4f40_9881_1170_3466545b1295["from_llm_and_tools()"]
  4079b11a_3240_0a70_5830_e3af3b13b06e["OpenAIMultiFunctionsAgent"]
  b23ba04a_4f40_9881_1170_3466545b1295 -->|defined in| 4079b11a_3240_0a70_5830_e3af3b13b06e
  ecb86771_2888_ed00_30f6_8f6a534064c4["create_prompt()"]
  b23ba04a_4f40_9881_1170_3466545b1295 -->|calls| ecb86771_2888_ed00_30f6_8f6a534064c4
  style b23ba04a_4f40_9881_1170_3466545b1295 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/agents/openai_functions_multi_agent/base.py lines 302–337

    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,
    ) -> BaseMultiActionAgent:
        """Construct an agent from an LLM and tools.

        Args:
            llm: The language model to use.
            tools: A list of 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. Default is a default system
                message.
            kwargs: Additional arguments.
        """
        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_multi_agent/base.py.
Where is from_llm_and_tools() defined?
from_llm_and_tools() is defined in libs/langchain/langchain_classic/agents/openai_functions_multi_agent/base.py at line 302.
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