File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -249,8 +249,6 @@ providers:
249249 - key: vertexai
250250 type: vertexai
251251 api_key: your-gemini-api-key
252- project_id: your-project
253- location: us-central1
254252
255253# Option 2: Service Account (uses Vertex AI)
256254providers:
Original file line number Diff line number Diff line change @@ -103,19 +103,22 @@ impl VertexAIProvider {
103103#[ async_trait]
104104impl Provider for VertexAIProvider {
105105 fn new ( config : & ProviderConfig ) -> Self {
106- let project_id = config
107- . params
108- . get ( "project_id" )
109- . expect ( "project_id is required for VertexAI provider" )
110- . to_string ( ) ;
111- let location_str = config
112- . params
113- . get ( "location" )
114- . expect ( "location is required for VertexAI provider" )
115- . to_string ( ) ;
106+ let has_api_key = !config. api_key . is_empty ( ) ;
116107
117- let location = Self :: validate_location ( & location_str)
118- . expect ( "Invalid location provided in configuration" ) ;
108+ let project_id = config. params . get ( "project_id" ) . cloned ( ) . unwrap_or_default ( ) ;
109+ let location_str = config. params . get ( "location" ) . cloned ( ) . unwrap_or_default ( ) ;
110+
111+ // project_id and location only required for service account mode
112+ if !has_api_key && ( project_id. is_empty ( ) || location_str. is_empty ( ) ) {
113+ panic ! ( "project_id and location are required when no api_key is provided" ) ;
114+ }
115+
116+ let location = if location_str. is_empty ( ) {
117+ String :: new ( )
118+ } else {
119+ Self :: validate_location ( & location_str)
120+ . expect ( "Invalid location provided in configuration" )
121+ } ;
119122
120123 Self {
121124 config : config. clone ( ) ,
You can’t perform that action at this time.
0 commit comments