aboutsummaryrefslogtreecommitdiffstats
path: root/tools/web_search_aichat.sh
blob: a20bd35040f0a8890ac8c45cd35b42ae4757f3ce (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env bash
set -e

# @describe Perform a web search 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.

# @meta require-tools aichat

# @env WEB_SEARCH_MODEL! The model for web-searching.
#
# supported aichat models:
#   - vertexai:gemini-*
#   - perplexity:*-online
#   - ernie:*
#   - lingyiwanwu:yi-large-rag
# @env LLM_OUTPUT=/dev/stdout The output path

main() {
    client="${WEB_SEARCH_MODEL%%:*}"
    if [[ "$client" == "vertexai" ]]; then
        export AICHAT_PATCH_VERTEXAI_CHAT_COMPLETIONS='{"gemini-.*":{"body":{"tools":[{"googleSearchRetrieval":{}}]}}}'
    fi
    aichat -m "$WEB_SEARCH_MODEL" "$argc_query" >> "$LLM_OUTPUT"
}

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