aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/run-tool.sh
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-10-18 18:28:03 +0800
committerGitHub <noreply@github.com>2024-10-18 18:28:03 +0800
commit6eb391bdc76ed070299f1b70e96f021a03a6d97a (patch)
treec28eba4cac9b9da1773ad35524fa02c2dd3bca25 /scripts/run-tool.sh
parentb5377bf28bb4d7ec114b7ab9ef1ecec3995cfe66 (diff)
downloadllm-functions-docker-6eb391bdc76ed070299f1b70e96f021a03a6d97a.tar.gz
feat: controls displaying the results from function call (#111)
Diffstat (limited to 'scripts/run-tool.sh')
-rwxr-xr-xscripts/run-tool.sh28
1 files changed, 28 insertions, 0 deletions
diff --git a/scripts/run-tool.sh b/scripts/run-tool.sh
index bdc5547..4ede4a1 100755
--- a/scripts/run-tool.sh
+++ b/scripts/run-tool.sh
@@ -88,7 +88,35 @@ EOF
eval "'$tool_path' $args"
if [[ "$no_llm_output" -eq 1 ]]; then
cat "$LLM_OUTPUT"
+ else
+ dump_result
+ fi
+}
+
+dump_result() {
+ if [ ! -t 1 ]; then
+ return;
+ fi
+ local env_name env_value show_result=0
+ env_name="LLM_TOOL_DUMP_RESULT_$(echo "$LLM_TOOL_NAME" | tr '[:lower:]' '[:upper:]' | tr '-' '_')"
+ env_value="${!env_name}"
+ if [[ "$LLM_TOOL_DUMP_RESULT" == "1" || "$LLM_TOOL_DUMP_RESULT" == "true" ]]; then
+ if [[ "$env_value" != "0" && "$env_value" != "false" ]]; then
+ show_result=1
+ fi
+ else
+ if [[ "$env_value" == "1" || "$env_value" == "true" ]]; then
+ show_result=1
+ fi
fi
+ if [[ "$show_result" -ne 1 ]]; then
+ return
+ fi
+ cat <<EOF
+$(echo -e "\e[2m")----------------------
+$(cat "$LLM_OUTPUT")
+----------------------$(echo -e "\e[0m")
+EOF
}
die() {