Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion agents/semantickernel-agents-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.microsoft.semantic-kernel</groupId>
<artifactId>semantickernel-parent</artifactId>
<version>1.4.4-RC3-SNAPSHOT</version>
<version>1.4.5-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
4 changes: 2 additions & 2 deletions aiservices/google/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.microsoft.semantic-kernel</groupId>
<artifactId>semantickernel-parent</artifactId>
<version>1.4.4-RC3-SNAPSHOT</version>
<version>1.4.5-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand All @@ -17,7 +17,7 @@
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>26.49.0</version>
<version>26.80.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion aiservices/huggingface/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.microsoft.semantic-kernel</groupId>
<artifactId>semantickernel-parent</artifactId>
<version>1.4.4-RC3-SNAPSHOT</version>
<version>1.4.5-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public HuggingFacePromptExecutionSettings(PromptExecutionSettings copy) {
copy.getUser(),
copy.getStopSequences(),
copy.getTokenSelectionBiases(),
copy.getResponseFormat() == null ? null : copy.getResponseFormat());
copy.getResponseFormat() == null ? null : copy.getResponseFormat(),
copy.getMaxCompletionTokens() == null ? null : copy.getMaxCompletionTokens().toString());
this.topK = null;
this.repetitionPenalty = null;
this.maxTime = null;
Expand Down Expand Up @@ -101,10 +102,12 @@ public HuggingFacePromptExecutionSettings(
@Nullable Boolean details,
@Nullable Boolean logProbs,
@Nullable Integer topLogProbs,
@Nullable Long seed) {
@Nullable Long seed,
@Nullable Boolean maxCompletionTokensEnable) {
super(
serviceId, modelId, temperature, topP, presencePenalty, frequencyPenalty, maxTokens,
resultsPerPrompt, bestOf, user, stopSequences, tokenSelectionBiases, responseFormat);
resultsPerPrompt, bestOf, user, stopSequences, tokenSelectionBiases, responseFormat,
Boolean.toString(Boolean.TRUE.equals(maxCompletionTokensEnable)));

this.topK = topK;
this.repetitionPenalty = repetitionPenalty;
Expand Down Expand Up @@ -151,6 +154,7 @@ public static HuggingFacePromptExecutionSettings fromExecutionSettings(
null,
null,
null,
null,
null);
}

