Add getNativeClient API to VectorStore interface
Adds getNativeClient API to VectorStore interface allowing access to the underlying native client implementation. This change: - Adds getNativeClient() default method to VectorStore interface returning Optional<T> - Implements getNativeClient() in all vector store implementations exposing their respective native clients - Adds integration tests verifying native client access for all implementations Fixes: #2137 Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
This commit is contained in:
committed by
Mark Pollack
parent
54463e6622
commit
16a596f8b7
@@ -476,6 +476,13 @@ public class PgVectorStore extends AbstractObservationVectorStore implements Ini
|
||||
return SIMILARITY_TYPE_MAPPING.get(this.distanceType).value();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Optional<T> getNativeClient() {
|
||||
@SuppressWarnings("unchecked")
|
||||
T client = (T) this.jdbcTemplate;
|
||||
return Optional.of(client);
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, pgvector performs exact nearest neighbor search, which provides perfect
|
||||
* recall. You can add an index to use approximate nearest neighbor search, which
|
||||
|
||||
@@ -482,6 +482,15 @@ public class PgVectorStoreIT {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void getNativeClientTest() {
|
||||
this.contextRunner.run(context -> {
|
||||
PgVectorStore vectorStore = context.getBean(PgVectorStore.class);
|
||||
Optional<JdbcTemplate> nativeClient = vectorStore.getNativeClient();
|
||||
assertThat(nativeClient).isPresent();
|
||||
});
|
||||
}
|
||||
|
||||
@SpringBootConfiguration
|
||||
@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class })
|
||||
public static class TestApplication {
|
||||
|
||||
Reference in New Issue
Block a user