Skip to content
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

Spring have to always create collection ChromaDB #1567

Open
novakma2 opened this issue Oct 19, 2024 · 0 comments
Open

Spring have to always create collection ChromaDB #1567

novakma2 opened this issue Oct 19, 2024 · 0 comments

Comments

@novakma2
Copy link

Bug description
With latest version of 1.0.0-M3, even when using the base package for ChromaDB and manually initialising the collections, it's trying to create a collection messing up the Buildpacks and CDS.

Environment
Spring AI version 1.0.0-M3
Spring Boot version 3.3.4
ChromaDB version 0.5.11
Java 21

Steps to reproduce
Create empty spring boot project, add following dependencies:

<dependency>
     <groupId>org.springframework.ai</groupId>
     <artifactId>spring-ai-chroma-store</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-openai-spring-boot-starter</artifactId>
</dependency>

Implement the Vectorstore beans and all that jazz

    @Bean
    public RestClient.Builder builder() {
        return RestClient.builder().requestFactory(new SimpleClientHttpRequestFactory());
    }

    @Bean
    public ChromaApi chromaApi(RestClient.Builder clientBuilder) {
        String chromaUrl = "http://" + chromaHost + ":" + chromaPort;
        return new ChromaApi(chromaUrl, clientBuilder);
    }

    @Bean
    @Primary
    public VectorStore chromaVectorStore(EmbeddingModel embeddingModel, ChromaApi chromaApi) {
        return new ChromaVectorStore(embeddingModel, chromaApi, "init", true); // here
    }

in the previous version, you could set it to false, and it would skip the init and it would all work, now it throws an exception that it doesn't exist
I would imagine that we who manage multiple collections, either create a constructor without creating any collection because if you don't specify the name, it puts the default one there. Or it doesn't throw an exception when init is set to false.

Expected behavior
Let us manage the collection creations, or when init set to false, don't create collection and don't throw exception breaking CDS image building

Minimal Complete Reproducible example
The example above and run the usual

mvn spring-boot:build-image

with corresponding pom config

<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
	<image>
		<env>
			<BP_JVM_VERSION>21</BP_JVM_VERSION>
			<BPL_JVM_CDS_ENABLED>true</BPL_JVM_CDS_ENABLED>
			<BP_JVM_CDS_ENABLED>true</BP_JVM_CDS_ENABLED>
			<CDS_TRAINING_JAVA_TOOL_OPTIONS>
				-Dspring.profiles.active=prod
				-Dspring.flyway.enabled=false
				-Dspring.data.jdbc.dialect=postgresql
				-Dspring.sql.init.mode=never
				-Dspring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
				-Dspring.jpa.properties.hibernate.boot.allow_jdbc_metadata_access=false
				-Dspring.jpa.hibernate.ddl-auto=none
				-Dspring.sql.init.mode=never
				-Dwebsocket.origin-patterns.load-on-start=false
			</CDS_TRAINING_JAVA_TOOL_OPTIONS>
			<BPE_DELIM_JAVA_TOOL_OPTIONS xml:space="preserve"> </BPE_DELIM_JAVA_TOOL_OPTIONS>
			<BPE_APPEND_JAVA_TOOL_OPTIONS>
				-Dspring.profiles.active=prod
			</BPE_APPEND_JAVA_TOOL_OPTIONS>
		</env>
	</image>
</configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants