summaryrefslogtreecommitdiffstats
path: root/Argcfile.sh
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-06-26 13:48:55 +0800
committerGitHub <noreply@github.com>2024-06-26 13:48:55 +0800
commit2e1dc1f7d58f037e83a184f4c9e662696d1425be (patch)
tree6530c186a24b5a9d0897812675dd0471af7a1ce9 /Argcfile.sh
parent95bad975f4fb47fe86df1837660a1341009ea12a (diff)
downloadaichat-2e1dc1f7d58f037e83a184f4c9e662696d1425be.tar.gz
refactor: improve azure-openai (#652)
Diffstat (limited to 'Argcfile.sh')
-rwxr-xr-xArgcfile.sh32
1 files changed, 20 insertions, 12 deletions
diff --git a/Argcfile.sh b/Argcfile.sh
index 5f04b6f..7433e26 100755
--- a/Argcfile.sh
+++ b/Argcfile.sh
@@ -159,7 +159,11 @@ models() {
# @flag -S --no-stream
# @arg text~
chat-openai-compatible() {
- _openai_chat "$@"
+ _wrapper curl -i "$argc_api_base/chat/completions" \
+-X POST \
+-H "Content-Type: application/json" \
+-H "Authorization: Bearer $argc_api_key" \
+-d "$(_build_body openai "$@")"
}
# @cmd List models by openai-compatible api
@@ -169,6 +173,20 @@ models-openai-compatible() {
_openai_models
}
+# @cmd Chat with azure-openai api
+# @option --api-url! $$
+# @option --api-key! $$
+# @option -m --model! $$
+# @flag -S --no-stream
+# @arg text~
+chat-azure-openai() {
+ _wrapper curl -i "$argc_api_url" \
+-X POST \
+-H "Content-Type: application/json" \
+-H "api-key: $argc_api_key" \
+-d "$(_build_body openai "$@")"
+}
+
# @cmd Chat with gemini api
# @env GEMINI_API_KEY!
# @option -m --model=gemini-1.0-pro-latest $GEMINI_MODEL
@@ -397,20 +415,10 @@ _argc_before() {
fi
}
-_openai_chat() {
- api_base="${api_base:-"$argc_api_base"}"
- api_key="${api_key:-"$argc_api_key"}"
- _wrapper curl -i $curl_args "$api_base/chat/completions" \
--X POST \
--H "Content-Type: application/json" \
--H "Authorization: Bearer $api_key" \
--d "$(_build_body openai "$@")"
-}
-
_openai_models() {
api_base="${api_base:-"$argc_api_base"}"
api_key="${api_key:-"$argc_api_key"}"
- _wrapper curl $curl_args "$api_base/models" \
+ _wrapper curl "$api_base/models" \
-H "Authorization: Bearer $api_key" \
}