From 503ec98bd14fd833c5687790234f550a24b01107 Mon Sep 17 00:00:00 2001 From: sigoden Date: Thu, 25 Apr 2024 21:19:04 +0800 Subject: [PATCH] feat: support moonshot again (#442) --- config.example.yaml | 4 ++++ src/client/mod.rs | 1 + src/client/moonshot.rs | 11 +++++++++++ 3 files changed, 16 insertions(+) create mode 100644 src/client/moonshot.rs diff --git a/config.example.yaml b/config.example.yaml index 10eeeaa..79e369a 100644 --- a/config.example.yaml +++ b/config.example.yaml @@ -119,3 +119,7 @@ clients: # See https://help.aliyun.com/zh/dashscope/ - type: qianwen api_key: sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + + # See https://platform.moonshot.cn/docs/intro + - type: moonshot + api_key: sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx diff --git a/src/client/mod.rs b/src/client/mod.rs index 9de07d3..ff7ea42 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -32,4 +32,5 @@ register_client!( (ollama, "ollama", OllamaConfig, OllamaClient), (ernie, "ernie", ErnieConfig, ErnieClient), (qianwen, "qianwen", QianwenConfig, QianwenClient), + (moonshot, "moonshot", MoonshotConfig, MoonshotClient), ); diff --git a/src/client/moonshot.rs b/src/client/moonshot.rs new file mode 100644 index 0000000..6befadb --- /dev/null +++ b/src/client/moonshot.rs @@ -0,0 +1,11 @@ +openai_compatible_module!( + MoonshotConfig, + MoonshotClient, + "https://api.moonshot.cn/v1", + [ + // https://platform.moonshot.cn/docs/intro#%E6%A8%A1%E5%9E%8B%E5%88%97%E8%A1%A8 + ("moonshot-v1-8k", "text", 8000), + ("moonshot-v1-32k", "text", 32000), + ("moonshot-v1-128k", "text", 128000), + ] +);