Skip to content

Commit d07b490

Browse files
authored
Merge pull request #164 from pwgit-create/develop
Develop
2 parents 73004a9 + 3ed9105 commit d07b490

File tree

8 files changed

+47
-25
lines changed

8 files changed

+47
-25
lines changed

AppWish/AppWish/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>pn.dev</groupId>
77
<artifactId>code-generator-gui-ollama</artifactId>
8-
<version>2.0</version>
8+
<version>2.0.1</version>
99
<name>CodeGenerator-GUI</name>
1010

1111

@@ -45,7 +45,7 @@
4545
<dependency>
4646
<groupId>pn.dev</groupId>
4747
<artifactId>code-generator-ollama</artifactId>
48-
<version>2.0</version>
48+
<version>2.0.1</version>
4949
</dependency>
5050
<dependency>
5151
<groupId>org.openjfx</groupId>

AppWish/AppWish/src/main/java/pn/app_wish/AppWish.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ private final ProcessBuilder GetProcessBuilderForRunningGeneratedJavaApplication
196196
} else {
197197
// New App
198198
// Continue an App
199-
pb = new ProcessBuilder(new AppCmd(javaExecutablePath).GetCMDForRunningCodeBaseApplication());
199+
pb = new ProcessBuilder(new AppCmd(javaExecutablePath).GetCMDForRunningApp_Application());
200200
}
201201
return pb;
202202
}

