Home / File/ base.py — langchain Source File

base.py — langchain Source File

Architecture documentation for base.py, a python file in the langchain codebase. 16 imports, 0 dependents.

File python AgentOrchestration ClassicChains 16 imports 5 functions 3 classes

Entity Profile

Dependency Diagram

graph LR
  0331239a_f3d1_a093_b494_8cbb257ab96b["base.py"]
  e6310202_b39e_ec9f_8b57_921c9c39c97d["asyncio"]
  0331239a_f3d1_a093_b494_8cbb257ab96b --> e6310202_b39e_ec9f_8b57_921c9c39c97d
  9d14ea65_8b2e_6721_a947_acc89905651f["json"]
  0331239a_f3d1_a093_b494_8cbb257ab96b --> 9d14ea65_8b2e_6721_a947_acc89905651f
  2bf6d401_816d_d011_3b05_a6114f55ff58["collections.abc"]
  0331239a_f3d1_a093_b494_8cbb257ab96b --> 2bf6d401_816d_d011_3b05_a6114f55ff58
  996b2db9_46dd_901f_f7eb_068bafab4b12["time"]
  0331239a_f3d1_a093_b494_8cbb257ab96b --> 996b2db9_46dd_901f_f7eb_068bafab4b12
  feec1ec4_6917_867b_d228_b134d0ff8099["typing"]
  0331239a_f3d1_a093_b494_8cbb257ab96b --> feec1ec4_6917_867b_d228_b134d0ff8099
  59e0d3b0_0f8e_4b79_d442_e9b4821561c7["langchain_core.agents"]
  0331239a_f3d1_a093_b494_8cbb257ab96b --> 59e0d3b0_0f8e_4b79_d442_e9b4821561c7
  17a62cb3_fefd_6320_b757_b53bb4a1c661["langchain_core.callbacks"]
  0331239a_f3d1_a093_b494_8cbb257ab96b --> 17a62cb3_fefd_6320_b757_b53bb4a1c661
  86d015d7_8a78_acc2_abd6_9cb22b0ae1aa["langchain_core.load"]
  0331239a_f3d1_a093_b494_8cbb257ab96b --> 86d015d7_8a78_acc2_abd6_9cb22b0ae1aa
  31eab4ab_7281_1e6c_b17d_12e6ad9de07a["langchain_core.runnables"]
  0331239a_f3d1_a093_b494_8cbb257ab96b --> 31eab4ab_7281_1e6c_b17d_12e6ad9de07a
  121262a1_0bd6_d637_bce3_307ab6b3ecd4["langchain_core.tools"]
  0331239a_f3d1_a093_b494_8cbb257ab96b --> 121262a1_0bd6_d637_bce3_307ab6b3ecd4
  5c738c12_cc4f_cee1_0e1d_562012a5f844["langchain_core.utils.function_calling"]
  0331239a_f3d1_a093_b494_8cbb257ab96b --> 5c738c12_cc4f_cee1_0e1d_562012a5f844
  dd5e7909_a646_84f1_497b_cae69735550e["pydantic"]
  0331239a_f3d1_a093_b494_8cbb257ab96b --> dd5e7909_a646_84f1_497b_cae69735550e
  f85fae70_1011_eaec_151c_4083140ae9e5["typing_extensions"]
  0331239a_f3d1_a093_b494_8cbb257ab96b --> f85fae70_1011_eaec_151c_4083140ae9e5
  082af17d_b8ac_eccd_d339_93cabe1a9b40["openai"]
  0331239a_f3d1_a093_b494_8cbb257ab96b --> 082af17d_b8ac_eccd_d339_93cabe1a9b40
  style 0331239a_f3d1_a093_b494_8cbb257ab96b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from __future__ import annotations

import asyncio
import json
from collections.abc import Callable, Sequence
from json import JSONDecodeError
from time import sleep
from typing import (
    TYPE_CHECKING,
    Any,
)

from langchain_core.agents import AgentAction, AgentFinish
from langchain_core.callbacks import CallbackManager
from langchain_core.load import dumpd
from langchain_core.runnables import RunnableConfig, RunnableSerializable, ensure_config
from langchain_core.tools import BaseTool
from langchain_core.utils.function_calling import convert_to_openai_tool
from pydantic import BaseModel, Field, model_validator
from typing_extensions import Self, override

if TYPE_CHECKING:
    import openai
    from openai.types.beta.threads import ThreadMessage
    from openai.types.beta.threads.required_action_function_tool_call import (
        RequiredActionFunctionToolCall,
    )


class OpenAIAssistantFinish(AgentFinish):
    """AgentFinish with run and thread metadata.

    Args:
        run_id: Run id.
        thread_id: Thread id.
    """

    run_id: str
    thread_id: str

    @classmethod
    def is_lc_serializable(cls) -> bool:
        """Check if the class is serializable by LangChain.

        Returns:
            False
        """
        return False


class OpenAIAssistantAction(AgentAction):
    """AgentAction with info needed to submit custom tool output to existing run.

    Args:
        tool_call_id: Tool call id.
        run_id: Run id.
        thread_id: Thread id
    """

    tool_call_id: str
// ... (772 more lines)

Subdomains

Dependencies

  • asyncio
  • collections.abc
  • json
  • langchain_core.agents
  • langchain_core.callbacks
  • langchain_core.load
  • langchain_core.runnables
  • langchain_core.tools
  • langchain_core.utils.function_calling
  • openai
  • openai.types.beta.threads
  • openai.types.beta.threads.required_action_function_tool_call
  • pydantic
  • time
  • typing
  • typing_extensions

Frequently Asked Questions

What does base.py do?
base.py is a source file in the langchain codebase, written in python. It belongs to the AgentOrchestration domain, ClassicChains subdomain.
What functions are defined in base.py?
base.py defines 5 function(s): _get_assistants_tool, _get_openai_async_client, _get_openai_client, _is_assistants_builtin_tool, openai.
What does base.py depend on?
base.py imports 16 module(s): asyncio, collections.abc, json, langchain_core.agents, langchain_core.callbacks, langchain_core.load, langchain_core.runnables, langchain_core.tools, and 8 more.
Where is base.py in the architecture?
base.py is located at libs/langchain/langchain_classic/agents/openai_assistant/base.py (domain: AgentOrchestration, subdomain: ClassicChains, directory: libs/langchain/langchain_classic/agents/openai_assistant).

Analyze Your Own Codebase

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

Try Supermodel Free