Rename prompt-related entities
Due to the distinction between "system" and "user" prompts being
relevant only in stateless mode, and misleading in some entities,
certain occurrences of the term "UserPrompt" have been renamed.
The term "UserPrompt" remains unchanged where it specifically refers to
the stateless user prompt. Where entities include entirely data,
"UserPrompt" has been renamed to "DataPrompt". In all other instances,
it has been simplified to "Prompt".
Change-Id: I185d028e8ba5e993f94eb79b23c3ef163dfaf2c9
Signed-off-by: Patrizio <patrizio.gelosi@amarulasolutions.com>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/data/ChangeSetDataHandler.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/data/ChangeSetDataHandler.java
index f4dd638..8cf9875 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/data/ChangeSetDataHandler.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/data/ChangeSetDataHandler.java
@@ -4,7 +4,7 @@
import com.googlesource.gerrit.plugins.chatgpt.localization.Localizer;
import com.googlesource.gerrit.plugins.chatgpt.mode.common.client.api.gerrit.GerritChange;
import com.googlesource.gerrit.plugins.chatgpt.mode.common.client.api.gerrit.GerritClient;
-import com.googlesource.gerrit.plugins.chatgpt.mode.common.client.prompt.ChatGptUserPrompt;
+import com.googlesource.gerrit.plugins.chatgpt.mode.common.client.prompt.ChatGptDataPrompt;
import com.googlesource.gerrit.plugins.chatgpt.mode.common.model.api.gerrit.GerritPermittedVotingRange;
import com.googlesource.gerrit.plugins.chatgpt.mode.common.model.data.ChangeSetData;
import com.googlesource.gerrit.plugins.chatgpt.mode.common.model.data.GerritClientData;
@@ -22,7 +22,7 @@
Localizer localizer
) {
GerritClientData gerritClientData = gerritClient.getClientData(change);
- ChatGptUserPrompt chatGptUserPrompt = new ChatGptUserPrompt(
+ ChatGptDataPrompt chatGptDataPrompt = new ChatGptDataPrompt(
config,
changeSetData,
change,
@@ -32,7 +32,7 @@
changeSetData.setCommentPropertiesSize(gerritClientData.getCommentProperties().size());
changeSetData.setDirectives(new HashSet<>());
changeSetData.setReviewSystemMessage(null);
- changeSetData.setGptRequestUserPrompt(chatGptUserPrompt.buildPrompt());
+ changeSetData.setGptDataPrompt(chatGptDataPrompt.buildPrompt());
if (config.isVotingEnabled() && !change.getIsCommentEvent()) {
GerritPermittedVotingRange permittedVotingRange = gerritClient.getPermittedVotingRange(change);
if (permittedVotingRange != null) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/interfaces/mode/common/client/prompt/IChatGptUserPrompt.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/interfaces/mode/common/client/prompt/IChatGptDataPrompt.java
similarity index 91%
rename from src/main/java/com/googlesource/gerrit/plugins/chatgpt/interfaces/mode/common/client/prompt/IChatGptUserPrompt.java
rename to src/main/java/com/googlesource/gerrit/plugins/chatgpt/interfaces/mode/common/client/prompt/IChatGptDataPrompt.java
index d8036df..d226c5b 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/interfaces/mode/common/client/prompt/IChatGptUserPrompt.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/interfaces/mode/common/client/prompt/IChatGptDataPrompt.java
@@ -5,7 +5,7 @@
import java.util.List;
-public interface IChatGptUserPrompt {
+public interface IChatGptDataPrompt {
void addMessageItem(int i);
List<GerritComment> getCommentProperties();
List<ChatGptMessageItem> getMessageItems();
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptUserPrompt.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptDataPrompt.java
similarity index 75%
rename from src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptUserPrompt.java
rename to src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptDataPrompt.java
index c993d1b..48d8b99 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptUserPrompt.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptDataPrompt.java
@@ -1,7 +1,7 @@
package com.googlesource.gerrit.plugins.chatgpt.mode.common.client.prompt;
import com.googlesource.gerrit.plugins.chatgpt.config.Configuration;
-import com.googlesource.gerrit.plugins.chatgpt.interfaces.mode.common.client.prompt.IChatGptUserPrompt;
+import com.googlesource.gerrit.plugins.chatgpt.interfaces.mode.common.client.prompt.IChatGptDataPrompt;
import com.googlesource.gerrit.plugins.chatgpt.localization.Localizer;
import com.googlesource.gerrit.plugins.chatgpt.mode.common.client.api.gerrit.GerritChange;
import com.googlesource.gerrit.plugins.chatgpt.mode.common.model.api.chatgpt.ChatGptMessageItem;
@@ -14,17 +14,17 @@
import static com.googlesource.gerrit.plugins.chatgpt.utils.GsonUtils.getGson;
@Slf4j
-public class ChatGptUserPrompt {
- private final IChatGptUserPrompt chatGptUserPromptHandler;
+public class ChatGptDataPrompt {
+ private final IChatGptDataPrompt chatGptDataPromptHandler;
- public ChatGptUserPrompt(
+ public ChatGptDataPrompt(
Configuration config,
ChangeSetData changeSetData,
GerritChange change,
GerritClientData gerritClientData,
Localizer localizer
) {
- chatGptUserPromptHandler = ChatGptUserPromptFactory.getChatGptUserPrompt(
+ chatGptDataPromptHandler = ChatGptPromptFactory.getChatGptDataPrompt(
config,
changeSetData,
change,
@@ -34,10 +34,10 @@
}
public String buildPrompt() {
- for (int i = 0; i < chatGptUserPromptHandler.getCommentProperties().size(); i++) {
- chatGptUserPromptHandler.addMessageItem(i);
+ for (int i = 0; i < chatGptDataPromptHandler.getCommentProperties().size(); i++) {
+ chatGptDataPromptHandler.addMessageItem(i);
}
- List<ChatGptMessageItem> messageItems = chatGptUserPromptHandler.getMessageItems();
+ List<ChatGptMessageItem> messageItems = chatGptDataPromptHandler.getMessageItems();
return messageItems.isEmpty() ? "" : getGson().toJson(messageItems);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptUserPromptBase.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptDataPromptBase.java
similarity index 95%
rename from src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptUserPromptBase.java
rename to src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptDataPromptBase.java
index 4dc5b2b..c080bc2 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptUserPromptBase.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptDataPromptBase.java
@@ -1,7 +1,7 @@
package com.googlesource.gerrit.plugins.chatgpt.mode.common.client.prompt;
import com.googlesource.gerrit.plugins.chatgpt.config.Configuration;
-import com.googlesource.gerrit.plugins.chatgpt.interfaces.mode.common.client.prompt.IChatGptUserPrompt;
+import com.googlesource.gerrit.plugins.chatgpt.interfaces.mode.common.client.prompt.IChatGptDataPrompt;
import com.googlesource.gerrit.plugins.chatgpt.localization.Localizer;
import com.googlesource.gerrit.plugins.chatgpt.mode.common.client.patch.code.InlineCode;
import com.googlesource.gerrit.plugins.chatgpt.mode.common.client.patch.diff.FileDiffProcessed;
@@ -19,7 +19,7 @@
import java.util.List;
@Slf4j
-public abstract class ChatGptUserPromptBase implements IChatGptUserPrompt {
+public abstract class ChatGptDataPromptBase implements IChatGptDataPrompt {
protected final GerritClientData gerritClientData;
protected final HashMap<String, FileDiffProcessed> fileDiffsProcessed;
protected final CommentData commentData;
@@ -30,7 +30,7 @@
@Getter
protected List<GerritComment> commentProperties;
- public ChatGptUserPromptBase(
+ public ChatGptDataPromptBase(
Configuration config,
ChangeSetData changeSetData,
GerritClientData gerritClientData,
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptUserPromptRequests.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptDataPromptRequests.java
similarity index 95%
rename from src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptUserPromptRequests.java
rename to src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptDataPromptRequests.java
index 4ccd5f1..11fd9c9 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptUserPromptRequests.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptDataPromptRequests.java
@@ -13,11 +13,11 @@
import static com.googlesource.gerrit.plugins.chatgpt.settings.Settings.CHAT_GPT_ROLE_USER;
@Slf4j
-public class ChatGptUserPromptRequests extends ChatGptUserPromptBase {
+public class ChatGptDataPromptRequests extends ChatGptDataPromptBase {
protected ChatGptMessageItem messageItem;
protected List<ChatGptRequestMessage> messageHistory;
- public ChatGptUserPromptRequests(
+ public ChatGptDataPromptRequests(
Configuration config,
ChangeSetData changeSetData,
GerritClientData gerritClientData,
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptUserPromptReview.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptDataPromptReview.java
similarity index 90%
rename from src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptUserPromptReview.java
rename to src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptDataPromptReview.java
index 7ec4e84..7b06465 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptUserPromptReview.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptDataPromptReview.java
@@ -1,7 +1,7 @@
package com.googlesource.gerrit.plugins.chatgpt.mode.common.client.prompt;
import com.googlesource.gerrit.plugins.chatgpt.config.Configuration;
-import com.googlesource.gerrit.plugins.chatgpt.interfaces.mode.common.client.prompt.IChatGptUserPrompt;
+import com.googlesource.gerrit.plugins.chatgpt.interfaces.mode.common.client.prompt.IChatGptDataPrompt;
import com.googlesource.gerrit.plugins.chatgpt.localization.Localizer;
import com.googlesource.gerrit.plugins.chatgpt.mode.common.model.api.chatgpt.ChatGptMessageItem;
import com.googlesource.gerrit.plugins.chatgpt.mode.common.model.api.chatgpt.ChatGptRequestMessage;
@@ -13,8 +13,8 @@
import java.util.List;
@Slf4j
-public class ChatGptUserPromptReview extends ChatGptUserPromptBase implements IChatGptUserPrompt {
- public ChatGptUserPromptReview(
+public class ChatGptDataPromptReview extends ChatGptDataPromptBase implements IChatGptDataPrompt {
+ public ChatGptDataPromptReview(
Configuration config,
ChangeSetData changeSetData,
GerritClientData gerritClientData,
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptPrompt.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptPrompt.java
index bd991f1..ab9efb5 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptPrompt.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptPrompt.java
@@ -55,7 +55,7 @@
this.config = config;
// Avoid repeated loading of prompt constants
if (DEFAULT_GPT_SYSTEM_PROMPT == null) {
- loadPrompts("prompts");
+ loadDefaultPrompts("prompts");
}
}
@@ -64,7 +64,7 @@
this.isCommentEvent = isCommentEvent;
}
- public static String getCommentRequestUserPrompt(int commentPropertiesSize) {
+ public static String getCommentRequestPrompt(int commentPropertiesSize) {
return joinWithSpace(new ArrayList<>(List.of(
DEFAULT_GPT_PROMPT_FORCE_JSON_FORMAT,
buildFieldSpecifications(REQUEST_REPLY_ATTRIBUTES),
@@ -77,7 +77,7 @@
return String.format(DEFAULT_GPT_REVIEW_PROMPT_COMMIT_MESSAGES, DEFAULT_GPT_HOW_TO_FIND_COMMIT_MESSAGE);
}
- protected void loadPrompts(String promptFilename) {
+ protected void loadDefaultPrompts(String promptFilename) {
String promptFile = String.format("config/%s.json", promptFilename);
Class<? extends ChatGptPrompt> me = this.getClass();
try (InputStreamReader reader = FileUtils.getInputStreamReader(promptFile)) {
@@ -119,7 +119,7 @@
);
}
- public String getPatchSetReviewUserPrompt() {
+ public String getPatchSetReviewPrompt() {
List<String> attributes = new ArrayList<>(PATCH_SET_REVIEW_REPLY_ATTRIBUTES);
if (config.isVotingEnabled() || config.getFilterNegativeComments()) {
updateScoreDescription();
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptUserPromptFactory.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptPromptFactory.java
similarity index 64%
rename from src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptUserPromptFactory.java
rename to src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptPromptFactory.java
index 7303412..a7653e7 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptUserPromptFactory.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptPromptFactory.java
@@ -1,20 +1,20 @@
package com.googlesource.gerrit.plugins.chatgpt.mode.common.client.prompt;
import com.googlesource.gerrit.plugins.chatgpt.config.Configuration;
-import com.googlesource.gerrit.plugins.chatgpt.interfaces.mode.common.client.prompt.IChatGptUserPrompt;
+import com.googlesource.gerrit.plugins.chatgpt.interfaces.mode.common.client.prompt.IChatGptDataPrompt;
import com.googlesource.gerrit.plugins.chatgpt.localization.Localizer;
import com.googlesource.gerrit.plugins.chatgpt.mode.common.client.api.gerrit.GerritChange;
import com.googlesource.gerrit.plugins.chatgpt.mode.common.model.data.ChangeSetData;
import com.googlesource.gerrit.plugins.chatgpt.mode.common.model.data.GerritClientData;
-import com.googlesource.gerrit.plugins.chatgpt.mode.stateful.client.prompt.ChatGptUserPromptRequestsStateful;
-import com.googlesource.gerrit.plugins.chatgpt.mode.stateless.client.prompt.ChatGptUserPromptRequestsStateless;
+import com.googlesource.gerrit.plugins.chatgpt.mode.stateful.client.prompt.ChatGptDataPromptRequestsStateful;
+import com.googlesource.gerrit.plugins.chatgpt.mode.stateless.client.prompt.ChatGptDataPromptRequestsStateless;
import com.googlesource.gerrit.plugins.chatgpt.settings.Settings;
import lombok.extern.slf4j.Slf4j;
@Slf4j
-public class ChatGptUserPromptFactory {
+public class ChatGptPromptFactory {
- public static IChatGptUserPrompt getChatGptUserPrompt(
+ public static IChatGptDataPrompt getChatGptDataPrompt(
Configuration config,
ChangeSetData changeSetData,
GerritChange change,
@@ -23,15 +23,15 @@
) {
if (change.getIsCommentEvent()) {
if ((config.getGptMode() == Settings.Modes.stateless)) {
- log.info("ChatGptUserPromptFactory: Returned ChatGptUserPromptRequestsStateless");
- return new ChatGptUserPromptRequestsStateless(config, changeSetData, gerritClientData, localizer);
+ log.info("ChatGptPromptFactory: Returned ChatGptDataPromptRequestsStateless");
+ return new ChatGptDataPromptRequestsStateless(config, changeSetData, gerritClientData, localizer);
} else {
- log.info("ChatGptUserPromptFactory: Returned ChatGptUserPromptRequestsStateful");
- return new ChatGptUserPromptRequestsStateful(config, changeSetData, gerritClientData, localizer);
+ log.info("ChatGptPromptFactory: Returned ChatGptDataPromptRequestsStateful");
+ return new ChatGptDataPromptRequestsStateful(config, changeSetData, gerritClientData, localizer);
}
} else {
- log.info("ChatGptUserPromptFactory: Returned ChatGptUserPromptReview");
- return new ChatGptUserPromptReview(config, changeSetData, gerritClientData, localizer);
+ log.info("ChatGptPromptFactory: Returned ChatGptDataPromptReview");
+ return new ChatGptDataPromptReview(config, changeSetData, gerritClientData, localizer);
}
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/model/data/ChangeSetData.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/model/data/ChangeSetData.java
index 083d9f9..060f38e 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/model/data/ChangeSetData.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/model/data/ChangeSetData.java
@@ -14,7 +14,7 @@
public class ChangeSetData {
@NonNull
private Integer gptAccountId;
- private String gptRequestUserPrompt;
+ private String gptDataPrompt;
private Integer commentPropertiesSize;
@NonNull
private Integer votingMinScore;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateful/client/prompt/ChatGptUserPromptRequestsStateful.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateful/client/prompt/ChatGptDataPromptRequestsStateful.java
similarity index 76%
rename from src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateful/client/prompt/ChatGptUserPromptRequestsStateful.java
rename to src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateful/client/prompt/ChatGptDataPromptRequestsStateful.java
index f187f9a..5c2e390 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateful/client/prompt/ChatGptUserPromptRequestsStateful.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateful/client/prompt/ChatGptDataPromptRequestsStateful.java
@@ -1,14 +1,14 @@
package com.googlesource.gerrit.plugins.chatgpt.mode.stateful.client.prompt;
import com.googlesource.gerrit.plugins.chatgpt.config.Configuration;
-import com.googlesource.gerrit.plugins.chatgpt.interfaces.mode.common.client.prompt.IChatGptUserPrompt;
+import com.googlesource.gerrit.plugins.chatgpt.interfaces.mode.common.client.prompt.IChatGptDataPrompt;
import com.googlesource.gerrit.plugins.chatgpt.localization.Localizer;
-import com.googlesource.gerrit.plugins.chatgpt.mode.common.client.prompt.ChatGptUserPromptRequests;
+import com.googlesource.gerrit.plugins.chatgpt.mode.common.client.prompt.ChatGptDataPromptRequests;
import com.googlesource.gerrit.plugins.chatgpt.mode.common.model.data.ChangeSetData;
import com.googlesource.gerrit.plugins.chatgpt.mode.common.model.data.GerritClientData;
-public class ChatGptUserPromptRequestsStateful extends ChatGptUserPromptRequests implements IChatGptUserPrompt {
- public ChatGptUserPromptRequestsStateful(
+public class ChatGptDataPromptRequestsStateful extends ChatGptDataPromptRequests implements IChatGptDataPrompt {
+ public ChatGptDataPromptRequestsStateful(
Configuration config,
ChangeSetData changeSetData,
GerritClientData gerritClientData,
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateful/client/prompt/ChatGptPromptStateful.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateful/client/prompt/ChatGptPromptStateful.java
index 9a16f7c..9791ab2 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateful/client/prompt/ChatGptPromptStateful.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateful/client/prompt/ChatGptPromptStateful.java
@@ -35,7 +35,7 @@
this.isCommentEvent = change.getIsCommentEvent();
// Avoid repeated loading of prompt constants
if (DEFAULT_GPT_ASSISTANT_NAME == null) {
- loadPrompts("promptsStateful");
+ loadDefaultPrompts("promptsStateful");
}
}
@@ -51,13 +51,13 @@
if (change.getIsCommentEvent()) {
instructions.addAll(List.of(
DEFAULT_GPT_ASSISTANT_INSTRUCTIONS_REQUESTS,
- getCommentRequestUserPrompt(changeSetData.getCommentPropertiesSize())
+ getCommentRequestPrompt(changeSetData.getCommentPropertiesSize())
));
}
else {
instructions.addAll(List.of(
getGptAssistantInstructionsReview(),
- getPatchSetReviewUserPrompt()
+ getPatchSetReviewPrompt()
));
if (config.getGptReviewCommitMessages()) {
instructions.add(getReviewPromptCommitMessages());
@@ -67,19 +67,19 @@
}
public String getDefaultGptThreadReviewMessage(String patchSet) {
- String gptRequestUserPrompt = getGptRequestUserPrompt();
- if (gptRequestUserPrompt != null && !gptRequestUserPrompt.isEmpty()) {
- log.debug("Request User Prompt retrieved: {}", gptRequestUserPrompt);
- return gptRequestUserPrompt;
+ String gptRequestDataPrompt = getGptRequestDataPrompt();
+ if (gptRequestDataPrompt != null && !gptRequestDataPrompt.isEmpty()) {
+ log.debug("Request User Prompt retrieved: {}", gptRequestDataPrompt);
+ return gptRequestDataPrompt;
}
else {
return String.format(DEFAULT_GPT_MESSAGE_REVIEW, patchSet);
}
}
- private String getGptRequestUserPrompt() {
+ private String getGptRequestDataPrompt() {
if (changeSetData == null || !isCommentEvent) return null;
- return changeSetData.getGptRequestUserPrompt();
+ return changeSetData.getGptDataPrompt();
}
private String getGptAssistantInstructionsReview() {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateless/client/prompt/ChatGptUserPromptRequestsStateless.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateless/client/prompt/ChatGptDataPromptRequestsStateless.java
similarity index 81%
rename from src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateless/client/prompt/ChatGptUserPromptRequestsStateless.java
rename to src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateless/client/prompt/ChatGptDataPromptRequestsStateless.java
index 2216ed0..8682352 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateless/client/prompt/ChatGptUserPromptRequestsStateless.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateless/client/prompt/ChatGptDataPromptRequestsStateless.java
@@ -1,17 +1,17 @@
package com.googlesource.gerrit.plugins.chatgpt.mode.stateless.client.prompt;
import com.googlesource.gerrit.plugins.chatgpt.config.Configuration;
-import com.googlesource.gerrit.plugins.chatgpt.interfaces.mode.common.client.prompt.IChatGptUserPrompt;
+import com.googlesource.gerrit.plugins.chatgpt.interfaces.mode.common.client.prompt.IChatGptDataPrompt;
import com.googlesource.gerrit.plugins.chatgpt.localization.Localizer;
-import com.googlesource.gerrit.plugins.chatgpt.mode.common.client.prompt.ChatGptUserPromptRequests;
+import com.googlesource.gerrit.plugins.chatgpt.mode.common.client.prompt.ChatGptDataPromptRequests;
import com.googlesource.gerrit.plugins.chatgpt.mode.common.model.api.chatgpt.ChatGptMessageItem;
import com.googlesource.gerrit.plugins.chatgpt.mode.common.model.data.ChangeSetData;
import com.googlesource.gerrit.plugins.chatgpt.mode.common.model.data.GerritClientData;
import lombok.extern.slf4j.Slf4j;
@Slf4j
-public class ChatGptUserPromptRequestsStateless extends ChatGptUserPromptRequests implements IChatGptUserPrompt {
- public ChatGptUserPromptRequestsStateless(
+public class ChatGptDataPromptRequestsStateless extends ChatGptDataPromptRequests implements IChatGptDataPrompt {
+ public ChatGptDataPromptRequestsStateless(
Configuration config,
ChangeSetData changeSetData,
GerritClientData gerritClientData,
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateless/client/prompt/ChatGptPromptStateless.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateless/client/prompt/ChatGptPromptStateless.java
index b466c91..7ed6f94 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateless/client/prompt/ChatGptPromptStateless.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateless/client/prompt/ChatGptPromptStateless.java
@@ -51,16 +51,16 @@
public String getGptUserPrompt(ChangeSetData changeSetData, String patchSet) {
List<String> prompt = new ArrayList<>();
- String gptRequestUserPrompt = changeSetData.getGptRequestUserPrompt();
- boolean isValidRequestUserPrompt = gptRequestUserPrompt != null && !gptRequestUserPrompt.isEmpty();
- if (isCommentEvent && isValidRequestUserPrompt) {
- log.debug("Request User Prompt retrieved: {}", gptRequestUserPrompt);
+ String gptRequestDataPrompt = changeSetData.getGptDataPrompt();
+ boolean isValidRequestDataPrompt = gptRequestDataPrompt != null && !gptRequestDataPrompt.isEmpty();
+ if (isCommentEvent && isValidRequestDataPrompt) {
+ log.debug("Request User Prompt retrieved: {}", gptRequestDataPrompt);
prompt.addAll(Arrays.asList(
DEFAULT_GPT_REQUEST_PROMPT_DIFF,
patchSet,
DEFAULT_GPT_REQUEST_PROMPT_REQUESTS,
- gptRequestUserPrompt,
- getCommentRequestUserPrompt(changeSetData.getCommentPropertiesSize())
+ gptRequestDataPrompt,
+ getCommentRequestPrompt(changeSetData.getCommentPropertiesSize())
));
}
else {
@@ -68,9 +68,9 @@
prompt.addAll(getReviewSteps());
prompt.add(ChatGptPromptStateless.DEFAULT_GPT_REVIEW_PROMPT_DIFF);
prompt.add(patchSet);
- if (isValidRequestUserPrompt) {
+ if (isValidRequestDataPrompt) {
prompt.add(ChatGptPromptStateless.DEFAULT_GPT_REVIEW_PROMPT_MESSAGE_HISTORY);
- prompt.add(gptRequestUserPrompt);
+ prompt.add(gptRequestDataPrompt);
}
if (!changeSetData.getDirectives().isEmpty()) {
prompt.add(DEFAULT_GPT_REVIEW_PROMPT_DIRECTIVES);
@@ -83,7 +83,7 @@
private void loadStatelessPrompts() {
// Avoid repeated loading of prompt constants
if (DEFAULT_GPT_SYSTEM_PROMPT_INPUT_DESCRIPTION == null) {
- loadPrompts("promptsStateless");
+ loadDefaultPrompts("promptsStateless");
}
}
@@ -92,7 +92,7 @@
joinWithSpace(new ArrayList<>(List.of(
DEFAULT_GPT_REVIEW_PROMPT_REVIEW,
DEFAULT_GPT_PROMPT_FORCE_JSON_FORMAT,
- getPatchSetReviewUserPrompt()
+ getPatchSetReviewPrompt()
)))
));
if (config.getGptReviewCommitMessages()) {
diff --git a/src/test/java/com/googlesource/gerrit/plugins/chatgpt/ChatGptReviewStatefulTest.java b/src/test/java/com/googlesource/gerrit/plugins/chatgpt/ChatGptReviewStatefulTest.java
index 6c74d1d..cae1e16 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/chatgpt/ChatGptReviewStatefulTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/chatgpt/ChatGptReviewStatefulTest.java
@@ -197,12 +197,12 @@
String reviewMessageCode = getReviewMessage( "__files/chatGptRunStepsResponse.json", 0);
String reviewMessageCommitMessage = getReviewMessage( "__files/chatGptRunStepsResponse.json", 1);
- String reviewUserPrompt = chatGptPromptStateful.getDefaultGptThreadReviewMessage(formattedPatchContent);
+ String reviewPrompt = chatGptPromptStateful.getDefaultGptThreadReviewMessage(formattedPatchContent);
handleEventBasedOnType(SupportedEvents.PATCH_SET_CREATED);
ArgumentCaptor<ReviewInput> captor = testRequestSent();
- Assert.assertEquals(reviewUserPrompt, requestContent);
+ Assert.assertEquals(reviewPrompt, requestContent);
Assert.assertEquals(reviewMessageCode, getCapturedMessage(captor, "test_file_1.py"));
Assert.assertEquals(reviewMessageCommitMessage, getCapturedMessage(captor, GERRIT_PATCH_SET_FILENAME));
}
@@ -223,12 +223,12 @@
String reviewMessageCode = getReviewMessage("__files/chatGptRunStepsResponse.json", 0);
String reviewMessageCommitMessage = getReviewMessage("__files/chatGptRunStepsResponse.json", 1);
- String reviewUserPrompt = chatGptPromptStateful.getDefaultGptThreadReviewMessage(formattedPatchContent);
+ String reviewPrompt = chatGptPromptStateful.getDefaultGptThreadReviewMessage(formattedPatchContent);
handleEventBasedOnType(SupportedEvents.PATCH_SET_CREATED);
ArgumentCaptor<ReviewInput> captor = testRequestSent();
- Assert.assertEquals(reviewUserPrompt, requestContent);
+ Assert.assertEquals(reviewPrompt, requestContent);
Assert.assertEquals(reviewMessageCode, getCapturedMessage(captor, "test_file_1.py"));
Assert.assertEquals(reviewMessageCommitMessage, getCapturedMessage(captor, GERRIT_PATCH_SET_FILENAME));
}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/chatgpt/ChatGptReviewStatelessTest.java b/src/test/java/com/googlesource/gerrit/plugins/chatgpt/ChatGptReviewStatelessTest.java
index 1adb0c7..2ff1254 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/chatgpt/ChatGptReviewStatelessTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/chatgpt/ChatGptReviewStatelessTest.java
@@ -111,7 +111,7 @@
ChatGptPromptStateless.DEFAULT_GPT_REVIEW_PROMPT,
ChatGptPromptStateless.DEFAULT_GPT_REVIEW_PROMPT_REVIEW + " " +
ChatGptPromptStateless.DEFAULT_GPT_PROMPT_FORCE_JSON_FORMAT + " " +
- chatGptPromptStateless.getPatchSetReviewUserPrompt(),
+ chatGptPromptStateless.getPatchSetReviewPrompt(),
ChatGptPromptStateless.getReviewPromptCommitMessages(),
ChatGptPromptStateless.DEFAULT_GPT_REVIEW_PROMPT_DIFF,
diffContent,
@@ -190,7 +190,7 @@
diffContent,
ChatGptPromptStateless.DEFAULT_GPT_REQUEST_PROMPT_REQUESTS,
readTestFile("__files/stateless/chatGptExpectedRequestMessage.json"),
- ChatGptPromptStateless.getCommentRequestUserPrompt(commentPropertiesSize)
+ ChatGptPromptStateless.getCommentRequestPrompt(commentPropertiesSize)
));
testRequestSent();
String userPrompt = prompts.get(1).getAsJsonObject().get("content").getAsString();