feat(provider): add Google VertexAI support#24
Conversation
Signed-off-by: David Anyatonwu <davidanyatonwu@gmail.com>
Signed-off-by: David Anyatonwu <davidanyatonwu@gmail.com>
…tting - Changed project_id retrieval to use expect for mandatory parameter. - Updated location retrieval to use unwrap_or for default value. - Modified endpoint formatting to dynamically include location in the URL for both chat and embeddings requests. - Refactored test provider setup to use constants for project_id and location.
|
@galkleinman This PR is ready for review. running 9 tests
test providers::vertexai::tests::test_chat_completions_with_api_key ... ignored, Requires valid API key which is not available yet
test providers::vertexai::provider::tests::test_gemini_request_conversion ... ok
test providers::vertexai::provider::tests::test_gemini_response_conversion ... ok
test providers::vertexai::provider::tests::test_provider_new_missing_project_id - should panic ... ok
test providers::vertexai::provider::tests::test_provider_new ... ok
test providers::vertexai::tests::test_chat_completions ... ok
test providers::vertexai::tests::test_chat_completions_with_tools ... ok
test providers::vertexai::tests::test_embeddings ... ok
test providers::vertexai::tests::test_completions ... ok
test result: ok. 8 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 3.32s
Running unittests src/main.rs (target/debug/deps/hub-e2c6417f88e881cd)
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Doc-tests hub
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
|
- Introduced a new method `validate_location` to sanitize and validate location input, defaulting to "us-central1" if invalid. - Updated the provider initialization to utilize the new location validation method. - Added extensive unit tests for the provider, covering various scenarios including location validation, request conversion, and handling of empty messages. - Ensured that invalid characters in location parameters are filtered out correctly. - Enhanced tests to verify the precedence of API key over credentials path in configuration. This commit improves the robustness of the VertexAIProvider by ensuring valid location formats and enhancing test coverage.
nirga
left a comment
There was a problem hiding this comment.
Hey @onyedikachi-david - left a lot of comments. You're code isn't following idiomatic rust constructs and it's not following other providers already implemented in this repo. You're also missing integration (black box) tests which tests the whole system - not just the provider.
src/providers/vertexai/provider.rs
Outdated
| .collect(); | ||
|
|
||
| if sanitized.is_empty() { | ||
| "us-central1".to_string() // Default if invalid |
There was a problem hiding this comment.
for say the user didn't configure one
| } | ||
| } | ||
|
|
||
| #[cfg(test)] |
There was a problem hiding this comment.
this should not be here, it belongs to the test file
src/providers/vertexai/provider.rs
Outdated
|
|
||
| } | ||
|
|
||
| #[cfg(test)] |
|
addressed your reviews @nirga |
|
Hey @onyedikachi-david - can you sign the CLA on this? |
|
Hi, @nirga, I just did, I think it's requesting for yours also, since you made merge.
|
|
I'll fix that @onyedikachi-david |
|
Done @nirga |
ba4a72d to
79a9fbe
Compare
nirga
left a comment
There was a problem hiding this comment.
Thanks @onyedikachi-david - I rebased but it seems build / test is now failing. Can you check?
Also, you haven't addressed my comment regarding test code in verrtexai/provider.rs
Oh, totally forgot, let me check. |
… request handling
|
Hello, @nirga, I have addressed all and did some (alot 😌) refactoring also. hub/Users/onyedikachi on feat/add-vertexai-provider is 📦 0.3.0 via 🦀 1.88.0 using ☁️ default/heavenya took 2.4s
⇣6% ➜ cargo test
Compiling hub v0.3.0 (/Users/onyedikachi/Documents/codes/algora-bounties/hub)
Finished `test` profile [unoptimized + debuginfo] target(s) in 7.86s
Running unittests src/lib.rs (target/debug/deps/hub-9b56fda26de774a9)
running 29 tests
test providers::bedrock::test::titan_tests::test_titan_provider_new ... ok
test providers::bedrock::test::antropic_tests::test_bedrock_provider_new ... ok
test providers::bedrock::test::ai21_tests::test_ai21_provider_new ... ok
test providers::bedrock::test::ai21_tests::test_ai21_provider_chat_completions ... ok
test providers::bedrock::test::antropic_tests::test_bedrock_provider_chat_completions ... ok
test providers::bedrock::test::titan_tests::test_chat_completions ... ok
test providers::vertexai::tests::test_chat_completions_with_api_key ... ignored, Requires valid API key which is not available yet
test providers::bedrock::test::ai21_tests::test_ai21_provider_completions ... ok
test providers::vertexai::tests::test_empty_message_handling ... ok
test providers::bedrock::test::titan_tests::test_embeddings ... ok
test providers::vertexai::tests::test_gemini_request_conversion ... ok
test providers::vertexai::tests::test_gemini_request_with_array_content ... ok
test providers::vertexai::tests::test_gemini_request_with_system_message ... ok
test providers::vertexai::tests::test_gemini_response_conversion ... ok
test providers::vertexai::tests::test_gemini_request_with_tools ... ok
test providers::vertexai::tests::test_gemini_response_with_tool_calls ... ok
test providers::vertexai::tests::test_generation_config_limits ... ok
test providers::vertexai::tests::test_location_validation ... ok
test providers::vertexai::tests::test_invalid_location_format - should panic ... ok
test providers::vertexai::tests::test_provider_new_missing_project_id - should panic ... ok
test providers::vertexai::tests::test_response_error_mapping ... ok
test providers::vertexai::tests::test_tool_choice_none ... ok
test providers::vertexai::tests::test_auth_config_credentials_only ... ok
test providers::vertexai::tests::test_provider_new ... ok
test providers::vertexai::tests::test_auth_config_precedence ... ok
test providers::vertexai::tests::test_completions - should panic ... ok
test providers::vertexai::tests::test_chat_completions_with_tools ... ok
test providers::vertexai::tests::test_embeddings ... ok
test providers::vertexai::tests::test_chat_completions ... ok
test result: ok. 28 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 2.90s
Running unittests src/main.rs (target/debug/deps/hub-c43e446858e3fa57)
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Doc-tests hub
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
hub/Users/onyedikachi on feat/add-vertexai-provider is 📦 0.3.0 via 🦀 1.88.0 using ☁️ default/heavenya took 14.1s
⇣6% ➜ |
|
Thanks @onyedikachi-david - can you also lint / fix formatting issues? |
Signed-off-by: David Anyatonwu <davidanyatonwu@gmail.com>
|
Done @nirga |
nirga
left a comment
There was a problem hiding this comment.
Thanks @onyedikachi-david! Looks like tests are failing though
|
@onyedikachi-david and now formatting errors again 😅 |
Signed-off-by: David Anyatonwu <davidanyatonwu@gmail.com>
|
@nirga Sorry about that, always forgetting to fmt. just did |
|
@onyedikachi-david still failing |
Fixed, it was clippy warnings this time |

Add Google VertexAI Provider Support
This PR adds support for Google VertexAI models (Gemini) as a new provider in the Hub, allowing users to route their LLM requests to Google's models through our unified API interface.
Definition of Done
Changes Made
Added new VertexAI provider implementation
Added comprehensive test suite
Updated documentation
Added robust configuration support
Testing
cargo testSecurity Considerations
Notes
Fixes #19
/claim #19