Skip to content

Commit bc0f640

Browse files
committed
Adding Book class and pom fixes
1 parent 1ca9439 commit bc0f640

4 files changed

Lines changed: 75 additions & 33 deletions

File tree

  • data/semantickernel-data-postgres
  • samples/semantickernel-learn-resources

data/semantickernel-data-postgres/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
<relativePath>../../pom.xml</relativePath>
1111
</parent>
1212

13-
<groupId>com.microsoft.semantic-kernel</groupId>
1413
<artifactId>semantickernel-data-postgres</artifactId>
1514
<name>Semantic Kernel PostreSQL connector</name>
1615
<description>Provides a PostreSQL connector for the Semantic Kernel</description>

samples/semantickernel-learn-resources/pom.xml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,16 @@
4141
<groupId>com.microsoft.semantic-kernel</groupId>
4242
<artifactId>semantickernel-data-redis</artifactId>
4343
</dependency>
44-
44+
<dependency>
45+
<groupId>com.microsoft.semantic-kernel</groupId>
46+
<artifactId>semantickernel-data-oracle</artifactId>
47+
<version>1.4.4-RC2-SNAPSHOT</version>
48+
</dependency>
49+
<dependency>
50+
<groupId>com.microsoft.semantic-kernel</groupId>
51+
<artifactId>semantickernel-data-postgres</artifactId>
52+
<version>1.4.4-RC2-SNAPSHOT</version>
53+
</dependency>
4554
<dependency>
4655
<groupId>org.apache.logging.log4j</groupId>
4756
<artifactId>log4j-api</artifactId>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
package com.microsoft.semantickernel.samples.documentationexamples.data.vectorstores.oracle;
3+
4+
import com.microsoft.semantickernel.data.vectorstorage.annotations.VectorStoreRecordData;
5+
import com.microsoft.semantickernel.data.vectorstorage.annotations.VectorStoreRecordKey;
6+
import com.microsoft.semantickernel.data.vectorstorage.annotations.VectorStoreRecordVector;
7+
import com.microsoft.semantickernel.data.vectorstorage.definition.DistanceFunction;
8+
import com.microsoft.semantickernel.data.vectorstorage.definition.IndexKind;
9+
import java.util.List;
10+
11+
public class Book {
12+
13+
@VectorStoreRecordKey
14+
private final String isbn;
15+
16+
public Book(String isbn, String title, String author, int pages,
17+
List<String> tags, String summary, List<Float> summaryEmbedding) {
18+
this.isbn = isbn;
19+
this.title = title;
20+
this.author = author;
21+
this.pages = pages;
22+
this.tags = tags;
23+
this.summary = summary;
24+
this.summaryEmbedding = summaryEmbedding;
25+
}
26+
27+
@VectorStoreRecordData(isFilterable = true)
28+
private final String title;
29+
30+
@VectorStoreRecordData(isFilterable = true)
31+
private final String author;
32+
33+
@VectorStoreRecordData
34+
private final int pages;
35+
36+
@VectorStoreRecordData(isFilterable = true)
37+
private final List<String> tags;
38+
39+
@VectorStoreRecordData( isFilterable = true, isFullTextSearchable = true )
40+
private final String summary;
41+
42+
@VectorStoreRecordVector(dimensions = 4, distanceFunction = DistanceFunction.COSINE_DISTANCE, indexKind = IndexKind.HNSW)
43+
private final List<Float> summaryEmbedding;
44+
45+
}

samples/semantickernel-learn-resources/src/main/java/com/microsoft/semantickernel/samples/documentationexamples/data/vectorstores/oracle/Main.java

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33

44
import com.microsoft.semantickernel.data.jdbc.JDBCVectorStore;
55
import com.microsoft.semantickernel.data.jdbc.JDBCVectorStoreOptions;
6-
import com.microsoft.semantickernel.data.jdbc.JDBCVectorStoreRecordCollection;
76
import com.microsoft.semantickernel.data.jdbc.JDBCVectorStoreRecordCollectionOptions;
8-
import com.microsoft.semantickernel.data.jdbc.postgres.PostgreSQLVectorStoreQueryProvider;
9-
import com.microsoft.semantickernel.samples.documentationexamples.data.index.Hotel;
7+
import com.microsoft.semantickernel.data.jdbc.oracle.OracleVectorStoreQueryProvider;
8+
import com.microsoft.semantickernel.data.vectorstorage.VectorStoreRecordCollection;
9+
import java.sql.SQLException;
10+
import java.util.Arrays;
11+
import java.util.List;
12+
import oracle.jdbc.datasource.impl.OracleDataSource;
1013