Expand Down
2 changes: 1 addition & 1 deletion aiservices/openai/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.microsoft.semantic-kernel</groupId>
<artifactId>semantickernel-parent</artifactId>
<version>1.4.4-RC3-SNAPSHOT</version>
<version>1.4.5-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
import com.microsoft.semantickernel.orchestration.ToolCallBehavior;
import com.microsoft.semantickernel.orchestration.responseformat.JsonResponseSchema;
import com.microsoft.semantickernel.orchestration.responseformat.JsonSchemaResponseFormat;
import com.microsoft.semantickernel.semanticfunctions.KernelFunction;
import com.microsoft.semantickernel.semanticfunctions.KernelArguments;
import com.microsoft.semantickernel.semanticfunctions.KernelFunction;
import com.microsoft.semantickernel.services.chatcompletion.AuthorRole;
import com.microsoft.semantickernel.services.chatcompletion.ChatCompletionService;
import com.microsoft.semantickernel.services.chatcompletion.ChatHistory;
Expand Down Expand Up @@ -149,7 +149,7 @@ public Mono<List<ChatMessageContent<?>>> getChatMessageContentsAsync(

if (invocationContext != null
&& invocationContext
.returnMode() == InvocationReturnMode.LAST_MESSAGE_ONLY) {
.returnMode() == InvocationReturnMode.LAST_MESSAGE_ONLY) {
chatHistoryResult = new ChatHistory(
Collections.singletonList(
CollectionUtil.getLastOrNull(chatHistoryResult.getMessages())));
Expand Down Expand Up @@ -183,7 +183,7 @@ public Mono<List<ChatMessageContent<?>>> getChatMessageContentsAsync(

if (invocationContext != null
&& invocationContext
.returnMode() == InvocationReturnMode.LAST_MESSAGE_ONLY) {
.returnMode() == InvocationReturnMode.LAST_MESSAGE_ONLY) {
result = new ChatHistory(
Collections.singletonList(
CollectionUtil.getLastOrNull(result.getMessages())));
Expand Down Expand Up @@ -443,31 +443,31 @@ private Mono<ChatMessages> internalChatMessageContentsAsync(
.getOptions();

return Mono.deferContextual(contextView -> {
ChatCompletionSpan span = ChatCompletionSpan.startChatCompletionSpan(
SemanticKernelTelemetry.getTelemetry(invocationContext),
contextView,
getModelId(),
SemanticKernelTelemetry.OPEN_AI_PROVIDER,
options.getMaxTokens(),
options.getTemperature(),
options.getTopP());

return getClient()
.getChatCompletionsWithResponse(getDeploymentName(), options,
OpenAIRequestSettings.getRequestOptions())
.contextWrite(span.getReactorContextModifier())
.flatMap(completionsResult -> {
if (completionsResult.getStatusCode() >= 400) {
return Mono.error(new AIException(ErrorCodes.SERVICE_ERROR,
"Request failed: " + completionsResult.getStatusCode()));
}
ChatCompletionSpan span = ChatCompletionSpan.startChatCompletionSpan(
SemanticKernelTelemetry.getTelemetry(invocationContext),
contextView,
getModelId(),
SemanticKernelTelemetry.OPEN_AI_PROVIDER,
options.getMaxTokens(),
options.getTemperature(),
options.getTopP());

return getClient()
.getChatCompletionsWithResponse(getDeploymentName(), options,
OpenAIRequestSettings.getRequestOptions())
.contextWrite(span.getReactorContextModifier())
.flatMap(completionsResult -> {
if (completionsResult.getStatusCode() >= 400) {
return Mono.error(new AIException(ErrorCodes.SERVICE_ERROR,
"Request failed: " + completionsResult.getStatusCode()));
}

return Mono.just(completionsResult.getValue());
})
.doOnError(span::endSpanWithError)
.doOnSuccess(span::endSpanWithUsage)
.doOnTerminate(span::close);
})
return Mono.just(completionsResult.getValue());
})
.doOnError(span::endSpanWithError)
.doOnSuccess(span::endSpanWithUsage)
.doOnTerminate(span::close);
})
.flatMap(completions -> {
List<ChatResponseMessage> responseMessages = completions
.getChoices()
Expand Down Expand Up @@ -920,7 +920,8 @@ private static ChatCompletionsOptions getCompletionsOptions(
}

Map<String, Integer> logit = null;
if (promptExecutionSettings.getTokenSelectionBiases() != null) {
if (promptExecutionSettings.getTokenSelectionBiases() != null
&& !promptExecutionSettings.getTokenSelectionBiases().isEmpty()) {
logit = promptExecutionSettings
.getTokenSelectionBiases()
.entrySet()
Expand All @@ -937,12 +938,13 @@ private static ChatCompletionsOptions getCompletionsOptions(
.setFrequencyPenalty(promptExecutionSettings.getFrequencyPenalty())
.setPresencePenalty(promptExecutionSettings.getPresencePenalty())
.setMaxTokens(promptExecutionSettings.getMaxTokens())
.setMaxCompletionTokens(promptExecutionSettings.getMaxCompletionTokens())
.setN(promptExecutionSettings.getResultsPerPrompt())
// Azure OpenAI WithData API does not allow to send empty array of stop sequences
// 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"
.setStop(promptExecutionSettings.getStopSequences() == null
|| promptExecutionSettings.getStopSequences().isEmpty() ? null
: promptExecutionSettings.getStopSequences())
: promptExecutionSettings.getStopSequences())
.setUser(promptExecutionSettings.getUser())
.setLogitBias(logit);

Expand Down Expand Up @@ -1147,7 +1149,7 @@ private static OpenAIToolCallConfig getToolCallBehaviorConfig(
toolChoice,
toolCallBehavior.isAutoInvokeAllowed()
&& requestIndex < Math.min(MAXIMUM_INFLIGHT_AUTO_INVOKES,
toolCallBehavior.getMaximumAutoInvokeAttempts()),
toolCallBehavior.getMaximumAutoInvokeAttempts()),
null);
}

Expand Down Expand Up @@ -1262,11 +1264,11 @@ private static ChatRequestAssistantMessage formAssistantMessage(

String args = arguments != null && !arguments.isEmpty()
? arguments.entrySet().stream()
.map(entry -> String.format("\"%s\": \"%s\"",
StringEscapeUtils.escapeJson(entry.getKey()),
StringEscapeUtils.escapeJson(
entry.getValue().toPromptString())))
.collect(Collectors.joining(",", "{", "}"))
.map(entry -> String.format("\"%s\": \"%s\"",
StringEscapeUtils.escapeJson(entry.getKey()),
StringEscapeUtils.escapeJson(
entry.getValue().toPromptString())))
.collect(Collectors.joining(",", "{", "}"))
: "{}";

String prefix = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,20 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.microsoft.semantickernel.exceptions.SKException;
import com.microsoft.semantickernel.orchestration.responseformat.ResponseSchemaGenerator;
import com.microsoft.semantickernel.plugin.KernelPluginFactory;
import com.microsoft.semantickernel.semanticfunctions.InputVariable;
import com.microsoft.semantickernel.semanticfunctions.KernelFunctionMetadata;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.apache.commons.lang3.StringUtils;

class OpenAIFunction {

Expand Down Expand Up @@ -229,14 +227,9 @@ private static String getJavaTypeToOpenAiFunctionType(String javaType) {
}

private static String getObjectSchema(String type, String description) {
String schema = "{ \"type\" : \"object\" }";
try {
Class<?> clazz = Class.forName(type);
schema = ResponseSchemaGenerator.jacksonGenerator().generateSchema(clazz);
Class<?> clazz = KernelPluginFactory.getTypeForName(type);
String schema = ResponseSchemaGenerator.jacksonGenerator().generateSchema(clazz);

} catch (ClassNotFoundException | SKException ignored) {

}
Map<String, Object> properties = BinaryData.fromString(schema).toObject(Map.class);
if (StringUtils.isNotBlank(description)) {
properties.put("description", description);
Expand Down
19 changes: 12 additions & 7 deletions api-test/integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.microsoft.semantic-kernel</groupId>
<artifactId>api-test</artifactId>
<version>1.4.4-RC3-SNAPSHOT</version>
<version>1.4.5-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -90,18 +90,18 @@
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>9.0.0</version>
<version>9.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.7.3</version> <!-- Use the latest version -->
<version>42.7.10</version> <!-- Use the latest version -->
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.46.1.0</version>
<version>3.53.0.0</version>
</dependency>

<dependency>
Expand All @@ -122,7 +122,7 @@
<dependency>
<groupId>com.redis</groupId>
<artifactId>testcontainers-redis</artifactId>
<version>2.2.2</version>
<version>2.2.4</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -147,7 +147,12 @@
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.7.3</version>
<version>2.7.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.microsoft.semantic-kernel</groupId>
<artifactId>semantickernel-api-data</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -157,7 +162,7 @@
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-bom</artifactId>
<version>1.18.3</version>
<version>2.0.4</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.microsoft.semantickernel.Kernel;
import com.microsoft.semantickernel.plugin.KernelPlugin;
import com.microsoft.semantickernel.plugin.KernelPluginFactory;
import org.junit.Ignore;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ public class Hotel {
@VectorStoreRecordData(isFilterable = true)
private final String name;

@VectorStoreRecordData
@VectorStoreRecordData(isFilterable = true)
private final int code;

@JsonProperty("summary")
@VectorStoreRecordData()
@VectorStoreRecordData(isFilterable = true)
private final String description;

@JsonProperty("summaryEmbedding1")
Expand Down
Loading
Loading