Riorganizza il codice per migliorare la gestione degli strumenti di documentazione e codice sorgente
This commit is contained in:
@@ -80,25 +80,28 @@ public class AdvancedAIPromptSolver extends StepSolver {
|
||||
for(String tool: this.qai_available_tools.split(",")){
|
||||
logger.info("Tool: {}", tool);
|
||||
|
||||
|
||||
String selctedProject = "";
|
||||
String selectedApplication = "";
|
||||
|
||||
if(this.scenarioExecution.getScenarioExecutionInput().getInputs().get("selected_project")!=null){
|
||||
selctedProject = this.scenarioExecution.getScenarioExecutionInput().getInputs().get("selected_project");
|
||||
} else {
|
||||
selctedProject = this.scenarioExecution.getScenarioExecutionInput().getInputs().get("input_project");
|
||||
}
|
||||
if(this.scenarioExecution.getScenarioExecutionInput().getInputs().get("selected_application")!=null){
|
||||
selectedApplication = this.scenarioExecution.getScenarioExecutionInput().getInputs().get("selected_application");
|
||||
} else {
|
||||
selectedApplication = this.scenarioExecution.getScenarioExecutionInput().getInputs().get("input_application");
|
||||
}
|
||||
|
||||
logger.info("Selected project: {}", selctedProject);
|
||||
logger.info("Selected application: {}", selectedApplication);
|
||||
|
||||
switch(tool.trim()){
|
||||
case "DocumentationTool" -> {
|
||||
logger.info("Instantiating DocumentationTool");
|
||||
String selctedProject = "";
|
||||
String selectedApplication = "";
|
||||
|
||||
if(this.scenarioExecution.getScenarioExecutionInput().getInputs().get("selected_project")!=null){
|
||||
selctedProject = this.scenarioExecution.getScenarioExecutionInput().getInputs().get("selected_project");
|
||||
} else {
|
||||
selctedProject = this.scenarioExecution.getScenarioExecutionInput().getInputs().get("input_project");
|
||||
}
|
||||
if(this.scenarioExecution.getScenarioExecutionInput().getInputs().get("selected_application")!=null){
|
||||
selectedApplication = this.scenarioExecution.getScenarioExecutionInput().getInputs().get("selected_application");
|
||||
} else {
|
||||
selectedApplication = this.scenarioExecution.getScenarioExecutionInput().getInputs().get("input_application");
|
||||
}
|
||||
|
||||
this.scenarioExecution.getScenarioExecutionInput().getInputs().get("selected_project");
|
||||
|
||||
|
||||
tools = new com.olympus.hermione.tools.DocumentationTool(
|
||||
selectedApplication,
|
||||
selctedProject,
|
||||
@@ -107,23 +110,13 @@ public class AdvancedAIPromptSolver extends StepSolver {
|
||||
|
||||
case "SourceCodeTool" -> {
|
||||
logger.info("Instantiating SourceCodeTool");
|
||||
tools = new com.olympus.hermione.tools.SourceCodeTool(this.discoveryClient);
|
||||
tools = new com.olympus.hermione.tools.SourceCodeTool(this.discoveryClient,
|
||||
selectedApplication,
|
||||
selctedProject);
|
||||
}
|
||||
case "DocAndSourceCodeTool" -> {
|
||||
logger.info("Instantiating DocAndSourceCodeTool");
|
||||
String selctedProject = "";
|
||||
String selectedApplication = "";
|
||||
|
||||
if(this.scenarioExecution.getScenarioExecutionInput().getInputs().get("selected_project")!=null){
|
||||
selctedProject = this.scenarioExecution.getScenarioExecutionInput().getInputs().get("selected_project");
|
||||
} else {
|
||||
selctedProject = this.scenarioExecution.getScenarioExecutionInput().getInputs().get("input_project");
|
||||
}
|
||||
if(this.scenarioExecution.getScenarioExecutionInput().getInputs().get("selected_application")!=null){
|
||||
selectedApplication = this.scenarioExecution.getScenarioExecutionInput().getInputs().get("selected_application");
|
||||
} else {
|
||||
selectedApplication = this.scenarioExecution.getScenarioExecutionInput().getInputs().get("input_application");
|
||||
}
|
||||
|
||||
|
||||
tools = new com.olympus.hermione.tools.DocAndSourceCodeTool(
|
||||
selectedApplication,
|
||||
|
||||
@@ -84,8 +84,8 @@ public class DocAndSourceCodeTool {
|
||||
similaritySearchCodeInput.setQuery(query);
|
||||
similaritySearchCodeInput.setTopK("3");
|
||||
similaritySearchCodeInput.setSimilarityThreshold("0.7");
|
||||
similaritySearchCodeInput.setFilterExpression("");
|
||||
|
||||
similaritySearchCodeInput.setFilterExpression("'ksApplicationName' == '" + this.application+"'");
|
||||
logger.info("[TOOL]LLM SourceCodeTool getCodeBySimilarity filterExpression: " + similaritySearchCodeInput.getFilterExpression());
|
||||
ServiceInstance serviceInstance = discoveryClient.getInstances("source-code-module").get(0);
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
@@ -93,7 +93,7 @@ public class DocAndSourceCodeTool {
|
||||
restTemplate.postForEntity(serviceInstance.getUri() + "/similarity-search-code",
|
||||
similaritySearchCodeInput,CodeRagResponse[].class ).getBody();
|
||||
String code="";
|
||||
|
||||
|
||||
if (ragresponse == null || ragresponse.length == 0) {
|
||||
logger.warning("No source code found for the given query: " + query);
|
||||
return "No source code found for the given query.";
|
||||
|
||||
@@ -14,19 +14,22 @@ import com.olympus.dto.SimilaritySearchCodeInput;
|
||||
|
||||
|
||||
public class SourceCodeTool {
|
||||
private DiscoveryClient discoveryClient;
|
||||
|
||||
Logger logger = Logger.getLogger(SourceCodeTool.class.getName());
|
||||
|
||||
public SourceCodeTool(DiscoveryClient discoveryClient) {
|
||||
private DiscoveryClient discoveryClient;
|
||||
private String application;
|
||||
|
||||
|
||||
public SourceCodeTool(DiscoveryClient discoveryClient,String application, String project) {
|
||||
this.discoveryClient = discoveryClient;
|
||||
this.application = application;
|
||||
}
|
||||
|
||||
|
||||
@Tool(description = "Get the source code of a class by fully qualified name")
|
||||
public String getClassCodeByFullyQualifidClassName(String fullyQualifiedClassName) {
|
||||
|
||||
logger.info("[TOOL]LLM SourceCodeTool Getting source code for class: " + fullyQualifiedClassName);
|
||||
logger.info("[TOOL]LLM SourceCodeTool getClassCodeByFullyQualifidClassName source code for class: " + fullyQualifiedClassName);
|
||||
ServiceInstance serviceInstance = discoveryClient.getInstances("source-code-module").get(0);
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
@@ -41,13 +44,14 @@ public class SourceCodeTool {
|
||||
@Tool(description = "Retrieve the source code that match concept with natural language query ")
|
||||
public String getCodeBySimilarity(String query) {
|
||||
|
||||
logger.info("[TOOL]LLM SourceCodeTool Getting source code for class: " + query);
|
||||
logger.info("[TOOL]LLM SourceCodeTool getCodeBySimilarity source code for class: " + query);
|
||||
SimilaritySearchCodeInput similaritySearchCodeInput = new SimilaritySearchCodeInput();
|
||||
similaritySearchCodeInput.setQuery(query);
|
||||
similaritySearchCodeInput.setTopK("3");
|
||||
similaritySearchCodeInput.setSimilarityThreshold("0.7");
|
||||
similaritySearchCodeInput.setFilterExpression("");
|
||||
similaritySearchCodeInput.setFilterExpression("ksApplicationName == '" + this.application+"'");
|
||||
|
||||
logger.info("[TOOL]LLM SourceCodeTool getCodeBySimilarity filterExpression: " + similaritySearchCodeInput.getFilterExpression());
|
||||
ServiceInstance serviceInstance = discoveryClient.getInstances("source-code-module").get(0);
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user