DNFileRAG.Infrastructure
1.0.0
See the version list below for details.
dotnet add package DNFileRAG.Infrastructure --version 1.0.0
NuGet\Install-Package DNFileRAG.Infrastructure -Version 1.0.0
<PackageReference Include="DNFileRAG.Infrastructure" Version="1.0.0" />
<PackageVersion Include="DNFileRAG.Infrastructure" Version="1.0.0" />
<PackageReference Include="DNFileRAG.Infrastructure" />
paket add DNFileRAG.Infrastructure --version 1.0.0
#r "nuget: DNFileRAG.Infrastructure, 1.0.0"
#:package DNFileRAG.Infrastructure@1.0.0
#addin nuget:?package=DNFileRAG.Infrastructure&version=1.0.0
#tool nuget:?package=DNFileRAG.Infrastructure&version=1.0.0
DNFileRAG
A .NET 9-powered, real-time file-driven RAG (Retrieval-Augmented Generation) engine that auto-ingests documents and serves fast, contextual query responses via API.
Installation
NuGet Package
dotnet add package DNFileRAG.Infrastructure
From Source
git clone https://github.com/MLidstrom/DNFileRAG.git
cd DNFileRAG
dotnet build
Features
- Real-time Document Ingestion - Automatically watches directories and indexes new/modified documents
- Multiple Document Formats - Supports PDF, DOCX, TXT, MD, and HTML files
- Flexible Embedding Providers - OpenAI, Azure OpenAI, or Ollama (local)
- Multiple LLM Providers - OpenAI, Azure OpenAI, Anthropic, or Ollama (local)
- Vector Search - Powered by Qdrant for fast semantic search
- REST API - Simple API for queries and document management
- Clean Architecture - Modular, testable, and extensible design
Quick Start
Prerequisites
- .NET 9 SDK
- Qdrant vector database (Docker recommended)
- One of: OpenAI API key, Azure OpenAI, or Ollama for local inference
1. Start Qdrant
docker run -p 6333:6333 -p 6334:6334 qdrant/qdrant
2. Clone and Build
git clone https://github.com/MLidstrom/DNFileRAG.git
cd DNFileRAG
dotnet build
3. Configure
Edit src/DNFileRAG/appsettings.json:
{
"Qdrant": {
"Host": "localhost",
"Port": 6333,
"CollectionName": "DNFileRAG",
"VectorSize": 1536
},
"Embedding": {
"Provider": "Ollama",
"Ollama": {
"BaseUrl": "http://localhost:11434",
"Model": "nomic-embed-text"
}
},
"Llm": {
"Provider": "Ollama",
"Ollama": {
"BaseUrl": "http://localhost:11434",
"Model": "llama3.2"
}
}
}
4. Run
cd src/DNFileRAG
dotnet run
The API will be available at http://localhost:8181
API Endpoints
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/documents |
List all indexed documents |
POST |
/api/documents/upload |
Upload a document for indexing |
DELETE |
/api/documents/{fileId} |
Remove a document from the index |
POST |
/api/query |
Query the RAG engine |
POST |
/api/reindex |
Trigger full reindex |
GET |
/health |
Health check |
Query Example
curl -X POST http://localhost:8181/api/query \
-H "Content-Type: application/json" \
-d '{"query": "What is the main topic of the documents?"}'
Project Structure
DNFileRAG/
├── src/
│ ├── DNFileRAG/ # Web API host
│ ├── DNFileRAG.Core/ # Domain models & interfaces
│ └── DNFileRAG.Infrastructure/ # External service implementations
│ ├── Embeddings/ # Embedding providers
│ ├── Llm/ # LLM providers
│ ├── Parsers/ # Document parsers
│ ├── Services/ # Core services
│ └── VectorStore/ # Qdrant integration
└── tests/
└── DNFileRAG.Tests/ # Unit tests
Configuration
Embedding Providers
| Provider | Config Key | Requirements |
|---|---|---|
| OpenAI | OpenAI |
API Key |
| Azure OpenAI | AzureOpenAI |
Endpoint, API Key, Deployment |
| Ollama | Ollama |
Local Ollama instance |
LLM Providers
| Provider | Config Key | Requirements |
|---|---|---|
| OpenAI | OpenAI |
API Key |
| Azure OpenAI | AzureOpenAI |
Endpoint, API Key, Deployment |
| Anthropic | Anthropic |
API Key |
| Ollama | Ollama |
Local Ollama instance |
Local Development with Ollama
For fully local development without API keys:
- Install Ollama
- Pull required models:
ollama pull mxbai-embed-large # Recommended: 1024 dims, stable ollama pull llama3.2 - Set providers to
Ollamain configuration - Configure vector size to match embedding model:
| Embedding Model | Vector Size | Notes |
|---|---|---|
mxbai-embed-large |
1024 | Recommended for stability |
nomic-embed-text |
768 | May crash on some PDFs (Ollama Windows bug) |
all-minilm |
384 | Smaller, faster |
Query Guardrails
DNFileRAG includes relevance score filtering to prevent off-topic queries:
{
"Rag": {
"MinRelevanceScore": 0.6
}
}
Queries with no documents above the threshold return a "no relevant information" response without calling the LLM, saving cost and preventing hallucination
Docker
docker-compose up -d
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Qdrant - Vector database
- Serilog - Structured logging
- PdfPig - PDF parsing
- DocumentFormat.OpenXml - DOCX parsing
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- DNFileRAG.Core (>= 1.0.0)
- DocumentFormat.OpenXml (>= 3.3.0)
- HtmlAgilityPack (>= 1.12.4)
- Microsoft.Extensions.Hosting.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Http (>= 9.0.0)
- Microsoft.Extensions.Options (>= 9.0.0)
- PdfPig (>= 0.1.12)
- Qdrant.Client (>= 1.16.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.