adding support for moonshot and z-ai (#578)

* adding support for moonshot and z-ai

* Revert unwanted changes to arch_config.yaml

---------

Co-authored-by: Salman Paracha <salmanparacha@MacBook-Pro-288.local>
This commit is contained in:
Salman Paracha 2025-09-30 12:24:06 -07:00 committed by GitHub
parent 7df1b8cdb0
commit 045a5e9751
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 186 additions and 22 deletions

View file

@ -17,6 +17,8 @@ pub enum ProviderId {
XAI,
TogetherAI,
Ollama,
Moonshotai,
Zhipu,
}
impl From<&str> for ProviderId {
@ -34,6 +36,8 @@ impl From<&str> for ProviderId {
"xai" => ProviderId::XAI,
"together_ai" => ProviderId::TogetherAI,
"ollama" => ProviderId::Ollama,
"moonshotai" => ProviderId::Moonshotai,
"zhipu" => ProviderId::Zhipu,
_ => panic!("Unknown provider: {}", value),
}
}
@ -58,7 +62,9 @@ impl ProviderId {
| ProviderId::AzureOpenAI
| ProviderId::XAI
| ProviderId::TogetherAI
| ProviderId::Ollama,
| ProviderId::Ollama
| ProviderId::Moonshotai
| ProviderId::Zhipu,
SupportedAPIs::AnthropicMessagesAPI(_)) => SupportedAPIs::OpenAIChatCompletions(OpenAIApi::ChatCompletions),
(ProviderId::OpenAI
@ -71,7 +77,9 @@ impl ProviderId {
| ProviderId::AzureOpenAI
| ProviderId::XAI
| ProviderId::TogetherAI
| ProviderId::Ollama,
| ProviderId::Ollama
| ProviderId::Moonshotai
| ProviderId::Zhipu,
SupportedAPIs::OpenAIChatCompletions(_)) => SupportedAPIs::OpenAIChatCompletions(OpenAIApi::ChatCompletions),
}
}
@ -92,6 +100,8 @@ impl Display for ProviderId {
ProviderId::XAI => write!(f, "xai"),
ProviderId::TogetherAI => write!(f, "together_ai"),
ProviderId::Ollama => write!(f, "ollama"),
ProviderId::Moonshotai => write!(f, "moonshotai"),
ProviderId::Zhipu => write!(f, "zhipu"),
}
}
}

View file

@ -787,7 +787,7 @@ mod tests {
// Test OpenAI event type (should be None)
let openai_event = ChatCompletionsStreamResponse {
id: "test".to_string(),
object: "chat.completion.chunk".to_string(),
object: Some("chat.completion.chunk".to_string()),
created: 123456789,
model: "gpt-4".to_string(),
choices: vec![],