Fix qdrant vector store value factory (#3173)
- Fix the QdrantValueFactory to handle "java.util.List" type - Update the integration test to use List type values Resolves #3164 Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
This commit is contained in:
committed by
GitHub
parent
add7ca8489
commit
48fb663c31
@@ -32,6 +32,7 @@ import org.springframework.util.Assert;
|
||||
* Utility methods for building io.qdrant.client.grpc.JsonWithInt.Value from Java objects.
|
||||
*
|
||||
* @author Anush Shetty
|
||||
* @author Ilayaperumal Gopinathan
|
||||
* @since 0.8.1
|
||||
*/
|
||||
final class QdrantValueFactory {
|
||||
@@ -65,6 +66,10 @@ final class QdrantValueFactory {
|
||||
return value((Map<String, Object>) value);
|
||||
}
|
||||
|
||||
if (value instanceof List) {
|
||||
return value((List<Object>) value);
|
||||
}
|
||||
|
||||
switch (value.getClass().getSimpleName()) {
|
||||
case "String":
|
||||
return ValueFactory.value((String) value);
|
||||
@@ -81,6 +86,16 @@ final class QdrantValueFactory {
|
||||
}
|
||||
}
|
||||
|
||||
private static Value value(List<Object> elements) {
|
||||
List<Value> values = new ArrayList<Value>(elements.size());
|
||||
|
||||
for (Object element : elements) {
|
||||
values.add(value(element));
|
||||
}
|
||||
|
||||
return ValueFactory.list(values);
|
||||
}
|
||||
|
||||
private static Value value(Object[] elements) {
|
||||
List<Value> values = new ArrayList<Value>(elements.length);
|
||||
|
||||
|
||||
@@ -79,10 +79,11 @@ public class QdrantVectorStoreIT extends BaseVectorStoreTests {
|
||||
List<Document> documents = List.of(
|
||||
new Document("Spring AI rocks!! Spring AI rocks!! Spring AI rocks!! Spring AI rocks!! Spring AI rocks!!",
|
||||
Collections.singletonMap("meta1", "meta1")),
|
||||
new Document("Hello World Hello World Hello World Hello World Hello World Hello World Hello World"),
|
||||
new Document("Hello World Hello World Hello World Hello World Hello World Hello World Hello World",
|
||||
Collections.singletonMap("meta1", List.of("meta-list"))),
|
||||
new Document(
|
||||
"Great Depression Great Depression Great Depression Great Depression Great Depression Great Depression",
|
||||
Collections.singletonMap("meta2", "meta2")));
|
||||
Collections.singletonMap("meta2", List.of("meta-list"))));
|
||||
|
||||
@BeforeAll
|
||||
static void setup() throws InterruptedException, ExecutionException {
|
||||
|
||||
Reference in New Issue
Block a user