PromptsLibrary 1.0.2
dotnet add package PromptsLibrary --version 1.0.2
NuGet\Install-Package PromptsLibrary -Version 1.0.2
<PackageReference Include="PromptsLibrary" Version="1.0.2" />
<PackageVersion Include="PromptsLibrary" Version="1.0.2" />
<PackageReference Include="PromptsLibrary" />
paket add PromptsLibrary --version 1.0.2
#r "nuget: PromptsLibrary, 1.0.2"
#:package PromptsLibrary@1.0.2
#addin nuget:?package=PromptsLibrary&version=1.0.2
#tool nuget:?package=PromptsLibrary&version=1.0.2
PromptsLibrary
A lightweight .NET library for managing and rendering templated prompts using Handlebars templates.
Features
- 📁 Group-based prompt organization
- 🎨 Handlebars template support
- 📝 Dynamic parameter injection
- 📊 Comprehensive logging
- ⚡ .NET 8 optimized
Installation
Add to your project via NuGet: Install-Package PromptsLibrary
Quick Start
Configuration
builder.Services.AddPromptsLibrary();
Create Prompts
create a text file (*.txt) with your desired name and put your prompt inside it.
Summarize the following text in {{count}} words.
{{text}}
Create Prompts Folder
Create a folder named prompts (lowercase recommended) in your project root:
Set the "Copy To Output Directory" for all of your prompts to "Copy Always" or "Copy if newer"
├── prompts/
│ ├── summarization/
│ │ ├── simple.txt
│ │ └── with-bullets.txt
│ ├── translation/
└── english-to-persian.txt
Usage
public async Task<string> SummarizeText(string text, int count = 150)
{
var parameters = new { text, count };
var prompt = _promptsLibraryService.RenderPrompt(
groupName: "summarization", //prompt parent folder
promptName: "simple", // without .txt extension
parameters: parameters
);
// Send to LLM...
}
Options
you can set the options via appsettings.json or when you creating the service
builder.Services.AddPromptsLibrary(options =>
{
options.PromptsFolderPath = "MyPrompts"; // default: "prompts"
options.SkipEmptyGroups = false; // default: true
options.SkipEmptyPrompts = false; // default: true
options.SkipUncompilablePrompts = true; // default: false
});
Dependencies
- Handlebars.Net - Template engine
- Microsoft.Extensions.Logging
- Microsoft.Extensions.Options
License
MIT
Contributing
Contributions are welcome! Please follow these guidelines:
- Create a feature branch
- Add/update tests
- Ensure all tests pass
- Submit a pull request
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. 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. |
-
net8.0
- Handlebars.Net (>= 2.1.3)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.0)
- System.Configuration.ConfigurationManager (>= 10.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.