openai[patch]: VCR some tests (#31524)

This commit is contained in:
ccurme 2025-06-06 19:00:57 -04:00 committed by GitHub
parent 5187817006
commit ece9e31a7a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 6 deletions

View File

@ -381,7 +381,7 @@ def test_stream_reasoning_summary() -> None:
assert isinstance(response_2, AIMessage) assert isinstance(response_2, AIMessage)
# TODO: VCR some of these @pytest.mark.vcr
def test_code_interpreter() -> None: def test_code_interpreter() -> None:
llm = ChatOpenAI(model="o4-mini", use_responses_api=True) llm = ChatOpenAI(model="o4-mini", use_responses_api=True)
llm_with_tools = llm.bind_tools( llm_with_tools = llm.bind_tools(
@ -420,8 +420,8 @@ def test_code_interpreter() -> None:
_ = llm_with_tools.invoke([input_message, full, next_message]) _ = llm_with_tools.invoke([input_message, full, next_message])
@pytest.mark.vcr
def test_mcp_builtin() -> None: def test_mcp_builtin() -> None:
pytest.skip() # TODO: set up VCR
llm = ChatOpenAI(model="o4-mini", use_responses_api=True) llm = ChatOpenAI(model="o4-mini", use_responses_api=True)
llm_with_tools = llm.bind_tools( llm_with_tools = llm.bind_tools(
@ -434,10 +434,14 @@ def test_mcp_builtin() -> None:
} }
] ]
) )
response = llm_with_tools.invoke( input_message = {
"What transport protocols does the 2025-03-26 version of the MCP spec " "role": "user",
"(modelcontextprotocol/modelcontextprotocol) support?" "content": (
) "What transport protocols does the 2025-03-26 version of the MCP spec "
"support?"
),
}
response = llm_with_tools.invoke([input_message])
approval_message = HumanMessage( approval_message = HumanMessage(
[ [
@ -453,6 +457,10 @@ def test_mcp_builtin() -> None:
_ = llm_with_tools.invoke( _ = llm_with_tools.invoke(
[approval_message], previous_response_id=response.response_metadata["id"] [approval_message], previous_response_id=response.response_metadata["id"]
) )
# Zero-data retention (e.g., as below) requires change in output format.
# _ = llm_with_tools.invoke(
# [input_message, response, approval_message]
# )
@pytest.mark.vcr() @pytest.mark.vcr()