Home / File/ tagging.py — langchain Source File

tagging.py — langchain Source File

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

Entity Profile

Dependency Diagram

graph LR
  d7a84d7c_0dad_2b82_1285_762f1da3e11b["tagging.py"]
  feec1ec4_6917_867b_d228_b134d0ff8099["typing"]
  d7a84d7c_0dad_2b82_1285_762f1da3e11b --> feec1ec4_6917_867b_d228_b134d0ff8099
  2485b66a_3839_d0b6_ad9c_a4ff40457dc6["langchain_core._api"]
  d7a84d7c_0dad_2b82_1285_762f1da3e11b --> 2485b66a_3839_d0b6_ad9c_a4ff40457dc6
  e929cf21_6ab8_6ff3_3765_0d35a099a053["langchain_core.language_models"]
  d7a84d7c_0dad_2b82_1285_762f1da3e11b --> e929cf21_6ab8_6ff3_3765_0d35a099a053
  2b2663e7_3c78_e2fb_75f2_99a68ca124a7["langchain_core.output_parsers.openai_functions"]
  d7a84d7c_0dad_2b82_1285_762f1da3e11b --> 2b2663e7_3c78_e2fb_75f2_99a68ca124a7
  435e49bf_bb2e_2016_ead7_0afb9d57ad71["langchain_core.prompts"]
  d7a84d7c_0dad_2b82_1285_762f1da3e11b --> 435e49bf_bb2e_2016_ead7_0afb9d57ad71
  9a0fc770_8c3f_14bc_3c7d_37852927778e["langchain_classic.chains.base"]
  d7a84d7c_0dad_2b82_1285_762f1da3e11b --> 9a0fc770_8c3f_14bc_3c7d_37852927778e
  4044d59c_c0a5_a371_f49b_bea3da4e20ac["langchain_classic.chains.llm"]
  d7a84d7c_0dad_2b82_1285_762f1da3e11b --> 4044d59c_c0a5_a371_f49b_bea3da4e20ac
  0c185122_d3ba_0c43_f0ed_a34e98a95301["langchain_classic.chains.openai_functions.utils"]
  d7a84d7c_0dad_2b82_1285_762f1da3e11b --> 0c185122_d3ba_0c43_f0ed_a34e98a95301
  style d7a84d7c_0dad_2b82_1285_762f1da3e11b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from typing import Any

from langchain_core._api import deprecated
from langchain_core.language_models import BaseLanguageModel
from langchain_core.output_parsers.openai_functions import (
    JsonOutputFunctionsParser,
    PydanticOutputFunctionsParser,
)
from langchain_core.prompts import ChatPromptTemplate

from langchain_classic.chains.base import Chain
from langchain_classic.chains.llm import LLMChain
from langchain_classic.chains.openai_functions.utils import (
    _convert_schema,
    get_llm_kwargs,
)


def _get_tagging_function(schema: dict) -> dict:
    return {
        "name": "information_extraction",
        "description": "Extracts the relevant information from the passage.",
        "parameters": _convert_schema(schema),
    }


_TAGGING_TEMPLATE = """Extract the desired information from the following passage.

Only extract the properties mentioned in the 'information_extraction' function.

Passage:
{input}
"""


@deprecated(
    since="0.2.13",
    message=(
        "LangChain has introduced a method called `with_structured_output` that "
        "is available on ChatModels capable of tool calling. "
        "See API reference for this function for replacement: <"
        "https://api.python.langchain.com/en/latest/chains/langchain.chains.openai_functions.tagging.create_tagging_chain.html"
        "> You can read more about `with_structured_output` here: "
        "<https://docs.langchain.com/oss/python/langchain/models#structured-outputs>. "
        "If you notice other issues, please provide "
        "feedback here: "
        "<https://github.com/langchain-ai/langchain/discussions/18154>"
    ),
    removal="1.0",
)
def create_tagging_chain(
    schema: dict,
    llm: BaseLanguageModel,
    prompt: ChatPromptTemplate | None = None,
    **kwargs: Any,
) -> Chain:
    """Create tagging chain from schema.

    Create a chain that extracts information from a passage
    based on a schema.
// ... (130 more lines)

Subdomains

Dependencies

  • langchain_classic.chains.base
  • langchain_classic.chains.llm
  • langchain_classic.chains.openai_functions.utils
  • langchain_core._api
  • langchain_core.language_models
  • langchain_core.output_parsers.openai_functions
  • langchain_core.prompts
  • typing

Frequently Asked Questions

What does tagging.py do?
tagging.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 tagging.py?
tagging.py defines 3 function(s): _get_tagging_function, create_tagging_chain, create_tagging_chain_pydantic.
What does tagging.py depend on?
tagging.py imports 8 module(s): langchain_classic.chains.base, langchain_classic.chains.llm, langchain_classic.chains.openai_functions.utils, langchain_core._api, langchain_core.language_models, langchain_core.output_parsers.openai_functions, langchain_core.prompts, typing.
Where is tagging.py in the architecture?
tagging.py is located at libs/langchain/langchain_classic/chains/openai_functions/tagging.py (domain: AgentOrchestration, subdomain: ClassicChains, directory: libs/langchain/langchain_classic/chains/openai_functions).

Analyze Your Own Codebase

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

Try Supermodel Free