fix: handle empty tool response (#8118)
* handle empty tool response * Update src/backend/base/langflow/components/tools/mcp_component.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * DataFrame * fix test --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
43629b21ad
commit
076b228599
2 changed files with 14 additions and 6 deletions
|
|
@ -108,7 +108,10 @@ class TestMCPToolsComponent(ComponentTestBaseWithoutClient):
|
|||
|
||||
# Mock the coroutine response
|
||||
mock_response = AsyncMock()
|
||||
mock_response.content = [MagicMock(text="Test response")]
|
||||
mock_content_item = MagicMock()
|
||||
mock_content_item.text = "Test response"
|
||||
mock_content_item.model_dump.return_value = {"text": "Test response"}
|
||||
mock_response.content = [mock_content_item]
|
||||
mock_create_coroutine.return_value = AsyncMock(return_value=mock_response)
|
||||
|
||||
# Create a mock tool and add it to the cache
|
||||
|
|
@ -126,7 +129,8 @@ class TestMCPToolsComponent(ComponentTestBaseWithoutClient):
|
|||
mock_get_inputs.return_value = {"test_tool": [mock_input]}
|
||||
output = await component.build_output()
|
||||
|
||||
assert output.text == "Test response"
|
||||
# Use iloc to access the first row's 'text' column value
|
||||
assert output.iloc[0]["text"] == "Test response"
|
||||
# Verify the mocks were called correctly
|
||||
mock_get_inputs.assert_called_once_with(component.tools)
|
||||
mock_structured_tool.coroutine.assert_called_once_with(test_param="test value")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue