Skip to content

Commit 4fe5a42

Browse files
author
Milder Hernandez Cagua
committed
Format
1 parent 921f883 commit 4fe5a42

17 files changed

+351
-265
lines changed

semantickernel-api/src/main/java/com/microsoft/semantickernel/services/audio/AudioToTextService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ static Builder builder() {
3333
/**
3434
* Builder for the AudioToTextService.
3535
*/
36-
abstract class Builder extends OpenAiServiceBuilder<OpenAIAsyncClient, AudioToTextService, Builder> {
36+
abstract class Builder
37+
extends OpenAiServiceBuilder<OpenAIAsyncClient, AudioToTextService, Builder> {
3738

3839
}
3940
}

semantickernel-api/src/main/java/com/microsoft/semantickernel/services/openai/OpenAiServiceBuilder.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
* @param <T> The service type
1212
* @param <U> The builder type
1313
*/
14-
public abstract class OpenAiServiceBuilder<C, T extends AIService, U extends OpenAiServiceBuilder<C, T, U>> implements
15-
14+
public abstract class OpenAiServiceBuilder<C, T extends AIService, U extends OpenAiServiceBuilder<C, T, U>>
15+
implements
16+
1617
SemanticKernelBuilder<T> {
1718

1819
@Nullable

semantickernel-api/src/main/java/com/microsoft/semantickernel/services/textcompletion/TextGenerationService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ Flux<StreamingTextContent> getStreamingTextContentsAsync(
6161
/**
6262
* Builder for a TextGenerationService
6363
*/
64-
abstract class Builder extends OpenAiServiceBuilder<OpenAIAsyncClient, TextGenerationService, Builder> {
64+
abstract class Builder
65+
extends OpenAiServiceBuilder<OpenAIAsyncClient, TextGenerationService, Builder> {
6566
}
6667
}

semantickernel-experimental/src/main/java/com/microsoft/semantickernel/connectors/data/azureaisearch/AzureAISearchVectorStoreRecordCollection.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,15 @@ public AzureAISearchVectorStoreRecordCollection(
9191

9292
// Validate supported types
9393
VectorStoreRecordDefinition.validateSupportedTypes(
94-
Collections.singletonList(recordDefinition.getKeyDeclaredField(this.options.getRecordClass())),
95-
supportedKeyTypes);
94+
Collections
95+
.singletonList(recordDefinition.getKeyDeclaredField(this.options.getRecordClass())),
96+
supportedKeyTypes);
9697
VectorStoreRecordDefinition.validateSupportedTypes(
97-
recordDefinition.getDataDeclaredFields(this.options.getRecordClass()),
98-
supportedDataTypes);
98+
recordDefinition.getDataDeclaredFields(this.options.getRecordClass()),
99+
supportedDataTypes);
99100
VectorStoreRecordDefinition.validateSupportedTypes(
100-
recordDefinition.getVectorDeclaredFields(this.options.getRecordClass()),
101-
supportedVectorTypes);
101+
recordDefinition.getVectorDeclaredFields(this.options.getRecordClass()),
102+
supportedVectorTypes);
102103

103104
// Add non-vector fields to the list
104105
nonVectorFields.add(this.recordDefinition.getKeyField().getName());

semantickernel-experimental/src/main/java/com/microsoft/semantickernel/connectors/data/jdbc/JDBCVectorStore.java

Lines changed: 30 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1+
// Copyright (c) Microsoft. All rights reserved.
12
package com.microsoft.semantickernel.connectors.data.jdbc;
23

34
import com.microsoft.semantickernel.data.recorddefinition.VectorStoreRecordDefinition;
4-
import com.microsoft.semantickernel.exceptions.SKException;
5+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
56
import reactor.core.publisher.Mono;
7+
import reactor.core.scheduler.Schedulers;
68

79
import javax.annotation.Nonnull;
810
import javax.annotation.Nullable;
911
import java.sql.Connection;
10-
import java.sql.ResultSet;
11-
import java.sql.SQLException;
12-
import java.util.ArrayList;
1312
import java.util.List;
1413

1514
/**
@@ -27,14 +26,18 @@ public class JDBCVectorStore implements SQLVectorStore<JDBCVectorStoreRecordColl
2726
* @param connection the connection
2827
* @param options the options
2928
*/
30-
public JDBCVectorStore(@Nonnull Connection connection, @Nullable JDBCVectorStoreOptions options) {
29+
@SuppressFBWarnings("EI_EXPOSE_REP2")
30+
public JDBCVectorStore(@Nonnull Connection connection,
31+
@Nullable JDBCVectorStoreOptions options) {
3132
this.connection = connection;
3233
this.options = options;
3334

3435
if (this.options != null && this.options.getQueryProvider() != null) {
3536
this.queryProvider = this.options.getQueryProvider();
3637
} else {
37-
this.queryProvider = new JDBCVectorStoreDefaultQueryProvider(connection);
38+
this.queryProvider = JDBCVectorStoreDefaultQueryProvider.builder()
39+
.withConnection(connection)
40+
.build();
3841
}
3942
}
4043

@@ -57,30 +60,30 @@ public static Builder builder() {
5760
*/
5861
@Override
5962
public <Key, Record> JDBCVectorStoreRecordCollection<?> getCollection(
60-
@Nonnull String collectionName,
61-
@Nonnull Class<Record> recordClass,
62-
@Nullable VectorStoreRecordDefinition recordDefinition) {
63+
@Nonnull String collectionName,
64+
@Nonnull Class<Record> recordClass,
65+
@Nullable VectorStoreRecordDefinition recordDefinition) {
6366

6467
if (this.options != null && this.options.getVectorStoreRecordCollectionFactory() != null) {
6568
return this.options.getVectorStoreRecordCollectionFactory()
6669
.createVectorStoreRecordCollection(
6770
connection,
6871
collectionName,
6972
JDBCVectorStoreRecordCollectionOptions.<Record>builder()
70-
.withRecordClass(recordClass)
71-
.withRecordDefinition(recordDefinition)
72-
.withQueryProvider(this.queryProvider)
73-
.build());
74-
}
75-
76-
return new JDBCVectorStoreRecordCollection<>(
77-
connection,
78-
collectionName,
79-
JDBCVectorStoreRecordCollectionOptions.<Record>builder()
8073
.withRecordClass(recordClass)
8174
.withRecordDefinition(recordDefinition)
8275
.withQueryProvider(this.queryProvider)
8376
.build());
77+
}
78+
79+
return new JDBCVectorStoreRecordCollection<>(
80+
connection,
81+
collectionName,
82+
JDBCVectorStoreRecordCollectionOptions.<Record>builder()
83+
.withRecordClass(recordClass)
84+
.withRecordDefinition(recordDefinition)
85+
.withQueryProvider(this.queryProvider)
86+
.build());
8487
}
8588

8689
/**
@@ -90,30 +93,17 @@ public <Key, Record> JDBCVectorStoreRecordCollection<?> getCollection(
9093
*/
9194
@Override
9295
public Mono<List<String>> getCollectionNamesAsync() {
93-
return Mono.fromCallable(() -> {
94-
List<String> collectionNames = new ArrayList<>();
95-
try {
96-
ResultSet resultSet = queryProvider.getCollectionNames();
97-
while (resultSet.next()) {
98-
collectionNames.add(resultSet.getString(1));
99-
}
100-
101-
return collectionNames;
102-
} catch (SQLException e) {
103-
throw new SKException("Failed to get collection names.", e);
104-
}
105-
});
96+
return Mono.fromCallable(queryProvider::getCollectionNames)
97+
.subscribeOn(Schedulers.boundedElastic());
10698
}
10799

100+
/**
101+
* Prepares the vector store.
102+
*/
108103
@Override
109104
public Mono<Void> prepareAsync() {
110-
return Mono.fromRunnable(() -> {
111-
try {
112-
queryProvider.prepareVectorStore();
113-
} catch (SQLException e) {
114-
throw new SKException("Failed to prepare vector store.", e);
115-
}
116-
});
105+
return Mono.fromRunnable(queryProvider::prepareVectorStore)
106+
.subscribeOn(Schedulers.boundedElastic()).then();
117107
}
118108

119109
/**
@@ -129,6 +119,7 @@ public static class Builder {
129119
* @param connection the connection
130120
* @return the builder
131121
*/
122+
@SuppressFBWarnings("EI_EXPOSE_REP2")
132123
public Builder withConnection(Connection connection) {
133124
this.connection = connection;
134125
return this;

0 commit comments

Comments
 (0)