Skip to content

1.3.0

Latest
Compare
Choose a tag to compare
@clun clun released this 21 Jun 11:22
· 184 commits to main since this release

This release introduces the following changes

New Features

  • Different Embeddings providers supported by Astra : uptageAI, nVidia, voyageAI, JinaAI, openAI, Azure OpenAi,
// ---------------------------------------------------------------
// Create a collection for OpenAI - with no KEY in the Astra UI
// ---------------------------------------------------------------
DataAPIClient client = new DataAPIClient(astraToken, DataAPIOptions
   .builder()
   .withEmbeddingAPIKey("MY_OPEN_API_KEY")
   .build());
Database db = client
  .getDatabase(astraApiEndpoint, "default_keyspace");
Collection<Document> collectionWithOpenAI = localDb
 .createCollection(CollectionOptions.builder()
   .vectorDimension(1536)
   .vectorSimilarity(SimilarityMetric.COSINE)
   .vectorize("openai", "text-embedding-3-small")
   .build());
// Insert Stuff
collectionWithOpenAI.insertMany(
        new Document(1).vectorize("A lovestruck Romeo sings the streets a serenade"),
        new Document(2).vectorize("Finds a streetlight, steps out of the shade")
);

// ---------------------------------------------------------------
// Create a collection for OpenAI - with KEY in the AstraUI
// ---------------------------------------------------------------
DataAPIClient client2 = new DataAPIClient(astraToken);
Database db2 = client.getDatabase(astraApiEndpoint, "default_keyspace");
Collection<Document> collection2 = db2.createCollection("openai_with_shared_key",
   CollectionOptions.builder()
     .vectorDimension(1536)
     .vectorSimilarity(SimilarityMetric.COSINE)
     .vectorize("openai", "text-embedding-3-small", "OPENAI_API_KEY")
     .build(), new CommandOptions<>());
// Insert Stuff
collection2.insertMany(
        new Document(1).vectorize("A lovestruck Romeo sings the streets a serenade"),
        new Document(2).vectorize("Finds a streetlight, steps out of the shade")
);

Feature Updates

  • The $vector and $vectorize operation are now in the sort block

  • A new options sortVector is needed to retrieve the vector otherwize it is not returned by the API.

 FindIterable<Document> docs= collection.find(new FindOptions()
      .sort("You shouldn't come around here singing up at people like that")
      .includeSortVector()
      .includeSimilarity());
  • bulkWrite* operations are at collection level are deprecated, they will be implemented at server side in future release to ensure atomicity.

  • deleteMany now accepts an empty filter to perform the deleteAll() operation

  • Improve alignment with the others clients and the API. This release support Datastax Enterprise and HCD with dedicated token provider

String token = new UsernamePasswordTokenProvider(cassandraUserName, cassandraPassword).getTokenAsString();
DataAPIClient client = new DataAPIClient(token, builder().withDestination(HCD).build());