aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-11-14 21:54:44 +0800
committerGitHub <noreply@github.com>2024-11-14 21:54:44 +0800
commit1b96d4ee4cadf05163d653373423a615723240aa (patch)
treeb528d9e7791a2ed1ca8ce36098eec7c160200613 /tools
parentafbd03f963b08419a3835c9473d757bf936c8b92 (diff)
downloadllm-functions-docker-1b96d4ee4cadf05163d653373423a615723240aa.tar.gz
feat: add `LLM_OUTPUT=/dev/stdout` to all tools/agents bashscripts (#123)
Diffstat (limited to 'tools')
-rwxr-xr-xtools/demo_sh.sh2
-rwxr-xr-xtools/execute_command.sh2
-rwxr-xr-xtools/execute_sql_code.sh4
-rwxr-xr-xtools/fetch_url_via_curl.sh5
-rwxr-xr-xtools/fetch_url_via_jina.sh3
-rwxr-xr-xtools/fs_cat.sh2
-rwxr-xr-xtools/fs_ls.sh2
-rwxr-xr-xtools/fs_mkdir.sh2
-rwxr-xr-xtools/fs_rm.sh2
-rwxr-xr-xtools/fs_write.sh2
-rwxr-xr-xtools/get_current_time.sh2
-rwxr-xr-xtools/get_current_weather.sh2
-rwxr-xr-xtools/search_arxiv.sh4
-rwxr-xr-xtools/search_wikipedia.sh2
-rwxr-xr-xtools/search_wolframalpha.sh4
-rwxr-xr-xtools/send_mail.sh8
-rwxr-xr-xtools/send_twilio.sh6
-rwxr-xr-xtools/web_search_aichat.sh2
-rwxr-xr-xtools/web_search_perplexity.sh4
-rwxr-xr-xtools/web_search_tavily.sh4
20 files changed, 52 insertions, 12 deletions
diff --git a/tools/demo_sh.sh b/tools/demo_sh.sh
index 11dc72b..4a932c0 100755
--- a/tools/demo_sh.sh
+++ b/tools/demo_sh.sh
@@ -11,6 +11,8 @@ set -e
# @option --array+ <VALUE> Define a required string array property
# @option --array-optional* Define a optional string array property
+# @env LLM_OUTPUT=/dev/stdout The output path
+
main() {
cat <<EOF >> "$LLM_OUTPUT"
string: ${argc_string}
diff --git a/tools/execute_command.sh b/tools/execute_command.sh
index c9f4a7d..b263b10 100755
--- a/tools/execute_command.sh
+++ b/tools/execute_command.sh
@@ -4,6 +4,8 @@ set -e
# @describe Execute the shell command.
# @option --command! The command to execute.
+# @env LLM_OUTPUT=/dev/stdout The output path
+
main() {
if [ -t 1 ]; then
read -r -p "Are you sure you want to continue? [Y/n] " ans
diff --git a/tools/execute_sql_code.sh b/tools/execute_sql_code.sh
index ce99c79..df57dea 100755
--- a/tools/execute_sql_code.sh
+++ b/tools/execute_sql_code.sh
@@ -4,9 +4,11 @@ set -e
# @describe Execute the sql code.
# @option --code! The code to execute.
-# @env USQL_DSN! The database url, e.g. pgsql://user:pass@host/dbname
# @meta require-tools usql
+# @env USQL_DSN! The database url, e.g. pgsql://user:pass@host/dbname
+# @env LLM_OUTPUT=/dev/stdout The output path
+
main() {
if ! grep -qi '^select' <<<"$argc_code"; then
if [ -t 1 ]; then
diff --git a/tools/fetch_url_via_curl.sh b/tools/fetch_url_via_curl.sh
index 540984e..508b7cf 100755
--- a/tools/fetch_url_via_curl.sh
+++ b/tools/fetch_url_via_curl.sh
@@ -2,9 +2,12 @@
set -e
# @describe Extract the content from a given URL.
-# @meta require-tools pandoc
# @option --url! The URL to scrape.
+# @meta require-tools pandoc
+
+# @env LLM_OUTPUT=/dev/stdout The output path
+
main() {
# span and div tags are dropped from the HTML https://pandoc.org/MANUAL.html#raw-htmltex and sed removes any inline SVG images in image tags from the Markdown content.
curl -fsSL "$argc_url" | \
diff --git a/tools/fetch_url_via_jina.sh b/tools/fetch_url_via_jina.sh
index add01ee..2d6b698 100755
--- a/tools/fetch_url_via_jina.sh
+++ b/tools/fetch_url_via_jina.sh
@@ -2,9 +2,10 @@
set -e
# @describe Extract the content from a given URL.
+# @option --url! The URL to scrape.
# @env JINA_API_KEY The api key
-# @option --url! The URL to scrape.
+# @env LLM_OUTPUT=/dev/stdout The output path
main() {
curl_args=()
diff --git a/tools/fs_cat.sh b/tools/fs_cat.sh
index 37fe5dc..9fcf702 100755
--- a/tools/fs_cat.sh
+++ b/tools/fs_cat.sh
@@ -6,6 +6,8 @@ set -e
# @option --path! The path of the file to read
+# @env LLM_OUTPUT=/dev/stdout The output path
+
main() {
cat "$argc_path" >> "$LLM_OUTPUT"
}
diff --git a/tools/fs_ls.sh b/tools/fs_ls.sh
index c7deb40..d26132f 100755
--- a/tools/fs_ls.sh
+++ b/tools/fs_ls.sh
@@ -5,6 +5,8 @@ set -e
# @option --path! The path of the directory to list
+# @env LLM_OUTPUT=/dev/stdout The output path
+
main() {
ls -1 "$argc_path" >> "$LLM_OUTPUT"
}
diff --git a/tools/fs_mkdir.sh b/tools/fs_mkdir.sh
index 8305f10..a91954f 100755
--- a/tools/fs_mkdir.sh
+++ b/tools/fs_mkdir.sh
@@ -5,6 +5,8 @@ set -e
# @option --path! The path of the directory to create
+# @env LLM_OUTPUT=/dev/stdout The output path
+
main() {
mkdir -p "$argc_path"
echo "Directory created: $argc_path" >> "$LLM_OUTPUT"
diff --git a/tools/fs_rm.sh b/tools/fs_rm.sh
index 77b5cee..dd1e2f7 100755
--- a/tools/fs_rm.sh
+++ b/tools/fs_rm.sh
@@ -5,6 +5,8 @@ set -e
# @option --path! The path of the file or directory to remove
+# @env LLM_OUTPUT=/dev/stdout The output path
+
main() {
if [[ -f "$argc_path" ]]; then
_guard_path "$argc_path" Remove
diff --git a/tools/fs_write.sh b/tools/fs_write.sh
index b37a2d5..bdf8e85 100755
--- a/tools/fs_write.sh
+++ b/tools/fs_write.sh
@@ -9,6 +9,8 @@ set -e
# @option --path! The path of the file to write to
# @option --contents! The full contents to write to the file
+# @env LLM_OUTPUT=/dev/stdout The output path
+
main() {
_guard_path "$argc_path" Write
mkdir -p "$(dirname "$argc_path")"
diff --git a/tools/get_current_time.sh b/tools/get_current_time.sh
index 70752eb..1d1bc84 100755
--- a/tools/get_current_time.sh
+++ b/tools/get_current_time.sh
@@ -3,6 +3,8 @@ set -e
# @describe Get the current time.
+# @env LLM_OUTPUT=/dev/stdout The output path
+
main() {
date >> "$LLM_OUTPUT"
}
diff --git a/tools/get_current_weather.sh b/tools/get_current_weather.sh
index ab3e613..e942290 100755
--- a/tools/get_current_weather.sh
+++ b/tools/get_current_weather.sh
@@ -4,6 +4,8 @@ set -e
# @describe Get the current weather in a given location.
# @option --location! The city and optionally the state or country, e.g., "London", "San Francisco, CA".
+# @env LLM_OUTPUT=/dev/stdout The output path
+
main() {
curl -fsSL "https://wttr.in/$(echo "$argc_location" | sed 's/ /+/g')?format=4&M" \
>> "$LLM_OUTPUT"
diff --git a/tools/search_arxiv.sh b/tools/search_arxiv.sh
index 2aa7966..1a7f279 100755
--- a/tools/search_arxiv.sh
+++ b/tools/search_arxiv.sh
@@ -3,9 +3,11 @@ set -e
# @describe Search arXiv for a query and return the top papers.
-# @env ARXIV_MAX_RESULTS=3 The max results to return.
# @option --query! The query to search for.
+# @env ARXIV_MAX_RESULTS=3 The max results to return.
+# @env LLM_OUTPUT=/dev/stdout The output path
+
main() {
encoded_query="$(jq -nr --arg q "$argc_query" '$q|@uri')"
url="http://export.arxiv.org/api/query?search_query=all:$encoded_query&max_results=$ARXIV_MAX_RESULTS"
diff --git a/tools/search_wikipedia.sh b/tools/search_wikipedia.sh
index ebbc49d..0bf791e 100755
--- a/tools/search_wikipedia.sh
+++ b/tools/search_wikipedia.sh
@@ -6,6 +6,8 @@ set -e
# @option --query! The query to search for.
+# @env LLM_OUTPUT=/dev/stdout The output path
+
main() {
encoded_query="$(jq -nr --arg q "$argc_query" '$q|@uri')"
base_url="https://en.wikipedia.org/w/api.php"
diff --git a/tools/search_wolframalpha.sh b/tools/search_wolframalpha.sh
index 4da189e..788ebf9 100755
--- a/tools/search_wolframalpha.sh
+++ b/tools/search_wolframalpha.sh
@@ -4,9 +4,11 @@ set -e
# @describe Get an answer to a question using Wolfram Alpha. Input should the query in English.
# Use it to answer user questions that require computation, detailed facts, data analysis, or complex queries.
-# @env WOLFRAM_API_ID! The api id
# @option --query! The query to search for.
+# @env WOLFRAM_API_ID! The api id
+# @env LLM_OUTPUT=/dev/stdout The output path
+
main() {
encoded_query="$(jq -nr --arg q "$argc_query" '$q|@uri')"
url="https://api.wolframalpha.com/v2/query?appid=$WOLFRAM_API_ID&input=$encoded_query&output=json&format=plaintext"
diff --git a/tools/send_mail.sh b/tools/send_mail.sh
index a09ee98..bcf7e95 100755
--- a/tools/send_mail.sh
+++ b/tools/send_mail.sh
@@ -2,13 +2,15 @@
set -e
# @describe Send a email.
+# @option --recipient! The recipient of the email.
+# @option --subject! The subject of the email.
+# @option --body! The body of the email.
+
# @env EMAIL_SMTP_ADDR! The SMTP Address, e.g. smtps://smtp.gmail.com:465
# @env EMAIL_SMTP_USER! The SMTP User, e.g. alice@gmail.com
# @env EMAIL_SMTP_PASS! The SMTP Password
# @env EMAIL_SENDER_NAME The sender name
-# @option --recipient! The recipient of the email.
-# @option --subject! The subject of the email.
-# @option --body! The body of the email.
+# @env LLM_OUTPUT=/dev/stdout The output path
main() {
sender_name="${EMAIL_SENDER_NAME:-$(echo "$EMAIL_SMTP_USER" | awk -F'@' '{print $1}')}"
diff --git a/tools/send_twilio.sh b/tools/send_twilio.sh
index cb9717e..2a197ff 100755
--- a/tools/send_twilio.sh
+++ b/tools/send_twilio.sh
@@ -2,11 +2,13 @@
set -e
# @describe Send SMS or Twilio Messaging Channels messages using Twilio API.
+# @option --to-number! The recipient's phone number. Prefix with 'whatsapp:' for WhatsApp messages, e.g. whatsapp:+1234567890
+# @option --message! The content of the message to be sent
+
# @env TWILIO_ACCOUNT_SID! The twilio account sid
# @env TWILIO_AUTH_TOKEN! The twilio auth token
# @env TWILIO_FROM_NUMBER! The twilio from number
-# @option --to-number! The recipient's phone number. Prefix with 'whatsapp:' for WhatsApp messages, e.g. whatsapp:+1234567890
-# @option --message! The content of the message to be sent
+# @env LLM_OUTPUT=/dev/stdout The output path
main() {
from_number="$TWILIO_FROM_NUMBER"
diff --git a/tools/web_search_aichat.sh b/tools/web_search_aichat.sh
index e35948f..6a6528e 100755
--- a/tools/web_search_aichat.sh
+++ b/tools/web_search_aichat.sh
@@ -7,6 +7,7 @@ set -e
# @option --query! The query to search for.
# @meta require-tools aichat
+
# @env WEB_SEARCH_MODEL! The model for web-searching.
#
# supported aichat models:
@@ -15,6 +16,7 @@ set -e
# - perplexity:*-online
# - ernie:*
# - lingyiwanwu:yi-large-rag
+# @env LLM_OUTPUT=/dev/stdout The output path
main() {
client="${WEB_SEARCH_MODEL%%:*}"
diff --git a/tools/web_search_perplexity.sh b/tools/web_search_perplexity.sh
index c5b7ee6..62ece1f 100755
--- a/tools/web_search_perplexity.sh
+++ b/tools/web_search_perplexity.sh
@@ -4,9 +4,11 @@ set -e
# @describe Perform a web search using Perplexity API to get up-to-date information or additional context.
# Use this when you need current information or feel a search could provide a better answer.
+# @option --query! The query to search for.
+
# @env PERPLEXITY_API_KEY! The api key
# @env PERPLEXITY_WEB_SEARCH_MODEL=llama-3.1-sonar-small-128k-online The LLM model for web search
-# @option --query! The query to search for.
+# @env LLM_OUTPUT=/dev/stdout The output path
main() {
curl -fsS -X POST https://api.perplexity.ai/chat/completions \
diff --git a/tools/web_search_tavily.sh b/tools/web_search_tavily.sh
index 38f5385..1bf1e9d 100755
--- a/tools/web_search_tavily.sh
+++ b/tools/web_search_tavily.sh
@@ -4,9 +4,11 @@ set -e
# @describe Perform a web search using Tavily API to get up-to-date information or additional context.
# Use this when you need current information or feel a search could provide a better answer.
-# @env TAVILY_API_KEY! The api key
# @option --query! The query to search for.
+# @env TAVILY_API_KEY! The api key
+# @env LLM_OUTPUT=/dev/stdout The output path The output path
+
main() {
curl -fsSL -X POST https://api.tavily.com/search \
-H "content-type: application/json" \