Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions tools/web_search_perplexity.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,20 @@ set -e
# @env LLM_OUTPUT=/dev/stdout The output path

main() {
curl -fsS -X POST https://api.perplexity.ai/chat/completions \
-H "authorization: Bearer $PERPLEXITY_API_KEY" \
-H "accept: application/json" \
-H "content-type: application/json" \
--data '
{
"model": "'"$PERPLEXITY_WEB_SEARCH_MODEL"'",
"messages": [
{
"role": "user",
"content": "'"$argc_query"'"
}
]
}
' | \
jq -n --arg model "${PERPLEXITY_WEB_SEARCH_MODEL}" --arg query "$argc_query" \
'{
"model": $model,
"messages": [
{ "role": "user", "content": $query }
]
}' |
curl -fsSL --d @- \
-X POST https://api.perplexity.ai/chat/completions \
-H "authorization: Bearer $PERPLEXITY_API_KEY" \
-H "accept: application/json" \
-H "content-type: application/json" |
jq -r '.choices[0].message.content' \
>> "$LLM_OUTPUT"
>>"$LLM_OUTPUT"
}

eval "$(argc --argc-eval "$0" "$@")"
20 changes: 11 additions & 9 deletions tools/web_search_tavily.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ set -e
# @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" \
-d '
{
"api_key": "'"$TAVILY_API_KEY"'",
"query": "'"$argc_query"'",
"include_answer": true
}' | \
jq -r '.answer' >> "$LLM_OUTPUT"
jq -n --arg api_key "$TAVILY_API_KEY" --arg query "$argc_query" \
'{
"api_key": $api_key,
"query": $query,
"include_answer": true
}' |
curl -fsSL -d @- \
-X POST https://api.tavily.com/search \
-H "content-type: application/json" |
jq -r '.answer' \
>>"$LLM_OUTPUT"
}

eval "$(argc --argc-eval "$0" "$@")"