Caution
This Repo is in an Early Preview state, meaning that everything is subject to change
A Simple and Opinionated AI RAG Solutions for SourceCode, where you just need to setup and point to your source and we take care of the rest.
Step 1: Install SimpleRag Nuget + your Embedding Generator (in this sample Azure OpenAI via Semantic Kernel and SQL Server 2025 as VectorStore)
dotnet add package SimpleRag
dotnet add package Microsoft.SemanticKernel
dotnet add package Microsoft.SemanticKernel.Connectors.SqlServer
string endpoint = builder.Configuration["AiEndpoint"]!;
string key = builder.Configuration["AiKey"]!;
string embeddingDeploymentName = builder.Configuration["AiEmbeddingDeploymentName"]!;
string sqlServerConnectionString = builder.Configuration["SqlServerConnectionString"]!;
string githubToken = builder.Configuration["GitHubToken"]!;
//Setup Github Credentials (optional, but needed if you wish to RAG data directly from GitHub)
builder.Services.AddSingleton(new GitHubCredentials(githubToken));
//Setup Embedding Generator
builder.Services.AddAzureOpenAIEmbeddingGenerator(embeddingDeploymentName, endpoint, key);
//Setup SimpleRag
builder.Services.AddSimpleRag(vectorStoreConfiguration, options => new SqlServerVectorStore(sqlServerConnectionString, new SqlServerVectorStoreOptions
{
EmbeddingGenerator = options.GetRequiredService<IEmbeddingGenerator<string, Embedding<float>>>()
}));
Step 3: Ingest Data into your VectorStore (in this sample the TrelloDotNet open-source repo)
public class IngestionExample(Ingestion ingestion, IServiceProvider serviceProvider)
{
public async Task Sync()
{
CollectionId collectionId = new("TrelloDotNet");
DataSourceProviderGitHub filesProvider = new(serviceProvider)
{
GitHubRepository = new()
{
Owner = "rwjdk",
Name = "TrelloDotNet"
}
};
await ingestion.IngestAsync(
[
new CSharpDataSource(serviceProvider)
{
CollectionId = collectionId,
Id = new SourceId("Code"),
Recursive = true,
Path = "src",
FileIgnorePatterns = "TrelloDotNet.Tests",
FilesProvider = filesProvider
},
new MarkdownDataSource(serviceProvider)
{
CollectionId = collectionId,
Id = new SourceId("Markdown"),
Recursive = true,
Path = "/",
FilesProvider = filesProvider
LevelsToChunk = 3,
}
], new IngestionOptions
{
OnProgressNotification = notification => Console.WriteLine(notification.GetFormattedMessageWithDetails()),
}, cancellationToken);
}
}
public class SearchExample(Search search)
{
public async Task<string> SearchAsync(string question)
{
SearchResult searchResult = await search.SearchAsync(new SearchOptions
{
CollectionId = new CollectionId("TrelloDotNet"),
SearchQuery = searchQuery,
NumberOfRecordsBack = 10
});
return searchResult.GetAsStringResult();
}
}