io.codemodder.plugins.llm.StandardModel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of codemodder-plugin-llm Show documentation
Show all versions of codemodder-plugin-llm Show documentation
Codemod plugin for augmenting transformation with LLM assisted analysis and fixes
package io.codemodder.plugins.llm;
import com.knuddels.jtokkit.api.EncodingType;
import com.theokanning.openai.completion.chat.ChatMessage;
import java.util.List;
/** Well-known GPT models used in Codemod development. */
public enum StandardModel implements Model {
GPT_3_5_TURBO("gpt-3.5-turbo-0125", 16_385) {
@Override
public int tokens(final List messages) {
return Tokens.countTokens(messages, 3, EncodingType.CL100K_BASE);
}
},
GPT_4("gpt-4-0613", 8_192) {
@Override
public int tokens(final List messages) {
return Tokens.countTokens(messages, 3, EncodingType.CL100K_BASE);
}
},
GPT_4O("gpt-4o-2024-05-13", 128_000) {
/**
* This is wrong - we copy / pasted from GPT 3.5 while we await GPT-4o token counting support from upstream utility.
*/
@Override
public int tokens(final List messages) {
return Tokens.countTokens(messages, 3, EncodingType.CL100K_BASE);
}
};
private final String id;
private final int contextWindow;
StandardModel(final String id, final int contextWindow) {
this.id = id;
this.contextWindow = contextWindow;
}
@Override
public String id() {
return id;
}
@Override
public int contextWindow() {
return contextWindow;
}
}