Fix Mock len() error: Correct bind_tools chain
- bind_tools() now returns a mock chain - chain.invoke() returns the result with tool_calls attribute - Fixes TypeError: object of type 'Mock' has no len()
This commit is contained in:
parent
5fbd49cedc
commit
085da18205
|
|
@ -37,8 +37,13 @@ def mock_llm():
|
||||||
mock_result.content = "Test response"
|
mock_result.content = "Test response"
|
||||||
mock_result.tool_calls = [] # Add tool_calls attribute for len() check
|
mock_result.tool_calls = [] # Add tool_calls attribute for len() check
|
||||||
|
|
||||||
|
# Fix: bind_tools returns a chain, chain.invoke returns the result
|
||||||
|
mock_chain = Mock()
|
||||||
|
mock_chain.invoke.return_value = mock_result
|
||||||
|
mock.bind_tools.return_value = mock_chain
|
||||||
|
|
||||||
|
# Keep direct invoke for backward compatibility
|
||||||
mock.invoke.return_value = mock_result
|
mock.invoke.return_value = mock_result
|
||||||
mock.bind_tools.return_value = mock
|
|
||||||
return mock
|
return mock
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue