File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
application/src/main/java/org/togetherjava/tjbot/features Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 44
55import java .util .Optional ;
66
7+ /**
8+ * A utility class for formatting code using ChatGPT.
9+ */
710public final class ChatGPTFormatter {
811 private final ChatGptService chatGptService ;
912
13+ /**
14+ * Constructs a new {@link ChatGPTFormatter} with the provided {@link ChatGptService}.
15+ *
16+ * @param chatGptService the {@link ChatGptService} used for formatting code
17+ */
1018 public ChatGPTFormatter (ChatGptService chatGptService ) {
1119 this .chatGptService = chatGptService ;
1220 }
1321
22+ /**
23+ * Formats the provided code using ChatGPT.
24+ *
25+ * @param code the code to be formatted
26+ * @return an Optional containing the formatted code if successful, empty otherwise
27+ */
1428 public Optional <String > format (CharSequence code ) {
1529 return chatGptService .formatCode (code );
1630 }
Original file line number Diff line number Diff line change @@ -40,6 +40,12 @@ public MessageEmbed apply(CodeFence codeFence) {
4040 .build ();
4141 }
4242
43+ /**
44+ * Formats the provided code using either the ChatGPT formatter or the generic formatter.
45+ *
46+ * @param code the code to be formatted
47+ * @return the formatted code
48+ */
4349 private String formatCode (CharSequence code ) {
4450 return chatGPTFormatter .format (code ).orElse (formatter .format (code ));
4551 }
You can’t perform that action at this time.
0 commit comments