diff options
| author | sigoden <sigoden@gmail.com> | 2024-05-18 10:21:57 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-18 10:21:57 +0800 |
| commit | 07ce5ccaf634beee7ab14c86130c8cb659d96e31 (patch) | |
| tree | e18863c2c58c64779031e4518bf8bcd6b3884bf3 /bin/search_duckduckgo | |
| parent | 1a24e820dd95e66a990c1bcbb21b045ed5355a9b (diff) | |
| download | llm-functions-docker-07ce5ccaf634beee7ab14c86130c8cb659d96e31.tar.gz | |
refactor: retrieve function returns json (#4)
Diffstat (limited to 'bin/search_duckduckgo')
| -rwxr-xr-x | bin/search_duckduckgo | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/bin/search_duckduckgo b/bin/search_duckduckgo index 49f7028..c5ab565 100755 --- a/bin/search_duckduckgo +++ b/bin/search_duckduckgo @@ -4,17 +4,13 @@ set -e # @describe Takes in a query string and returns search result from DuckDuckGo. # 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. main() { - 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" -' + ddgr -n $DDG_MAX_RESULTS --json "$argc_query" } eval "$(argc --argc-eval "$0" "$@")" |
