diff --git a/Directory.Build.props b/Directory.Build.props index ff1e5ee05..a8d4b6782 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -26,8 +26,8 @@ https://github.com/managedcode/graphrag https://github.com/managedcode/graphrag Managed Code GraphRag - 10.0.6 - 10.0.6 + 10.0.7 + 10.0.7 diff --git a/README.md b/README.md index ead13d634..cfbf7307d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,13 @@ # GraphRAG for .NET +[![NuGet](https://img.shields.io/nuget/v/ManagedCode.GraphRag.svg)](https://www.nuget.org/packages/ManagedCode.GraphRag/) +[![NuGet Neo4j](https://img.shields.io/nuget/v/ManagedCode.GraphRag.Neo4j.svg?label=Neo4j)](https://www.nuget.org/packages/ManagedCode.GraphRag.Neo4j/) +[![NuGet Postgres](https://img.shields.io/nuget/v/ManagedCode.GraphRag.Postgres.svg?label=Postgres)](https://www.nuget.org/packages/ManagedCode.GraphRag.Postgres/) +[![NuGet CosmosDb](https://img.shields.io/nuget/v/ManagedCode.GraphRag.CosmosDb.svg?label=CosmosDb)](https://www.nuget.org/packages/ManagedCode.GraphRag.CosmosDb/) +[![NuGet JanusGraph](https://img.shields.io/nuget/v/ManagedCode.GraphRag.JanusGraph.svg?label=JanusGraph)](https://www.nuget.org/packages/ManagedCode.GraphRag.JanusGraph/) +[![Build Status](https://github.com/managedcode/graphrag/actions/workflows/ci.yml/badge.svg)](https://github.com/managedcode/graphrag/actions) +[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) + GraphRAG for .NET is a ground-up port of Microsoft's GraphRAG reference implementation to the modern .NET 10 stack. The port keeps parity with the original Python pipelines while embracing native .NET idioms—dependency injection, logging abstractions, async I/O, and strongly-typed configuration. > ℹ️ The upstream Python code remains available under [`submodules/graphrag-python`](submodules/graphrag-python) for side-by-side reference. Treat it as read-only unless a task explicitly targets the submodule. @@ -390,19 +398,19 @@ The Cosmos adapter (`ManagedCode.GraphRag.CosmosDb`) targets the SQL API and wor 1. **Provide a connection string.** Set `COSMOS_EMULATOR_CONNECTION_STRING` or configure options manually. 2. **Register the store.** ```csharp -builder.Services.AddCosmosGraphStore("cosmos", options => -{ - options.ConnectionString = cosmosConnectionString; - options.DatabaseId = "GraphRagIntegration"; - options.NodesContainerId = "nodes"; - options.EdgesContainerId = "edges"; - options.ConfigureClientOptions = clientOptions => - { - clientOptions.GatewayModeMaxConnectionLimit = 100; - }; - options.ConfigureSerializer = serializer => serializer.PropertyNamingPolicy = null; -}); -``` + builder.Services.AddCosmosGraphStore("cosmos", options => + { + options.ConnectionString = cosmosConnectionString; + options.DatabaseId = "GraphRagIntegration"; + options.NodesContainerId = "nodes"; + options.EdgesContainerId = "edges"; + options.ConfigureClientOptions = clientOptions => + { + clientOptions.GatewayModeMaxConnectionLimit = 100; + }; + options.ConfigureSerializer = serializer => serializer.PropertyNamingPolicy = null; + }); + ``` As with other adapters, the first Cosmos store becomes the unkeyed default. If you already have a `CosmosClient`, set `options.ClientFactory` to return it and GraphRAG will reuse that instance. > **Tip:** `IGraphStore` now exposes full graph inspection and mutation helpers (`GetNodesAsync`, `GetRelationshipsAsync`, `DeleteNodesAsync`, `DeleteRelationshipsAsync`) in addition to the targeted APIs (`InitializeAsync`, `Upsert*`, `GetOutgoingRelationshipsAsync`). These use the same AGE-powered primitives, so you can inspect, prune, or export the graph without dropping down to concrete implementations. diff --git a/src/ManagedCode.GraphRag.Postgres/ApacheAge/AgeConnectionManager.cs b/src/ManagedCode.GraphRag.Postgres/ApacheAge/AgeConnectionManager.cs index a90b49c51..acc625570 100644 --- a/src/ManagedCode.GraphRag.Postgres/ApacheAge/AgeConnectionManager.cs +++ b/src/ManagedCode.GraphRag.Postgres/ApacheAge/AgeConnectionManager.cs @@ -135,12 +135,7 @@ private async Task LoadAgeAsync(NpgsqlConnection connection, CancellationToken c await using var checkCommand = connection.CreateCommand(); checkCommand.CommandText = "SELECT 1 FROM pg_extension WHERE extname = 'age';"; checkCommand.CommandTimeout = 0; - var result = await checkCommand.ExecuteScalarAsync(cancellationToken).ConfigureAwait(false); - - if (result is null) - { - throw new AgeException("AGE extension is not installed."); - } + var result = await checkCommand.ExecuteScalarAsync(cancellationToken).ConfigureAwait(false) ?? throw new AgeException("AGE extension is not installed."); await using var load = connection.CreateCommand(); load.CommandText = "LOAD 'age';"; diff --git a/src/ManagedCode.GraphRag/Utils/Hashing.cs b/src/ManagedCode.GraphRag/Utils/Hashing.cs index 02b94949e..de20c1f6e 100644 --- a/src/ManagedCode.GraphRag/Utils/Hashing.cs +++ b/src/ManagedCode.GraphRag/Utils/Hashing.cs @@ -30,7 +30,10 @@ public static string GenerateSha512Hash(IEnumerable buffer) { - if (string.IsNullOrEmpty(value)) return; + if (string.IsNullOrEmpty(value)) + { + return; + } var remaining = value.AsSpan(); diff --git a/tests/ManagedCode.GraphRag.Tests/Storage/Postgres/PostgresAgtypeParameterTests.cs b/tests/ManagedCode.GraphRag.Tests/Storage/Postgres/PostgresAgtypeParameterTests.cs index ad6c6ff77..cf27dcd79 100644 --- a/tests/ManagedCode.GraphRag.Tests/Storage/Postgres/PostgresAgtypeParameterTests.cs +++ b/tests/ManagedCode.GraphRag.Tests/Storage/Postgres/PostgresAgtypeParameterTests.cs @@ -5,8 +5,8 @@ using GraphRag.Storage.Postgres.ApacheAge; using GraphRag.Storage.Postgres.ApacheAge.Types; using ManagedCode.GraphRag.Tests.Integration; -using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging.Abstractions; using Npgsql; namespace ManagedCode.GraphRag.Tests.Storage.Postgres;