refactor: search tools (#76)

This commit is contained in:
sigoden
2024-07-17 09:23:52 +08:00
committed by GitHub
parent a4087408a2
commit 2ee24731dc
10 changed files with 43 additions and 23 deletions
+2 -2
View File
@@ -5,14 +5,14 @@ set -e
# Use this when you need current information or feel a search could provide a better answer.
# @env SEARXNG_API_BASE! The api url
# @env SEARXNG_MAX_RESULTS=5 The max results to return.
# @env SEARCH_MAX_RESULTS=5 The max results to return.
# @option --query! The query to search for.
main() {
encoded_query="$(jq -nr --arg q "$argc_query" '$q|@uri')"
url="$SEARXNG_API_BASE/search?q=$encoded_query&categories=general&language=en-US&format=json"
curl -fsSL "$url" | \
jq '[.results[:'"$SEARXNG_MAX_RESULTS"'] | .[] | {url: .url, title: .title, content: .content}]' \
jq '[.results[:'"$SEARCH_MAX_RESULTS"'] | .[] | {link: .url, title: .title, snippet: .content}]' \
>> "$LLM_OUTPUT"
}