PromptStream.AI 0.8.5

dotnet add package PromptStream.AI --version 0.8.5
                    
NuGet\Install-Package PromptStream.AI -Version 0.8.5
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PromptStream.AI" Version="0.8.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PromptStream.AI" Version="0.8.5" />
                    
Directory.Packages.props
<PackageReference Include="PromptStream.AI" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PromptStream.AI --version 0.8.5
                    
#r "nuget: PromptStream.AI, 0.8.5"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package PromptStream.AI@0.8.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PromptStream.AI&version=0.8.5
                    
Install as a Cake Addin
#tool nuget:?package=PromptStream.AI&version=0.8.5
                    
Install as a Cake Tool

<p align="center"> <img src="https://github.com/AndrewClements84/PromptStream.AI/blob/master/assets/logo.png?raw=true" alt="PromptStream.AI" width="500"/> </p>

🧠 PromptStream.AI

Build Docs NuGet Version NuGetDownloads Coverage License: MIT Buy Me A Coffee


🧩 Description

PromptStream.AI — Token-aware prompt composition, validation, and conversational context toolkit for .NET.

Built atop Flow.AI.Core and TokenFlow.AI,
PromptStream.AI enables developers to compose, validate, generate, and manage multi-turn AI prompts with token budgeting, interpolation, and contextual memory.


⚙️ Key Features

  • 🧩 Token-aware prompt builder with variable interpolation ({{variable}} syntax)
  • Validation engine for token limits, structure, and completeness
  • 💬 Shared Core Models from Flow.AI.Core (PromptTemplate, PromptInstance, PromptMessage, PromptResponse)
  • 🧠 Context manager with replay, merge, summarization, and JSON persistence
  • 💾 Persistent context storage (ToJson / LoadFromJson)
  • 🧮 Token budgeting tools (EstimateTokenUsage, TrimToTokenBudget)
  • CLI utility (PromptStream.AI.CLI) for building, validating, analyzing, and generating prompts
  • 🔌 Seamless integration with TokenFlow.AI for model-aware tokenization

🚀 Installation

dotnet add package PromptStream.AI

Requires:

  • .NET 8.0 or higher
  • Flow.AI.Core v0.2.0+
  • (optional) TokenFlow.AI for advanced token metrics

🧠 Quickstart Example

using System;
using System.Collections.Generic;
using Flow.AI.Core.Models;
using Flow.AI.Core.Interfaces;
using TokenFlow.AI.Integration;
using PromptStream.AI.Services;

// Initialize the service with token tracking
var tokenProvider = new BasicTokenFlowProvider();
var modelClient = new TokenFlowModelClient("gpt-4o-mini");
var context = new PromptContextManager();

var service = new PromptStreamService(tokenProvider, context, modelClient);

// Define a shared Core template
var template = new PromptTemplate
{
    Id = "summarize-v1",
    Template = "Summarize the following:\n\n{{input}}\n\nBe concise.",
    RequiredVariables = new() { "input" }
};

// Variables to inject
var variables = new Dictionary<string, string>
{
    ["input"] = "Flow.AI enables composable AI workflows for .NET developers."
};

// Build and validate
var (instance, validation) = service.BuildAndValidate(template, variables);

if (validation.IsValid)
{
    Console.WriteLine($"✅ Valid prompt ({validation.TokenCount} tokens)");
    Console.WriteLine(instance.RenderedText);
}
else
{
    Console.WriteLine($"❌ Invalid: {string.Join(", ", validation.Errors)}");
}

// Add a user message to the context
context.AddMessage(new PromptMessage { Role = "user", Content = instance.RenderedText });

💻 CLI Usage (PromptStream.AI.CLI)

PromptStream.AI includes a full command-line interface for developers to build, validate, analyze, and generate prompts directly from the terminal.

🧩 Build a prompt
dotnet run --project src/PromptStream.AI.CLI/PromptStream.AI.CLI.csproj -- build --template "Hello {{name}}" --var name=Andrew
✅ Validate a prompt
dotnet run --project src/PromptStream.AI.CLI/PromptStream.AI.CLI.csproj -- validate --template "Summarize {{topic}}" --var topic="AI in .NET"
🤖 Generate a model response
dotnet run --project src/PromptStream.AI.CLI/PromptStream.AI.CLI.csproj -- generate --template "Explain {{concept}}" --var concept="tokenization" --save context.json
🧠 Manage conversation context
dotnet run --project src/PromptStream.AI.CLI/PromptStream.AI.CLI.csproj -- context --load context.json --summarize
📊 Analyze prompt usage
dotnet run --project src/PromptStream.AI.CLI/PromptStream.AI.CLI.csproj -- analyze --template "Summarize {{topic}}" --var topic="AI" --model gpt-4o-mini

Available commands: | Command | Description | |----------|--------------| | build | Render a prompt with variable substitution | | validate | Validate prompt completeness and token limits | | generate | Build, validate, and produce a model-like response | | context | Load, save, summarize, or clear conversation context | | analyze | Estimate token usage and cost for prompts |


🌟 Supporting the Project

If you find PromptStream.AI helpful, please consider
starring the repository and ☕ supporting my work.
Your support helps keep the Flow.AI ecosystem growing.


Part of the Flow.AI Ecosystem
© 2025 Andrew Clements

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on PromptStream.AI:

Package Downloads
PromptStream.AI.Integration.TokenFlow

Integration adapter connecting PromptStream.AI with TokenFlow.AI for model-aware tokenization.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.8.5 183 10/13/2025
0.8.3 175 10/12/2025
0.8.1 169 10/12/2025
0.8.0 163 10/12/2025
0.1.5 121 10/11/2025
0.1.1 90 10/10/2025
0.1.0 96 10/10/2025