Skip to content

Commit 3128efc

Browse files
committed
Support max_completion_tokens and bump maven versions
1 parent 55f5d71 commit 3128efc

25 files changed

Lines changed: 178 additions & 110 deletions

File tree

aiservices/google/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<dependency>
1818
<groupId>com.google.cloud</groupId>
1919
<artifactId>libraries-bom</artifactId>
20-
<version>26.49.0</version>
20+
<version>26.80.0</version>
2121
<type>pom</type>
2222
<scope>import</scope>
2323
</dependency>

aiservices/huggingface/src/main/java/com/microsoft/semantickernel/aiservices/huggingface/services/HuggingFacePromptExecutionSettings.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ public HuggingFacePromptExecutionSettings(PromptExecutionSettings copy) {
4747
copy.getUser(),
4848
copy.getStopSequences(),
4949
copy.getTokenSelectionBiases(),
50-
copy.getResponseFormat() == null ? null : copy.getResponseFormat());
50+
copy.getResponseFormat() == null ? null : copy.getResponseFormat(),
51+
copy.getMaxCompletionTokens() == null ? null : copy.getMaxCompletionTokens().toString());
5152
this.topK = null;
5253
this.repetitionPenalty = null;
5354
this.maxTime = null;
@@ -101,10 +102,11 @@ public HuggingFacePromptExecutionSettings(
101102
@Nullable Boolean details,
102103
@Nullable Boolean logProbs,
103104
@Nullable Integer topLogProbs,
104-
@Nullable Long seed) {
105+
@Nullable Long seed,
106+
@Nullable Boolean maxCompletionTokens) {
105107
super(
106108
serviceId, modelId, temperature, topP, presencePenalty, frequencyPenalty, maxTokens,
107-
resultsPerPrompt, bestOf, user, stopSequences, tokenSelectionBiases, responseFormat);
109+
resultsPerPrompt, bestOf, user, stopSequences, tokenSelectionBiases, responseFormat, Boolean.toString(maxCompletionTokens));
108110

109111
this.topK = topK;
110112
this.repetitionPenalty = repetitionPenalty;
@@ -151,6 +153,7 @@ public static HuggingFacePromptExecutionSettings fromExecutionSettings(
151153
null,
152154
null,
153155
null,
156+
null,
154157
null);
155158
}
156159

