From 2352c3c3bf849b647b2f7313f9c0c1de888f6b56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A2=85=EC=9B=90=20Jongwon?= Date: Thu, 7 Dec 2023 20:45:13 +0900 Subject: [PATCH 1/3] =?UTF-8?q?JIRA-179=20#feat=20#comment=20"Code=20?= =?UTF-8?q?=EC=9C=A0=ED=9A=A8=EC=84=B1=20=EA=B2=80=EC=A6=9D=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/epimetheus/scripts/start_server.sh | 4 ++-- backend/epimetheus/scripts/stop_server.sh | 6 +++--- .../service/TaskServiceStreamImpl.java | 16 +++++++++------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/backend/epimetheus/scripts/start_server.sh b/backend/epimetheus/scripts/start_server.sh index 816d99b2..f7a89a10 100644 --- a/backend/epimetheus/scripts/start_server.sh +++ b/backend/epimetheus/scripts/start_server.sh @@ -1,6 +1,6 @@ PROJECT_ROOT="/home/ubuntu/jenkins" JAR_FILE="$PROJECT_ROOT/epimetheus.jar" -CONTAINER_NAME="node-validation-server" +# CONTAINER_NAME="node-validation-server" APP_LOG="$PROJECT_ROOT/application.log" ERROR_LOG="$PROJECT_ROOT/error.log" @@ -15,4 +15,4 @@ nohup java -jar $JAR_FILE > $APP_LOG 2> $ERROR_LOG & CURRENT_PID=$(pgrep -f $JAR_FILE) echo "$TIME_NOW > Current PID: $CURRENT_PID" >> $DEPLOY_LOG -sudo docker run -d -p 3000:3000 --name $CONTAINER_NAME tank3a/code-validation \ No newline at end of file +# sudo docker run -d -p 3000:3000 --name $CONTAINER_NAME tank3a/code-validation \ No newline at end of file diff --git a/backend/epimetheus/scripts/stop_server.sh b/backend/epimetheus/scripts/stop_server.sh index c1500fc4..8bdafb53 100644 --- a/backend/epimetheus/scripts/stop_server.sh +++ b/backend/epimetheus/scripts/stop_server.sh @@ -1,6 +1,6 @@ PROJECT_ROOT="/home/ubuntu/jenkins" JAR_FILE="$PROJECT_ROOT/epimetheus.jar" -CONTAINER_NAME="node-validation-server" +# CONTAINER_NAME="node-validation-server" CURRENT_PID=$(pgrep -f $JAR_FILE) DEPLOY_LOG="$PROJECT_ROOT/deploy.log" @@ -12,5 +12,5 @@ else sudo kill -9 $CURRENT_PID fi -sudo docker stop $CONTAINER_NAME -sudo docker rm $CONTAINER_NAME \ No newline at end of file +# sudo docker stop $CONTAINER_NAME +#sudo docker rm $CONTAINER_NAME \ No newline at end of file diff --git a/backend/epimetheus/src/main/java/uos/capstone/epimetheus/service/TaskServiceStreamImpl.java b/backend/epimetheus/src/main/java/uos/capstone/epimetheus/service/TaskServiceStreamImpl.java index 36c95dfb..c29bcd71 100644 --- a/backend/epimetheus/src/main/java/uos/capstone/epimetheus/service/TaskServiceStreamImpl.java +++ b/backend/epimetheus/src/main/java/uos/capstone/epimetheus/service/TaskServiceStreamImpl.java @@ -121,13 +121,15 @@ private String stopWordParse(StringBuffer stringBuffer){ @Override public String saveCode(TaskStep taskStep){ - String checkCode = taskExecuteService.executeSubTask(taskStep); - if(checkCode.contains(CodeValidationResponse.SUCCESS.getMessage())) { - databaseService.updateCode(taskStep); - return checkCode; - } - - throw new CodeValidationException(checkCode); +// String checkCode = taskExecuteService.executeSubTask(taskStep); +// if(checkCode.contains(CodeValidationResponse.SUCCESS.getMessage())) { + TaskStep task = similarityService.getSimilarStep(taskStep.getTitle()); + task.setCode(taskStep.getCode()); + databaseService.updateCode(task); + return "[SUCCESS]"; +// } + +// throw new CodeValidationException(checkCode); } @Override From c1cad56ce44ded57d714728e1be9d24950ef9166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A2=85=EC=9B=90=20Jongwon?= Date: Thu, 7 Dec 2023 20:46:12 +0900 Subject: [PATCH 2/3] =?UTF-8?q?JIRA-178=20#feat=20#comment=20"=EB=B9=84?= =?UTF-8?q?=EC=8A=B7=ED=95=9C=20step=20=EC=B0=BE=EC=95=84=20=EB=B0=98?= =?UTF-8?q?=ED=99=98=20=EC=8B=9C=20=ED=95=B4=EB=8B=B9=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=20=EC=88=98=EC=A0=95=20=ED=9B=84=20=EC=A0=80=EC=9E=A5=EB=90=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epimetheus/service/CosineSimilarityService.java | 2 +- .../epimetheus/service/MongoDBServiceImpl.java | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/backend/epimetheus/src/main/java/uos/capstone/epimetheus/service/CosineSimilarityService.java b/backend/epimetheus/src/main/java/uos/capstone/epimetheus/service/CosineSimilarityService.java index e15aa675..98c49e26 100644 --- a/backend/epimetheus/src/main/java/uos/capstone/epimetheus/service/CosineSimilarityService.java +++ b/backend/epimetheus/src/main/java/uos/capstone/epimetheus/service/CosineSimilarityService.java @@ -24,7 +24,7 @@ public TaskStep getSimilarStep(String step) { double[] inputVector = llamaAdapter.getVectorFromSentence(step).block(); Optional similar = databaseService.getAllData().stream() .filter(data -> data.getValues() != null && data.getValues().length == inputVector.length) - .filter(data -> cosineSimilarity(inputVector, data.getValues()) >= 0.8) + .filter(data -> cosineSimilarity(inputVector, data.getValues()) >= 0.9) .sorted(Comparator.comparing(data -> (-1) * cosineSimilarity(inputVector, data.getValues()))) .findFirst(); diff --git a/backend/epimetheus/src/main/java/uos/capstone/epimetheus/service/MongoDBServiceImpl.java b/backend/epimetheus/src/main/java/uos/capstone/epimetheus/service/MongoDBServiceImpl.java index 1aed3921..be60d89d 100644 --- a/backend/epimetheus/src/main/java/uos/capstone/epimetheus/service/MongoDBServiceImpl.java +++ b/backend/epimetheus/src/main/java/uos/capstone/epimetheus/service/MongoDBServiceImpl.java @@ -8,7 +8,9 @@ import uos.capstone.epimetheus.dtos.llamaTasks.CodeLanguage; import uos.capstone.epimetheus.repository.MongoDBRepository; +import java.util.Comparator; import java.util.List; +import java.util.Optional; @Service @RequiredArgsConstructor @@ -33,14 +35,7 @@ public TaskStep saveByTitle(String step, double[] vector) { @Override public void updateCode(TaskStep taskStep){ - TaskStep stepToUpdate = mongoRepository.findById(taskStep.getTitle()).orElse(TaskStep.builder() - .title(taskStep.getTitle()) - .values(llamaAdapter.getVectorFromSentence(taskStep.getTitle()).block()) - .language(CodeLanguage.JAVASCRIPT) - .build()); - stepToUpdate.setCode(taskStep.getCode()); - - mongoRepository.save(stepToUpdate); + mongoRepository.save(taskStep); } @Override From d6b8f1446fdf127ff1008acba3753a2ce52a6d98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A2=85=EC=9B=90=20Jongwon?= Date: Thu, 7 Dec 2023 20:46:37 +0900 Subject: [PATCH 3/3] =?UTF-8?q?JIRA-180=20#feat=20#comment=20"=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=83=9D=EC=84=B1=20Prompt=20=EC=A3=BC=EC=84=9D=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/epimetheus/src/main/resources/static/CodePrompt.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/epimetheus/src/main/resources/static/CodePrompt.txt b/backend/epimetheus/src/main/resources/static/CodePrompt.txt index e62c3694..83422f2e 100644 --- a/backend/epimetheus/src/main/resources/static/CodePrompt.txt +++ b/backend/epimetheus/src/main/resources/static/CodePrompt.txt @@ -8,5 +8,5 @@ Rule: 5. Start your response with the sentence "This is created by AI.". 6. If you are providing any comment, cover it with code comment. ###Request: Please make a javascript code block of the following step. Step: Open the web-browser. -###Response: This is created by AI. +###Response://This is created by AI. window.open("https://www.google.com", "_self"); \ No newline at end of file