PromptStream.AI 0.1.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package PromptStream.AI --version 0.1.5
                    
NuGet\Install-Package PromptStream.AI -Version 0.1.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.1.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PromptStream.AI" Version="0.1.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.1.5
                    
#r "nuget: PromptStream.AI, 0.1.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.1.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.1.5
                    
Install as a Cake Addin
#tool nuget:?package=PromptStream.AI&version=0.1.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 NuGet 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
  • ๐Ÿ”ข Integrated token counting via ITokenFlowProvider
  • ๐Ÿง  Context manager with replay, merge, summarization, and JSON persistence
  • ๐Ÿ’ฌ Assistant reply tracking and multi-turn chat history
  • ๐Ÿ’พ Persistent context storage (ToJson / LoadFromJson)
  • ๐Ÿงฎ Token budgeting tools (EstimateTokenUsage, TrimToTokenBudget)
  • โšก CLI utility (PromptStream.AI.CLI) for building, validating, 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
  • (optional) TokenFlow.AI for model-specific token counting

๐Ÿง  Quickstart Example

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

// Create a token provider (TokenFlow.AI adapter)
var tokenProvider = new TokenFlowProvider("gpt-4o-mini");

// Initialize PromptStream service (with context-aware memory)
var service = new PromptStreamService(tokenProvider);

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

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

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 an assistant reply for multi-turn context
service.AddAssistantReply("Sure! Here's a short summary...");

๐Ÿ’ป CLI Usage (PromptStream.AI.CLI)

PromptStream.AI now includes a lightweight command-line interface for developers to build, validate, 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

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 |


๐Ÿงฉ Namespace Overview

Namespace Description
PromptStream.AI.Models Core prompt, validation, and message models
PromptStream.AI.Builders Responsible for rendering prompt templates
PromptStream.AI.Validation Handles validation, token limits, and structure
PromptStream.AI.Services High-level orchestrator combining build, validate, and context
PromptStream.AI.Context Manages conversational memory and context tracking
PromptStream.AI.Extensions Utility helpers for interpolation and cleanup
PromptStream.AI.CLI Developer command-line interface for building and testing prompts

๐Ÿงช Testing & Coverage

dotnet test --collect:"XPlat Code Coverage"

All core logic is tested using xUnit and coverlet, with full integration into Codecov for continuous coverage tracking.


๐Ÿ—บ๏ธ Roadmap

Feature Status
Core Models (PromptTemplate, PromptInstance, PromptValidationResult) โœ…
PromptBuilder & Validator โœ…
Context Manager & Message Tracking โœ…
Context Enhancements (merge, summarize, token budgeting, JSON persistence) โœ…
PromptStreamService orchestration layer โœ…
Assistant reply integration โœ…
CLI tool for build, validate, generate, context โœ…
Token cost estimator (TokenFlow.AI integration) ๐Ÿ”„ Planned
OpenAI-style function call validation ๐Ÿ”„ Planned
Visual prompt editor in Flow.AI Studio ๐Ÿ”„ Planned

๐Ÿค Contributing

Contributions are welcome!
If youโ€™d like to extend functionality or improve coverage, please fork the repo and submit a pull request.

See CONTRIBUTING.md for guidelines.


๐Ÿ“œ License

This project is licensed under the MIT License โ€” see the LICENSE file for details.


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