priompt  by anysphere

JSX-based prompting library for context window management

created 2 years ago
2,651 stars

Top 18.1% on sourcepulse

GitHubView on GitHub
Project Summary

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

  • Install: npm install @anysphere/priompt && npm install -D @anysphere/priompt-preview (or yarn/pnpm equivalents).
  • Prerequisites: Node.js.
  • Examples: Refer to examples/README.md.

Highlighted Details

  • JSX-based declarative prompt authoring.
  • Priority-based content inclusion for context window management.
  • Components for messages (<UserMessage>, <AssistantMessage>, <SystemMessage>), tool definitions (<Tools>, <ZTools>), and more.
  • Features like onEject/onInclude callbacks and sourcemaps for debugging.

Maintenance & Community

  • MIT Licensed. Contributions are welcome.

Licensing & Compatibility

  • MIT License. Permissive for commercial use and closed-source linking.

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.

Health Check
Last commit

6 months ago

Responsiveness

1+ week

Pull Requests (30d)
0
Issues (30d)
0
Star History
198 stars in the last 90 days

Explore Similar Projects

Starred by Chip Huyen Chip Huyen(Author of AI Engineering, Designing Machine Learning Systems), Jeff Hammerbacher Jeff Hammerbacher(Cofounder of Cloudera), and
2 more.

prompt-engine by microsoft

0.0%
3k
NPM library for LLM prompt engineering
created 3 years ago
updated 2 years ago
Feedback? Help us improve.