[GH-ISSUE #4154] bug: API Reference index pages missing classes due to lazy dynamic imports (e.g., langchain-core/prompts) #2785

Open
opened 2026-06-05 17:26:46 -04:00 by yindo · 0 comments
Owner

Originally created by @gagan-devv on GitHub (May 25, 2026).
Original GitHub issue: https://github.com/langchain-ai/docs/issues/4154

Type of issue

issue / bug

Language

Python

Product

LangChain

Link to reference page

https://reference.langchain.com/python/langchain-core/prompts

Description

Description

There is a structural rendering bug on the automated Python API reference site (reference.langchain.com).

On module index pages—such as https://reference.langchain.com/python/langchain-core/prompts—only a single class (ChatPromptTemplate) is visible. However, multiple critical sibling classes (like PromptTemplate, StringPromptTemplate, FewShotPromptTemplate, etc.) exist under this exact path and can be accessed directly via global search or direct URLs.

When a user tries to navigate backward using the breadcrumb hierarchy, they land on a broken, incomplete module page.

Root Cause Analysis

Looking at libs/core/langchain_core/prompts/__init__.py, the __all__ tuple is fully populated. However, LangChain utilizes lazy dynamic imports via __getattr__ and a _dynamic_imports dictionary:

if TYPE_CHECKING:
    from langchain_core.prompts.chat import ChatPromptTemplate
    from langchain_core.prompts.prompt import PromptTemplate
    # ... other imports

__all__ = (
    "ChatPromptTemplate",
    "PromptTemplate",
    # ... full export list
)

Because these classes are only explicitly imported under the if TYPE_CHECKING: block and loaded dynamically at runtime, the static analysis tool or documentation generator inspecting the module is failing to discover the exported attributes. It seems to only catch classes that happen to be implicitly loaded or referenced elsewhere (like ChatPromptTemplate).

Steps to Reproduce
Go to https://reference.langchain.com/python/langchain-core/prompts.

Observe that only ChatPromptTemplate is listed under Classes.

Search for PromptTemplate in the global search bar, click it, and observe its path is indeed Python > langchain-core > prompts > prompt > PromptTemplate.

Click on prompts in the breadcrumb path to go back, and notice the index page remains unpopulated.

Expected Behavior
The documentation generator should properly parse the module's all export list or evaluate the dynamic imports so that all public-facing classes and functions are listed on their respective package index layouts.

Image Image Image Image
Originally created by @gagan-devv on GitHub (May 25, 2026). Original GitHub issue: https://github.com/langchain-ai/docs/issues/4154 ### Type of issue issue / bug ### Language Python ### Product LangChain ### Link to reference page https://reference.langchain.com/python/langchain-core/prompts ### Description ### Description There is a structural rendering bug on the automated Python API reference site (`reference.langchain.com`). On module index pages—such as `https://reference.langchain.com/python/langchain-core/prompts`—only a single class (`ChatPromptTemplate`) is visible. However, multiple critical sibling classes (like `PromptTemplate`, `StringPromptTemplate`, `FewShotPromptTemplate`, etc.) exist under this exact path and can be accessed directly via global search or direct URLs. When a user tries to navigate backward using the breadcrumb hierarchy, they land on a broken, incomplete module page. ### Root Cause Analysis Looking at `libs/core/langchain_core/prompts/__init__.py`, the `__all__` tuple is fully populated. However, LangChain utilizes **lazy dynamic imports** via `__getattr__` and a `_dynamic_imports` dictionary: ```python if TYPE_CHECKING: from langchain_core.prompts.chat import ChatPromptTemplate from langchain_core.prompts.prompt import PromptTemplate # ... other imports __all__ = ( "ChatPromptTemplate", "PromptTemplate", # ... full export list ) ``` Because these classes are only explicitly imported under the if TYPE_CHECKING: block and loaded dynamically at runtime, the static analysis tool or documentation generator inspecting the module is failing to discover the exported attributes. It seems to only catch classes that happen to be implicitly loaded or referenced elsewhere (like ChatPromptTemplate). Steps to Reproduce Go to https://reference.langchain.com/python/langchain-core/prompts. Observe that only ChatPromptTemplate is listed under Classes. Search for PromptTemplate in the global search bar, click it, and observe its path is indeed Python > langchain-core > prompts > prompt > PromptTemplate. Click on prompts in the breadcrumb path to go back, and notice the index page remains unpopulated. Expected Behavior The documentation generator should properly parse the module's __all__ export list or evaluate the dynamic imports so that all public-facing classes and functions are listed on their respective package index layouts. <img width="2758" height="1644" alt="Image" src="https://github.com/user-attachments/assets/e8619aa3-bf78-4c37-8ef5-84436bc8912b" /> <img width="2758" height="1644" alt="Image" src="https://github.com/user-attachments/assets/e3016775-0169-4a34-98d6-083d0c2c42c6" /> <img width="2758" height="1644" alt="Image" src="https://github.com/user-attachments/assets/ce9fd1e8-37d5-4a53-a268-e0f808f531a0" /> <img width="2758" height="1644" alt="Image" src="https://github.com/user-attachments/assets/d93505ce-b703-45ad-9e06-4b9b415d64a6" />
yindo added the externalreference labels 2026-06-05 17:26:46 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/docs#2785