-
Notifications
You must be signed in to change notification settings - Fork 300
feat(providers): add Novita AI as OpenAI-compatible provider #451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -886,6 +886,14 @@ const DEEPSEEK_MODELS: &[(&str, &str)] = &[ | |||||||||||||||||||||||||||||||||||||||||||||||
| /// Known Moonshot models. | ||||||||||||||||||||||||||||||||||||||||||||||||
| const MOONSHOT_MODELS: &[(&str, &str)] = &[("kimi-k2.5", "Kimi K2.5")]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| /// Known Novita AI models. | ||||||||||||||||||||||||||||||||||||||||||||||||
| /// See: <https://novita.ai/docs/llm-api> | ||||||||||||||||||||||||||||||||||||||||||||||||
| const NOVITA_MODELS: &[(&str, &str)] = &[ | ||||||||||||||||||||||||||||||||||||||||||||||||
| ("moonshotai/kimi-k2.5", "Kimi K2.5 (Novita)"), | ||||||||||||||||||||||||||||||||||||||||||||||||
| ("deepseek/deepseek-v3.2", "DeepSeek V3.2 (Novita)"), | ||||||||||||||||||||||||||||||||||||||||||||||||
| ("zai-org/glm-5", "GLM-5 (Novita)"), | ||||||||||||||||||||||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| /// Known Google Gemini models. | ||||||||||||||||||||||||||||||||||||||||||||||||
| /// See: <https://ai.google.dev/gemini-api/docs/models> | ||||||||||||||||||||||||||||||||||||||||||||||||
| const GEMINI_MODELS: &[(&str, &str)] = &[ | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -1030,6 +1038,16 @@ const OPENAI_COMPAT_PROVIDERS: &[OpenAiCompatDef] = &[ | |||||||||||||||||||||||||||||||||||||||||||||||
| requires_api_key: true, | ||||||||||||||||||||||||||||||||||||||||||||||||
| local_only: false, | ||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| OpenAiCompatDef { | ||||||||||||||||||||||||||||||||||||||||||||||||
| config_name: "novita", | ||||||||||||||||||||||||||||||||||||||||||||||||
| env_key: "NOVITA_API_KEY", | ||||||||||||||||||||||||||||||||||||||||||||||||
| env_base_url_key: "NOVITA_BASE_URL", | ||||||||||||||||||||||||||||||||||||||||||||||||
| default_base_url: "https://api.novita.ai/openai", | ||||||||||||||||||||||||||||||||||||||||||||||||
| models: NOVITA_MODELS, | ||||||||||||||||||||||||||||||||||||||||||||||||
| supports_model_discovery: true, | ||||||||||||||||||||||||||||||||||||||||||||||||
| requires_api_key: true, | ||||||||||||||||||||||||||||||||||||||||||||||||
| local_only: false, | ||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| #[cfg(any(feature = "provider-openai-codex", feature = "provider-github-copilot"))] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -2789,6 +2807,7 @@ mod tests { | |||||||||||||||||||||||||||||||||||||||||||||||
| assert!(!ZAI_MODELS.is_empty()); | ||||||||||||||||||||||||||||||||||||||||||||||||
| assert!(!MOONSHOT_MODELS.is_empty()); | ||||||||||||||||||||||||||||||||||||||||||||||||
| assert!(!GEMINI_MODELS.is_empty()); | ||||||||||||||||||||||||||||||||||||||||||||||||
| assert!(!NOVITA_MODELS.is_empty()); | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| #[test] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -2811,6 +2830,7 @@ mod tests { | |||||||||||||||||||||||||||||||||||||||||||||||
| ZAI_MODELS, | ||||||||||||||||||||||||||||||||||||||||||||||||
| MOONSHOT_MODELS, | ||||||||||||||||||||||||||||||||||||||||||||||||
| GEMINI_MODELS, | ||||||||||||||||||||||||||||||||||||||||||||||||
| NOVITA_MODELS, | ||||||||||||||||||||||||||||||||||||||||||||||||
| ] { | ||||||||||||||||||||||||||||||||||||||||||||||||
| let mut ids: Vec<&str> = models.iter().map(|(id, _)| *id).collect(); | ||||||||||||||||||||||||||||||||||||||||||||||||
| ids.sort(); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -4046,4 +4066,37 @@ mod tests { | |||||||||||||||||||||||||||||||||||||||||||||||
| assert!(!supports_reasoning_for_model("gpt-5.2")); | ||||||||||||||||||||||||||||||||||||||||||||||||
| assert!(!supports_reasoning_for_model("claude-3-haiku-20240307")); | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| #[test] | ||||||||||||||||||||||||||||||||||||||||||||||||
| fn novita_provider_is_registered() { | ||||||||||||||||||||||||||||||||||||||||||||||||
| let def = OPENAI_COMPAT_PROVIDERS | ||||||||||||||||||||||||||||||||||||||||||||||||
| .iter() | ||||||||||||||||||||||||||||||||||||||||||||||||
| .find(|d| d.config_name == "novita") | ||||||||||||||||||||||||||||||||||||||||||||||||
| .expect("novita not in OPENAI_COMPAT_PROVIDERS"); | ||||||||||||||||||||||||||||||||||||||||||||||||
| assert_eq!(def.env_key, "NOVITA_API_KEY"); | ||||||||||||||||||||||||||||||||||||||||||||||||
| assert_eq!(def.default_base_url, "https://api.novita.ai/openai"); | ||||||||||||||||||||||||||||||||||||||||||||||||
| assert!(def.requires_api_key); | ||||||||||||||||||||||||||||||||||||||||||||||||
| assert!(!def.local_only); | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| #[test] | ||||||||||||||||||||||||||||||||||||||||||||||||
| fn novita_model_ids_are_chat_capable() { | ||||||||||||||||||||||||||||||||||||||||||||||||
| for (model_id, _) in NOVITA_MODELS { | ||||||||||||||||||||||||||||||||||||||||||||||||
| assert!( | ||||||||||||||||||||||||||||||||||||||||||||||||
| is_chat_capable_model(model_id), | ||||||||||||||||||||||||||||||||||||||||||||||||
| "novita model {model_id} should be chat capable" | ||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| #[test] | ||||||||||||||||||||||||||||||||||||||||||||||||
| fn novita_context_windows() { | ||||||||||||||||||||||||||||||||||||||||||||||||
| // moonshotai/kimi-k2.5 — capability ID is "kimi-k2.5" → 128k | ||||||||||||||||||||||||||||||||||||||||||||||||
| assert_eq!( | ||||||||||||||||||||||||||||||||||||||||||||||||
| context_window_for_model("moonshotai/kimi-k2.5"), | ||||||||||||||||||||||||||||||||||||||||||||||||
| 128_000 | ||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| // zai-org/glm-5 — capability ID is "glm-5" → 128k | ||||||||||||||||||||||||||||||||||||||||||||||||
| assert_eq!(context_window_for_model("zai-org/glm-5"), 128_000); | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+4092
to
+4101
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The
Either add a
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
known_providers()In
provider-setup/src/lib.rs, the newKnownProviderentry is inserted betweenkimi-codeandvenice(matching the alphabetical-ish ordering of the surrounding list). Here inOPENAI_COMPAT_PROVIDERSthe same provider is appended at the very end, aftergemini.Keeping the two lists in the same relative order makes it easier to cross-reference them and reduces the risk of accidentally missing a provider when adding the next one. Consider moving this entry to follow
zai/moonshot, where the other same-region providers live:Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!