JSX-based prompting library for context window management
Top 18.1% on sourcepulse
Priompt is a JSX-based library for designing prompts for Large Language Models (LLMs), enabling structured and prioritized content inclusion within limited context windows. It targets developers and researchers building complex LLM applications, offering a declarative approach to prompt engineering that mirrors web development patterns.
How It Works
Priompt renders prompts from JSX components, assigning priorities to elements to manage context window usage. It employs a binary search mechanism to find an optimal cutoff priority, ensuring the rendered prompt adheres to token limits while maximizing the inclusion of high-priority content. Key components like <scope>
, <first>
, and <empty>
allow fine-grained control over content inclusion, fallback strategies, and token reservation.
Quick Start & Requirements
npm install @anysphere/priompt && npm install -D @anysphere/priompt-preview
(or yarn/pnpm equivalents).examples/README.md
.Highlighted Details
<UserMessage>
, <AssistantMessage>
, <SystemMessage>
), tool definitions (<Tools>
, <ZTools>
), and more.onEject
/onInclude
callbacks and sourcemaps for debugging.Maintenance & Community
Licensing & Compatibility
Limitations & Caveats
The library acknowledges that overusing priorities might lead to hard-to-cache prompts, potentially increasing LLM inference costs or latency. The current renderer has performance limitations with very large numbers of scopes (over 10K) and may not always guarantee the absolute optimal token cutoff due to potential edge cases in its binary search implementation.
6 months ago
1+ week