Skip to content

Commit c58ccf3

Browse files
authored
Add gpt-4-turbo model; use for code changing (#416)
Without function calling, we need to use models that support `json_object` as a response format. At some point we should revisit function calling with the new client, but it seems substantially more complicated than the old API. It also appears to be deprecated in favor of "tool calling"": > For function call sample, see [function call](https://github.com/Azure/azure-sdk-for-java/tree/azure-ai-openai_1.0.0-beta.10/sdk/openai/azure-ai-openai/src/samples/java/com/azure/ai/openai/ChatCompletionsFunctionCall.java). However, they are considered a legacy feature. Using tools is the preferred way. For more details see sample [tool calls](https://github.com/Azure/azure-sdk-for-java/blob/azure-ai-openai_1.0.0-beta.10/sdk/openai/azure-ai-openai/src/samples/java/com/azure/ai/openai/usage/GetChatCompletionsToolCallSample.java). https://learn.microsoft.com/en-us/java/api/overview/azure/ai-openai-readme?view=azure-java-preview#chat-completions
1 parent 98991c0 commit c58ccf3

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

core-codemods/src/main/java/io/codemodder/codemods/LogFailedLoginCodemod.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public LogFailedLoginCodemod(
6868
"""
6969
.replace('\n', ' '))),
7070
StandardModel.GPT_4O_2024_05_13,
71-
StandardModel.GPT_4_0613);
71+
StandardModel.GPT_4_TURBO_2024_04_09);
7272
}
7373

7474
@Override

plugins/codemodder-plugin-llm/src/main/java/io/codemodder/plugins/llm/SarifToLLMForBinaryVerificationAndFixingCodemod.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package io.codemodder.plugins.llm;
22

3-
import static io.codemodder.plugins.llm.StandardModel.GPT_3_5_TURBO_0125;
3+
import static io.codemodder.plugins.llm.StandardModel.GPT_4_TURBO_2024_04_09;
44

55
import com.azure.ai.openai.models.ChatRequestSystemMessage;
66
import com.azure.ai.openai.models.ChatRequestUserMessage;
@@ -47,7 +47,7 @@ protected SarifToLLMForBinaryVerificationAndFixingCodemod(
4747
*/
4848
protected SarifToLLMForBinaryVerificationAndFixingCodemod(
4949
final RuleSarif sarif, final OpenAIService openAI) {
50-
this(sarif, openAI, GPT_3_5_TURBO_0125);
50+
this(sarif, openAI, GPT_4_TURBO_2024_04_09);
5151
}
5252

5353
@Override

plugins/codemodder-plugin-llm/src/main/java/io/codemodder/plugins/llm/SarifToLLMForMultiOutcomeCodemod.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ protected SarifToLLMForMultiOutcomeCodemod(
5656
openAI,
5757
remediationOutcomes,
5858
StandardModel.GPT_4O_2024_05_13,
59-
StandardModel.GPT_4_0613);
59+
StandardModel.GPT_4_TURBO_2024_04_09);
6060
}
6161

6262
protected SarifToLLMForMultiOutcomeCodemod(

plugins/codemodder-plugin-llm/src/main/java/io/codemodder/plugins/llm/StandardModel.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ public int tokens(final List<String> messages) {
1717
return Tokens.countTokens(messages, 3, EncodingType.CL100K_BASE);
1818
}
1919
},
20+
GPT_4_TURBO_2024_04_09("gpt-4-turbo-2024-04-09", 128_000) {
21+
@Override
22+
public int tokens(final List<String> messages) {
23+
return Tokens.countTokens(messages, 3, EncodingType.CL100K_BASE);
24+
}
25+
},
2026
GPT_4O_2024_05_13("gpt-4o-2024-05-13", 128_000) {
2127
/**
2228
* This is wrong - we copy / pasted from GPT 3.5 while we await GPT-4o token counting support <a

0 commit comments

Comments
 (0)