1114
public class Main {
12-
public static void main(String[] args) {
15+
public static void main(String[] args) throws SQLException {
16+
1317
// Configure the data source
1418
OracleDataSource dataSource = new OracleDataSource();
1519
dataSource.setURL("jdbc:oracle:thin:@localhost:1521/FREEPDB1");
@@ -29,50 +33,35 @@ public static void main(String[] args) {
2933
.build())
3034
.build();
3135

32-
VectorStoreRecordCollection<String, Hotel> collection = vectorStore.getCollection(
33-
"skhotels",
34-
JDBCVectorStoreRecordCollectionOptions.<Hotel>builder()
35-
.withRecordClass(Hotel.class)
36+
VectorStoreRecordCollection<String, Book> collection = vectorStore.getCollection(
37+
"books",
38+
JDBCVectorStoreRecordCollectionOptions.<Book>builder()
39+
.withRecordClass(Book.class)
3640
.build());
3741

3842
// Create the collection if it doesn't exist yet.
3943
collection.createCollectionIfNotExistsAsync().block();
4044

41-
collection.upsertBatchAsync(getHotels(), null).block();
45+
collection.upsertBatchAsync(books, null).block();
4246

4347
// Retrieve the upserted record.
44-
var retrievedHotel = collection.getAsync("1", null).block();
48+
//var retrievedBook = collection.getAsync("1", null).block();
4549

4650
// Generate a vector for your search text, using your chosen embedding generation implementation.
4751
// Just showing a placeholder method here for brevity.
4852
// var searchVector = generateEmbeddingsAsync(
49-
// "I'm looking for a hotel where customer happiness is the priority.").block();
53+
// "I'm looking for a Book where customer happiness is the priority.").block();
5054

5155
// Do the search.
5256
// var searchResult = collection.searchAsync(searchVector, VectorSearchOptions.builder()
5357
// .withTop(1).build()).block();
5458

55-
// Hotel record = searchResult.getResults().get(0).getRecord();
56-
// System.out.printf("Found hotel description: %s\n", record.getDescription());
59+
// Book record = searchResult.getResults().get(0).getRecord();
60+
// System.out.printf("Found Book description: %s\n", record.getDescription());
5761

5862
}
5963

60-
private static List<Hotel> getHotels() {
61-
return Arrays.asList(
62-
new Hotel("id_1", "Hotel 1", 1, "Hotel 1 description",
63-
Arrays.asList(0.5f, 3.2f, 7.1f, -4.0f, 2.8f, 10.0f, -1.3f, 5.5f), null, null, null,
64-
4.0),
65-
new Hotel("id_2", "Hotel 2", 2, "Hotel 2 description",
66-
Arrays.asList(-2.0f, 8.1f, 0.9f, 5.4f, -3.3f, 2.2f, 9.9f, -4.5f), null, null, null,
67-
4.0),
68-
new Hotel("id_3", "Hotel 3", 3, "Hotel 3 description",
69-
Arrays.asList(4.5f, -6.2f, 3.1f, 7.7f, -0.8f, 1.1f, -2.2f, 8.3f), null, null, null,
70-
5.0),
71-
new Hotel("id_4", "Hotel 4", 4, "Hotel 4 description",
72-
Arrays.asList(7.0f, 1.2f, -5.3f, 2.5f, 6.6f, -7.8f, 3.9f, -0.1f), null, null, null,
73-
4.0),
74-
new Hotel("id_5", "Hotel 5", 5, "Hotel 5 description",
75-
Arrays.asList(-3.5f, 4.4f, -1.2f, 9.9f, 5.7f, -6.1f, 7.8f, -2.0f), null, null, null,
76-
4.0));
77-
}
64+
static List<Book> books = Arrays.asList(
65+
new Book("1", "one", "sking", 0, null, "sum", null));
66+
7867
}

0 commit comments

Comments
 (0)