Skip to content

manusoft/ManuHub.PromptKit

Repository files navigation

Static Badge NuGet Version NuGet Downloads

Visitors

ManuHub.PromptKit

A lightweight, production-ready .NET library for building dynamic prompt templates with clean, fluent APIs.

No AI dependencies. No vendor lock-in. Just clean prompt composition.


🚀 Why this exists

AI apps constantly suffer from:

  • messy string templates
  • duplicated prompts
  • hard-to-debug variable issues
  • no prompt version control
  • unclear final output

PromptKit solves this.


✨ Features

  • Fluent prompt builder API
  • File-based prompt loading
  • Object/model binding
  • Prompt composition system
  • Debugging & diagnostics tools
  • Token estimation helper
  • Serialization support (JSON)
  • Fully testable architecture
  • No external dependencies

📦 Installation

dotnet add package ManuHub.PromptKit

⚡ Quick Start

using ManuHub.PromptKit;

var result = Prompt.From("Hello {{name}}")
    .Set("name", "Manoj")
    .Render();

Console.WriteLine(result);

Output: Hello Manoj


📁 File-based prompts

var prompt = PromptLoader.Load("prompts/email.prompt")
    .Set("name", "Sarah")
    .Set("body", "Welcome!")
    .Render();

email.prompt content:

Subject: Welcome, {{name}}!
Body: Hi {{name}},\n\nWelcome to our service!\n\nBest regards,\nThe Team

Output:

Subject: Welcome, Sarah!
Body: Hi Sarah,

Welcome to our service!

Best regards,
The Team

🧠 Object binding

var result = Prompt.From("Hello {{name}}")
    .SetModel(new { name = "Alex" })
    .Render();

Output: Hello Alex


🧩 Prompt composition

var final = PromptComposer.Combine(
    Prompt.From("System: You are helpful assistant."),
    Prompt.From("User: Summarize {{text}}").Set("text", article)
);

Output:

System: You are helpful assistant.
User: Summarize [article content]

🐛 Debugging

var debug = Prompt.From("Hello {{name}}")
    .Debug();

Console.WriteLine(debug.FinalPrompt);
Console.WriteLine(string.Join(",", debug.MissingVariables));

Output:

Final Prompt: Hello {{name}}
Missing Variables: name

📊 Token estimation

var tokens = prompt.EstimateTokens();

Output: Estimated tokens: 5


💾 Serialization

var json = PromptSerializer.ToJson(prompt);
var restored = PromptSerializer.FromJson(json);

Output:

Serialized Prompt: {"Template":"Hello {{name}}","Variables":{"name":"Manoj"}}
Restored Prompt: Hello {{name}}

🧪 Testing

Fully covered with xUnit tests.

dotnet test

🏗️ Architecture

  • Immutable Prompt core
  • Snapshot-based serialization
  • Fluent API design
  • Zero dependency design

📌 Roadmap (future)

  • Prompt caching system
  • Prompt versioning system
  • Prompt performance profiler
  • Memory extension package (PromptKit.Memory)

📜 License

MIT

About

A lightweight, production-ready .NET library for building dynamic prompt templates with clean, fluent APIs.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages