Skip to content

Commit

Permalink
Merge pull request #164 from pwgit-create/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
pwgit-create authored Jul 3, 2024
2 parents 73004a9 + 3ed9105 commit d07b490
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 25 deletions.
4 changes: 2 additions & 2 deletions AppWish/AppWish/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>pn.dev</groupId>
<artifactId>code-generator-gui-ollama</artifactId>
<version>2.0</version>
<version>2.0.1</version>
<name>CodeGenerator-GUI</name>


Expand Down Expand Up @@ -45,7 +45,7 @@
<dependency>
<groupId>pn.dev</groupId>
<artifactId>code-generator-ollama</artifactId>
<version>2.0</version>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
Expand Down
2 changes: 1 addition & 1 deletion AppWish/AppWish/src/main/java/pn/app_wish/AppWish.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ private final ProcessBuilder GetProcessBuilderForRunningGeneratedJavaApplication
} else {
// New App
// Continue an App
pb = new ProcessBuilder(new AppCmd(javaExecutablePath).GetCMDForRunningCodeBaseApplication());
pb = new ProcessBuilder(new AppCmd(javaExecutablePath).GetCMDForRunningApp_Application());
}
return pb;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

public record AppCmd(String javaExecutablePath) {

public final String[] GetCMDForRunningCodeBaseApplication() {
public final String[] GetCMDForRunningApp_Application() {

return new String[]{StaticAppWishConstants.BASH_PATH,StaticAppWishConstants.C_ARGUMENT, StaticAppWishConstants.JAVA_TEXT + javaExecutablePath};
}
Expand Down
2 changes: 1 addition & 1 deletion cg/CodeGenerator/CodeGenerator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>pn.dev</groupId>
<artifactId>code-generator-ollama</artifactId>
<version>2.0</version>
<version>2.0.1</version>


<description>The Java Application-Generator (pn.dev.code-generator-ollama) creates applications by giving a string of your desired features for a Java application, like this: AppSystem.StartCodeGenerator(String appWish)</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,14 @@ public record QuestionConstants() {
* @part-of-question-chain WHICH_CLASS_ARE_NEEDED_FOR_APP_PREFIX
* @chain-order 4/5
*/
public final static String ONLY_CLASS_NAMES_IN_ANSWER="Your response should only contain the needed classes name for the application and there shall be one class name per line, your reply must not contain anything else";
public final static String ONLY_CLASS_NAMES_IN_ANSWER="The response should only contain the necessary class names for the application, with one class name per line, and should not contain any other information.";

/**
* @use-info Clarify that no numbers or dots should be included in the response from the AI-model
* @part-of-question-chain WHICH_CLASS_ARE_NEEDED_FOR_APP_PREFIX
* @chain-order 5/5
*/
public final static String CLARIFY_THAT_NO_DOTS_OR_NUMBERS_SHOULD_BE_INCLUDED_IN_THE_RESPONSE="Your response should not contain number,dots or spaces to state the order of the classes, there should only be one class name per line and nothing else in your response";
public final static String CLARIFY_THAT_NO_DOTS_OR_NUMBERS_SHOULD_BE_INCLUDED_IN_THE_RESPONSE="The only thing you need to include in your response is one class name per line. That is imperative!";

/**
* This is the line that initiates the phase that happens after the classes for the super app has been stated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,7 @@ public static String GetDocFilePathForSuperApp(){
*/
public static boolean ValidateResponseOnSuperAppGetAllClassesQuestion(String responseFromAiModelOnGetAllClassesFromSuperAppQuestion){

return !responseFromAiModelOnGetAllClassesFromSuperAppQuestion.contains(" ")
&& !responseFromAiModelOnGetAllClassesFromSuperAppQuestion.contains(":")
return !responseFromAiModelOnGetAllClassesFromSuperAppQuestion.contains(":")
&& !responseFromAiModelOnGetAllClassesFromSuperAppQuestion.contains(",");

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private static String removeDelimiters(String input, boolean isStartDelimiter) {
if (isStartDelimiter) {
delimiter = CommonStringConstants.JAVA_CODE_GENERATION_START_DELMITER_STRING;
returnValue = RemoveAllExceptTheFirstOccurrenceOfaAWord(returnValue, delimiter);
returnValue = RemoveAllExceptTheFirstOccurrenceOfaAWord(returnValue,delimiter + "\n");
returnValue = RemoveAllExceptTheFirstOccurrenceOfaAWord(returnValue, delimiter + "\n");
} else if (!isStartDelimiter) {
delimiter = CommonStringConstants.JAVA_CODE_GENERATION_END_DELMITER_STRING;
returnValue = RemoveAllExceptTheLastOccurrenceOfWord(returnValue, delimiter);
Expand Down Expand Up @@ -237,13 +237,24 @@ public static List<String> GetListOfClassNamesInSuperAppGeneration(String input)
List<String> tmpClassNames = new LinkedList<>();

for (String className : classNamesArr) {
if (!className.contains(" ")
|| !className.equals("\n")
|| !Character.isLowerCase(className.codePointAt(0))
&& (className.matches("^[a-z\nA-Z]+$") || className.matches("^[0-9\n]+$"))) {
if (!className.equals("\n")) {

if(!className.equalsIgnoreCase("\n")){
tmpClassNames.add(className);}
if (className.contains(" ")) {

className = className.trim();

if (className.contains(".")) {
className = className.split("\\.")[1];
}

if (Character.isDigit(className.codePointAt(0))) {
className = className.
replaceFirst(String.valueOf(className.codePointAt(0)), "");

}

}
tmpClassNames.add(className.trim());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ public void RemoveExtraStartDelimitersInResponseTest() {
"@END_HERE\n";



//
final String JAVA_CODE_WITH_EXTRA_DELIMITERS = "@START_HERE \\n" + //
"\"import java.awt.*;\n" + //
Expand Down Expand Up @@ -318,27 +317,40 @@ public void AppendWithCorrectNumberOfBraceBucketsAtEndOfTheString() {
}

@Test
public void ConvertStringWithClassNamesIntoAListTest(){
public void ConvertStringWithClassNamesIntoAListTest() {

final String text ="Jframe\nAccount\nMain";
final int expected=3;
final String text = "Jframe\nAccount\nMain";
final int expected = 3;
final int actual = StringUtil.GetListOfClassNamesInSuperAppGeneration(text).size();

Assertions.assertEquals(expected,actual);
Assertions.assertEquals(expected, actual);
}

@Test
public void GetListOfClassNamesInSuperAppGenerationTest(){
public void GetListOfClassNamesInSuperAppGenerationTest() {

final String TEST_INPUT = "Here are the class names for your application:\n\nQuestionClass\nAnswerClass\nUserClass\nQuestionServiceClass\nAnswerServiceClass\nUserServiceClass\nMainClass";

final String TEST_INPUT="Here are the class names for your application:\n\nQuestionClass\nAnswerClass\nUserClass\nQuestionServiceClass\nAnswerServiceClass\nUserServiceClass\nMainClass";
final String PERFECT_RESPONSE_FROM_AI_MODEL = "\nQuestionClass\nAnswerClass\nUserClass\nQuestionServiceClass\nAnswerServiceClass\nUserServiceClass\nMainClass";


final List<String> EXPECTED = Arrays.stream(PERFECT_RESPONSE_FROM_AI_MODEL.split("\n")).toList();
final List<String> ACTUAL = StringUtil.GetListOfClassNamesInSuperAppGeneration(TEST_INPUT);

Assertions.assertEquals(EXPECTED, ACTUAL);
}

@Test
public void GetListOfClassNamesInSuperAppGenerationTest2() {

final String PERFECT_RESPONSE_FROM_AI_MODEL="\nQuestionClass\nAnswerClass\nUserClass\nQuestionServiceClass\nAnswerServiceClass\nUserServiceClass\nMainClass";
final String TEST_INPUT = "1. PackageScanner\n2. SecurityAnalyzer\n3. VulnerabilityChecker\n4. ReportGenerator\n5. UserInterface\n6. ApplicationManager\n7. Main";
final String PERFECT_RESPONSE_FROM_AI_MODEL = "PackageScanner\nSecurityAnalyzer\nVulnerabilityChecker\nReportGenerator\nUserInterface\nApplicationManager\nMain";


final List<String> EXPECTED = Arrays.stream(PERFECT_RESPONSE_FROM_AI_MODEL.split("\n")).toList();
final List<String> ACTUAL = StringUtil.GetListOfClassNamesInSuperAppGeneration(TEST_INPUT);

Assertions.assertEquals(EXPECTED,ACTUAL);
Assertions.assertEquals(EXPECTED, ACTUAL);
}

}

0 comments on commit d07b490

Please sign in to comment.