Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,34 +1,39 @@
package org.togetherjava.tjbot.features.chatgpt;

import com.openai.models.ChatModel;
import com.openai.models.Reasoning;
import com.openai.models.ReasoningEffort;

/**
* Logical abstraction over OpenAI chat models.
* <p>
* This enum allows the application to select models based on performance/quality intent rather than
* hard-coding specific OpenAI model versions throughout the codebase.
* This enum allows the application to select models and reasoning efforts based on
* performance/quality intent rather than hard-coding specific OpenAI model versions throughout the
* codebase.
*
*/
public enum ChatGptModel {
/**
* Fastest response time with the lowest computational cost.
*/
FASTEST(ChatModel.GPT_3_5_TURBO),
FASTEST(ChatModel.GPT_6_LUNA, ReasoningEffort.NONE),

/**
* Balanced option between speed and quality.
*/
FAST(ChatModel.GPT_4_1_MINI),
FAST(ChatModel.GPT_6_LUNA, ReasoningEffort.LOW),

/**
* Highest quality responses with increased reasoning capability.
*/
HIGH_QUALITY(ChatModel.GPT_5_MINI);
HIGH_QUALITY(ChatModel.GPT_6_LUNA, ReasoningEffort.MEDIUM);

private final ChatModel chatModel;
private final ReasoningEffort reasoningEffort;

ChatGptModel(ChatModel chatModel) {
ChatGptModel(ChatModel chatModel, ReasoningEffort reasoningEffort) {
this.chatModel = chatModel;
this.reasoningEffort = reasoningEffort;
}

/**
Expand All @@ -38,6 +43,20 @@ public ChatModel toChatModel() {
return chatModel;
}

/**
* @return the reasoning effort used by this enum.
*/
public ReasoningEffort toReasoningEffort() {
return reasoningEffort;
}

/**
* @return the reasoning used by this enum.
*/
public Reasoning toReasoning() {
return Reasoning.builder().effort(reasoningEffort).build();
}

@Override
public String toString() {
return chatModel.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ private Optional<String> sendPrompt(String prompt, ChatGptModel chatModel,
try {
ResponseCreateParams.Builder paramsBuilder = ResponseCreateParams.builder()
.model(chatModel.toChatModel())
.reasoning(chatModel.toReasoning())
.input(prompt)
.maxOutputTokens(MAX_TOKENS);

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ version '1.0-SNAPSHOT'
ext {
jooqVersion = '3.21.2'
jacksonVersion = '2.19.1'
chatGPTVersion = '4.58.0'
chatGPTVersion = '4.109.0'
junitVersion = '6.1.0'
}

Expand Down
Loading