-
-
Notifications
You must be signed in to change notification settings - Fork 215
feat: add MiniMax as embedding provider #894
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 1 commit
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -61,6 +61,28 @@ fn test_local_embedding_success() { | |||||
| println!("embedding: {:?}", embedding); | ||||||
| } | ||||||
|
|
||||||
| #[tokio::test] | ||||||
| #[ignore] // Requires API key and network | ||||||
| async fn test_minimax_embedding_success() { | ||||||
| let model = get_embedding_model(None, Some("minimax:embo-01"), None).unwrap(); | ||||||
| let result = model.fetch_embedding_async("test text").await; | ||||||
| assert!(result.is_ok(), "MiniMax embedding failed: {:?}", result.err()); | ||||||
| let embedding = result.unwrap(); | ||||||
| assert_eq!(embedding.len(), 1536); // embo-01 produces 1536-dimensional embeddings | ||||||
| println!("embedding: {embedding:?}"); | ||||||
| } | ||||||
|
|
||||||
| #[tokio::test] | ||||||
| #[ignore] // Requires API key and network | ||||||
| async fn test_minimax_embedding_with_query_type() { | ||||||
| let model = get_embedding_model(None, Some("minimax:embo-01:query"), None).unwrap(); | ||||||
| let result = model.fetch_embedding_async("search query text").await; | ||||||
| assert!(result.is_ok()); | ||||||
| let embedding = result.unwrap(); | ||||||
| assert_eq!(embedding.len(), 1536); | ||||||
| println!("embedding: {embedding:?}"); | ||||||
| } | ||||||
|
|
||||||
| #[test] | ||||||
| fn test_local_embedding_invalid_url() { | ||||||
| let model = get_embedding_model(None, Some("local"), Some("invalid_url")); | ||||||
|
|
@@ -163,6 +185,66 @@ fn test_parse_gemini_provider_empty_model() { | |||||
| assert_eq!(model, ""); // Returns empty string when no model specified after colon | ||||||
| } | ||||||
|
|
||||||
| #[test] | ||||||
| fn test_parse_minimax_provider_with_model() { | ||||||
| let result = EmbeddingModelImpl::parse_provider_and_model(Some("minimax:embo-01")); | ||||||
| assert!(result.is_ok()); | ||||||
| let (provider, model) = result.unwrap(); | ||||||
| match provider { | ||||||
| EmbeddingProvider::MiniMax { embedding_type } => { | ||||||
| assert_eq!(embedding_type, "db"); | ||||||
| } | ||||||
| _ => panic!("Expected MiniMax provider"), | ||||||
| } | ||||||
| assert_eq!(model, "embo-01"); | ||||||
| } | ||||||
|
|
||||||
| #[test] | ||||||
| fn test_parse_minimax_provider_with_type() { | ||||||
| let result = EmbeddingModelImpl::parse_provider_and_model(Some("minimax:embo-01:query")); | ||||||
| assert!(result.is_ok()); | ||||||
| let (provider, model) = result.unwrap(); | ||||||
| match provider { | ||||||
| EmbeddingProvider::MiniMax { embedding_type } => { | ||||||
| assert_eq!(embedding_type, "query"); | ||||||
| } | ||||||
| _ => panic!("Expected MiniMax provider"), | ||||||
| } | ||||||
| assert_eq!(model, "embo-01"); | ||||||
| } | ||||||
|
|
||||||
| #[test] | ||||||
| fn test_parse_minimax_provider_empty_model() { | ||||||
| let result = EmbeddingModelImpl::parse_provider_and_model(Some("minimax:")); | ||||||
| assert!(result.is_ok()); | ||||||
| let (provider, model) = result.unwrap(); | ||||||
| match provider { | ||||||
| EmbeddingProvider::MiniMax { embedding_type } => { | ||||||
| assert_eq!(embedding_type, "db"); | ||||||
| } | ||||||
| _ => panic!("Expected MiniMax provider"), | ||||||
| } | ||||||
| assert_eq!(model, ""); | ||||||
|
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.
This test asserts
Suggested change
|
||||||
| } | ||||||
|
|
||||||
| #[test] | ||||||
| fn test_new_minimax_without_api_key_fails() { | ||||||
| unsafe { | ||||||
| std::env::remove_var("MINIMAX_API_KEY"); | ||||||
| } | ||||||
| let result = EmbeddingModelImpl::new(None, Some("minimax:embo-01"), None); | ||||||
| assert!(result.is_err()); | ||||||
| } | ||||||
|
|
||||||
| #[test] | ||||||
| fn test_new_minimax_with_api_key() { | ||||||
| let result = EmbeddingModelImpl::new(Some("test-key"), Some("minimax:embo-01"), None); | ||||||
| assert!(result.is_ok()); | ||||||
| let model = result.unwrap(); | ||||||
| assert!(matches!(model.provider, EmbeddingProvider::MiniMax { .. })); | ||||||
| assert_eq!(model.model, "embo-01"); | ||||||
| } | ||||||
|
|
||||||
| #[test] | ||||||
| fn test_parse_local_provider() { | ||||||
| let result = EmbeddingModelImpl::parse_provider_and_model(Some("local")); | ||||||
|
|
||||||
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.
unwrap_orfallback — default"embo-01"is never appliedBecause the match guard already requires
m.starts_with("minimax:"), callingm.splitn(2, ':')will always produce at least two parts:["minimax", "<rest>"]. This meansparts.get(1)always returnsSome(...)— evenSome("")when the input is"minimax:". The.unwrap_or(&"embo-01")fallback is therefore dead code and the intended default is never applied.Concretely,
"minimax:"results inmodel_name = ""(not"embo-01"), which will be sent verbatim to the MiniMax API and cause a server-side error rather than a clean default.The same dead-fallback pattern exists in the Gemini arm (line 125), but this PR introduces it again for MiniMax.
A clean fix is to use
strip_prefixand treat an empty suffix as the default: