Skip to content

Commit 4440992

Browse files
committed
feat: send empty optional if length exceeds threshold
1 parent f70ddb5 commit 4440992

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

application/src/main/java/org/togetherjava/tjbot/features/chatgpt/ChatGptService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public class ChatGptService {
4545
* a separate iteration based on the input.
4646
*/
4747
private static final int MAX_NUMBER_OF_RESPONSES = 1;
48+
private static final int MAX_CODE_LENGTH = 2000;
4849
private static final String AI_MODEL = "gpt-3.5-turbo";
4950

5051
private boolean isDisabled = false;
@@ -115,7 +116,7 @@ public Optional<String> ask(String question, String context) {
115116
}
116117

117118
public Optional<String> formatCode(CharSequence code) {
118-
if (isDisabled) {
119+
if (isDisabled || code.length() > MAX_CODE_LENGTH) {
119120
return Optional.empty();
120121
}
121122

0 commit comments

Comments
 (0)