feat: implement KM-RAG methodology artifacts and core architectural standards with supporting query and service updates
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using FluentResults;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.AI;
|
||||
using NexusReader.Infrastructure.Services; // For PromptRegistry
|
||||
|
||||
namespace NexusReader.Application.Commands.AI;
|
||||
|
||||
|
||||
@@ -28,15 +28,10 @@ internal sealed class GetKnowledgeGraphQueryHandler : IQueryHandler<GetKnowledge
|
||||
if (graph is null)
|
||||
return Result.Ok(new GraphDataDto());
|
||||
|
||||
var nodes = graph.Nodes
|
||||
.Select(n => new GraphNodeDto(n.Id, n.Label, n.Group))
|
||||
.ToList();
|
||||
|
||||
var links = graph.Links
|
||||
.Select(l => new GraphLinkDto(l.Source, l.Target, l.Value))
|
||||
.ToList();
|
||||
|
||||
return Result.Ok(new GraphDataDto { Nodes = nodes, Links = links });
|
||||
if (graph is null)
|
||||
return Result.Ok(new GraphDataDto());
|
||||
|
||||
return Result.Ok(graph);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ using Microsoft.Extensions.AI;
|
||||
using NexusReader.Application.DTOs.AI;
|
||||
using NexusReader.Application.Abstractions.Persistence;
|
||||
using Pgvector.EntityFrameworkCore;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace NexusReader.Application.Queries.Library;
|
||||
|
||||
@@ -88,7 +89,7 @@ public class SearchLibrarySemanticallyQueryHandler : IRequestHandler<SearchLibra
|
||||
RelevanceScore = (float)(1 - c.Vector!.CosineDistance(queryVector)),
|
||||
Metadata = string.IsNullOrEmpty(c.MetadataJson)
|
||||
? null
|
||||
: System.Text.Json.JsonSerializer.Deserialize<Dictionary<string, object>>(c.MetadataJson)
|
||||
: JsonSerializer.Deserialize<Dictionary<string, object>>(c.MetadataJson)
|
||||
};
|
||||
|
||||
// Enrich snippet with definitions if present
|
||||
|
||||
@@ -24,6 +24,11 @@ public class WasmKnowledgeService : IKnowledgeService
|
||||
return await CallKnowledgeApiAsync("/api/knowledge/graph", text, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<Result<KnowledgePacket>> GetKnowledgeMapAsync(string text, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await CallKnowledgeApiAsync("/api/knowledge/map", text, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<Result<KnowledgePacket>> GetSummaryAndQuizAsync(string text, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await CallKnowledgeApiAsync("/api/knowledge/summary", text, cancellationToken);
|
||||
|
||||
Reference in New Issue
Block a user