RAGFlowSharp is a .NET-based RAG (Retrieval-Augmented Generation) workflow management library that provides a comprehensive set of APIs to manage various components in RAG applications.
- Dataset Management
- File Processing
- Text Chunking
- Session Management
- Intelligent Agent
- Chat Assistant
dotnet add package RAGFlowSharp
// Configure services in Program.cs or Startup.cs
services.AddRAGFlowSharp(options =>
{
options.ApiKey = "<your-api-key>";
options.BaseUrl = "http://your.ragflow.base.url";
});
public class MyRAGService
{
private readonly IRagflowApi _ragflowApi;
public MyRAGService(IRagflowApi ragflowApi)
{
_ragflowApi = ragflowApi;
}
public async Task ProcessDocument()
{
// Create dataset
var dataset = await _ragflowApi.DatasetApi.CreateDatasetAsync(new CreateDatasetRequest
{
Name = "MyDataset",
Description = "Sample Dataset"
});
// Upload file
var file = await _ragflowApi.FileApi.UploadFileAsync(new UploadFileRequest
{
DatasetId = dataset.Id,
FileName = "example.pdf",
FileContent = File.ReadAllBytes("path/to/file.pdf")
});
// Process text chunks
var chunks = await _ragflowApi.ChunkApi.ProcessFileAsync(new ProcessFileRequest
{
FileId = file.Id
});
// Create session
var session = await _ragflowApi.SessionApi.CreateSessionAsync(new CreateSessionRequest
{
DatasetId = dataset.Id
});
// Use chat assistant
var response = await _ragflowApi.ChatAssistantApi.ChatAsync(new ChatRequest
{
SessionId = session.Id,
Message = "Please analyze the main content of this document"
});
}
}
- Create dataset
- Get dataset list
- Update dataset information
- Delete dataset
- Upload file
- Get file list
- Delete file
- Get file content
- Process file chunks
- Get chunk list
- Update chunk information
- Delete chunk
- Create session
- Get session history
- Update session status
- Delete session
- Create agent
- Configure agent behavior
- Execute agent tasks
- Manage agent status
- Send message
- Get response
- Manage conversation context
- Configure assistant parameters
Issues and Pull Requests are welcome!
MIT License