- 添加HNSW向量索引提升检索性能 - 实现Hybrid检索模式支持向量和关键词双路召回 - 采用RRF算法融合多路召回结果 - 支持ParentChild分块模式的上下文回填 - 优化向量写入采用批量SQL操作提升性能 - 添加RAG PostgreSQL连接字符串配置 - 更新部署脚本增加PGVector集成测试 - 修正表名引用从document_chunks到b_document_chunks - 重构RagRetrievalService实现完整的检索流程 - 增加重排策略支持关键词和LLM重排 - 修改服务器部署地址配置
43 lines
1.5 KiB
C#
43 lines
1.5 KiB
C#
using System.Runtime.CompilerServices;
|
||
using BuildFlow.Shared.Domain.Common;
|
||
using File.Infrastructure.Persistence;
|
||
using Microsoft.EntityFrameworkCore;
|
||
|
||
namespace BuildFlow.File.Tests;
|
||
|
||
/// <summary>
|
||
/// file 模块 InMemory 测试数据库工厂。每个用例使用独立库名,并在保存前自动补齐审计字段
|
||
/// (IAuditable / IHasOperatorIP),避免实体因必填审计列缺失而失败。
|
||
/// </summary>
|
||
internal static class FileTestDb
|
||
{
|
||
public static FileDbContext Create([CallerMemberName] string testName = "")
|
||
{
|
||
var options = new DbContextOptionsBuilder<FileDbContext>()
|
||
.UseInMemoryDatabase($"file-{testName}-{Guid.NewGuid():N}")
|
||
.Options;
|
||
var db = new FileDbContext(options);
|
||
db.SavingChanges += FillAuditFields;
|
||
return db;
|
||
}
|
||
|
||
private static void FillAuditFields(object? sender, EventArgs args)
|
||
{
|
||
if (sender is not FileDbContext db) return;
|
||
|
||
foreach (var entry in db.ChangeTracker.Entries())
|
||
{
|
||
if (entry.Entity is IAuditable auditable)
|
||
{
|
||
auditable.CreatedBy ??= "test";
|
||
auditable.UpdatedBy ??= "test";
|
||
if (auditable.CreatedAt == default) auditable.CreatedAt = DateTime.UtcNow;
|
||
if (auditable.UpdatedAt == default) auditable.UpdatedAt = DateTime.UtcNow;
|
||
}
|
||
|
||
if (entry.Entity is IHasOperatorIP operatorEntity)
|
||
operatorEntity.OperatorIP ??= "127.0.0.1";
|
||
}
|
||
}
|
||
}
|