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
73 lines
2.5 KiB
Python
73 lines
2.5 KiB
Python
# SPDX-FileCopyrightText: 2022-present deepset GmbH <info@deepset.ai>
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
from dataclasses import asdict, dataclass
|
|
from typing import Any
|
|
|
|
|
|
@dataclass
|
|
class ConfirmationUIResult:
|
|
"""
|
|
Result of the confirmation UI interaction.
|
|
|
|
:param action:
|
|
The action taken by the user such as "confirm", "reject", or "modify".
|
|
This action type is not enforced to allow for custom actions to be implemented.
|
|
:param feedback:
|
|
Optional feedback message from the user. For example, if the user rejects the tool execution,
|
|
they might provide a reason for the rejection.
|
|
:param new_tool_params:
|
|
Optional set of new parameters for the tool. For example, if the user chooses to modify the tool parameters,
|
|
they can provide a new set of parameters here.
|
|
"""
|
|
|
|
action: str # "confirm", "reject", "modify"
|
|
feedback: str | None = None
|
|
new_tool_params: dict[str, Any] | None = None
|
|
|
|
|
|
@dataclass
|
|
class ToolExecutionDecision:
|
|
"""
|
|
Decision made regarding tool execution.
|
|
|
|
:param tool_name:
|
|
The name of the tool to be executed.
|
|
:param execute:
|
|
A boolean indicating whether to execute the tool with the provided parameters.
|
|
:param tool_call_id:
|
|
Optional unique identifier for the tool call. This can be used to track and correlate the decision with a
|
|
specific tool invocation.
|
|
:param feedback:
|
|
Optional feedback message.
|
|
For example, if the tool execution is rejected, this can contain the reason. Or if the tool parameters were
|
|
modified, this can contain the modification details.
|
|
:param final_tool_params:
|
|
Optional final parameters for the tool if execution is confirmed or modified.
|
|
"""
|
|
|
|
tool_name: str
|
|
execute: bool
|
|
tool_call_id: str | None = None
|
|
feedback: str | None = None
|
|
final_tool_params: dict[str, Any] | None = None
|
|
|
|
def to_dict(self) -> dict[str, Any]:
|
|
"""
|
|
Convert the ToolExecutionDecision to a dictionary representation.
|
|
|
|
:return: A dictionary containing the tool execution decision details.
|
|
"""
|
|
return asdict(self)
|
|
|
|
@classmethod
|
|
def from_dict(cls, data: dict[str, Any]) -> "ToolExecutionDecision":
|
|
"""
|
|
Populate the ToolExecutionDecision from a dictionary representation.
|
|
|
|
:param data: A dictionary containing the tool execution decision details.
|
|
:return: An instance of ToolExecutionDecision.
|
|
"""
|
|
return cls(**data)
|