Skip to content

Commit

Permalink
fix: remove deprecated image and change the default to the best and c…
Browse files Browse the repository at this point in the history
…heapest one
  • Loading branch information
anna-geller committed Aug 9, 2024
1 parent 85cece7 commit 15a0d65
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/main/java/io/kestra/plugin/openai/ChatCompletion.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
" - id: completion",
" type: io.kestra.plugin.openai.ChatCompletion",
" apiKey: \"yourOpenAIapiKey\"",
" model: gpt-3.5-turbo-0613",
" model: gpt-4o",
" prompt: \"{{inputs.prompt}}\"",
"",
" - id: response",
Expand All @@ -72,7 +72,7 @@
" - id: prioritize_response",
" type: io.kestra.plugin.openai.ChatCompletion",
" apiKey: \"yourOpenAIapiKey\"",
" model: gpt-4",
" model: gpt-4o",
" messages:",
" - role: user",
" content: \"{{ inputs.prompt }}\"",
Expand Down
20 changes: 10 additions & 10 deletions src/test/java/io/kestra/plugin/openai/ChatCompletionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ void runMessages() throws Exception {

ChatCompletion task = ChatCompletion.builder()
.apiKey(this.apiKey)
.model("gpt-3.5-turbo-0613")
.model("gpt-4o")
.clientTimeout(30)
.messages(messages)
.build();

ChatCompletion.Output runOutput = task.run(runContext);

assertThat(runOutput.getChoices().get(0).getMessage().getContent(), containsString("Paris"));
assertThat(runOutput.getModel(), containsString("gpt-3.5-turbo"));
assertThat(runOutput.getModel(), containsString("gpt-4o"));
assertThat(runOutput.getUsage().getPromptTokens(), is(14L));
}

Expand All @@ -52,14 +52,14 @@ void runPrompt() throws Exception {

ChatCompletion task = ChatCompletion.builder()
.apiKey(this.apiKey)
.model("gpt-3.5-turbo")
.model("gpt-4o")
.prompt("what is the capital of France?")
.build();

ChatCompletion.Output runOutput = task.run(runContext);

assertThat(runOutput.getChoices().get(0).getMessage().getContent(), containsString("Paris"));
assertThat(runOutput.getModel(), containsString("gpt-3.5-turbo"));
assertThat(runOutput.getModel(), containsString("gpt-4o"));
assertThat(runOutput.getUsage().getPromptTokens(), is(14L));
}

Expand All @@ -74,15 +74,15 @@ void runMessagesWithPrompt() throws Exception {

ChatCompletion task = ChatCompletion.builder()
.apiKey(this.apiKey)
.model("gpt-3.5-turbo-0613")
.model("gpt-4o")
.messages(messages)
.prompt("and the capital of germany?")
.build();

ChatCompletion.Output runOutput = task.run(runContext);

assertThat(runOutput.getChoices().get(0).getMessage().getContent(), containsString("Berlin"));
assertThat(runOutput.getModel(), containsString("gpt-3.5-turbo"));
assertThat(runOutput.getModel(), containsString("gpt-4o"));
assertThat(runOutput.getUsage().getPromptTokens(), is(35L));
}

Expand Down Expand Up @@ -120,7 +120,7 @@ void runFunction() throws Exception {

ChatCompletion task = ChatCompletion.builder()
.apiKey(this.apiKey)
.model("gpt-3.5-turbo")
.model("gpt-4o")
.messages(messages)
.functions(functions)
.functionCall("auto")
Expand All @@ -131,7 +131,7 @@ void runFunction() throws Exception {

assertThat(functionCall.getName(), containsString("test"));
assertThat(functionCall.getArguments().get("location").toString(), containsString("Lyon"));
assertThat(runOutput.getModel(), containsString("gpt-3.5-turbo"));
assertThat(runOutput.getModel(), containsString("gpt-4o"));
}

@Test
Expand Down Expand Up @@ -174,7 +174,7 @@ void runFunctionWithEnumValues() throws Exception {

ChatCompletion task = ChatCompletion.builder()
.apiKey(this.apiKey)
.model("gpt-3.5-turbo")
.model("gpt-4o")
.messages(messages)
.functions(functions)
.functionCall("record_customer_rating")
Expand All @@ -189,7 +189,7 @@ void runFunctionWithEnumValues() throws Exception {
.get("food_eaten").toString()
.toLowerCase(), containsString("steak"));
assertThat(functionCall.getArguments().get("customer_name").toString(), containsString("John Smith"));
assertThat(runOutput.getModel(), containsString("gpt-3.5-turbo"));
assertThat(runOutput.getModel(), containsString("gpt-4o"));
}

private ChatMessage buildMessage(String role, String content) {
Expand Down

0 comments on commit 15a0d65

Please sign in to comment.