Home / Function/ langchain_community() — langchain Function Reference

langchain_community() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  0393cea2_16ff_2ed6_ebe5_2e7f4968843e["langchain_community()"]
  abf79bd8_0d60_378a_f86d_85282499aced["base.py"]
  0393cea2_16ff_2ed6_ebe5_2e7f4968843e -->|defined in| abf79bd8_0d60_378a_f86d_85282499aced
  7c7dcf33_3baa_8fce_f162_be592bd68a91["APIChain()"]
  0393cea2_16ff_2ed6_ebe5_2e7f4968843e -->|calls| 7c7dcf33_3baa_8fce_f162_be592bd68a91
  eff5a83c_a231_93eb_991e_23a16d44c5fe["input_keys()"]
  0393cea2_16ff_2ed6_ebe5_2e7f4968843e -->|calls| eff5a83c_a231_93eb_991e_23a16d44c5fe
  4879529e_d5bd_9e72_7e52_9a51c14e15f0["output_keys()"]
  0393cea2_16ff_2ed6_ebe5_2e7f4968843e -->|calls| 4879529e_d5bd_9e72_7e52_9a51c14e15f0
  5ea71541_36bb_b130_39b6_e92a0da91ffc["validate_api_request_prompt()"]
  0393cea2_16ff_2ed6_ebe5_2e7f4968843e -->|calls| 5ea71541_36bb_b130_39b6_e92a0da91ffc
  88e2af56_bf23_79ce_2926_78f971f5e3cd["validate_limit_to_domains()"]
  0393cea2_16ff_2ed6_ebe5_2e7f4968843e -->|calls| 88e2af56_bf23_79ce_2926_78f971f5e3cd
  008948f4_f327_2d60_320f_b5f336cf118e["validate_api_answer_prompt()"]
  0393cea2_16ff_2ed6_ebe5_2e7f4968843e -->|calls| 008948f4_f327_2d60_320f_b5f336cf118e
  1ea4a52c_0867_4fcb_dd5a_6056c78eabd9["_call()"]
  0393cea2_16ff_2ed6_ebe5_2e7f4968843e -->|calls| 1ea4a52c_0867_4fcb_dd5a_6056c78eabd9
  357f19d8_3422_6a9d_533d_c62f93023ce8["_check_in_allowed_domain()"]
  0393cea2_16ff_2ed6_ebe5_2e7f4968843e -->|calls| 357f19d8_3422_6a9d_533d_c62f93023ce8
  ccc83700_c56e_645f_a5ce_9e44f26e609a["_acall()"]
  0393cea2_16ff_2ed6_ebe5_2e7f4968843e -->|calls| ccc83700_c56e_645f_a5ce_9e44f26e609a
  d039a841_651f_0d79_5787_6e56936ae26f["from_llm_and_api_docs()"]
  0393cea2_16ff_2ed6_ebe5_2e7f4968843e -->|calls| d039a841_651f_0d79_5787_6e56936ae26f
  dcd9d956_5009_828b_89fc_44cf835deaed["_chain_type()"]
  0393cea2_16ff_2ed6_ebe5_2e7f4968843e -->|calls| dcd9d956_5009_828b_89fc_44cf835deaed
  style 0393cea2_16ff_2ed6_ebe5_2e7f4968843e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/chains/api/base.py lines 57–386

    from langchain_community.utilities.requests import TextRequestsWrapper

    @deprecated(
        since="0.2.13",
        message=(
            "This class is deprecated and will be removed in langchain 1.0. "
            "See API reference for replacement: "
            "https://api.python.langchain.com/en/latest/chains/langchain.chains.api.base.APIChain.html"
        ),
        removal="1.0",
    )
    class APIChain(Chain):
        """Chain that makes API calls and summarizes the responses to answer a question.

        **Security Note**: This API chain uses the requests toolkit
            to make `GET`, `POST`, `PATCH`, `PUT`, and `DELETE` requests to an API.

            Exercise care in who is allowed to use this chain. If exposing
            to end users, consider that users will be able to make arbitrary
            requests on behalf of the server hosting the code. For example,
            users could ask the server to make a request to a private API
            that is only accessible from the server.

            Control access to who can submit issue requests using this toolkit and
            what network access it has.

            See https://docs.langchain.com/oss/python/security-policy for more
            information.

        !!! note
            This class is deprecated. See below for a replacement implementation using
            LangGraph. The benefits of this implementation are:

        - Uses LLM tool calling features to encourage properly-formatted API requests;
        - Support for both token-by-token and step-by-step streaming;
        - Support for checkpointing and memory of chat history;
        - Easier to modify or extend
            (e.g., with additional tools, structured responses, etc.)

        Install LangGraph with:

        ```bash
        pip install -U langgraph
        ```

        ```python
        from typing import Annotated, Sequence
        from typing_extensions import TypedDict

        from langchain_classic.chains.api.prompt import API_URL_PROMPT
        from langchain_community.agent_toolkits.openapi.toolkit import RequestsToolkit
        from langchain_community.utilities.requests import TextRequestsWrapper
        from langchain_core.messages import BaseMessage
        from langchain_core.prompts import ChatPromptTemplate
        from langchain_openai import ChatOpenAI
        from langchain_core.runnables import RunnableConfig
        from langgraph.graph import END, StateGraph
        from langgraph.graph.message import add_messages
        from langgraph.prebuilt.tool_node import ToolNode

        # NOTE: There are inherent risks in giving models discretion
        # to execute real-world actions. We must "opt-in" to these
        # risks by setting allow_dangerous_request=True to use these tools.
        # This can be dangerous for calling unwanted requests. Please make
        # sure your custom OpenAPI spec (yaml) is safe and that permissions
        # associated with the tools are narrowly-scoped.
        ALLOW_DANGEROUS_REQUESTS = True

        # Subset of spec for https://jsonplaceholder.typicode.com
        api_spec = \"\"\"
        openapi: 3.0.0
        info:
          title: JSONPlaceholder API
          version: 1.0.0
        servers:
          - url: https://jsonplaceholder.typicode.com
        paths:
          /posts:
            get:
              summary: Get posts
              parameters: &id001

Subdomains

Frequently Asked Questions

What does langchain_community() do?
langchain_community() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/chains/api/base.py.
Where is langchain_community() defined?
langchain_community() is defined in libs/langchain/langchain_classic/chains/api/base.py at line 57.
What does langchain_community() call?
langchain_community() calls 11 function(s): APIChain, _acall, _call, _chain_type, _check_in_allowed_domain, from_llm_and_api_docs, input_keys, output_keys, and 3 more.

Analyze Your Own Codebase

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

Try Supermodel Free