Skip to content

Commit

Permalink
feat: support moonshot ai (coaidev#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
zmh-program committed Mar 12, 2024
1 parent 422da58 commit 0ecd49e
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 25 deletions.
2 changes: 2 additions & 0 deletions adapter/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ var channelFactories = map[string]adaptercommon.FactoryCreator{
globals.SkylarkChannelType: skylark.NewChatInstanceFromConfig,
globals.ZhinaoChannelType: zhinao.NewChatInstanceFromConfig,
globals.MidjourneyChannelType: midjourney.NewChatInstanceFromConfig,

globals.MoonshotChannelType: openai.NewChatInstanceFromConfig, // openai format
}

func createChatRequest(conf globals.ChannelConfig, props *adaptercommon.ChatProps, hook globals.Hook) error {
Expand Down
8 changes: 7 additions & 1 deletion app/src/admin/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export const ChannelTypes: Record<string, string> = {
palm: "Google Gemini",
midjourney: "Midjourney Proxy",
sparkdesk: "讯飞星火 SparkDesk",
chatglm: "智谱 ChatGLM",
chatglm: "智谱清言 ChatGLM",
moonshot: "月之暗面 Moonshot",
qwen: "通义千问 TongYi",
hunyuan: "腾讯混元 Hunyuan",
zhinao: "360智脑 360GLM",
Expand Down Expand Up @@ -207,6 +208,11 @@ export const ChannelInfos: Record<string, ChannelInfo> = {
"> 接入点填写你的 Midjourney Proxy 的部署地址,如 *http://localhost:8080*, *https://example.com* \n" +
"> 注意:**请在系统设置中设置后端的公网 IP / 域名,否则无法接收回调报错 please provide available notify url** \n",
},
moonshot: {
endpoint: "https://api.moonshot.cn",
format: "<api-key>",
models: ["moonshot-v1-8k", "moonshot-v1-32k", "moonshot-v1-128k"],
}
};

export const defaultChannelModels: string[] = getUniqueList(
Expand Down
4 changes: 4 additions & 0 deletions app/src/admin/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ export const modelColorMapper: Record<string, string> = {
"spark-desk-v3": "blue-400",
"spark-desk-v3.5": "blue-400",

"moonshot-v1-8k": "black-500",
"moonshot-v1-32k": "black-500",
"moonshot-v1-128k": "black-500",

"chat-bison-001": "red-500",
"gemini-pro": "red-500",
"gemini-pro-vision": "red-500",
Expand Down
62 changes: 40 additions & 22 deletions app/src/admin/datasets/charge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,38 +119,56 @@ export const pricing: PricingDataset = [
},
{
models: ["spark-desk-v1.5"],
input: 0.15,
output: 0.15,
input: 0.015,
output: 0.015,
currency: Currency.CNY,
},
{
models: ["spark-desk-v2", "spark-desk-v3"],
input: 0.3,
output: 0.3,
input: 0.03,
output: 0.03,
currency: Currency.CNY,
},
{
models: ["moonshot-v1-8k"],
input: 0.012,
output: 0.012,
currency: Currency.CNY,
},
{
models: ["moonshot-v1-32k"],
input: 0.024,
output: 0.024,
currency: Currency.CNY,
},
{
models: ["moonshot-v1-128k"],
input: 0.06,
output: 0.06,
currency: Currency.CNY,
},
{
models: ["zhipu-chatglm-lite", "zhipu-chatglm-std", "zhipu-chatglm-turbo"],
input: 0.05,
output: 0.05,
input: 0.005,
output: 0.005,
currency: Currency.CNY,
},
{
models: ["zhipu-chatglm-pro"],
input: 0.1,
output: 0.1,
input: 0.01,
output: 0.01,
currency: Currency.CNY,
},
{
models: ["qwen-plus", "qwen-plus-net"],
input: 0.2,
output: 0.2,
input: 0.02,
output: 0.02,
currency: Currency.CNY,
},
{
models: ["qwen-turbo", "qwen-turbo-net"],
input: 0.08,
output: 0.08,
input: 0.008,
output: 0.008,
currency: Currency.CNY,
},
{
Expand All @@ -164,8 +182,8 @@ export const pricing: PricingDataset = [
},
{
models: ["hunyuan"],
input: 1,
output: 1,
input: 0.1,
output: 0.1,
currency: Currency.CNY,
},
{
Expand All @@ -176,26 +194,26 @@ export const pricing: PricingDataset = [
},
{
models: ["baichuan-53b"],
input: 0.2,
output: 0.2,
input: 0.02,
output: 0.02,
currency: Currency.CNY,
},
{
models: ["skylark-lite-public"],
input: 0.04,
output: 0.04,
input: 0.004,
output: 0.004,
currency: Currency.CNY,
},
{
models: ["skylark-plus-public"],
input: 0.08,
output: 0.08,
input: 0.008,
output: 0.008,
currency: Currency.CNY,
},
{
models: ["skylark-pro-public", "skylark-chat"],
input: 0.11,
output: 0.11,
input: 0.011,
output: 0.011,
currency: Currency.CNY,
},
];
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/admin/ChargeWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ function ChargeTable({ data, dispatch, onRefresh }: ChargeTableProps) {
dispatch({ type: "set", payload: props });

// scroll to top
scrollUp(getQuerySelector(".admin-content")!);
scrollUp(getQuerySelector(".admin-content > .scrollarea-viewport")!);
}}
>
<Settings2 className={`h-4 w-4`} />
Expand Down
2 changes: 1 addition & 1 deletion globals/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const (
BingChannelType = "bing"
PalmChannelType = "palm"
MidjourneyChannelType = "midjourney"
OneAPIChannelType = "oneapi"
MoonshotChannelType = "moonshot"
)

const (
Expand Down

0 comments on commit 0ecd49e

Please sign in to comment.