ZeroPrompt.Core 1.3.0

dotnet add package ZeroPrompt.Core --version 1.3.0
                    
NuGet\Install-Package ZeroPrompt.Core -Version 1.3.0
                    
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="ZeroPrompt.Core" Version="1.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ZeroPrompt.Core" Version="1.3.0" />
                    
Directory.Packages.props
<PackageReference Include="ZeroPrompt.Core" />
                    
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 ZeroPrompt.Core --version 1.3.0
                    
#r "nuget: ZeroPrompt.Core, 1.3.0"
                    
#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 ZeroPrompt.Core@1.3.0
                    
#: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=ZeroPrompt.Core&version=1.3.0
                    
Install as a Cake Addin
#tool nuget:?package=ZeroPrompt.Core&version=1.3.0
                    
Install as a Cake Tool

๐ŸŽฏ ZeroPrompt: Sovereign Pure C# Prompt Templating & Grammar-Constrained Engine

Version: 1.3.0 License: MIT .NET Multi-Targeting Zero External Dependencies

ZeroPrompt is an industrial-grade, zero-allocation prompt templating, Pushdown Automaton (PDA) JSON Schema state machine, Grammar-Constrained Logit Masker, and dynamic few-shot exemplar selector written in 100% pure C#. It operates at Tier 5 (Presentation & Orchestration) of the ZeroPlatform ecosystem.


โšก Key Capabilities

  • Zero-Allocation Prompt Templating (PromptTemplate):
    • Blazing-fast variable interpolation syntax {{variable_name}} without heavyweight regex or runtime reflection.
    • Span-based rendering directly into StringBuilder buffers.
    • Parameter validation and missing variable tracking.
  • Pushdown Automaton (PDA) JSON Grammar Engine (JsonGrammarState):
    • Microsecond deterministic stack-based validation of LLM generation streams.
    • Tracks nested objects ({), arrays ([), string literals, escape sequences, colons, and commas.
  • Schema-Constrained JSON Pushdown Automaton (SchemaConstrainedJsonGrammar):
    • 64-bit Bitmask Property Validation: Maps property indices to 64-bit unsigned integers (ulong), enforcing property whitelists, required property completeness, and strict data type constraints with single-cycle bitwise operations.
    • Zero Heap Allocations: Replaces heap-allocated bracket stacks with a fixed inline buffer (char[16]), reducing token candidate testing latency to under $0.5,\mu\text{s}$.
  • Strict Tool Calling Finite Automaton (ToolCallGrammarState):
    • Governs the <tool_call>{"tool": "<name>", "parameters": { ... }}</tool_call> syntax.
    • Zero Tool Name Hallucination: Only allows the generation of tool names explicitly registered in the agent's tool catalog. Automatically switches parameter schemas upon tool name resolution.
  • Context-Aware Grammar Logit Processor (ToolCallGrammarLogitProcessor):
    • Integrates directly with ZeroLlm via ContextAwareLogitProcessor. Dynamically sets invalid syntax/schema token logits to $-\infty$ (-1e9f), mathematically guaranteeing 100% syntactically valid JSON tool calls.
  • Dynamic Few-Shot Exemplar Selector (FewShotSelector):
    • Backed by ZeroVector.Core hardware-accelerated SIMD vector similarity (VectorMetrics.CosineSimilarity).
    • Dynamically selects the top-$K$ most semantically relevant few-shot demonstrations for prompts.
  • Transformer KV-Cache Layout Optimizer (PromptLayoutOptimizer):
    • Partitions prompt components strictly into cacheable static prefixes (StaticSystem, ToolDefinitions, FewShot, ContextRAG) and dynamic request-specific payloads (History, DynamicSuffix), cutting TTFT by up to 70%.
  • Zero External Dependencies & Multi-Targeting:
    • Compatible with .NET 8.0+, .NET Framework 4.6.2+, and .NET Standard 2.0.

๐Ÿš€ Quick Start

1. Template Rendering

using ZeroPrompt.Core.Templates;

var template = new PromptTemplate("You are a SCADA diagnostic engineer for line {{line_id}}. Analyze status: {{status}}.");
var context = new PromptContext()
    .Set("line_id", "LINE-04")
    .Set("status", "OVERHEAT_ALARM");

string prompt = template.Render(context);
Console.WriteLine(prompt);

2. Schema-Constrained JSON Grammar

using ZeroPrompt.Core.Grammar;

var schema = new JsonSchemaConstraint("so_query")
    .AddProperty("order_id", SchemaPropertyType.String, required: true)
    .AddProperty("limit", SchemaPropertyType.Number, required: false);

var grammar = new SchemaConstrainedJsonGrammar(schema);

// Validate character transitions with zero heap allocation
bool valid = grammar.CanAcceptNext("{\"order_id\": \"SO-2026-001\"}".AsSpan());
Console.WriteLine($"Valid: {valid}");

3. Tool Call Grammar Logit Masking

using ZeroPrompt.Core.Grammar;

var schemas = new Dictionary<string, JsonSchemaConstraint>
{
    ["mds_db_so_query"] = new JsonSchemaConstraint("mds_db_so_query")
        .AddProperty("order_id", SchemaPropertyType.String, required: true)
};

var processor = new ToolCallGrammarLogitProcessor(tokenizer, schemas);

// Applied directly during LLM autoregressive token sampling
processor.Process(logitsSpan, pastTokensSpan);

๐Ÿ›ก๏ธ Architecture & Tier Compliance

flowchart TD
    PromptTemplate["ZeroPrompt.Core.Templates\n(PromptTemplate, PromptContext)"]
    JsonGrammar["ZeroPrompt.Core.Grammar\n(SchemaConstrainedJsonGrammar, ToolCallGrammarState)"]
    LogitMasker["ZeroPrompt.Core.Grammar\n(ToolCallGrammarLogitProcessor)"]
    FewShot["ZeroPrompt.Core.FewShot\n(FewShotSelector, Exemplar)"]
    
    FewShot --> VectorMetrics["ZeroVector.Core.Metrics\n(SIMD CosineSimilarity)"]
    LogitMasker --> ZeroLlm["ZeroLlm.Core.Sampling\n(ContextAwareLogitProcessor)"]
    JsonGrammar --> ZeroAgent["ZeroAgent.Core\n(AgentToolRegistry)"]

๐Ÿ“„ License

Architected and developed by Phong Vรต (kzxl) for the ZeroUniverse / ZeroPlatform ecosystem. Released under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on ZeroPrompt.Core:

Package Downloads
ZeroAgent.Core

Pure C# enterprise-grade cognitive AI Agent runtime (ReAct loop, tool registry, episodic memory via ZeroVector, and multi-agent swarm) for .NET.

ZeroAgent.Tools

Industrial and Operational Toolset for ZeroAgent (PLC Modbus, Gorilla TSDB Query, Host Telemetry, Columnar DataFrame, and HITL Safety Gates) in 100% pure C#.

ZeroAgent.Dialog

Deterministic Semantic Task-Oriented Dialogue System and Multi-Tier Agentic Memory Engine (Non-LLM) for ZeroAgent.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.3.0 54 10/3/2026
1.2.0 68 10/2/2026
1.1.0 81 10/1/2026
1.0.0 62 10/1/2026