- AI chat with SSE streaming (Microsoft Agent Framework + Qwen) - RAG Q&A with hybrid retrieval (vector + keyword RRF fusion) - Knowledge base CRUD with semantic text chunking - Embedding generation via Azure.AI.OpenAI / LM Studio - Document upload with chunked upload support - Redis caching for chat messages - Chunk/vector preview endpoints - gRPC auth service improvements - Removed demo menus, cleaned up seed data
47 lines
1.8 KiB
C#
47 lines
1.8 KiB
C#
using Microsoft.EntityFrameworkCore;
|
||
using Microsoft.Extensions.Configuration;
|
||
using Microsoft.Extensions.DependencyInjection;
|
||
using Pgvector.EntityFrameworkCore;
|
||
using RAG.Domain;
|
||
using RAG.Domain.Interfaces;
|
||
using RAG.Infrastructure.AI;
|
||
using RAG.Infrastructure.Cache;
|
||
using RAG.Infrastructure.Messaging;
|
||
using RAG.Infrastructure.Persistence;
|
||
using RAG.Infrastructure.Persistence.Interceptors;
|
||
using Volo.Abp.Modularity;
|
||
|
||
namespace RAG.Infrastructure;
|
||
|
||
/// <summary>
|
||
/// Infrastructure 层模块,注册数据库上下文、审计拦截器、Redis 缓存、RabbitMQ 消息队列。
|
||
/// 原 DependencyInjection.cs 的内容迁移至此。
|
||
/// </summary>
|
||
[DependsOn(typeof(RAGDomainModule))]
|
||
public class RAGInfrastructureModule : AbpModule
|
||
{
|
||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||
{
|
||
var services = context.Services;
|
||
var config = services.GetConfiguration();
|
||
|
||
// DbContext 挂载审计拦截器,拦截器从 DI 容器解析 ICurrentUserContext
|
||
services.AddDbContext<RagDbContext>((sp, options) =>
|
||
options.UseNpgsql(config.GetConnectionString("Default"), o => o.UseVector())
|
||
.AddInterceptors(sp.GetRequiredService<AuditInterceptor>()));
|
||
|
||
// Scoped 生命周期:每个 HTTP 请求创建一个拦截器实例,确保 ICurrentUserContext 正确获取当前用户
|
||
services.AddScoped<AuditInterceptor>();
|
||
|
||
services.AddRedisCache(config);
|
||
services.AddRabbitMq(config);
|
||
|
||
// AI 服务注册
|
||
services.Configure<AiOptions>(config.GetSection(AiOptions.SectionName));
|
||
services.AddScoped<IAIChatAgent, ChatAgentService>();
|
||
services.AddScoped<IEmbeddingService, EmbeddingService>();
|
||
services.AddScoped<ITextChunker, TextChunker>();
|
||
services.AddSingleton<IChatMessageCache, ChatMessageCache>();
|
||
}
|
||
}
|