[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
282b8f9a96
commit
f6f3b48a7c
3 changed files with 12 additions and 8 deletions
|
|
@ -5090,9 +5090,11 @@ class LlamaCppBackend:
|
|||
# so insertion order is deterministic (Python 3.7+).
|
||||
_tc_key = tool_name + str(arguments)
|
||||
_prev = _tool_call_history[-1] if _tool_call_history else None
|
||||
_denied = confirm_tool_calls and request_tool_decision(
|
||||
session_id, cancel_event=cancel_event
|
||||
) == "deny"
|
||||
_denied = (
|
||||
confirm_tool_calls
|
||||
and request_tool_decision(session_id, cancel_event = cancel_event)
|
||||
== "deny"
|
||||
)
|
||||
if _denied:
|
||||
result = TOOL_REJECTED_MESSAGE
|
||||
elif _prev and _prev[0] == _tc_key and not _prev[1]:
|
||||
|
|
|
|||
|
|
@ -320,9 +320,11 @@ def run_safetensors_tool_loop(
|
|||
}
|
||||
|
||||
tc_key = tool_name + str(arguments)
|
||||
denied = confirm_tool_calls and request_tool_decision(
|
||||
session_id, cancel_event=cancel_event
|
||||
) == "deny"
|
||||
denied = (
|
||||
confirm_tool_calls
|
||||
and request_tool_decision(session_id, cancel_event = cancel_event)
|
||||
== "deny"
|
||||
)
|
||||
if denied:
|
||||
result = TOOL_REJECTED_MESSAGE
|
||||
elif allowed_tool_names and tool_name not in allowed_tool_names:
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ def _key(session_id: Optional[str]) -> str:
|
|||
return session_id or ""
|
||||
|
||||
|
||||
def request_tool_decision(session_id, cancel_event=None, timeout=_DECISION_TIMEOUT):
|
||||
def request_tool_decision(session_id, cancel_event = None, timeout = _DECISION_TIMEOUT):
|
||||
"""Block until the user allows/denies the pending tool call.
|
||||
|
||||
Returns ``"allow"`` or ``"deny"``. Falls back to ``"deny"`` if the wait
|
||||
|
|
@ -45,7 +45,7 @@ def request_tool_decision(session_id, cancel_event=None, timeout=_DECISION_TIMEO
|
|||
_pending[key] = {"event": event, "decision": None}
|
||||
try:
|
||||
waited = 0.0
|
||||
while not event.wait(timeout=0.5):
|
||||
while not event.wait(timeout = 0.5):
|
||||
if cancel_event is not None and cancel_event.is_set():
|
||||
return "deny"
|
||||
waited += 0.5
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue