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
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,26 @@ public final class OpenAIRequestSettings {

private static final String SEMANTIC_KERNEL_VERSION_PROPERTY_NAME = "semantic-kernel.version";
private static final String SEMANTIC_KERNEL_VERSION_PROPERTIES_FILE = "semantic-kernel-version.properties";
private static final String useragent;

private static final String useragent;
private static final String header;

public static final String SEMANTIC_KERNEL_DISABLE_USERAGENT_PROPERTY = "semantic-kernel.useragent-disable";

private static final boolean disabled;

static {
disabled = isDisabled();
String version = loadVersion();
useragent = "semantic-kernel-java/" + version;
header = "java/" + version;
}

private static boolean isDisabled() {
return Boolean.parseBoolean(
System.getProperty(SEMANTIC_KERNEL_DISABLE_USERAGENT_PROPERTY, "false"));
}

private static String loadVersion() {

String version = "unknown";
Expand Down Expand Up @@ -58,9 +68,14 @@ private static String loadVersion() {
* @return The request options
*/
public static RequestOptions getRequestOptions() {
return new RequestOptions()
RequestOptions requestOptions = new RequestOptions();

if (disabled) {
return requestOptions;
}

return requestOptions
.setHeader(HttpHeaderName.fromString("Semantic-Kernel-Version"), header)
.setContext(
new Context(UserAgentPolicy.APPEND_USER_AGENT_CONTEXT_KEY, useragent));
.setContext(new Context(UserAgentPolicy.APPEND_USER_AGENT_CONTEXT_KEY, useragent));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ public static void main(String[] args) {
inMemoryDataStorage(embeddingGeneration);
}

public static void inMemoryDataStorage(OpenAITextEmbeddingGenerationService embeddingGeneration) {
public static void inMemoryDataStorage(
OpenAITextEmbeddingGenerationService embeddingGeneration) {
// Create a new Volatile vector store
var volatileVectorStore = new VolatileVectorStore();

Expand Down