Skip to content

Commit

Permalink
Adding vectorStoreClass and embeddingModelClass to SiloEntity
Browse files Browse the repository at this point in the history
  • Loading branch information
amengus87 committed May 27, 2024
1 parent 37ebcd7 commit 0256ee3
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 6 deletions.
20 changes: 15 additions & 5 deletions backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,36 @@ repositories {
}

dependencies {
compileOnly 'org.projectlombok:lombok:1.18.32'
annotationProcessor 'org.projectlombok:lombok:1.18.32'
annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf:3.2.5'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.hibernate.validator:hibernate-validator'
implementation 'dev.langchain4j:langchain4j-open-ai:0.30.0'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.5.0'

implementation 'dev.langchain4j:langchain4j-open-ai:0.31.0'
implementation 'dev.langchain4j:langchain4j:0.31.0'
implementation 'dev.langchain4j:langchain4j-core:0.31.0'
implementation 'dev.langchain4j:langchain4j-embeddings:0.31.0'
implementation 'dev.langchain4j:langchain4j-open-ai:0.31.0'
implementation 'dev.langchain4j:langchain4j-easy-rag:0.31.0'

implementation platform('org.dizitart:nitrite-bom:4.2.1')
implementation 'org.dizitart:nitrite'
implementation 'org.dizitart:nitrite-support'
implementation 'org.dizitart:nitrite-mvstore-adapter'
implementation 'org.dizitart:nitrite-jackson-mapper'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.5.0'

implementation 'net.sourceforge.argparse4j:argparse4j:0.9.0'
developmentOnly("org.springframework.boot:spring-boot-devtools")

testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'

compileOnly 'org.projectlombok:lombok:1.18.32'
annotationProcessor 'org.projectlombok:lombok:1.18.32'
testCompileOnly 'org.projectlombok:lombok:1.18.32'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.32'
}
Expand Down
12 changes: 11 additions & 1 deletion backend/src/main/java/ai/dragon/entity/SiloEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import org.dizitart.no2.repository.annotations.Entity;
import org.dizitart.no2.repository.annotations.Id;

import dev.langchain4j.model.embedding.bge.small.en.v15.BgeSmallEnV15QuantizedEmbeddingModel;
import dev.langchain4j.store.embedding.inmemory.InMemoryEmbeddingStore;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
Expand All @@ -24,10 +26,18 @@ public class SiloEntity implements IAbstractEntity {
@Schema(description = "Name of the Silo")
private String name;

private String embeddingStoreClass;
@NotNull
@Schema(description = "Java Class to be used for the Vector Store")
private String vectorStoreClass;

@NotNull
@Schema(description = "Java Class to be used for the Embedding Model")
private String embeddingModelClass;

public SiloEntity() {
this.uuid = UUID.randomUUID();
this.name = String.format("Silo %s", this.uuid.toString());
this.vectorStoreClass = InMemoryEmbeddingStore.class.getCanonicalName();
this.embeddingModelClass = BgeSmallEnV15QuantizedEmbeddingModel.class.getCanonicalName();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package ai.dragon.listener;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Profile;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;

@Component
@Profile("!test")
public class StartupApplicationListener implements ApplicationListener<ContextRefreshedEvent> {
@Autowired
private ServletWebServerApplicationContext webServerAppCtxt;

@Override
public void onApplicationEvent(@NonNull ContextRefreshedEvent event) {
String scheme = "http";
String host = "localhost";
int port = webServerAppCtxt.getWebServer().getPort();

System.out.println("================================================");
System.out.println(String.format("APP URL\t\t : %s://%s:%d/", scheme, host, port));
System.out.println(String.format("Swagger UI\t : %s://%s:%d/api/swagger-ui.html", scheme, host, port));
System.out.println("================================================");
}
}
2 changes: 2 additions & 0 deletions backend/src/test/java/ai/dragon/DragonApplicationTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;

@SpringBootTest
@ActiveProfiles("test")
class DragonApplicationTests {
@Test
void contextLoads() {
Expand Down

0 comments on commit 0256ee3

Please sign in to comment.