Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

be-bugfix/codeSave #140

Merged
merged 3 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/epimetheus/scripts/start_server.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
# sudo docker run -d -p 3000:3000 --name $CONTAINER_NAME tank3a/code-validation
6 changes: 3 additions & 3 deletions backend/epimetheus/scripts/stop_server.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -12,5 +12,5 @@ else
sudo kill -9 $CURRENT_PID
fi

sudo docker stop $CONTAINER_NAME
sudo docker rm $CONTAINER_NAME
# sudo docker stop $CONTAINER_NAME
#sudo docker rm $CONTAINER_NAME
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public TaskStep getSimilarStep(String step) {
double[] inputVector = llamaAdapter.getVectorFromSentence(step).block();
Optional<TaskStep> 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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Loading