aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-05-16 07:13:07 +0000
committersigoden <sigoden@gmail.com>2024-05-16 08:25:57 +0000
commit4d0a8232570563e5f40da61cae3ae64e63aed7b5 (patch)
tree5f4cc3799387306d2bca557b0ae27a132e8a650f /bin
parentd346fe5874967f69adcadf7b3a1195a9d3f5d88e (diff)
downloadllm-functions-docker-4d0a8232570563e5f40da61cae3ae64e63aed7b5.tar.gz
refactor: minor refinement
Diffstat (limited to 'bin')
-rwxr-xr-xbin/duckduckgo_search13
1 files changed, 9 insertions, 4 deletions
diff --git a/bin/duckduckgo_search b/bin/duckduckgo_search
index 3c3f2eb..91e49df 100755
--- a/bin/duckduckgo_search
+++ b/bin/duckduckgo_search
@@ -1,14 +1,19 @@
#!/usr/bin/env bash
set -e
-# @describe Use this function to search DuckDuckGo for a query.
+# @describe Takes in a query string and returns search result.
+# Use it to answer user questions that require dates, facts, real-time information, or news.
+# This ensures accurate and up-to-date answers.
# @meta require-tools ddgr
+# @env DDG_MAX_RESULTS=5 The max results to return.
# @option --query! The query to search for.
-# @option --max-results=5 The number of returned results.
main() {
- ddgr --num $argc_max_results --json "$argc_query" | \
- jq -r '.[] | "**[\(.title)](\(.url))**\n\(.abstract)\n"'
+ ddgr -n $DDG_MAX_RESULTS --json "$argc_query" | \
+ jq -r '. as $input |
+reduce range(0; length) as $i ([]; . + [ $input[$i] | .index = $i ]) |
+.[] | "### \(.index+1). \u001b]8;;\(.url)\u001b\\\(.title)\u001b]8;;\u001b\\\n\(.abstract)\n"
+'
}
eval "$(argc --argc-eval "$0" "$@")"