Home / Function/ test_load_runnable_sequence_prompt_model() — langchain Function Reference

test_load_runnable_sequence_prompt_model() — langchain Function Reference

Architecture documentation for the test_load_runnable_sequence_prompt_model() function in test_load.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  d6134153_0ac3_f36d_8033_9e15951a10b8["test_load_runnable_sequence_prompt_model()"]
  f594231b_8e8d_61b8_e688_99b6f31430d1["test_load.py"]
  d6134153_0ac3_f36d_8033_9e15951a10b8 -->|defined in| f594231b_8e8d_61b8_e688_99b6f31430d1
  style d6134153_0ac3_f36d_8033_9e15951a10b8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/openai/tests/unit_tests/test_load.py lines 105–137

def test_load_runnable_sequence_prompt_model() -> None:
    """Test load() with a chain:

    `prompt | model (RunnableSequence)`.
    """
    prompt = ChatPromptTemplate.from_messages([("user", "Tell me about {topic}")])
    model = ChatOpenAI(model="gpt-4o-mini", temperature=0.7, openai_api_key="hello")  # type: ignore[call-arg]
    chain = prompt | model

    # Serialize
    chain_obj = dumpd(chain)

    # Deserialize
    # (ChatPromptTemplate contains HumanMessagePromptTemplate and PromptTemplate)
    chain2 = load(
        chain_obj,
        secrets_map={"OPENAI_API_KEY": "hello"},
        allowed_objects=[
            RunnableSequence,
            ChatPromptTemplate,
            HumanMessagePromptTemplate,
            PromptTemplate,
            ChatOpenAI,
        ],
    )

    # Verify structure
    assert isinstance(chain2, RunnableSequence)
    assert isinstance(chain2.first, ChatPromptTemplate)
    assert isinstance(chain2.last, ChatOpenAI)

    # Verify round-trip serialization
    assert dumpd(chain2) == chain_obj

Domain

Subdomains

Frequently Asked Questions

What does test_load_runnable_sequence_prompt_model() do?
test_load_runnable_sequence_prompt_model() is a function in the langchain codebase, defined in libs/partners/openai/tests/unit_tests/test_load.py.
Where is test_load_runnable_sequence_prompt_model() defined?
test_load_runnable_sequence_prompt_model() is defined in libs/partners/openai/tests/unit_tests/test_load.py at line 105.

Analyze Your Own Codebase

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

Try Supermodel Free