Merged PR 180: Aggiorna le dipendenze di Spring AI e rimuove la configurazione obsoleta di V...
Aggiorna le dipendenze di Spring AI e rimuove la configurazione obsoleta di VectorStore. Modifica la configurazione di sicurezza per consentire l'accesso a Swagger e aggiorna le credenziali nel file di configurazione.
This commit is contained in:
38
pom.xml
38
pom.xml
@@ -28,7 +28,7 @@
|
||||
</scm>
|
||||
<properties>
|
||||
<java.version>21</java.version>
|
||||
<spring-ai.version>1.0.0-M6</spring-ai.version>
|
||||
<spring-ai.version>1.0.0</spring-ai.version>
|
||||
<spring-cloud.version>2023.0.3</spring-cloud.version>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
@@ -69,32 +69,6 @@
|
||||
<artifactId>spring-boot-starter-data-rest</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-mongodb-atlas-store-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-openai-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-azure-openai-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-azure-store</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-chroma-store</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
|
||||
@@ -109,6 +83,16 @@
|
||||
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-starter-model-azure-openai</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-starter-vector-store-chroma</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-tika-document-reader</artifactId>
|
||||
|
||||
@@ -2,9 +2,6 @@ package com.olympus.apollo.config;
|
||||
|
||||
import org.springframework.ai.azure.openai.AzureOpenAiEmbeddingModel;
|
||||
import org.springframework.ai.embedding.EmbeddingModel;
|
||||
import org.springframework.ai.openai.OpenAiEmbeddingModel;
|
||||
import org.springframework.ai.vectorstore.VectorStore;
|
||||
import org.springframework.ai.vectorstore.azure.AzureVectorStore;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
@@ -12,26 +9,15 @@ import org.springframework.context.annotation.Primary;
|
||||
@Configuration
|
||||
public class ApolloConfig {
|
||||
|
||||
private final OpenAiEmbeddingModel openAiEmbeddingModel;
|
||||
private final AzureOpenAiEmbeddingModel azureOpenAiEmbeddingModel;
|
||||
|
||||
|
||||
// Autowiring beans from both libraries
|
||||
public ApolloConfig(OpenAiEmbeddingModel myServiceLib1,
|
||||
AzureOpenAiEmbeddingModel azureOpenAiEmbeddingModel) {
|
||||
this.openAiEmbeddingModel = myServiceLib1;
|
||||
public ApolloConfig( AzureOpenAiEmbeddingModel azureOpenAiEmbeddingModel) {
|
||||
this.azureOpenAiEmbeddingModel = azureOpenAiEmbeddingModel;
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Re-declaring and marking one as primary
|
||||
@Bean
|
||||
public EmbeddingModel primaryMyService() {
|
||||
return openAiEmbeddingModel; // Choose the one you want as primary
|
||||
}
|
||||
|
||||
// Optionally declare the other bean without primary
|
||||
@Bean
|
||||
@Primary
|
||||
public EmbeddingModel secondaryMyService() {
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
package com.olympus.apollo.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.ai.embedding.EmbeddingModel;
|
||||
import org.springframework.ai.vectorstore.VectorStore;
|
||||
import org.springframework.ai.vectorstore.azure.AzureVectorStore;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import com.azure.core.credential.AzureKeyCredential;
|
||||
import com.azure.search.documents.indexes.SearchIndexClient;
|
||||
import com.azure.search.documents.indexes.SearchIndexClientBuilder;
|
||||
|
||||
@Configuration
|
||||
public class VectorStoreConfig {
|
||||
|
||||
|
||||
@Value("${spring.ai.vectorstore.azure.api-key}")
|
||||
private String azureKey;
|
||||
@Value("${spring.ai.vectorstore.azure.url}")
|
||||
private String azureEndpoint;
|
||||
@Value("${spring.ai.vectorstore.azure.initialize-schema}")
|
||||
private boolean initSchema;
|
||||
|
||||
@Bean
|
||||
public SearchIndexClient searchIndexClient() {
|
||||
return new SearchIndexClientBuilder().endpoint(azureEndpoint)
|
||||
.credential(new AzureKeyCredential(azureKey))
|
||||
.buildClient();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public VectorStore azureVectorStore(SearchIndexClient searchIndexClient, @Qualifier("azureOpenAiEmbeddingModel") EmbeddingModel embeddingModel) {
|
||||
List<AzureVectorStore.MetadataField> fields = new ArrayList<>();
|
||||
|
||||
fields.add(AzureVectorStore.MetadataField.text("KsApplicationName"));
|
||||
fields.add(AzureVectorStore.MetadataField.text("KsProjectName"));
|
||||
fields.add(AzureVectorStore.MetadataField.text("KsDoctype"));
|
||||
fields.add(AzureVectorStore.MetadataField.text("KsDocSource"));
|
||||
fields.add(AzureVectorStore.MetadataField.text("KsFileSource"));
|
||||
fields.add(AzureVectorStore.MetadataField.text("KsDocumentId"));
|
||||
|
||||
//return new AzureVectorStore(searchIndexClient, embeddingModel,initSchema, fields);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import ch.qos.logback.classic.Logger;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/vsearch")
|
||||
|
||||
public class SearchDocController {
|
||||
|
||||
@Autowired
|
||||
@@ -31,19 +30,6 @@ public class SearchDocController {
|
||||
@PostMapping("/doc_search")
|
||||
public List<String> vectorSearch(@RequestBody VectorSearchRequest vectorSearchRequest) {
|
||||
|
||||
// SearchRequest request = SearchRequest.defaults()
|
||||
// .withQuery(vectorSearchRequest.getQuery())
|
||||
// .withTopK(vectorSearchRequest.getTopK())
|
||||
// .withSimilarityThreshold(vectorSearchRequest.getThreshold());
|
||||
|
||||
// List<Document> docs = this.vectorStore.similaritySearch(request);
|
||||
// logger.info("Number of VDB retrieved documents: " + docs.size());
|
||||
|
||||
// List<String> results = new ArrayList<>();
|
||||
// for(Document doc : docs){
|
||||
// results.add(doc.getContent());
|
||||
// }
|
||||
|
||||
Builder request_builder = SearchRequest.builder()
|
||||
.query(vectorSearchRequest.getQuery())
|
||||
.topK(vectorSearchRequest.getTopK())
|
||||
|
||||
@@ -34,13 +34,7 @@ public class REModuleService {
|
||||
commonReverseEngRequest.setCommitSha(gitInfo.getCommitId());
|
||||
|
||||
gitInfo.getCodeTypes().forEach(codeType -> {
|
||||
/*if(codeType.getType().equalsIgnoreCase("java")){
|
||||
commonReverseEngRequest.setApplicationType(codeType.getType());
|
||||
System.out.println("value is :"+javaREModule.revApplication(commonReverseEngRequest));
|
||||
}
|
||||
if(codeType.getType().equalsIgnoreCase("jsp")) {
|
||||
System.out.println("JSP Parser Module");
|
||||
}*/
|
||||
|
||||
commonReverseEngRequest.setApplicationType(codeType.getType());
|
||||
javaREModule.revApplication(commonReverseEngRequest);
|
||||
});
|
||||
|
||||
@@ -66,7 +66,7 @@ public class SecurityConfig {
|
||||
http
|
||||
.csrf().disable()
|
||||
.authorizeHttpRequests(auth -> auth
|
||||
.requestMatchers("/api/auth/**", "/login").permitAll()
|
||||
.requestMatchers("/api/auth/**", "/login","/swagger-ui/**", "/v3/api-docs/**", "/swagger-ui.html", "/swagger-resources/**", "/webjars/**").permitAll()
|
||||
.anyRequest().authenticated()
|
||||
)
|
||||
.authenticationProvider(authenticationProvider())
|
||||
@@ -77,11 +77,11 @@ public class SecurityConfig {
|
||||
|
||||
@Bean
|
||||
public AuthenticationManager authManager(HttpSecurity http) throws Exception {
|
||||
return http.getSharedObject(AuthenticationManagerBuilder.class)
|
||||
AuthenticationManagerBuilder builder = http.getSharedObject(AuthenticationManagerBuilder.class);
|
||||
builder
|
||||
.userDetailsService(userDetailsService)
|
||||
.passwordEncoder(passwordEncoder())
|
||||
.and()
|
||||
.build();
|
||||
.passwordEncoder(passwordEncoder());
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -96,9 +96,7 @@ public class DeletionService {
|
||||
|
||||
ksDocumentRepository.save(ksDocument);
|
||||
logger.info("KSDocument with id {} deleted from VectorStore successfully.", deletionRequest.getKsDocumentId());
|
||||
// }else{
|
||||
// logger.warn("KSDocument with id {} does not exist.", deletionRequest.getKsDocumentId());
|
||||
// }
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("An error occurred while deleting records: ", e+" "+Thread.currentThread().getName());
|
||||
throw new RuntimeException("An error occurred while deleting records", e);
|
||||
|
||||
@@ -26,15 +26,11 @@ spring:
|
||||
openai:
|
||||
api-key: "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||
vectorstore:
|
||||
azure:
|
||||
api-key: "jxKxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||
url: "https://search-olympus.search.windows.net"
|
||||
initialize-schema: true
|
||||
chroma:
|
||||
client:
|
||||
host: "http://108.142.74.161"
|
||||
host: "http://128.251.239.194"
|
||||
port: "8000"
|
||||
key-token: "tKAJfN1Yv5lP7pKorJHGfHMQhNEcM9uu"
|
||||
key-token: "BxZWXFXC4UMSxamf5xP5SioGIg3FPfP7"
|
||||
initialize-schema: "true"
|
||||
collection-name: "olympus"
|
||||
data:
|
||||
|
||||
Reference in New Issue
Block a user