aiservices/openai/src/main/java/com/microsoft/semantickernel/aiservices/openai/chatcompletion/OpenAIChatCompletion.java

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@
6565
import com.microsoft.semantickernel.orchestration.ToolCallBehavior;
6666
import com.microsoft.semantickernel.orchestration.responseformat.JsonResponseSchema;
6767
import com.microsoft.semantickernel.orchestration.responseformat.JsonSchemaResponseFormat;
68-
import com.microsoft.semantickernel.semanticfunctions.KernelFunction;
6968
import com.microsoft.semantickernel.semanticfunctions.KernelArguments;
69+
import com.microsoft.semantickernel.semanticfunctions.KernelFunction;
7070
import com.microsoft.semantickernel.services.chatcompletion.AuthorRole;
7171
import com.microsoft.semantickernel.services.chatcompletion.ChatCompletionService;
7272
import com.microsoft.semantickernel.services.chatcompletion.ChatHistory;
@@ -149,7 +149,7 @@ public Mono<List<ChatMessageContent<?>>> getChatMessageContentsAsync(
149149

150150
if (invocationContext != null
151151
&& invocationContext
152-
.returnMode() == InvocationReturnMode.LAST_MESSAGE_ONLY) {
152+
.returnMode() == InvocationReturnMode.LAST_MESSAGE_ONLY) {
153153
chatHistoryResult = new ChatHistory(
154154
Collections.singletonList(
155155
CollectionUtil.getLastOrNull(chatHistoryResult.getMessages())));
@@ -183,7 +183,7 @@ public Mono<List<ChatMessageContent<?>>> getChatMessageContentsAsync(
183183

184184
if (invocationContext != null
185185
&& invocationContext
186-
.returnMode() == InvocationReturnMode.LAST_MESSAGE_ONLY) {
186+
.returnMode() == InvocationReturnMode.LAST_MESSAGE_ONLY) {
187187
result = new ChatHistory(
188188
Collections.singletonList(
189189
CollectionUtil.getLastOrNull(result.getMessages())));
@@ -443,31 +443,31 @@ private Mono<ChatMessages> internalChatMessageContentsAsync(
443443
.getOptions();
444444

445445
return Mono.deferContextual(contextView -> {
446-
ChatCompletionSpan span = ChatCompletionSpan.startChatCompletionSpan(
447-
SemanticKernelTelemetry.getTelemetry(invocationContext),
448-
contextView,
449-
getModelId(),
450-
SemanticKernelTelemetry.OPEN_AI_PROVIDER,
451-
options.getMaxTokens(),
452-
options.getTemperature(),
453-
options.getTopP());
454-
455-
return getClient()
456-
.getChatCompletionsWithResponse(getDeploymentName(), options,
457-
OpenAIRequestSettings.getRequestOptions())
458-
.contextWrite(span.getReactorContextModifier())
459-
.flatMap(completionsResult -> {
460-
if (completionsResult.getStatusCode() >= 400) {
461-
return Mono.error(new AIException(ErrorCodes.SERVICE_ERROR,
462-
"Request failed: " + completionsResult.getStatusCode()));
463-
}
446+
ChatCompletionSpan span = ChatCompletionSpan.startChatCompletionSpan(
447+
SemanticKernelTelemetry.getTelemetry(invocationContext),
448+
contextView,
449+
getModelId(),
450+
SemanticKernelTelemetry.OPEN_AI_PROVIDER,
451+
options.getMaxTokens(),
452+
options.getTemperature(),
453+
options.getTopP());
454+
455+
return getClient()
456+
.getChatCompletionsWithResponse(getDeploymentName(), options,
457+
OpenAIRequestSettings.getRequestOptions())
458+
.contextWrite(span.getReactorContextModifier())
459+
.flatMap(completionsResult -> {
460+
if (completionsResult.getStatusCode() >= 400) {
461+
return Mono.error(new AIException(ErrorCodes.SERVICE_ERROR,
462+
"Request failed: " + completionsResult.getStatusCode()));
463+
}
464464

465-
return Mono.just(completionsResult.getValue());
466-
})
467-
.doOnError(span::endSpanWithError)
468-
.doOnSuccess(span::endSpanWithUsage)
469-
.doOnTerminate(span::close);
470-
})
465+
return Mono.just(completionsResult.getValue());
466+
})
467+
.doOnError(span::endSpanWithError)
468+
.doOnSuccess(span::endSpanWithUsage)
469+
.doOnTerminate(span::close);
470+
})
471471
.flatMap(completions -> {
472472
List<ChatResponseMessage> responseMessages = completions
473473
.getChoices()
@@ -920,7 +920,8 @@ private static ChatCompletionsOptions getCompletionsOptions(
920920
}
921921

922922
Map<String, Integer> logit = null;
923-
if (promptExecutionSettings.getTokenSelectionBiases() != null) {
923+
if (promptExecutionSettings.getTokenSelectionBiases() != null
924+
&& !promptExecutionSettings.getTokenSelectionBiases().isEmpty()) {
924925
logit = promptExecutionSettings
925926
.getTokenSelectionBiases()
926927
.entrySet()
@@ -937,12 +938,13 @@ private static ChatCompletionsOptions getCompletionsOptions(
937938
.setFrequencyPenalty(promptExecutionSettings.getFrequencyPenalty())
938939
.setPresencePenalty(promptExecutionSettings.getPresencePenalty())
939940
.setMaxTokens(promptExecutionSettings.getMaxTokens())
941+
.setMaxCompletionTokens(promptExecutionSettings.getMaxCompletionTokens())
940942
.setN(promptExecutionSettings.getResultsPerPrompt())
941943
// Azure OpenAI WithData API does not allow to send empty array of stop sequences
942944
// Gives back "Validation error at #/stop/str: Input should be a valid string\nValidation error at #/stop/list[str]: List should have at least 1 item after validation, not 0"
943945
.setStop(promptExecutionSettings.getStopSequences() == null
944946
|| promptExecutionSettings.getStopSequences().isEmpty() ? null
945-
: promptExecutionSettings.getStopSequences())
947+
: promptExecutionSettings.getStopSequences())
946948
.setUser(promptExecutionSettings.getUser())
947949
.setLogitBias(logit);
948950

@@ -1147,7 +1149,7 @@ private static OpenAIToolCallConfig getToolCallBehaviorConfig(
11471149
toolChoice,
11481150
toolCallBehavior.isAutoInvokeAllowed()
11491151
&& requestIndex < Math.min(MAXIMUM_INFLIGHT_AUTO_INVOKES,
1150-
toolCallBehavior.getMaximumAutoInvokeAttempts()),
1152+
toolCallBehavior.getMaximumAutoInvokeAttempts()),
11511153
null);
11521154
}
11531155

@@ -1262,11 +1264,11 @@ private static ChatRequestAssistantMessage formAssistantMessage(
12621264

12631265
String args = arguments != null && !arguments.isEmpty()
12641266
? arguments.entrySet().stream()
1265-
.map(entry -> String.format("\"%s\": \"%s\"",
1266-
StringEscapeUtils.escapeJson(entry.getKey()),
1267-
StringEscapeUtils.escapeJson(
1268-
entry.getValue().toPromptString())))
1269-
.collect(Collectors.joining(",", "{", "}"))
1267+
.map(entry -> String.format("\"%s\": \"%s\"",
1268+
StringEscapeUtils.escapeJson(entry.getKey()),
1269+
StringEscapeUtils.escapeJson(
1270+
entry.getValue().toPromptString())))
1271+
.collect(Collectors.joining(",", "{", "}"))
12701272
: "{}";
12711273

12721274
String prefix = "";

api-test/integration-tests/pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,18 @@
9090
<dependency>
9191
<groupId>com.mysql</groupId>
9292
<artifactId>mysql-connector-j</artifactId>
93-
<version>9.0.0</version>
93+
<version>9.6.0</version>
9494
<scope>test</scope>
9595
</dependency>
9696
<dependency>
9797
<groupId>org.postgresql</groupId>
9898
<artifactId>postgresql</artifactId>
99-
<version>42.7.3</version> <!-- Use the latest version -->
99+
<version>42.7.10</version> <!-- Use the latest version -->
100100
</dependency>
101101
<dependency>
102102
<groupId>org.xerial</groupId>
103103
<artifactId>sqlite-jdbc</artifactId>
104-
<version>3.46.1.0</version>
104+
<version>3.53.0.0</version>
105105
</dependency>
106106

107107
<dependency>
@@ -147,7 +147,7 @@
147147
<dependency>
148148
<groupId>org.hsqldb</groupId>
149149
<artifactId>hsqldb</artifactId>
150-
<version>2.7.3</version>
150+
<version>2.7.4</version>
151151
<scope>test</scope>
152152
</dependency>
153153
<dependency>
@@ -162,7 +162,7 @@
162162
<dependency>
163163
<groupId>org.testcontainers</groupId>
164164
<artifactId>testcontainers-bom</artifactId>
165-
<version>1.21.4</version>
165+
<version>2.0.4</version>
166166
<type>pom</type>
167167
<scope>import</scope>
168168
</dependency>

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import com.microsoft.semantickernel.Kernel;
55
import com.microsoft.semantickernel.plugin.KernelPlugin;
66
import com.microsoft.semantickernel.plugin.KernelPluginFactory;
7-
import org.junit.Ignore;
87
import org.junit.jupiter.api.Assertions;
98
import org.junit.jupiter.api.Disabled;
109
import org.junit.jupiter.api.Test;

data/semantickernel-data-jdbc/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,17 @@
6666
<dependency>
6767
<groupId>org.postgresql</groupId>
6868
<artifactId>postgresql</artifactId>
69-
<version>42.7.7</version>
69+
<version>42.7.10</version>
7070
</dependency>
7171
<dependency>
7272
<groupId>org.xerial</groupId>
7373
<artifactId>sqlite-jdbc</artifactId>
74-
<version>3.47.0.0</version>
74+
<version>3.53.0.0</version>
7575
</dependency>
7676
<dependency>
7777
<groupId>com.oracle.database.jdbc</groupId>
7878
<artifactId>ojdbc11</artifactId>
79-
<version>23.7.0.25.01</version>
79+
<version>23.26.1.0.0</version>
8080
</dependency>
8181
</dependencies>
8282
</project>

data/semantickernel-data-oracle/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@
6161
<dependency>
6262
<groupId>com.oracle.database.jdbc</groupId>
6363
<artifactId>ojdbc11</artifactId>
64-
<version>23.7.0.25.01</version>
64+
<version>23.26.1.0.0</version>
6565
</dependency>
6666
<dependency>
6767
<groupId>com.oracle.database.jdbc</groupId>
6868
<artifactId>ojdbc-provider-jackson-oson</artifactId>
69-
<version>1.0.4</version>
69+
<version>1.0.6</version>
7070
</dependency>
7171
<dependency>
7272
<groupId>org.junit.jupiter</groupId>

data/semantickernel-data-oracle/src/test/java/com/microsoft/semantickernel/data/jdbc/oracle/Hotel.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,8 @@
88
import com.microsoft.semantickernel.data.vectorstorage.annotations.VectorStoreRecordVector;
99
import com.microsoft.semantickernel.data.vectorstorage.definition.DistanceFunction;
1010
import com.microsoft.semantickernel.data.vectorstorage.definition.IndexKind;
11-
1211
import java.util.List;
1312

14-
import static com.fasterxml.jackson.annotation.JsonCreator.Mode.DELEGATING;
15-
import static com.fasterxml.jackson.annotation.JsonCreator.Mode.PROPERTIES;
16-
1713
public class Hotel {
1814
@VectorStoreRecordKey
1915
private final String id;
@@ -52,13 +48,8 @@ public class Hotel {
5248
@VectorStoreRecordData
5349
private double rating;
5450

55-
@JsonCreator(mode = DELEGATING)
56-
public Hotel() {
57-
this(null, null, 0, 0d, null, null, null, null, null, null, 0.0);
58-
}
59-
60-
@JsonCreator(mode = PROPERTIES)
61-
protected Hotel(
51+
@JsonCreator
52+
public Hotel(
6253
@JsonProperty("id") String id,
6354
@JsonProperty("name") String name,
6455
@JsonProperty("code") int code,

data/semantickernel-data-postgres/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<dependency>
5252
<groupId>org.postgresql</groupId>
5353
<artifactId>postgresql</artifactId>
54-
<version>42.7.7</version>
54+
<version>42.7.10</version>
5555
</dependency>
5656
</dependencies>
5757
</project>

data/semantickernel-data-sqlite/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
<dependency>
5353
<groupId>org.xerial</groupId>
5454
<artifactId>sqlite-jdbc</artifactId>
55-
<version>3.47.0.0</version>
55+
<version>3.53.0.0</version>
5656
</dependency>
5757
</dependencies>
5858
</project>

0 commit comments

Comments
 (0)