Skip to content

Commit

Permalink
💄 style: improve zhipu model config (lobehub#3635)
Browse files Browse the repository at this point in the history
1. change glm-4-flash config, enabled by default and support function call
2. add model list support
  • Loading branch information
FrankCheungDev authored Aug 27, 2024
1 parent d3ff41e commit 1274e6a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ ENV \
# 01.AI
ZEROONE_API_KEY="" \
# Zhipu
ZHIPU_API_KEY=""
ZHIPU_API_KEY="" ZHIPU_MODEL_LIST=""

USER nextjs

Expand Down
2 changes: 2 additions & 0 deletions src/config/llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const getLLMConfig = () => {

ENABLED_ZHIPU: z.boolean(),
ZHIPU_API_KEY: z.string().optional(),
ZHIPU_MODEL_LIST: z.string().optional(),

ENABLED_DEEPSEEK: z.boolean(),
DEEPSEEK_API_KEY: z.string().optional(),
Expand Down Expand Up @@ -109,6 +110,7 @@ export const getLLMConfig = () => {

ENABLED_ZHIPU: !!process.env.ZHIPU_API_KEY,
ZHIPU_API_KEY: process.env.ZHIPU_API_KEY,
ZHIPU_MODEL_LIST: process.env.ZHIPU_MODEL_LIST,

ENABLED_DEEPSEEK: !!process.env.DEEPSEEK_API_KEY,
DEEPSEEK_API_KEY: process.env.DEEPSEEK_API_KEY,
Expand Down
2 changes: 2 additions & 0 deletions src/config/modelProviders/zhipu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ const ZhiPu: ModelProviderCard = {
{
description: '适用简单任务,速度最快,价格最实惠的版本',
displayName: 'GLM-4-Flash',
enabled: true,
functionCall: true,
id: 'glm-4-flash',
tokens: 128_000,
},
Expand Down
12 changes: 11 additions & 1 deletion src/server/globalConfig/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
OpenRouterProviderCard,
SiliconCloudProviderCard,
TogetherAIProviderCard,
ZhiPuProviderCard,
} from '@/config/modelProviders';
import { enableNextAuth } from '@/const/auth';
import { parseSystemAgent } from '@/server/globalConfig/parseSystemAgent';
Expand All @@ -26,6 +27,8 @@ export const getServerGlobalConfig = () => {

ENABLED_MOONSHOT,
ENABLED_ZHIPU,
ZHIPU_MODEL_LIST,

ENABLED_AWS_BEDROCK,
ENABLED_GOOGLE,
ENABLED_GROQ,
Expand Down Expand Up @@ -136,7 +139,14 @@ export const getServerGlobalConfig = () => {
}),
},
zeroone: { enabled: ENABLED_ZEROONE },
zhipu: { enabled: ENABLED_ZHIPU },
zhipu: {
enabled: ENABLED_ZHIPU,
enabledModels: extractEnabledModels(ZHIPU_MODEL_LIST),
serverModelCards: transformToChatModelCards({
defaultChatModels: ZhiPuProviderCard.chatModels,
modelString: ZHIPU_MODEL_LIST
}),
},
},
oAuthSSOProviders: authEnv.NEXT_AUTH_SSO_PROVIDERS.trim().split(/[,,]/),
systemAgent: parseSystemAgent(appEnv.SYSTEM_AGENT),
Expand Down

0 comments on commit 1274e6a

Please sign in to comment.