diff options
| author | sigoden <sigoden@gmail.com> | 2024-06-22 06:52:45 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-22 06:52:45 +0800 |
| commit | adfb7c2b49ba4ba691e89683afa700eabbb3388c (patch) | |
| tree | 730829361b85a15e5dd0d323ae185c00068ce053 /scripts/run-bot.sh | |
| parent | a799428b397ac7789a91cf94a9c408ee8a2dd6e2 (diff) | |
| download | llm-functions-docker-adfb7c2b49ba4ba691e89683afa700eabbb3388c.tar.gz | |
refactor: rename bot to agent (#44)
Diffstat (limited to 'scripts/run-bot.sh')
| -rwxr-xr-x | scripts/run-bot.sh | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/scripts/run-bot.sh b/scripts/run-bot.sh deleted file mode 100755 index a709453..0000000 --- a/scripts/run-bot.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env bash -set -e - -main() { - this_file_name=run-bot.sh - parse_argv "$@" - root_dir="$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/.." &> /dev/null && pwd)" - setup_env - bot_tools_path="$root_dir/bots/$bot_name/tools.sh" - run -} - -parse_argv() { - if [[ "$0" == *"$this_file_name" ]]; then - bot_name="$1" - bot_func="$2" - bot_data="$3" - else - bot_name="$(basename "$0")" - bot_func="$1" - bot_data="$2" - fi - if [[ "$bot_name" == *.sh ]]; then - bot_name="${bot_name:0:$((${#bot_name}-3))}" - fi -} - -setup_env() { - export LLM_ROOT_DIR="$root_dir" - if [[ -f "$LLM_ROOT_DIR/.env" ]]; then - source "$LLM_ROOT_DIR/.env" - fi - export LLM_BOT_NAME="$bot_name" - export LLM_BOT_ROOT_DIR="$LLM_ROOT_DIR/bots/$bot_name" - export LLM_BOT_CACHE_DIR="$LLM_ROOT_DIR/cache/$bot_name" -} - -run() { - if [[ -z "$bot_data" ]]; then - die "No JSON data" - fi - - _jq=jq - if [[ "$OS" == "Windows_NT" ]]; then - _jq="jq -b" - bot_tools_path="$(cygpath -w "$bot_tools_path")" - fi - - data="$( - echo "$bot_data" | \ - $_jq -r ' - to_entries | .[] | - (.key | split("_") | join("-")) as $key | - if .value | type == "array" then - .value | .[] | "--\($key)\n\(. | @json)" - elif .value | type == "boolean" then - if .value then "--\($key)" else "" end - else - "--\($key)\n\(.value | @json)" - end' - )" || { - die "Invalid JSON data" - } - while IFS= read -r line; do - if [[ "$line" == '--'* ]]; then - args+=("$line") - else - args+=("$(echo "$line" | $_jq -r '.')") - fi - done <<< "$data" - "$bot_tools_path" "$bot_func" "${args[@]}" -} - -die() { - echo "$*" >&2 - exit 1 -} - -main "$@" - |
