c56bef871b
Sync docs with Docusaurus / sync (push) Waiting to run
Tests / Check if changed (push) Waiting to run
Tests / format (push) Blocked by required conditions
Tests / check-imports (push) Blocked by required conditions
Tests / Unit / macos-latest (push) Blocked by required conditions
Tests / Unit / ubuntu-latest (push) Blocked by required conditions
Tests / Unit / windows-latest (push) Blocked by required conditions
Tests / mypy (push) Blocked by required conditions
Tests / Integration / ubuntu-latest (push) Blocked by required conditions
Tests / Integration / macos-latest (push) Blocked by required conditions
Tests / Integration / windows-latest (push) Blocked by required conditions
Tests / notify-slack-on-failure (push) Blocked by required conditions
Tests / Mark tests as completed (push) Blocked by required conditions
Docker image release / Build base image (push) Waiting to run
CodeQL / Analyze (python) (push) Has been cancelled
Update Platform Components Table / update (push) Has been cancelled
59 lines
2.0 KiB
Python
59 lines
2.0 KiB
Python
# SPDX-FileCopyrightText: 2022-present deepset GmbH <info@deepset.ai>
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
from haystack.human_in_the_loop import ConfirmationUIResult, ToolExecutionDecision
|
|
|
|
|
|
class TestConfirmationUIResult:
|
|
def test_init(self):
|
|
original = ConfirmationUIResult(action="reject", feedback="Changed my mind")
|
|
assert original.action == "reject"
|
|
assert original.feedback == "Changed my mind"
|
|
assert original.new_tool_params is None
|
|
|
|
|
|
class TestToolExecutionDecision:
|
|
def test_init(self):
|
|
decision = ToolExecutionDecision(
|
|
execute=True,
|
|
tool_name="test_tool",
|
|
tool_call_id="test_tool_call_id",
|
|
final_tool_params={"param1": "new_value"},
|
|
)
|
|
assert decision.execute is True
|
|
assert decision.final_tool_params == {"param1": "new_value"}
|
|
assert decision.tool_call_id == "test_tool_call_id"
|
|
assert decision.tool_name == "test_tool"
|
|
|
|
def test_to_dict(self):
|
|
original = ToolExecutionDecision(
|
|
execute=True,
|
|
tool_name="test_tool",
|
|
tool_call_id="test_tool_call_id",
|
|
final_tool_params={"param1": "new_value"},
|
|
)
|
|
as_dict = original.to_dict()
|
|
assert as_dict == {
|
|
"execute": True,
|
|
"tool_name": "test_tool",
|
|
"tool_call_id": "test_tool_call_id",
|
|
"feedback": None,
|
|
"final_tool_params": {"param1": "new_value"},
|
|
}
|
|
|
|
def test_from_dict(self):
|
|
data = {
|
|
"execute": False,
|
|
"tool_name": "another_tool",
|
|
"tool_call_id": "another_tool_call_id",
|
|
"feedback": "Not needed",
|
|
"final_tool_params": {"paramA": 123},
|
|
}
|
|
decision = ToolExecutionDecision.from_dict(data)
|
|
assert decision.execute is False
|
|
assert decision.tool_name == "another_tool"
|
|
assert decision.tool_call_id == "another_tool_call_id"
|
|
assert decision.feedback == "Not needed"
|
|
assert decision.final_tool_params == {"paramA": 123}
|