Skip to content

VertexAiEmbeddingConnectionDetails not automatically injected despite being configured as properties #4800

@nguyen-trantrung

Description

@nguyen-trantrung

Please do a quick search on GitHub issues first, there might be already a duplicate issue for the one you are about to create.
If the bug is trivial, just go ahead and create the issue. Otherwise, please take a few moments and fill in the following sections:

Bug description

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 0 of method textEmbedding in org.springframework.ai.model.vertexai.autoconfigure.embedding.VertexAiTextEmbeddingAutoConfiguration required a bean of type 'org.springframework.ai.vertexai.embedding.VertexAiEmbeddingConnectionDetails' that could not be found.


Action:

Consider defining a bean of type 'org.springframework.ai.vertexai.embedding.VertexAiEmbeddingConnectionDetails' in your configuration.

Encountered error with org.springframework.ai:spring-ai-starter-model-vertex-ai-embedding package. VertexAiEmbeddingConnectionDetails not being automatically injected for VertexAiTextEmbeddingAutoConfiguration.

Environment
Spring AI Version: 1.1.0-M3

Steps to reproduce

implementation 'org.springframework.ai:spring-ai-pgvector-store'
implementation 'org.springframework.ai:spring-ai-starter-model-vertex-ai-embedding'

In application.yaml:

spring:
  ai:
    vertex:
      ai:
        embedding:
          project-id: xxxx
          location: xxxx
          text:
            enabled: true
            options:
              model: text-multilingual-embedding-002
              task-type: RETRIEVAL_DOCUMENT

Expected behavior
Since the configuration is valid, it should automatically infer project-id and location and automatically init VertexAiEmbeddingConnectionDetails.

Minimal Complete Reproducible example
If i manually create the bean, then the error goes away.

    @Value("${spring.ai.vertex.ai.embedding.project-id}")
    private String projectId;

    @Value("${spring.ai.vertex.ai.embedding.location}")
    private String location;

    @Bean
    VertexAiEmbeddingConnectionDetails connectionDetails() {
        return VertexAiEmbeddingConnectionDetails.builder()
                .projectId(projectId)
                .location(location)
                .build();
    }

Solution
Adding implementation 'com.google.cloud:google-cloud-vertexai:1.38.0' works since autoconfiguration depends on VertexAI.class being exists.

Therefore adding com.google.cloud:google-cloud-vertexai to spring-ai-starter-model-vertex-ai-embedding should work.

Or setting @ConditionalOnClass({com.google.cloud.aiplatform.v1.PredictionServiceSettings})

Metadata

Metadata

Labels

bugSomething isn't workingvertex

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions