Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/config/entities/providers-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
"mistral",
"modelscope",
"modelscope-cn",
"siliconflow",
"siliconflow-cn",
"moonshotai",
"moonshotai-cn",
"openai",
Expand Down Expand Up @@ -67,6 +69,8 @@
"mistral",
"modelscope",
"modelscope-cn",
"siliconflow",
"siliconflow-cn",
"moonshotai",
"moonshotai-cn",
"openai",
Expand Down
16 changes: 16 additions & 0 deletions src/config/entities/providers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ pub enum ProviderConfig {
ModelScope(configs::ModelScopeProviderConfig),
#[serde(rename = "modelscope-cn")]
ModelScopeCn(configs::ModelScopeCnProviderConfig),
#[serde(rename = "siliconflow")]
SiliconFlow(configs::SiliconFlowProviderConfig),
#[serde(rename = "siliconflow-cn")]
SiliconFlowCn(configs::SiliconFlowCnProviderConfig),
#[serde(rename = "moonshotai")]
MoonshotAi(configs::MoonshotAiProviderConfig),
#[serde(rename = "moonshotai-cn")]
Expand Down Expand Up @@ -73,6 +77,8 @@ impl ProviderConfig {
Self::Mistral(_) => identifiers::MISTRAL,
Self::ModelScope(_) => identifiers::MODELSCOPE,
Self::ModelScopeCn(_) => identifiers::MODELSCOPE_CN,
Self::SiliconFlow(_) => identifiers::SILICONFLOW,
Self::SiliconFlowCn(_) => identifiers::SILICONFLOW_CN,
Self::MoonshotAi(_) => identifiers::MOONSHOT_AI,
Self::MoonshotAiCn(_) => identifiers::MOONSHOT_AI_CN,
Self::OpenAI(_) => identifiers::OPENAI,
Expand Down Expand Up @@ -210,6 +216,16 @@ mod tests {
"type": "modelscope-cn",
"config": { "api_key": "test_key" }
}), true, None)]
#[case::siliconflow_ok(json!({
"name": "siliconflow-primary",
"type": "siliconflow",
"config": { "api_key": "test_key" }
}), true, None)]
#[case::siliconflow_cn_ok(json!({
"name": "siliconflow-cn-primary",
"type": "siliconflow-cn",
"config": { "api_key": "test_key" }
}), true, None)]
#[case::moonshotai_ok(json!({
"name": "moonshot-primary",
"type": "moonshotai",
Expand Down
21 changes: 18 additions & 3 deletions src/gateway/providers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub mod modelscope;
pub mod moonshot;
pub mod openai;
pub mod openrouter;
pub mod siliconflow;
pub mod xai;
pub mod zhipuai;

Expand All @@ -28,13 +29,14 @@ pub use modelscope::{ModelScope, ModelScopeCn};
pub use moonshot::{MoonshotAi, MoonshotAiCn};
pub use openai::OpenAIDef;
pub use openrouter::OpenRouter;
pub use siliconflow::{SiliconFlow, SiliconFlowCn};
pub use xai::Xai;
pub use zhipuai::ZhipuAi;

pub mod identifiers {
use super::{
anthropic, azure, bedrock, cohere, deepseek, fireworks, gemini, groq, mistral, moonshot,
modelscope, openai, openrouter, xai, zhipuai,
anthropic, azure, bedrock, cohere, deepseek, fireworks, gemini, groq, mistral, modelscope,
moonshot, openai, openrouter, siliconflow, xai, zhipuai,
};

pub const ANTHROPIC: &str = anthropic::IDENTIFIER;
Expand All @@ -48,6 +50,8 @@ pub mod identifiers {
pub const MISTRAL: &str = mistral::IDENTIFIER;
pub const MODELSCOPE: &str = modelscope::IDENTIFIER;
pub const MODELSCOPE_CN: &str = modelscope::CN_IDENTIFIER;
pub const SILICONFLOW: &str = siliconflow::IDENTIFIER;
pub const SILICONFLOW_CN: &str = siliconflow::CN_IDENTIFIER;
pub const MOONSHOT_AI: &str = moonshot::IDENTIFIER;
pub const MOONSHOT_AI_CN: &str = moonshot::CN_IDENTIFIER;
pub const OPENAI: &str = openai::IDENTIFIER;
Expand All @@ -71,6 +75,7 @@ pub mod configs {
moonshot::{MoonshotAiCnProviderConfig, MoonshotAiProviderConfig},
openai::OpenAIProviderConfig,
openrouter::OpenRouterProviderConfig,
siliconflow::{SiliconFlowCnProviderConfig, SiliconFlowProviderConfig},
xai::XaiProviderConfig,
zhipuai::ZhipuAiProviderConfig,
};
Expand All @@ -91,6 +96,8 @@ pub fn default_provider_registry() -> Result<ProviderRegistry> {
.register(Mistral)?
.register(ModelScope)?
.register(ModelScopeCn)?
.register(SiliconFlow)?
.register(SiliconFlowCn)?
.register(MoonshotAi)?
.register(MoonshotAiCn)?
.register(OpenAIDef)?
Expand Down Expand Up @@ -120,7 +127,15 @@ mod tests {
assert_eq!(registry.get("groq").unwrap().name(), "groq");
assert_eq!(registry.get("mistral").unwrap().name(), "mistral");
assert_eq!(registry.get("modelscope").unwrap().name(), "modelscope");
assert_eq!(registry.get("modelscope-cn").unwrap().name(), "modelscope-cn");
assert_eq!(
registry.get("modelscope-cn").unwrap().name(),
"modelscope-cn"
);
assert_eq!(registry.get("siliconflow").unwrap().name(), "siliconflow");
assert_eq!(
registry.get("siliconflow-cn").unwrap().name(),
"siliconflow-cn"
);
assert_eq!(registry.get("moonshotai").unwrap().name(), "moonshotai");
assert_eq!(
registry.get("moonshotai-cn").unwrap().name(),
Expand Down
Loading