feat: add LLM_OUTPUT=/dev/stdout to all tools/agents bashscripts (#123)

This commit is contained in:
sigoden
2024-11-14 21:54:44 +08:00
committed by GitHub
parent afbd03f963
commit 1b96d4ee4c
23 changed files with 58 additions and 12 deletions
+2
View File
@@ -1,6 +1,8 @@
#!/usr/bin/env bash
set -e
# @env LLM_OUTPUT=/dev/stdout The output path
# @cmd Create a new file at the specified path with contents.
# @option --path! The path where the file should be created
# @option --contents! The contents of the file
+2
View File
@@ -1,6 +1,8 @@
#!/usr/bin/env bash
set -e
# @env LLM_OUTPUT=/dev/stdout The output path
# @cmd Get the ip info
get_ipinfo() {
curl -fsSL https://httpbin.org/ip >> "$LLM_OUTPUT"
+2
View File
@@ -1,6 +1,8 @@
#!/usr/bin/env bash
set -e
# @env LLM_OUTPUT=/dev/stdout The output path
# @cmd Add a new todo item
# @option --desc! The todo description
add_todo() {
+2
View File
@@ -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}
+2
View File
@@ -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
+3 -1
View File
@@ -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
+4 -1
View File
@@ -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" | \
+2 -1
View File
@@ -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=()
+2
View File
@@ -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"
}
+2
View File
@@ -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"
}
+2
View File
@@ -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"
+2
View File
@@ -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
+2
View File
@@ -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")"
+2
View File
@@ -3,6 +3,8 @@ set -e
# @describe Get the current time.
# @env LLM_OUTPUT=/dev/stdout The output path
main() {
date >> "$LLM_OUTPUT"
}
+2
View File
@@ -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"
+3 -1
View File
@@ -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"
+2
View File
@@ -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"
+3 -1
View File
@@ -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"
+5 -3
View File
@@ -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}')}"
+4 -2
View File
@@ -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"
+2
View File
@@ -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%%:*}"
+3 -1
View File
@@ -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 \
+3 -1
View File
@@ -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" \