test_web_search() — langchain Function Reference
Architecture documentation for the test_web_search() function in test_responses_api.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 2037583b_1787_28d8_8640_e55a631bf086["test_web_search()"] 992496d5_b7d4_139f_00cf_3e585d851f81["test_responses_api.py"] 2037583b_1787_28d8_8640_e55a631bf086 -->|defined in| 992496d5_b7d4_139f_00cf_3e585d851f81 b0966d53_e5bb_3879_d8d6_00823de68309["_check_response()"] 2037583b_1787_28d8_8640_e55a631bf086 -->|calls| b0966d53_e5bb_3879_d8d6_00823de68309 style 2037583b_1787_28d8_8640_e55a631bf086 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/openai/tests/integration_tests/chat_models/test_responses_api.py lines 84–133
def test_web_search(output_version: Literal["responses/v1", "v1"]) -> None:
llm = ChatOpenAI(model=MODEL_NAME, output_version=output_version)
first_response = llm.invoke(
"What was a positive news story from today?",
tools=[{"type": "web_search_preview"}],
)
_check_response(first_response)
# Test streaming
full: BaseMessageChunk | None = None
for chunk in llm.stream(
"What was a positive news story from today?",
tools=[{"type": "web_search_preview"}],
):
assert isinstance(chunk, AIMessageChunk)
full = chunk if full is None else full + chunk
_check_response(full)
# Use OpenAI's stateful API
response = llm.invoke(
"what about a negative one",
tools=[{"type": "web_search_preview"}],
previous_response_id=first_response.response_metadata["id"],
)
_check_response(response)
# Manually pass in chat history
response = llm.invoke(
[
{"role": "user", "content": "What was a positive news story from today?"},
first_response,
{"role": "user", "content": "what about a negative one"},
],
tools=[{"type": "web_search_preview"}],
)
_check_response(response)
# Bind tool
response = llm.bind_tools([{"type": "web_search_preview"}]).invoke(
"What was a positive news story from today?"
)
_check_response(response)
for msg in [first_response, full, response]:
assert msg is not None
block_types = [block["type"] for block in msg.content] # type: ignore[index]
if output_version == "responses/v1":
assert block_types == ["web_search_call", "text"]
else:
assert block_types == ["server_tool_call", "server_tool_result", "text"]
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does test_web_search() do?
test_web_search() is a function in the langchain codebase, defined in libs/partners/openai/tests/integration_tests/chat_models/test_responses_api.py.
Where is test_web_search() defined?
test_web_search() is defined in libs/partners/openai/tests/integration_tests/chat_models/test_responses_api.py at line 84.
What does test_web_search() call?
test_web_search() calls 1 function(s): _check_response.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free