Skip to content
Open
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
22 changes: 22 additions & 0 deletions tools/web_search_ollama.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -e

# @describe Perform a web search using Ollama 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 OLLAMA_API_KEY! The api key
# @env LLM_OUTPUT=/dev/stdout The output path The output path

main() {
jq -n --arg query "$argc_query" \
'{
"query": $query
}' |
curl -fsSL -d @- \
-X POST https://ollama.com/api/web_search \
--header "Authorization: Bearer $OLLAMA_API_KEY" | jq -r '.results' >>"$LLM_OUTPUT"
}

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