Home / Function/ test_web_search() — langchain Function Reference

test_web_search() — langchain Function Reference

Architecture documentation for the test_web_search() function in test_chat_models.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  0e7de83f_5c67_80ef_1976_68204790e69b["test_web_search()"]
  e3f53a01_269b_94be_7535_eb0783d866bb["test_chat_models.py"]
  0e7de83f_5c67_80ef_1976_68204790e69b -->|defined in| e3f53a01_269b_94be_7535_eb0783d866bb
  style 0e7de83f_5c67_80ef_1976_68204790e69b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/xai/tests/integration_tests/test_chat_models.py lines 97–115

def test_web_search() -> None:
    llm = ChatXAI(model=MODEL_NAME).bind_tools([{"type": "web_search"}])

    # Test invoke
    response = llm.invoke("Look up the current time in Boston, MA.")
    assert response.content
    content_types = {block["type"] for block in response.content_blocks}
    assert content_types == {"server_tool_call", "server_tool_result", "text"}
    assert response.content_blocks[0]["name"] == "web_search"  # type: ignore[typeddict-item]

    # Test streaming
    full: AIMessageChunk | None = None
    for chunk in llm.stream("Look up the current time in Boston, MA."):
        assert isinstance(chunk, AIMessageChunk)
        full = chunk if full is None else full + chunk
    assert isinstance(full, AIMessageChunk)
    content_types = {block["type"] for block in full.content_blocks}
    assert content_types == {"server_tool_call", "server_tool_result", "text"}
    assert full.content_blocks[0]["name"] == "web_search"  # type: ignore[typeddict-item]

Domain

Subdomains

Frequently Asked Questions

What does test_web_search() do?
test_web_search() is a function in the langchain codebase, defined in libs/partners/xai/tests/integration_tests/test_chat_models.py.
Where is test_web_search() defined?
test_web_search() is defined in libs/partners/xai/tests/integration_tests/test_chat_models.py at line 97.

Analyze Your Own Codebase

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

Try Supermodel Free