Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.

Commit 01590b4

Browse files
committed
chore: scripts
Signed-off-by: thxCode <thxcode0824@gmail.com>
1 parent 15c43bd commit 01590b4

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
#
4+
# MIT license
5+
# Copyright (c) 2025 llama-box authors
6+
# SPDX-License-Identifier: MIT
7+
#
8+
9+
function square_of_number() {
10+
ARGS="${1}"
11+
ID="${2}"
12+
13+
INPUT_NUM=$(echo "${ARGS}" | jq -cr '.input_num')
14+
RESPONSE="$(echo "${INPUT_NUM}^2" | bc)"
15+
if [[ -z "${RESPONSE}" ]]; then
16+
MESSAGE="{\"role\":\"tool\",\"content\":\"{\\\"error\\\":\\\"Failed to calculate.\\\"}\",\"tool_call_id\":\"${ID}\"}"
17+
else
18+
MESSAGE="{\"role\":\"tool\",\"content\":\"{\\\"result\\\":\\\"${RESPONSE}\\\"}\",\"tool_call_id\":\"${ID}\"}"
19+
fi
20+
21+
echo "${MESSAGE}"
22+
}
23+
24+
function register_square_of_number() {
25+
TOOLNAMES+=("square_of_number")
26+
TOOLS+=("{\"type\":\"function\",\"function\":{\"name\":\"square_of_number\",\"description\":\"Output the square of the number.\",\"parameters\":{\"type\":\"object\",\"properties\":{\"input_num\":{\"type\":\"number\",\"description\":\"input_num is a number that will be squared.\"}},\"required\":[\"input_num\"]}}}")
27+
}
28+
29+
register_square_of_number
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
#
4+
# MIT license
5+
# Copyright (c) 2025 llama-box authors
6+
# SPDX-License-Identifier: MIT
7+
#
8+
9+
function square_root_of_number() {
10+
ARGS="${1}"
11+
ID="${2}"
12+
13+
INPUT_NUM=$(echo "${ARGS}" | jq -cr '.input_num')
14+
RESPONSE="$(echo "scale=4; sqrt(${INPUT_NUM})" | bc)"
15+
if [[ -z "${RESPONSE}" ]]; then
16+
MESSAGE="{\"role\":\"tool\",\"content\":\"{\\\"error\\\":\\\"Failed to calculate.\\\"}\",\"tool_call_id\":\"${ID}\"}"
17+
else
18+
MESSAGE="{\"role\":\"tool\",\"content\":\"{\\\"result\\\":\\\"${RESPONSE}\\\"}\",\"tool_call_id\":\"${ID}\"}"
19+
fi
20+
21+
echo "${MESSAGE}"
22+
}
23+
24+
function register_square_root_of_number() {
25+
TOOLNAMES+=("square_root_of_number")
26+
TOOLS+=("{\"type\":\"function\",\"function\":{\"name\":\"square_root_of_number\",\"description\":\"Output the square root of the number.\",\"parameters\":{\"type\":\"object\",\"properties\":{\"input_num\":{\"type\":\"number\",\"description\":\"input_num is the radicand.\"}},\"required\":[\"input_num\"]}}}")
27+
}
28+
29+
register_square_root_of_number

0 commit comments

Comments
 (0)