Refactor code to improve readability and maintainability

- In AdvancedAIPromptSolver.java, removed unnecessary logging statement and fixed a typo in variable name.
- In SourceCodeRagSolver.java, updated service name to match the correct module name.
- In application.properties, added Eureka configuration for service discovery.
This commit is contained in:
andrea.terzani
2024-10-07 11:47:36 +02:00
parent 4ac1a64ef6
commit 1a67074df5
3 changed files with 11 additions and 2 deletions

View File

@@ -73,7 +73,9 @@ public class AdvancedAIPromptSolver extends StepSolver {
if(qai_output_entityType!=null && qai_output_entityType.equals("CiaOutputEntity")){
logger.info("Output is of type CiaOutputEntity");
CiaOutputEntity ouputEntity = resp.entity(CiaOutputEntity.class);
CiaOutputEntity ouputEntity = resp.entity(CiaOutputEntity.class);
try {
ObjectMapper objectMapper = new ObjectMapper();
String jsonOutput = objectMapper.writeValueAsString(ouputEntity);

View File

@@ -73,13 +73,18 @@ public class SourceCodeRagSolver extends StepSolver {
similaritySearchCodeInput.setSimilarityThreshold(String.valueOf(this.threshold));
similaritySearchCodeInput.setFilterExpression(this.rag_filter);
ServiceInstance serviceInstance = discoveryClient.getInstances("java-source-code-service").get(0);
ServiceInstance serviceInstance = discoveryClient.getInstances("source-code-module").get(0);
RestTemplate restTemplate = new RestTemplate();
CodeRagResponse[] ragresponse =
restTemplate.postForEntity(serviceInstance.getUri() + "/similarity-search-code",
similaritySearchCodeInput,CodeRagResponse[].class ).getBody();
//TODO: Replace above using Feign interface
// var code = codeSimilritySearch(xxxxxxx)
String code="";
for (CodeRagResponse codeRagResponse : ragresponse) {
code += "SOURCE CODE OF "+codeRagResponse.getCodeType()+" : " + codeRagResponse.getFullyQualifiedName() +" \n";

View File

@@ -33,3 +33,5 @@ spring.ai.vectorstore.neo4j.index-name:spring-ai-document-index
spring.main.allow-bean-definition-overriding=true
logging.level.org.springframework.ai.chat.client.advisor=DEBUG
eureka.client.serviceUrl.defaultZone: ${EUREKA_URI:http://localhost:8761/eureka}
eureka.instance.preferIpAddress: true