WeaviateNET 1.21.1.3
See the version list below for details.
dotnet add package WeaviateNET --version 1.21.1.3
NuGet\Install-Package WeaviateNET -Version 1.21.1.3
<PackageReference Include="WeaviateNET" Version="1.21.1.3" />
paket add WeaviateNET --version 1.21.1.3
#r "nuget: WeaviateNET, 1.21.1.3"
// Install WeaviateNET as a Cake Addin #addin nuget:?package=WeaviateNET&version=1.21.1.3 // Install WeaviateNET as a Cake Tool #tool nuget:?package=WeaviateNET&version=1.21.1.3
Weaviate.NET
This library is designed to wrap Weaviate vector DB for .NET core. The core API has been wrapped with NSwagStudio and then some extra layer has been added. The API mapping is incomplete and Unit tests should be generalized (they currently use a demo instance).
It is designed to manipulate Weaviate objects and not just to adapt the connection to some LLM framework as other NuGet packages do.
What's new in version 1.21.1.3
- Added attributes VectorIndexConfig, ReplicationConfig, IndexStopwords, IndexTimestamps, IndexNullState, IndexPropertyLength, BM25Index, MultiTenancy to decorate class definition and control indexing options.
- Added attributes Tokenization, IndexFilterable, IndexSearchable to decorate class fields and control indexing options.
Implementation status
The library implements almost all the schema, class, and object manipulation. It is possible to perform GraphQL queries though the current implementation is pretty raw. Thanks to Newtonsoft JObject it is possible to parse returned data pretty easily.
Note that it is still possible to use the NSwag generated API from Weaviate swagger file by using the Client property of the WeaviateDB connection. By missing APIs we intend that the calls have not yet been nicely wrapped in the object model and tested.
Missing APIs
- References management
- /batch/references endpoint is not implemented
Untested APIs
- Tenant
- Shards
- Backups
- Classifications
Roadmap
After implementing the missing endpoints in the object model we will work in providing a better GraphQL experience. In the ideal world a LINQ provider would be great to integrate queries into C#.
Package versioning
The Weaviate.NET package on NuGet follows the versioning schema of Weaviate: version 1.20.5.1 of the package is the first release tested on version 1.20.5 of Weaviate. So look at the last number to check the library revision.
Using the library
The data model is respectful of the database object model. To start create a connection (using the authorization key) and update the Schema to load the configuration:
weaviateDB = new WeaviateDB("https://yourhost/v1", "WEAVIATE_KEY");
await weaviateDB.Update();
In the Weaviate model objects are made of a set of fields (i.e. properties) with the appropriate data type (see WeaviateDataType class for the full list). Weaviate.NET maps properties to class fields (with few restrictions of course). So we can define the class Movie to describe a movie document:
[IndexNullState] // annotation to configure indexing options
public class Movie
{
public string? film;
public string? genre;
public string? leadStudio;
public int audienceScore;
public double profitability;
public int rottenTomatoes;
public double worldWideGross;
public int year;
}
Notice that all names follow the camel notation, if you use pascal notation Weaviate will lower case the first letter.
If we want to expose the id field in the Movie class we can use the JsonIgnore attribute to avoid mapping it to a property:
[JsonIgnore]
public Guid? id;
Important: If you use a class with less properties the library will work, this is useful to perform schema updates or property masking. Magic is performed by Newtonsoft serializer/deserializer.
We can create the class in the schema and load data (of type WeaviateObject< Movie>):
var mc = weaviateDB.Schema.NewClass<Movie>("MovieDBTest");
Movie[] movies = ReadMoviesDBFromCsv();
var toadd = new List<WeaviateObject<Movie>>();
foreach (var m in movies) {
var d = mc.Create(); // create the document
d.Properties = m; // set the properties (of type Movie)
toadd.Add(d);
}
await mc.Add(toadd);
To query the database you use explicitly the GraphQL syntax and the ability of JObject to deserialize a field. This basic approach will be supported in the future but a better abstraction will be provided.
var q = new GraphQLQuery();
q.Query = @"{
Get {
MovieDBTest(
limit: 5
nearText: { concepts: [ "robot in the future" ] }
)
{
film
genre
leadStudio
audienceScore
profitability
rottenTomatoes
worldWideGross
year
}
}
}";
var ret = await weaviateDB.Schema.RawQuery(q);
var d = ret.Data["Get"];
var a = data.ToObject<Movie[]>();
Previous changes
version 1.21.1.2
- Now it is possible to define fields in classes that are not mapped to Weaviate properties if annotated with JsonIgnore attribute.
version 1.21.1.1
Now the DateTime? type is supported. The library will convert the DateTime? to DatTime.
version 1.21.0.2
Added method CountObjectsByProperty to count object with a specific value in a property.
Version 1.21.0.1
Added the CountObjects method to WeaviateClass.
Tested against version 1.21.0 of Weaviate
Version 1.20.5.3
Added the ListObjects method to WeaviateClass. Apparently if you omit the limit parameter you get an empty list so the parameter is defaulted to 25.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Newtonsoft.Json (>= 13.0.3)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on WeaviateNET:
Package | Downloads |
---|---|
Oraculum
Library to create and organize factual knowledge inside a Weaviate vector DB and define AI GPT based assistants using this knowledge. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.23.9.1 | 1,658 | 2/18/2024 |
1.23.7.1 | 643 | 2/3/2024 |
1.22.2.1 | 406 | 11/1/2023 |
1.21.6.2 | 479 | 10/22/2023 |
1.21.6.1 | 151 | 10/22/2023 |
1.21.3.1 | 266 | 9/20/2023 |
1.21.2.1 | 216 | 9/2/2023 |
1.21.1.5 | 312 | 8/29/2023 |
1.21.1.4 | 171 | 8/25/2023 |
1.21.1.3 | 167 | 8/25/2023 |
1.21.1.2 | 148 | 8/24/2023 |
1.21.1.1 | 143 | 8/24/2023 |
1.21.0.2 | 158 | 8/21/2023 |
1.21.0.1 | 160 | 8/21/2023 |
1.20.5.3 | 158 | 8/18/2023 |
1.20.5.2 | 132 | 8/18/2023 |
1.20.5.1 | 185 | 8/13/2023 |
1.20.5 | 183 | 8/12/2023 |
1.0.0 | 159 | 8/11/2023 |