Skip to content

Commit f47fe45

Browse files
authored
remove tests that depend on legacy model (#94)
* format * remove tests that depend on legacy model * Fix wiremock tests
1 parent 2d7368d commit f47fe45

File tree

15 files changed

+59
-43
lines changed

15 files changed

+59
-43
lines changed

api-test/integration-tests/src/test/java/com/microsoft/semantickernel/tests/Example05_InlineFunctionDefinitionTest.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;
77
import com.github.tomakehurst.wiremock.junit5.WireMockTest;
88
import com.microsoft.semantickernel.Kernel;
9+
import com.microsoft.semantickernel.aiservices.openai.chatcompletion.OpenAIChatCompletion;
910
import com.microsoft.semantickernel.orchestration.FunctionResult;
1011
import com.microsoft.semantickernel.orchestration.PromptExecutionSettings;
1112
import com.microsoft.semantickernel.semanticfunctions.KernelFunction;
@@ -27,13 +28,13 @@ public void main(WireMockRuntimeInfo wmRuntimeInfo) {
2728
.endpoint("http://localhost:" + wmRuntimeInfo.getHttpPort())
2829
.buildAsyncClient();
2930

30-
TextGenerationService textGenerationService = TextGenerationService.builder()
31+
OpenAIChatCompletion chatCompletion = OpenAIChatCompletion.builder()
3132
.withOpenAIAsyncClient(client)
32-
.withModelId("text-davinci-003")
33+
.withModelId("gpt-35-turbo")
3334
.build();
3435

3536
Kernel kernel = Kernel.builder()
36-
.withAIService(TextGenerationService.class, textGenerationService)
37+
.withAIService(OpenAIChatCompletion.class, chatCompletion)
3738
.build();
3839

3940
System.out.println("======== Inline Function Definition ========");
@@ -63,7 +64,7 @@ public void main(WireMockRuntimeInfo wmRuntimeInfo) {
6364
.build())
6465
.build();
6566

66-
WireMockUtil.mockCompletionResponse("I missed the F1 final race", "a-response");
67+
WireMockUtil.mockChatCompletionResponse("I missed the F1 final race", "a-response");
6768

6869
var result = kernel.invokeAsync(excuseFunction)
6970
.withArguments(
@@ -74,7 +75,7 @@ public void main(WireMockRuntimeInfo wmRuntimeInfo) {
7475

7576
Assertions.assertEquals("a-response", result.getResult());
7677

77-
WireMockUtil.mockCompletionResponse("sorry I forgot your birthday", "a-response-2");
78+
WireMockUtil.mockChatCompletionResponse("sorry I forgot your birthday", "a-response-2");
7879

7980
result = kernel.invokeAsync(excuseFunction)
8081
.withArguments(
@@ -85,7 +86,7 @@ public void main(WireMockRuntimeInfo wmRuntimeInfo) {
8586

8687
Assertions.assertEquals("a-response-2", result.getResult());
8788

88-
WireMockUtil.mockCompletionResponse("Translate this date ", "a-response-3");
89+
WireMockUtil.mockChatCompletionResponse("Translate this date ", "a-response-3");
8990

9091
var date = DateTimeFormatter.ISO_LOCAL_DATE.withZone(ZoneOffset.UTC)
9192
.format(Instant.ofEpochSecond(1));

api-test/integration-tests/src/test/java/com/microsoft/semantickernel/tests/KernelHooksTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ private static Builder getKernelBuilder(WireMockRuntimeInfo wmRuntimeInfo) {
2929
.buildAsyncClient();
3030

3131
ChatCompletionService openAIChatCompletion = OpenAIChatCompletion.builder()
32-
.withModelId("text-davinci-003")
32+
.withModelId("gpt-35-turbo")
3333
.withOpenAIAsyncClient(client)
3434
.build();
3535

api-test/integration-tests/src/test/java/com/microsoft/semantickernel/tests/WireMockUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public static void mockChatCompletionResponse(
116116
WireMock.reset();
117117
WireMock.stubFor(WireMock
118118
.post(new UrlPathPattern(
119-
new RegexPattern("/openai/deployments/text-davinci-003/chat/completions"), true))
119+
new RegexPattern("/openai/deployments/gpt-35-turbo/chat/completions"), true))
120120
.withRequestBody(WireMock.matching(".*" + regexMatcher + ".*"))
121121
.willReturn(WireMock.ok()
122122
.withBody(body)));

samples/semantickernel-concepts/semantickernel-syntax-examples/src/main/java/com/microsoft/semantickernel/samples/syntaxexamples/Example42_KernelBuilder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ public static void main(String[] args) {
4343
.credential(new KeyCredential("a-key"))
4444
.buildAsyncClient();
4545

46-
TextGenerationService textGenerationService = TextGenerationService.builder()
46+
ChatCompletionService openAIChatCompletion = OpenAIChatCompletion.builder()
47+
.withModelId("gpt-35-turbo")
4748
.withOpenAIAsyncClient(client2)
48-
.withModelId("text-davinci-003")
4949
.build();
5050

5151
Kernel kernel2 = Kernel.builder()
52-
.withAIService(TextGenerationService.class, textGenerationService)
52+
.withAIService(ChatCompletionService.class, openAIChatCompletion)
5353
.build();
5454
/////////////////////////////////////////////////////////
5555

samples/semantickernel-concepts/semantickernel-syntax-examples/src/main/java/com/microsoft/semantickernel/samples/syntaxexamples/RunAll.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
import com.microsoft.semantickernel.samples.syntaxexamples.functions.Example05_InlineFunctionDefinition;
1515
import com.microsoft.semantickernel.samples.syntaxexamples.functions.Example09_FunctionTypes;
1616
import com.microsoft.semantickernel.samples.syntaxexamples.functions.Example27_PromptFunctionsUsingChatGPT;
17+
import com.microsoft.semantickernel.samples.syntaxexamples.functions.Example59_OpenAIFunctionCalling;
1718
import com.microsoft.semantickernel.samples.syntaxexamples.functions.Example60_AdvancedMethodFunctions;
19+
import com.microsoft.semantickernel.samples.syntaxexamples.java.KernelFunctionYaml_Example;
20+
import com.microsoft.semantickernel.samples.syntaxexamples.memory.AzureAISearch;
1821
import com.microsoft.semantickernel.samples.syntaxexamples.plugins.Example10_DescribeAllPluginsAndFunctions;
1922
import com.microsoft.semantickernel.samples.syntaxexamples.plugins.Example13_ConversationSummaryPlugin;
2023
import com.microsoft.semantickernel.samples.syntaxexamples.template.Example06_TemplateLanguage;
@@ -35,35 +38,35 @@ public class RunAll {
3538

3639
public static void main(String[] args) {
3740
List<MainMethod> mains = Arrays.asList(
41+
AzureAISearch::main,
3842
Example01_NativeFunctions::main,
3943
Example03_Arguments::main,
4044
Example05_InlineFunctionDefinition::main,
4145
Example06_TemplateLanguage::main,
4246
Example08_RetryHandler::main,
4347
Example09_FunctionTypes::main,
4448
Example10_DescribeAllPluginsAndFunctions::main,
45-
//Example11_WebSearchQueries::main,
4649
Example13_ConversationSummaryPlugin::main,
4750
Example17_ChatGPT::main,
48-
//Example26_AADAuth::main,
49-
5051
Example27_PromptFunctionsUsingChatGPT::main,
5152
Example30_ChatWithPrompts::main,
5253
Example33_Chat::main,
5354
Example41_HttpClientUsage::main,
55+
Example42_KernelBuilder::main,
5456
Example43_GetModelResult::main,
5557
Example44_MultiChatCompletion::main,
5658
Example49_LogitBias::main,
5759
Example55_TextChunker::main,
5860
Example56_TemplateMethodFunctionsWithMultipleArguments::main,
5961
Example57_KernelHooks::main,
6062
Example58_ConfigureExecutionSettings::main,
63+
Example59_OpenAIFunctionCalling::main,
6164
Example60_AdvancedMethodFunctions::main,
62-
Example61_MultipleLLMs::main,
6365
Example62_CustomAIServiceSelector::main,
6466
Example63_ChatCompletionPrompts::main,
6567
Example64_MultiplePromptTemplates::main,
66-
Example69_MutableKernelPlugin::main);
68+
Example69_MutableKernelPlugin::main,
69+
KernelFunctionYaml_Example::main);
6770

6871
Scanner scanner = new Scanner(System.in);
6972
mains.forEach(mainMethod -> {

samples/semantickernel-concepts/semantickernel-syntax-examples/src/main/java/com/microsoft/semantickernel/samples/syntaxexamples/audio/Example82_Audio.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ public class Example82_Audio {
2222

2323
// Only required if AZURE_CLIENT_KEY is set
2424
private static final String CLIENT_ENDPOINT = System.getenv("CLIENT_ENDPOINT");
25-
private static final String MODEL_ID = System.getenv()
26-
.getOrDefault("MODEL_ID", "gpt-35-turbo");
2725

2826
private static final String TextToAudioModel = "tts-1";
2927
private static final String AudioToTextModel = "whisper-1";

samples/semantickernel-concepts/semantickernel-syntax-examples/src/main/java/com/microsoft/semantickernel/samples/syntaxexamples/configuration/Example08_RetryHandler.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,18 @@
77
import com.azure.core.http.policy.ExponentialBackoffOptions;
88
import com.azure.core.http.policy.RetryOptions;
99
import com.microsoft.semantickernel.Kernel;
10+
import com.microsoft.semantickernel.aiservices.openai.chatcompletion.OpenAIChatCompletion;
1011
import com.microsoft.semantickernel.exceptions.ConfigurationException;
1112
import com.microsoft.semantickernel.semanticfunctions.KernelFunction;
1213
import com.microsoft.semantickernel.semanticfunctions.KernelFunctionFromPrompt;
14+
import com.microsoft.semantickernel.services.chatcompletion.ChatCompletionService;
1315
import com.microsoft.semantickernel.services.textcompletion.TextGenerationService;
1416
import java.time.Duration;
1517

1618
public class Example08_RetryHandler {
1719

1820
private static final String MODEL_ID = System.getenv()
19-
.getOrDefault("MODEL_ID", "text-davinci-003");
21+
.getOrDefault("MODEL_ID", "gpt-35-turbo");
2022

2123
public static void main(String[] args) throws ConfigurationException {
2224
// Create a Kernel with the HttpClient
@@ -31,13 +33,13 @@ public static void main(String[] args) throws ConfigurationException {
3133
.credential(new AzureKeyCredential("BAD KEY"))
3234
.buildAsyncClient();
3335

34-
TextGenerationService textGenerationService = TextGenerationService.builder()
36+
ChatCompletionService openAIChatCompletion = OpenAIChatCompletion.builder()
3537
.withOpenAIAsyncClient(client)
3638
.withModelId(MODEL_ID)
3739
.build();
3840

3941
Kernel kernel = Kernel.builder()
40-
.withAIService(TextGenerationService.class, textGenerationService)
42+
.withAIService(ChatCompletionService.class, openAIChatCompletion)
4143
.build();
4244

4345
String question = "How popular is the Polly library?";

samples/semantickernel-concepts/semantickernel-syntax-examples/src/main/java/com/microsoft/semantickernel/samples/syntaxexamples/configuration/Example41_HttpClientUsage.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ private static void useCustomHttpClient() {
4747
.credential(new AzureKeyCredential("BAD KEY"))
4848
.buildAsyncClient();
4949

50-
TextGenerationService textGenerationService = TextGenerationService.builder()
50+
ChatCompletionService openAIChatCompletion = OpenAIChatCompletion.builder()
5151
.withOpenAIAsyncClient(client)
52-
.withModelId("text-davinci-003")
52+
.withModelId("gpt-35-turbo")
5353
.build();
5454

5555
Kernel kernel = Kernel.builder()
56-
.withAIService(TextGenerationService.class, textGenerationService)
56+
.withAIService(ChatCompletionService.class, openAIChatCompletion)
5757
.build();
5858
}
5959
}

samples/semantickernel-concepts/semantickernel-syntax-examples/src/main/java/com/microsoft/semantickernel/samples/syntaxexamples/functions/Example05_InlineFunctionDefinition.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
import com.azure.core.credential.AzureKeyCredential;
77
import com.azure.core.credential.KeyCredential;
88
import com.microsoft.semantickernel.Kernel;
9+
import com.microsoft.semantickernel.aiservices.openai.chatcompletion.OpenAIChatCompletion;
910
import com.microsoft.semantickernel.exceptions.ConfigurationException;
1011
import com.microsoft.semantickernel.orchestration.FunctionResult;
1112
import com.microsoft.semantickernel.orchestration.PromptExecutionSettings;
1213
import com.microsoft.semantickernel.semanticfunctions.KernelFunction;
1314
import com.microsoft.semantickernel.semanticfunctions.KernelFunctionArguments;
1415
import com.microsoft.semantickernel.semanticfunctions.KernelFunctionFromPrompt;
16+
import com.microsoft.semantickernel.services.chatcompletion.ChatCompletionService;
1517
import com.microsoft.semantickernel.services.textcompletion.TextGenerationService;
1618
import java.time.Instant;
1719
import java.time.ZoneOffset;
@@ -25,7 +27,7 @@ public class Example05_InlineFunctionDefinition {
2527
// Only required if AZURE_CLIENT_KEY is set
2628
private static final String CLIENT_ENDPOINT = System.getenv("CLIENT_ENDPOINT");
2729
private static final String MODEL_ID = System.getenv()
28-
.getOrDefault("MODEL_ID", "text-davinci-003");
30+
.getOrDefault("MODEL_ID", "gpt-35-turbo");
2931

3032
public static void main(String[] args) throws ConfigurationException {
3133

@@ -42,13 +44,13 @@ public static void main(String[] args) throws ConfigurationException {
4244
.buildAsyncClient();
4345
}
4446

45-
TextGenerationService textGenerationService = TextGenerationService.builder()
47+
ChatCompletionService openAIChatCompletion = OpenAIChatCompletion.builder()
4648
.withOpenAIAsyncClient(client)
4749
.withModelId(MODEL_ID)
4850
.build();
4951

5052
Kernel kernel = Kernel.builder()
51-
.withAIService(TextGenerationService.class, textGenerationService)
53+
.withAIService(ChatCompletionService.class, openAIChatCompletion)
5254
.build();
5355

5456
System.out.println("======== Inline Function Definition ========");

samples/semantickernel-concepts/semantickernel-syntax-examples/src/main/java/com/microsoft/semantickernel/samples/syntaxexamples/functions/Example09_FunctionTypes.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.azure.core.credential.AzureKeyCredential;
99
import com.azure.core.credential.KeyCredential;
1010
import com.microsoft.semantickernel.Kernel;
11+
import com.microsoft.semantickernel.aiservices.openai.chatcompletion.OpenAIChatCompletion;
1112
import com.microsoft.semantickernel.aiservices.openai.textcompletion.OpenAITextGenerationService;
1213
import com.microsoft.semantickernel.contextvariables.ContextVariable;
1314
import com.microsoft.semantickernel.contextvariables.ContextVariableType;
@@ -19,6 +20,7 @@
1920
import com.microsoft.semantickernel.semanticfunctions.KernelFunctionArguments;
2021
import com.microsoft.semantickernel.semanticfunctions.annotations.DefineKernelFunction;
2122
import com.microsoft.semantickernel.semanticfunctions.annotations.KernelFunctionParameter;
23+
import com.microsoft.semantickernel.services.chatcompletion.ChatCompletionService;
2224
import com.microsoft.semantickernel.services.textcompletion.TextGenerationService;
2325
import java.nio.file.Path;
2426
import java.time.Instant;
@@ -42,7 +44,7 @@ public class Example09_FunctionTypes {
4244
// Only required if AZURE_CLIENT_KEY is set
4345
private static final String CLIENT_ENDPOINT = System.getenv("CLIENT_ENDPOINT");
4446
private static final String MODEL_ID = System.getenv()
45-
.getOrDefault("MODEL_ID", "text-davinci-003");
47+
.getOrDefault("MODEL_ID", "gpt-35-turbo");
4648

4749
public static void main(String[] args) throws InterruptedException {
4850

@@ -61,7 +63,7 @@ public static void main(String[] args) throws InterruptedException {
6163
.buildAsyncClient();
6264
}
6365

64-
TextGenerationService textGenerationService = OpenAITextGenerationService.builder()
66+
ChatCompletionService openAIChatCompletion = OpenAIChatCompletion.builder()
6567
.withOpenAIAsyncClient(client)
6668
.withModelId(MODEL_ID)
6769
.build();
@@ -86,7 +88,7 @@ public static void main(String[] args) throws InterruptedException {
8688
Example09_FunctionTypes.class);
8789

8890
Kernel kernel = Kernel.builder()
89-
.withAIService(TextGenerationService.class, textGenerationService)
91+
.withAIService(ChatCompletionService.class, openAIChatCompletion)
9092
.withPlugin(plugin)
9193
.withPlugin(summarize)
9294
.withPlugin(examplePlugin)

0 commit comments

Comments
 (0)