From 370e8c46c77e9aa235ca066b08170f534f341aa9 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Sat, 6 Jul 2024 20:59:32 +0000 Subject: [PATCH] polish --- .vscode/launch.json | 10 ++++++++++ .../src/main/java/com/example/learning/Main.java | 2 +- rag/rag-springai-ollama-llm/docker/docker-compose.yml | 1 - .../LlmRagWithSpringAiApplication.java | 2 +- .../ai/llmragwithspringai/controller/AiController.java | 2 +- .../controller/DataIndexController.java | 6 +++--- 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 60a79b1..0044f2d 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -86,6 +86,16 @@ "projectName": "rag-langchain4j-AllMiniLmL6V2-llm", "args": "", "envFile": "${workspaceFolder}/.env" + }, + { + "type": "java", + "name": "Spring Boot-LlmRagWithSpringAiApplication", + "request": "launch", + "cwd": "${workspaceFolder}", + "mainClass": "com.learning.ai.llmragwithspringai.LlmRagWithSpringAiApplication", + "projectName": "rag-springai-ollama-llm", + "args": "", + "envFile": "${workspaceFolder}/.env" } ] } \ No newline at end of file diff --git a/java-openai/src/main/java/com/example/learning/Main.java b/java-openai/src/main/java/com/example/learning/Main.java index f25ae09..50ab1b2 100644 --- a/java-openai/src/main/java/com/example/learning/Main.java +++ b/java-openai/src/main/java/com/example/learning/Main.java @@ -43,6 +43,6 @@ public static void main(String[] args) throws IOException, InterruptedException String body = response.body(); ChatResponse chatResponse = mapper.readValue(body, ChatResponse.class); - System.out.println(chatResponse.choices().get(0).message().content()); + System.out.println(chatResponse.choices().getFirst().message().content()); } } \ No newline at end of file diff --git a/rag/rag-springai-ollama-llm/docker/docker-compose.yml b/rag/rag-springai-ollama-llm/docker/docker-compose.yml index 6fc0083..687c199 100644 --- a/rag/rag-springai-ollama-llm/docker/docker-compose.yml +++ b/rag/rag-springai-ollama-llm/docker/docker-compose.yml @@ -1,4 +1,3 @@ -version: '3.7' services: ollama: image: langchain4j/ollama-llama3:latest diff --git a/rag/rag-springai-ollama-llm/src/main/java/com/learning/ai/llmragwithspringai/LlmRagWithSpringAiApplication.java b/rag/rag-springai-ollama-llm/src/main/java/com/learning/ai/llmragwithspringai/LlmRagWithSpringAiApplication.java index 076804c..cb1894d 100644 --- a/rag/rag-springai-ollama-llm/src/main/java/com/learning/ai/llmragwithspringai/LlmRagWithSpringAiApplication.java +++ b/rag/rag-springai-ollama-llm/src/main/java/com/learning/ai/llmragwithspringai/LlmRagWithSpringAiApplication.java @@ -4,7 +4,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication -public class LlmRagWithSpringAiApplication { +class LlmRagWithSpringAiApplication { public static void main(String[] args) { SpringApplication.run(LlmRagWithSpringAiApplication.class, args); diff --git a/rag/rag-springai-ollama-llm/src/main/java/com/learning/ai/llmragwithspringai/controller/AiController.java b/rag/rag-springai-ollama-llm/src/main/java/com/learning/ai/llmragwithspringai/controller/AiController.java index 66887bc..78c78f3 100644 --- a/rag/rag-springai-ollama-llm/src/main/java/com/learning/ai/llmragwithspringai/controller/AiController.java +++ b/rag/rag-springai-ollama-llm/src/main/java/com/learning/ai/llmragwithspringai/controller/AiController.java @@ -15,7 +15,7 @@ @RestController @RequestMapping("/api/ai") @Validated -public class AiController { +class AiController { private static final Logger LOGGER = LoggerFactory.getLogger(AiController.class); diff --git a/rag/rag-springai-ollama-llm/src/main/java/com/learning/ai/llmragwithspringai/controller/DataIndexController.java b/rag/rag-springai-ollama-llm/src/main/java/com/learning/ai/llmragwithspringai/controller/DataIndexController.java index e24099e..1584773 100644 --- a/rag/rag-springai-ollama-llm/src/main/java/com/learning/ai/llmragwithspringai/controller/DataIndexController.java +++ b/rag/rag-springai-ollama-llm/src/main/java/com/learning/ai/llmragwithspringai/controller/DataIndexController.java @@ -10,7 +10,7 @@ @RestController @RequestMapping("/api/data/v1/") -public class DataIndexController { +class DataIndexController { private final DataIndexerService dataIndexerService; @@ -19,7 +19,7 @@ public DataIndexController(DataIndexerService dataIndexerService) { } @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) - public ResponseEntity load(@RequestPart("file") MultipartFile multipartFile) { + ResponseEntity load(@RequestPart("file") MultipartFile multipartFile) { try { this.dataIndexerService.loadData(multipartFile.getResource()); return ResponseEntity.ok("Data indexed successfully!"); @@ -30,7 +30,7 @@ public ResponseEntity load(@RequestPart("file") MultipartFile multipartF } @GetMapping("count") - public Map count() { + Map count() { return Map.of("count", dataIndexerService.count()); } }