AppWish/AppWish/src/main/java/pn/app_wish/model/AppCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
public record AppCmd(String javaExecutablePath) {
55

6-
public final String[] GetCMDForRunningCodeBaseApplication() {
6+
public final String[] GetCMDForRunningApp_Application() {
77

88
return new String[]{StaticAppWishConstants.BASH_PATH,StaticAppWishConstants.C_ARGUMENT, StaticAppWishConstants.JAVA_TEXT + javaExecutablePath};
99
}

cg/CodeGenerator/CodeGenerator/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>pn.dev</groupId>
88
<artifactId>code-generator-ollama</artifactId>
9-
<version>2.0</version>
9+
<version>2.0.1</version>
1010

1111

1212
<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>

cg/CodeGenerator/CodeGenerator/src/main/java/pn/cg/datastorage/constant/QuestionConstants.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,14 @@ public record QuestionConstants() {
160160
* @part-of-question-chain WHICH_CLASS_ARE_NEEDED_FOR_APP_PREFIX
161161
* @chain-order 4/5
162162
*/
163-
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";
163+
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.";
164164

165165
/**
166166
* @use-info Clarify that no numbers or dots should be included in the response from the AI-model
167167
* @part-of-question-chain WHICH_CLASS_ARE_NEEDED_FOR_APP_PREFIX
168168
* @chain-order 5/5
169169
*/
170-
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";
170+
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!";
171171

172172
/**
173173
* This is the line that initiates the phase that happens after the classes for the super app has been stated

cg/CodeGenerator/CodeGenerator/src/main/java/pn/cg/util/CodeGeneratorUtil.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,7 @@ public static String GetDocFilePathForSuperApp(){
248248
*/
249249
public static boolean ValidateResponseOnSuperAppGetAllClassesQuestion(String responseFromAiModelOnGetAllClassesFromSuperAppQuestion){
250250

251-
return !responseFromAiModelOnGetAllClassesFromSuperAppQuestion.contains(" ")
252-
&& !responseFromAiModelOnGetAllClassesFromSuperAppQuestion.contains(":")
251+
return !responseFromAiModelOnGetAllClassesFromSuperAppQuestion.contains(":")
253252
&& !responseFromAiModelOnGetAllClassesFromSuperAppQuestion.contains(",");
254253

255254
}

cg/CodeGenerator/CodeGenerator/src/main/java/pn/cg/util/StringUtil.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ private static String removeDelimiters(String input, boolean isStartDelimiter) {
159159
if (isStartDelimiter) {
160160
delimiter = CommonStringConstants.JAVA_CODE_GENERATION_START_DELMITER_STRING;
161161
returnValue = RemoveAllExceptTheFirstOccurrenceOfaAWord(returnValue, delimiter);
162-
returnValue = RemoveAllExceptTheFirstOccurrenceOfaAWord(returnValue,delimiter + "\n");
162+
returnValue = RemoveAllExceptTheFirstOccurrenceOfaAWord(returnValue, delimiter + "\n");
163163
} else if (!isStartDelimiter) {
164164
delimiter = CommonStringConstants.JAVA_CODE_GENERATION_END_DELMITER_STRING;
165165
returnValue = RemoveAllExceptTheLastOccurrenceOfWord(returnValue, delimiter);
@@ -237,13 +237,24 @@ public static List<String> GetListOfClassNamesInSuperAppGeneration(String input)
237237
List<String> tmpClassNames = new LinkedList<>();
238238

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

245-
if(!className.equalsIgnoreCase("\n")){
246-
tmpClassNames.add(className);}
242+
if (className.contains(" ")) {
243+
244+
className = className.trim();
245+
246+
if (className.contains(".")) {
247+
className = className.split("\\.")[1];
248+
}
249+
250+
if (Character.isDigit(className.codePointAt(0))) {
251+
className = className.
252+
replaceFirst(String.valueOf(className.codePointAt(0)), "");
253+
254+
}
255+
256+
}
257+
tmpClassNames.add(className.trim());
247258
}
248259
}
249260

cg/CodeGenerator/CodeGenerator/src/test/java/pn/cg/util/StringUtilTest.java

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ public void RemoveExtraStartDelimitersInResponseTest() {
140140
"@END_HERE\n";
141141

142142

143-
144143
//
145144
final String JAVA_CODE_WITH_EXTRA_DELIMITERS = "@START_HERE \\n" + //
146145
"\"import java.awt.*;\n" + //
@@ -318,27 +317,40 @@ public void AppendWithCorrectNumberOfBraceBucketsAtEndOfTheString() {
318317
}
319318

320319
@Test
321-
public void ConvertStringWithClassNamesIntoAListTest(){
320+
public void ConvertStringWithClassNamesIntoAListTest() {
322321

323-
final String text ="Jframe\nAccount\nMain";
324-
final int expected=3;
322+
final String text = "Jframe\nAccount\nMain";
323+
final int expected = 3;
325324
final int actual = StringUtil.GetListOfClassNamesInSuperAppGeneration(text).size();
326325

327-
Assertions.assertEquals(expected,actual);
326+
Assertions.assertEquals(expected, actual);
328327
}
329328

330329
@Test
331-
public void GetListOfClassNamesInSuperAppGenerationTest(){
330+
public void GetListOfClassNamesInSuperAppGenerationTest() {
331+
332+
final String TEST_INPUT = "Here are the class names for your application:\n\nQuestionClass\nAnswerClass\nUserClass\nQuestionServiceClass\nAnswerServiceClass\nUserServiceClass\nMainClass";
332333

333-
final String TEST_INPUT="Here are the class names for your application:\n\nQuestionClass\nAnswerClass\nUserClass\nQuestionServiceClass\nAnswerServiceClass\nUserServiceClass\nMainClass";
334+
final String PERFECT_RESPONSE_FROM_AI_MODEL = "\nQuestionClass\nAnswerClass\nUserClass\nQuestionServiceClass\nAnswerServiceClass\nUserServiceClass\nMainClass";
335+
336+
337+
final List<String> EXPECTED = Arrays.stream(PERFECT_RESPONSE_FROM_AI_MODEL.split("\n")).toList();
338+
final List<String> ACTUAL = StringUtil.GetListOfClassNamesInSuperAppGeneration(TEST_INPUT);
339+
340+
Assertions.assertEquals(EXPECTED, ACTUAL);
341+
}
342+
343+
@Test
344+
public void GetListOfClassNamesInSuperAppGenerationTest2() {
334345

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

337349

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

341-
Assertions.assertEquals(EXPECTED,ACTUAL);
353+
Assertions.assertEquals(EXPECTED, ACTUAL);
342354
}
343355

344356
}

0 commit comments

Comments
 (0)