27 lines
1014 B
C#
27 lines
1014 B
C#
using BuildFlow.Domain.Interfaces;
|
|
|
|
namespace BuildFlow.Rag.Tests.Stub;
|
|
|
|
/// <summary>
|
|
/// Stub IDocumentExtractorFactory + IDocumentExtractor:返回固定提取文本。
|
|
/// 绕过真实文档解析(PDF/Word/Html)。
|
|
/// </summary>
|
|
public sealed class StubDocumentExtractor : IDocumentExtractor
|
|
{
|
|
/// <summary>提取返回的固定文本。</summary>
|
|
public string ExtractedContent { get; init; } = "BuildFlow 使用 PostgreSQL + pgvector 作为向量数据库。.NET 10 模块化单体架构。";
|
|
|
|
/// <summary>提取返回的标题。</summary>
|
|
public string ExtractedTitle { get; init; } = "测试文档";
|
|
|
|
public IReadOnlyCollection<string> SupportedExtensions { get; init; } = ["md", "txt", "pdf", "docx"];
|
|
|
|
public Task<ExtractedDocument> ExtractAsync(string filePath, CancellationToken ct = default)
|
|
=> Task.FromResult(new ExtractedDocument
|
|
{
|
|
Content = ExtractedContent,
|
|
Title = ExtractedTitle,
|
|
SourcePath = filePath
|
|
});
|
|
}
|