Uppercased mode constants for consistency The mode constants "stateless" and "stateful" and have been updated to "STATELESS" and "STATEFUL" to align with naming standards and ensure uniformity with other constant values. Change-Id: I5613dc486e26a05a3d0ff1031158cf0e94db30f4 Signed-off-by: Patrizio <patrizio.gelosi@amarulasolutions.com>
diff --git a/README.md b/README.md index 4a11f73..7f414a1 100644 --- a/README.md +++ b/README.md
@@ -156,10 +156,10 @@ ### Optional Parameters Common to Both Modes - `gptMode`: Select whether requests are processed in Stateless or Stateful mode. For backward compatibility, the - default value is `stateless`. To enable Stateful mode, set this parameter to `stateful`. + default value is `STATELESS`. To enable Stateful mode, set this parameter to `STATEFUL`. - `gptModel`: The default model is `gpt-4o`. You can also configure it to `gpt-3.5-turbo` or `gpt-4-turbo`. -- `gptSystemPromptInstructions`: You can customize the default stateless system prompt ("Act as a PatchSet Reviewer") to - your preferred prompt. This same prompt is also used as the assistant instructions in stateful mode. +- `gptSystemPromptInstructions`: You can customize the default Stateless system prompt ("Act as a PatchSet Reviewer") to + your preferred prompt. This same prompt is also used as the assistant instructions in Stateful mode. - `gptReviewTemperature`: Specifies the temperature setting for ChatGPT when reviewing a Patch Set, with a default setting of 0.2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. @@ -280,7 +280,7 @@ - `getPollingInterval`: Sets the interval for ChatGPT polling on Stateful requests, defaulting to 1 second. - `gptConnectionRetryInterval`: Sets the interval between two connection attempts, with a default of 10 seconds. - `gptConnectionMaxRetryAttempts`: Determines the maximum number of retry attempts, defaulting to 2. -- `gptUploadedChunkSizeMb`: When uploading project repositories to ChatGPT in stateful mode, the repositories are +- `gptUploadedChunkSizeMb`: When uploading project repositories to ChatGPT in Stateful mode, the repositories are packaged and split into chunk files. This setting specifies the maximum size of each chunk file, with a default of 5 MB. @@ -406,7 +406,7 @@ Threads capture all prior interactions and evaluations involving ChatGPT within each Change Set. The history stored in these threads can be removed with the `/forget_thread` command. This functionality is crucial for preventing ChatGPT -from merely recycling old responses in stateful mode, particularly following modifications to configuration parameters. +from merely recycling old responses in Stateful mode, particularly following modifications to configuration parameters. #### Basic Syntax @@ -431,7 +431,7 @@ The `/show` command also enables you to view the prompts and assistant instructions used with your current configuration. -For example, running `@gpt /show --prompts` in stateless mode will return something like: +For example, running `@gpt /show --prompts` in Stateless mode will return something like: ``` PROMPTS CURRENTLY USED @@ -447,7 +447,7 @@ Subject: <COMMIT_MESSAGE> Change-Id: ... <PATCH_SET> ``` -Similarly, running `@gpt /show --instructions` in stateless mode will display something like: +Similarly, running `@gpt /show --instructions` in Stateless mode will display something like: ``` INSTRUCTIONS CURRENTLY USED @@ -492,7 +492,7 @@ ### Change Scope threadId: thread_XXXXXXXXXXXXXXXXXXXX dynamicConfig: - gptMode: stateful + gptMode: STATEFUL enabledVoting: true assistantIdLog: 2024-08-09 10:28:46.973108457: asst_XXXXXXXXXXXXXXXXXXXXXXXX @@ -540,7 +540,7 @@ gptCommentTemperature: 1.0 gptDomain: https://api.openai.com gptFullFileReview: true -gptMode: stateful +gptMode: STATEFUL gptModel: gpt-4-turbo gptReviewCommitMessages: true gptReviewPatchSet: true @@ -715,7 +715,7 @@ It's also possible to make multiple changes at once: ``` -@gpt /configure --gptMode=stateful --gptModel=gpt-4-turbo +@gpt /configure --gptMode=STATEFUL --gptModel=gpt-4-turbo ``` ## License
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/PatchSetReviewer.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/PatchSetReviewer.java index fdfa860..d7fa9ad 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/PatchSetReviewer.java +++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/PatchSetReviewer.java
@@ -70,7 +70,7 @@ commentProperties = gerritClient.getClientData(change).getCommentProperties(); gerritCommentRange = new GerritCommentRange(gerritClient, change); String patchSet = gerritClient.getPatchSet(change); - if (patchSet.isEmpty() && config.getGptMode() == Settings.Modes.stateless) { + if (patchSet.isEmpty() && config.getGptMode() == Settings.Modes.STATELESS) { log.info("No file to review has been found in the PatchSet"); return; }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/config/Configuration.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/config/Configuration.java index 253a20d..4f163be 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/config/Configuration.java +++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/config/Configuration.java
@@ -24,7 +24,7 @@ public static final double DEFAULT_GPT_REVIEW_TEMPERATURE = 0.2; public static final double DEFAULT_GPT_COMMENT_TEMPERATURE = 1.0; - private static final String DEFAULT_GPT_MODE = "stateless"; + private static final String DEFAULT_GPT_MODE = "STATELESS"; private static final boolean DEFAULT_REVIEW_PATCH_SET = true; private static final boolean DEFAULT_REVIEW_COMMIT_MESSAGES = true; private static final boolean DEFAULT_FULL_FILE_REVIEW = true;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/listener/GerritEventContextModule.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/listener/GerritEventContextModule.java index 82e00cd..e983b12 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/listener/GerritEventContextModule.java +++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/listener/GerritEventContextModule.java
@@ -35,8 +35,8 @@ protected void configure() { log.debug("Configuring bindings for GerritEventContextModule"); - bind(IChatGptClient.class).to(getChatGptMode()); - log.debug("Bound IChatGptClient to: {}", getChatGptMode().getSimpleName()); + bind(IChatGptClient.class).to(getChatGptClient()); + log.debug("Bound IChatGptClient to: {}", getChatGptClient().getSimpleName()); bind(IGerritClientPatchSet.class).to(getClientPatchSet()); log.debug("Bound IGerritClientPatchSet to: {}", getClientPatchSet().getSimpleName()); @@ -52,18 +52,18 @@ log.debug("PluginDataHandler bound to singleton provider"); } - private Class<? extends IChatGptClient> getChatGptMode() { + private Class<? extends IChatGptClient> getChatGptClient() { return switch (config.getGptMode()){ - case stateful -> config.getGptReviewCommitMessages() && config.getTaskSpecificAssistants() ? + case STATEFUL -> config.getGptReviewCommitMessages() && config.getTaskSpecificAssistants() ? ChatGptClientStatefulTaskSpecific.class : ChatGptClientStateful.class; - case stateless -> ChatGptClientStateless.class; + case STATELESS -> ChatGptClientStateless.class; }; } private Class<? extends IGerritClientPatchSet> getClientPatchSet() { return switch (config.getGptMode()){ - case stateful -> GerritClientPatchSetStateful.class; - case stateless -> GerritClientPatchSetStateless.class; + case STATEFUL -> GerritClientPatchSetStateful.class; + case STATELESS -> GerritClientPatchSetStateless.class; }; } }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/messages/debug/DebugCodeBlocksPromptingParamBase.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/messages/debug/DebugCodeBlocksPromptingParamBase.java index ed25d91..85549d3 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/messages/debug/DebugCodeBlocksPromptingParamBase.java +++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/messages/debug/DebugCodeBlocksPromptingParamBase.java
@@ -42,8 +42,8 @@ private List<String> getPromptingParameters() { switch (config.getGptMode()) { - case stateful -> populateStatefulParameters(); - case stateless -> populateStatelessParameters(); + case STATEFUL -> populateStatefulParameters(); + case STATELESS -> populateStatelessParameters(); } return promptingParameters.entrySet().stream() .map(e -> getAsTitle(e.getKey()) + "\n" + distanceCodeDelimiter(e.getValue()) + "\n")
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptPromptFactory.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptPromptFactory.java index 39b625e..40afa38 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptPromptFactory.java +++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptPromptFactory.java
@@ -69,7 +69,7 @@ Localizer localizer ) { if (change.getIsCommentEvent()) { - if (config.getGptMode() == Settings.Modes.stateless) { + if (config.getGptMode() == Settings.Modes.STATELESS) { log.info("ChatGptPromptFactory: Return ChatGptDataPromptRequestsStateless"); return new ChatGptDataPromptRequestsStateless(config, changeSetData, gerritClientData, localizer); }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateful/client/api/chatgpt/ChatGptClientStateful.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateful/client/api/chatgpt/ChatGptClientStateful.java index 63f4dad..ff55d3d 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateful/client/api/chatgpt/ChatGptClientStateful.java +++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateful/client/api/chatgpt/ChatGptClientStateful.java
@@ -136,7 +136,7 @@ log.debug("Processing tool calls from ChatGPT run."); yield getResponseContent(chatGptRunHandler.getFirstStepToolCalls()); } - default -> throw new IllegalStateException("Unexpected Step Type in stateful ChatGpt response: " + + default -> throw new IllegalStateException("Unexpected Step Type in Stateful ChatGpt response: " + chatGptRunHandler); }; }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateful/client/prompt/ChatGptDataPromptRequestsStateful.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateful/client/prompt/ChatGptDataPromptRequestsStateful.java index ce4871d..66675a5 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateful/client/prompt/ChatGptDataPromptRequestsStateful.java +++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateful/client/prompt/ChatGptDataPromptRequestsStateful.java
@@ -28,7 +28,7 @@ @Override protected ChatGptMessageItem getMessageItem(int i) { - log.debug("Getting stateful Message Item"); + log.debug("Getting Stateful Message Item"); ChatGptMessageItem messageItem = new ChatGptMessageItem(); setRequestFromCommentProperty(messageItem, i); String inReplyToMessage = getReferenceToLastMessage(i);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/settings/Settings.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/settings/Settings.java index 9e48495..73ec493 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/settings/Settings.java +++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/settings/Settings.java
@@ -22,7 +22,7 @@ public static final String CHAT_GPT_ROLE_ASSISTANT = "assistant"; public enum Modes { - stateless, - stateful + STATELESS, + STATEFUL } }
diff --git a/src/main/resources/localization/localTexts.properties b/src/main/resources/localization/localTexts.properties index d07855b..f488c05 100644 --- a/src/main/resources/localization/localTexts.properties +++ b/src/main/resources/localization/localTexts.properties
@@ -18,7 +18,7 @@ message.dump.stored.data.title=DUMP OF LOCAL DATA message.dump.prompts.title=PROMPTS CURRENTLY USED message.dump.instructions.title=INSTRUCTIONS CURRENTLY USED -message.dump.instructions.mode.mismatch=NO INSTRUCTIONS are used in stateless mode +message.dump.instructions.mode.mismatch=NO INSTRUCTIONS are used in Stateless mode message.command.codebase.upload.successful=Codebase successfully uploaded for this project message.command.codebase.upload.error=Error uploading Codebase for this project message.command.thread.forget=Thread history successfully removed
diff --git a/src/test/java/com/googlesource/gerrit/plugins/chatgpt/ChatGptReviewStatefulTestBase.java b/src/test/java/com/googlesource/gerrit/plugins/chatgpt/ChatGptReviewStatefulTestBase.java index 2157b67..76d573e 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/chatgpt/ChatGptReviewStatefulTestBase.java +++ b/src/test/java/com/googlesource/gerrit/plugins/chatgpt/ChatGptReviewStatefulTestBase.java
@@ -57,7 +57,7 @@ // Mock the Global Config values that differ from the ones provided by Default when(globalConfig.getString(Mockito.eq("gptMode"), Mockito.anyString())) - .thenReturn(Modes.stateful.name()); + .thenReturn(Modes.STATEFUL.name()); setupPluginData(); PluginDataHandlerProvider provider = new PluginDataHandlerProvider(mockPluginDataPath, getGerritChange());
diff --git a/src/test/java/com/googlesource/gerrit/plugins/chatgpt/ChatGptReviewTestBase.java b/src/test/java/com/googlesource/gerrit/plugins/chatgpt/ChatGptReviewTestBase.java index faa1077..cbb2956 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/chatgpt/ChatGptReviewTestBase.java +++ b/src/test/java/com/googlesource/gerrit/plugins/chatgpt/ChatGptReviewTestBase.java
@@ -403,17 +403,17 @@ private IChatGptClient getChatGptClient() { return switch (config.getGptMode()) { - case stateful -> config.getGptReviewCommitMessages() && config.getTaskSpecificAssistants() ? + case STATEFUL -> config.getGptReviewCommitMessages() && config.getTaskSpecificAssistants() ? new ChatGptClientStatefulTaskSpecific(config, gitRepoFiles, pluginDataHandlerProvider): new ChatGptClientStateful(config, gitRepoFiles, pluginDataHandlerProvider); - case stateless -> new ChatGptClientStateless(config); + case STATELESS -> new ChatGptClientStateless(config); }; } private IGerritClientPatchSet getGerritClientPatchSet() { return switch (config.getGptMode()) { - case stateful -> new GerritClientPatchSetStateful(config, accountCacheMock); - case stateless -> new GerritClientPatchSetStateless(config, accountCacheMock); + case STATEFUL -> new GerritClientPatchSetStateful(config, accountCacheMock); + case STATELESS -> new GerritClientPatchSetStateless(config, accountCacheMock); }; } }
diff --git a/src/test/resources/__files/commands/dumpConfig.txt b/src/test/resources/__files/commands/dumpConfig.txt index a7a03a0..4ac9f08 100644 --- a/src/test/resources/__files/commands/dumpConfig.txt +++ b/src/test/resources/__files/commands/dumpConfig.txt
@@ -55,7 +55,7 @@ gptConnectionTimeout: 30 gptDomain: http://localhost:9527 gptFullFileReview: true -gptMode: stateless +gptMode: STATELESS gptModel: gpt-4o gptPollingInterval: 1000 gptPollingTimeout: 180