Spaces:
Running
Running
File size: 1,948 Bytes
ceb70c7 4359d28 ceb70c7 4359d28 ceb70c7 4359d28 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
#
# SPDX-FileCopyrightText: Hadad <hadad@linuxmail.org>
# SPDX-License-Identifier: Apache-2.0
#
from config import REASONING_STEPS
def tool_reasoning(tool_name, tool_arguments, stage, error=None, result=None):
if tool_name == "web_search":
if stage == "completed":
preview = result[:300] + "..." if result and len(result) > 300 else result
return REASONING_STEPS["web_search"][stage].format(
query=tool_arguments.get("query", "") if tool_arguments else "",
engine=tool_arguments.get("engine", "google") if tool_arguments else "google",
preview=preview
)
elif stage == "error":
return REASONING_STEPS["web_search"][stage].format(
query=tool_arguments.get("query", "") if tool_arguments else "",
engine=tool_arguments.get("engine", "google") if tool_arguments else "google",
error=error
)
else:
return REASONING_STEPS["web_search"][stage].format(
query=tool_arguments.get("query", "") if tool_arguments else "",
engine=tool_arguments.get("engine", "google") if tool_arguments else "google"
)
elif tool_name == "read_url":
if stage == "completed":
preview = result[:300] + "..." if result and len(result) > 300 else result
return REASONING_STEPS["read_url"][stage].format(
url=tool_arguments.get("url", "") if tool_arguments else "",
preview=preview
)
elif stage == "error":
return REASONING_STEPS["read_url"][stage].format(
url=tool_arguments.get("url", "") if tool_arguments else "",
error=error
)
else:
return REASONING_STEPS["read_url"][stage].format(
url=tool_arguments.get("url", "") if tool_arguments else ""
) |