summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-05-07 16:40:18 +0800
committerGitHub <noreply@github.com>2024-05-07 16:40:18 +0800
commit956a9603904dfbd69771cd9ce56b3f4d23bca71f (patch)
treee91b8bd46a075d491fe76de51861bc21c85cf787
parent0071d84aa538364b70d9db8fcecf9f3ea64ead5e (diff)
downloadaichat-956a9603904dfbd69771cd9ce56b3f4d23bca71f.tar.gz
feat: support zhipuai client (#491)
-rwxr-xr-xArgcfile.sh1
-rw-r--r--config.example.yaml29
-rw-r--r--models.yaml24
-rw-r--r--src/client/mod.rs3
4 files changed, 41 insertions, 16 deletions
diff --git a/Argcfile.sh b/Argcfile.sh
index 82e79e5..c011456 100755
--- a/Argcfile.sh
+++ b/Argcfile.sh
@@ -63,6 +63,7 @@ OPENAI_COMPATIBLE_PLATFORMS=( \
octoai,meta-llama-3-8b-instruct,https://text.octoai.run/v1 \
perplexity,llama-3-8b-instruct,https://api.perplexity.ai \
together,meta-llama/Llama-3-8b-chat-hf,https://api.together.xyz/v1 \
+ zhipuai,glm-4,https://open.bigmodel.cn/api/paas/v4 \
)
# @cmd Chat with any LLM api
diff --git a/config.example.yaml b/config.example.yaml
index b2ea51a..a1dc07d 100644
--- a/config.example.yaml
+++ b/config.example.yaml
@@ -115,8 +115,8 @@ clients:
# See https://cloud.google.com/vertex-ai
- type: vertexai
- project_id: xxx # ENV: {client}_PROJECT_ID
- location: xxx # ENV: {client}_LOCATION
+ project_id: xxx # ENV: {client}_PROJECT_ID
+ location: xxx # ENV: {client}_LOCATION
# Specifies a application-default-credentials (adc) file, Optional field
# Run `gcloud auth application-default login` to init the adc file
# see https://cloud.google.com/docs/authentication/external/set-up-adc
@@ -133,8 +133,8 @@ clients:
# See https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/use-claude
- type: vertexai-claude
- project_id: xxx # ENV: {client}_PROJECT_ID
- location: xxx # ENV: {client}_LOCATION
+ project_id: xxx # ENV: {client}_PROJECT_ID
+ location: xxx # ENV: {client}_LOCATION
# Specifies a application-default-credentials (adc) file, Optional field
# Run `gcloud auth application-default login` to init the adc file
# see https://cloud.google.com/docs/authentication/external/set-up-adc
@@ -142,9 +142,9 @@ clients:
# See https://docs.aws.amazon.com/bedrock/latest/userguide/
- type: bedrock
- access_key_id: xxx # ENV: {client}_ACCESS_KEY_ID
- secret_access_key: xxx # ENV: {client}_SECRET_ACCESS_KEY
- region: xxx # ENV: {client}_REGION
+ access_key_id: xxx # ENV: {client}_ACCESS_KEY_ID
+ secret_access_key: xxx # ENV: {client}_SECRET_ACCESS_KEY
+ region: xxx # ENV: {client}_REGION
# See https://developers.cloudflare.com/workers-ai/
- type: cloudflare
@@ -157,23 +157,28 @@ clients:
# See https://cloud.baidu.com/doc/WENXINWORKSHOP/index.html
- type: ernie
- api_key: xxx # ENV: {client}_API_KEY
- secret_key: xxxx # ENV: {client}_SECRET_KEY
+ api_key: xxx # ENV: {client}_API_KEY
+ secret_key: xxxx # ENV: {client}_SECRET_KEY
# See https://help.aliyun.com/zh/dashscope/
- type: qianwen
- api_key: sk-xxx # ENV: {client}_API_KEY
+ api_key: sk-xxx # ENV: {client}_API_KEY
# See https://platform.moonshot.cn/docs/intro
- type: openai-compatible
name: moonshot
api_base: https://api.moonshot.cn/v1
- api_key: sk-xxx # ENV: {client}_API_KEY
+ api_key: sk-xxx # ENV: {client}_API_KEY
# See https://platform.deepseek.com/api-docs/
- type: openai-compatible
name: deepseek
- api_key: sk-xxx # ENV: {client}_API_KEY
+ api_key: sk-xxx # ENV: {client}_API_KEY
+
+ # See https://open.bigmodel.cn/dev/howuse/introduction
+ - type: openai-compatible
+ name: zhipuai
+ api_key: xxx # ENV: {client}_API_KEY
# See https://docs.endpoints.anyscale.com/
- type: openai-compatible
diff --git a/models.yaml b/models.yaml
index 2ecc937..89d881e 100644
--- a/models.yaml
+++ b/models.yaml
@@ -461,9 +461,9 @@
output_price: 8.4
- platform: deepseek
- docs:
- - https://platform.deepseek.com/api-docs/
- - https://platform.deepseek.com/api-docs/pricing
+ # docs:
+ # - https://platform.deepseek.com/api-docs/
+ # - https://platform.deepseek.com/api-docs/pricing
models:
- name: deepseek-chat
max_input_tokens: 32768
@@ -474,6 +474,24 @@
input_price: 0.14
output_price: 0.28
+- platform: zhipuai
+ # docs:
+ # - https://open.bigmodel.cn/dev/howuse/model
+ # - https://open.bigmodel.cn/pricing
+ models:
+ - name: glm-4
+ max_input_tokens: 128000
+ input_price: 14
+ output_price: 14
+ - name: glm-4v
+ max_input_tokens: 2048
+ input_price: 14
+ output_price: 14
+ - name: glm-3-turbo
+ max_input_tokens: 128000
+ input_price: 0.7
+ output_price: 0.7
+
- platform: anyscale
# docs:
# - https://docs.endpoints.anyscale.com/text-generation/query-a-model/#select-a-model
diff --git a/src/client/mod.rs b/src/client/mod.rs
index ab28032..7f902a1 100644
--- a/src/client/mod.rs
+++ b/src/client/mod.rs
@@ -45,7 +45,7 @@ register_client!(
(qianwen, "qianwen", QianwenConfig, QianwenClient),
);
-pub const OPENAI_COMPATIBLE_PLATFORMS: [(&str, &str); 11] = [
+pub const OPENAI_COMPATIBLE_PLATFORMS: [(&str, &str); 12] = [
("anyscale", "https://api.endpoints.anyscale.com/v1"),
("deepinfra", "https://api.deepinfra.com/v1/openai"),
("deepseek", "https://api.deepseek.com"),
@@ -57,4 +57,5 @@ pub const OPENAI_COMPATIBLE_PLATFORMS: [(&str, &str); 11] = [
("octoai", "https://text.octoai.run/v1"),
("perplexity", "https://api.perplexity.ai"),
("together", "https://api.together.xyz/v1"),
+ ("zhipuai", "https://open.bigmodel.cn/api/paas/v4"),
];