Skip to content

Commit 7f68674

Browse files
authored
Merge pull request #453 from TESTARtool/llm_development
Add reasoning effort to OpenAI API
2 parents 562e4c3 + c74aba5 commit 7f68674

File tree

17 files changed

+193
-53
lines changed

17 files changed

+193
-53
lines changed

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
#TESTAR v2.7.13 (24-Oct-2025)
2+
- Add reasoning effort to OpenAI API
3+
- Update corresponding llm protocols
4+
5+
16
#TESTAR v2.7.12 (22-Oct-2025)
27
- Bump org.seleniumhq.selenium:selenium-java from 4.36.0 to 4.37.0
38
- Update devtools dependencies to v141

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.7.12
1+
2.7.13

testar/resources/settings/03_webdriver_llm_parabank/test.settings

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ AbstractStateAttributes = WebWidgetId,WebWidgetName
168168
#################################################################
169169

170170
LlmPlatform = OpenAI
171-
LlmModel = gpt-4o-mini
171+
LlmModel = gpt-5-mini
172+
LlmReasoning = minimal
172173
LlmHostUrl = https://api.openai.com/v1/chat/completions
173174
LlmAuthorizationHeader = Bearer %OPENAI_API%
174175
LlmActionFewshotFile = prompts/fewshot_openai_action.json

testar/resources/settings/webdriver_llm_state_model_evaluator/test.settings

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ AbstractStateAttributes = WebWidgetId,WebWidgetName,WebWidgetStyle
176176
#################################################################
177177

178178
LlmPlatform = OpenAI
179-
LlmModel = gpt-4o-mini
179+
LlmModel = gpt-5-mini
180+
LlmReasoning = minimal
180181
LlmHostUrl = https://api.openai.com/v1/chat/completions
181182
LlmAuthorizationHeader = Bearer %OPENAI_API%
182183
LlmActionFewshotFile = prompts/fewshot_openai_action.json

testar/resources/settings/webdriver_llm_state_model_transition_evaluator/test.settings

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ AbstractStateAttributes = WebWidgetId,WebWidgetName,WebWidgetStyle
176176
#################################################################
177177

178178
LlmPlatform = OpenAI
179-
LlmModel = gpt-4o-mini
179+
LlmModel = gpt-5-mini
180+
LlmReasoning = minimal
180181
LlmHostUrl = https://api.openai.com/v1/chat/completions
181182
LlmAuthorizationHeader = Bearer %OPENAI_API%
182183
LlmActionFewshotFile = prompts/fewshot_openai_action.json

testar/resources/settings/webdriver_llm_state_widgets_evaluator/test.settings

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ AbstractStateAttributes = WebWidgetId,WebWidgetName
176176
#################################################################
177177

178178
LlmPlatform = OpenAI
179-
LlmModel = gpt-4o-mini
179+
LlmModel = gpt-5-mini
180+
LlmReasoning = minimal
180181
LlmHostUrl = https://api.openai.com/v1/chat/completions
181182
LlmAuthorizationHeader = Bearer %OPENAI_API%
182183
LlmActionFewshotFile = prompts/fewshot_openai_action.json

testar/src/org/testar/action/priorization/llm/LlmActionSelector.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public class LlmActionSelector implements IActionSelector {
6666

6767
private final String platform;
6868
private final String model;
69+
private final String reasoning;
6970
private final String hostUrl;
7071
private final String authorizationHeader;
7172
private final String actionFewshotFile;
@@ -79,7 +80,6 @@ public class LlmActionSelector implements IActionSelector {
7980
private int tokens_used;
8081
private Integer invalidActions;
8182

82-
private Gson gson = new Gson();
8383
private String previousTestGoal = "";
8484
private LlmTestGoal currentTestGoal;
8585

@@ -97,6 +97,7 @@ public LlmActionSelector(Settings settings, IPromptActionGenerator generator) {
9797

9898
this.platform = settings.get(ConfigTags.LlmPlatform);
9999
this.model = settings.get(ConfigTags.LlmModel);
100+
this.reasoning = settings.get(ConfigTags.LlmReasoning);
100101
this.hostUrl = settings.get(ConfigTags.LlmHostUrl);
101102
this.authorizationHeader = settings.get(ConfigTags.LlmAuthorizationHeader);
102103
this.historySize = settings.get(ConfigTags.LlmHistorySize);
@@ -110,7 +111,7 @@ public LlmActionSelector(Settings settings, IPromptActionGenerator generator) {
110111
}
111112

112113
private void initializeConversation() {
113-
conversation = LlmFactory.createLlmConversation(this.platform, this.model, this.temperature);
114+
conversation = LlmFactory.createLlmConversation(this.platform, this.model, this.reasoning, this.temperature);
114115
conversation.initConversation(this.actionFewshotFile);
115116
}
116117

@@ -171,9 +172,9 @@ private Action selectActionWithLlm(State state, Set<Action> actions) {
171172
logger.log(Level.DEBUG, "Generated prompt: " + prompt);
172173
conversation.addMessage("user", prompt);
173174

174-
String conversationJson = gson.toJson(conversation);
175+
String conversationJson = conversation.buildRequestBody();
175176
String llmResponse = getResponseFromLlm(conversationJson);
176-
LlmParseActionResponse llmParseResponse = new LlmParseActionResponse(gson);
177+
LlmParseActionResponse llmParseResponse = new LlmParseActionResponse(new Gson());
177178
LlmParseActionResult llmParseResult = llmParseResponse.parseLlmResponse(actions, llmResponse);
178179

179180
switch(llmParseResult.getParseResult()) {

testar/src/org/testar/llm/LlmConversation.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
public interface LlmConversation {
4545
static final Logger logger = LogManager.getLogger();
4646

47+
public String buildRequestBody();
48+
4749
public void initConversation(String fewshotFile);
4850

4951
public void addMessage(String role, String textContent);

testar/src/org/testar/llm/LlmFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ public class LlmFactory {
5050
* @param temperature Lower values result in more predictable output, usually between 0-1f.
5151
* @return LlmConversation for the chosen platform.
5252
*/
53-
public static LlmConversation createLlmConversation(String platform, String model, float temperature) {
53+
public static LlmConversation createLlmConversation(String platform, String model, String reasoning, float temperature) {
5454
switch (platform) {
5555
case "OpenAI":
56-
return new LlmConversationOpenAI(model, temperature);
56+
return new LlmConversationOpenAI(model, reasoning, temperature);
5757
case "Gemini":
5858
return new LlmConversationGemini();
5959
default:

testar/src/org/testar/llm/gemini/LlmConversationGemini.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import org.testar.llm.LlmConversation;
4242

4343
import com.google.gson.Gson;
44+
import com.google.gson.GsonBuilder;
4445

4546
/**
4647
* Conversation with the Gemini LLM.
@@ -65,6 +66,12 @@ public List<Content> getContents() {
6566
return contents;
6667
}
6768

69+
@Override
70+
public String buildRequestBody() {
71+
// Serialization for Gemini
72+
return new GsonBuilder().create().toJson(this);
73+
}
74+
6875
@Override
6976
public void initConversation(String fewshotFile) {
7077
try {

0 commit comments

Comments
 (0)