Skip to content

Commit

Permalink
💄 style: add SILICONCLOUD_MODEL_LIST & SILICONCLOUD_PROXY_URL sup…
Browse files Browse the repository at this point in the history
…port for SiliconCloud (lobehub#3492)

* ✨ feat: add SILICONCLOUD_MODEL_LIST support for SiliconCloud

* ✨ feat: add proxy url support for SiliconCloud

* ✨ feat: add baseURL support
  • Loading branch information
hezhijie0327 committed Aug 18, 2024
1 parent cccd089 commit e41be6d
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ ENV \
PERPLEXITY_API_KEY="" PERPLEXITY_PROXY_URL="" \
# Qwen
QWEN_API_KEY="" \
# SiliconCloud
SILICONCLOUD_API_KEY="" SILICONCLOUD_MODEL_LIST="" SILICONCLOUD_PROXY_URL="" \
# Stepfun
STEPFUN_API_KEY="" \
# Taichu
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile.database
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ ENV \
PERPLEXITY_API_KEY="" PERPLEXITY_PROXY_URL="" \
# Qwen
QWEN_API_KEY="" \
# SiliconCloud
SILICONCLOUD_API_KEY="" SILICONCLOUD_MODEL_LIST="" SILICONCLOUD_PROXY_URL="" \
# Stepfun
STEPFUN_API_KEY="" \
# Taichu
Expand Down
5 changes: 3 additions & 2 deletions src/app/api/chat/agentRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,12 @@ const getLlmOptionsFromPayload = (provider: string, payload: JWTPayload) => {
return { apiKey };
}
case ModelProvider.SiliconCloud: {
const { SILICONCLOUD_API_KEY } = getLLMConfig();
const { SILICONCLOUD_API_KEY, SILICONCLOUD_PROXY_URL } = getLLMConfig();

const apiKey = apiKeyManager.pick(payload?.apiKey || SILICONCLOUD_API_KEY);
const baseURL = payload?.endpoint || SILICONCLOUD_PROXY_URL;

return { apiKey };
return { apiKey, baseURL };
}
}
};
Expand Down
4 changes: 4 additions & 0 deletions src/config/llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ export const getLLMConfig = () => {

ENABLED_SILICONCLOUD: z.boolean(),
SILICONCLOUD_API_KEY: z.string().optional(),
SILICONCLOUD_MODEL_LIST: z.string().optional(),
SILICONCLOUD_PROXY_URL: z.string().optional(),
},
runtimeEnv: {
API_KEY_SELECT_MODE: process.env.API_KEY_SELECT_MODE,
Expand Down Expand Up @@ -177,6 +179,8 @@ export const getLLMConfig = () => {

ENABLED_SILICONCLOUD: !!process.env.SILICONCLOUD_API_KEY,
SILICONCLOUD_API_KEY: process.env.SILICONCLOUD_API_KEY,
SILICONCLOUD_MODEL_LIST: process.env.SILICONCLOUD_MODEL_LIST,
SILICONCLOUD_PROXY_URL: process.env.SILICONCLOUD_PROXY_URL,
},
});
};
Expand Down
3 changes: 3 additions & 0 deletions src/config/modelProviders/siliconcloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ const SiliconCloud: ModelProviderCard = {
id: 'siliconcloud',
modelList: { showModelFetcher: true },
name: 'SiliconCloud',
proxyUrl: {
placeholder: 'https://api.siliconflow.cn/v1',
},
};

export default SiliconCloud;
12 changes: 11 additions & 1 deletion src/server/globalConfig/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
OllamaProviderCard,
OpenAIProviderCard,
OpenRouterProviderCard,
SiliconCloudProviderCard,
TogetherAIProviderCard,
} from '@/config/modelProviders';
import { enableNextAuth } from '@/const/auth';
Expand Down Expand Up @@ -39,7 +40,9 @@ export const getServerGlobalConfig = () => {
ENABLED_BAICHUAN,
ENABLED_TAICHU,
ENABLED_AI360,

ENABLED_SILICONCLOUD,
SILICONCLOUD_MODEL_LIST,

ENABLED_AZURE_OPENAI,
AZURE_MODEL_LIST,
Expand Down Expand Up @@ -113,7 +116,14 @@ export const getServerGlobalConfig = () => {
},
perplexity: { enabled: ENABLED_PERPLEXITY },
qwen: { enabled: ENABLED_QWEN },
siliconcloud: { enabled: ENABLED_SILICONCLOUD },
siliconcloud: {
enabled: ENABLED_SILICONCLOUD,
enabledModels: extractEnabledModels(SILICONCLOUD_MODEL_LIST),
serverModelCards: transformToChatModelCards({
defaultChatModels: SiliconCloudProviderCard.chatModels,
modelString: SILICONCLOUD_MODEL_LIST,
}),
},
stepfun: { enabled: ENABLED_STEPFUN },

taichu: { enabled: ENABLED_TAICHU },
Expand Down

0 comments on commit e41be6d

Please sign in to comment.