Installation

SmartRAG is available as a NuGet package and supports .NET Standard 2.0/2.1, making it compatible with .NET Framework 4.6.1+, .NET Core 2.0+, and .NET 5+ applications. Choose your preferred installation method:

dotnet add package SmartRAG
Install-Package SmartRAG
<PackageReference Include="SmartRAG" Version="2.3.1" />

Configuration

Configure SmartRAG in your Program.cs or Startup.cs:

// Program.cs
using SmartRAG;

var builder = WebApplication.CreateBuilder(args);

// Add SmartRAG services
builder.Services.AddSmartRAG(options =>
{
    options.AIProvider = AIProvider.Anthropic;
    options.StorageProvider = StorageProvider.Qdrant;
    options.ApiKey = "your-api-key";
});

var app = builder.Build();

Quick Example

Here's a simple example using the actual SmartRAG implementation with conversation history:

// Inject the document search service
public class SearchController : ControllerBase
{
    private readonly IDocumentSearchService _documentSearchService;
    
    public SearchController(IDocumentSearchService documentSearchService)
    {
        _documentSearchService = documentSearchService;
    }
    
    [HttpPost("search")]
    public async Task<ActionResult> Search([FromBody] SearchRequest request)
    {
        string query = request?.Query ?? string.Empty;
        int maxResults = request?.MaxResults ?? 5;

        if (string.IsNullOrWhiteSpace(query))
            return BadRequest("Query cannot be empty");

        try
        {
            var response = await _documentSearchService.GenerateRagAnswerAsync(query, maxResults);
            return Ok(response);
        }
        catch (Exception ex)
        {
            return StatusCode(500, $"Internal server error: {ex.Message}");
        }
    }
}

public class SearchRequest
{
    [Required]
    public string Query { get; set; } = string.Empty;

    [Range(1, 50)]
    [DefaultValue(5)]
    public int MaxResults { get; set; } = 5;
}</code></pre>
                    </div>
                </div>
            </div>
        </section>

        
        

💬 Conversation History

SmartRAG automatically manages conversation history using intelligent session management. Each conversation maintains context across multiple questions and answers without requiring manual session handling.

How It Works

  • Automatic Session Management: Session IDs are generated and managed automatically
  • Automatic Context: Previous questions and answers are automatically included in context
  • Intelligent Truncation: Conversation history is intelligently truncated to maintain optimal performance
  • Storage Integration: Conversation data is stored using your configured storage provider

Usage Example

// First question
var firstRequest = new SearchRequest
{
    Query = "What is machine learning?",
    MaxResults = 5
};

// Follow-up question (remembers previous context automatically)
var followUpRequest = new SearchRequest
{
    Query = "Can you explain supervised learning in more detail?",
    MaxResults = 5
};

// Another follow-up
var anotherRequest = new SearchRequest
{
    Query = "What are the advantages of deep learning?",
    MaxResults = 5
};

Pro Tip

SmartRAG automatically manages session IDs and conversation context. No need to manually handle session management!

Next Steps

Now that you have SmartRAG installed and configured, explore these features:

Configuration

Learn about advanced configuration options and best practices.

Configure

API Reference

Explore the complete API documentation with examples.

View API

Examples

See practical examples including conversation history usage.

View Examples

Features

Discover all SmartRAG features including conversation management.

Explore Features

Need Help?

If you encounter any issues or need assistance:

</div> </div>