npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

promptml

v1.0.6

Published

An open source markup language for A.I. prompts

Downloads

439

Readme

PromptML

Build Status

PromptML is a Node.js library designed to simplify the process of generating and validating AI prompts. It allows users to specify prompt details, validation rules, and other configurations in a YAML file, making AI interactions more structured and easier to manage.

Installation

To use PromptML in your project, install it via npm:

npm install promptml

Usage

Here’s a quick example to get you started with PromptML. This example demonstrates how to use the library to process a YAML file containing prompt specifications.

First, ensure you have a YAML file with your prompt configuration. For example, test.prompt:

metadata:
  version: 1.0
  lastUpdated: "06/04/2024"
  createdBy: "Your Name"

engine: gpt-4-turbo-preview
role: You are a helpful assistant designed to output motivational quotes
prompt: >
  Generate a motivational quote in english along with the author and output the response in
  JSON with key names quote and author
validations:
  - type: format
    expected: JSON
    schema:
      required_keys: [quote, author]
  - type: language
    expected: English

Then, use the following code snippet to process the YAML file:

javascript code

const askTheAI = require('promptml');
//
//
const response = await askTheAI(filePath);

Features

  • Flexible Prompt Configuration: Define prompts, roles, and more in an easy-to-read YAML format.

  • Validation Rules: Ensure outputs meet specified criteria, including format, language, length, choices etc. The following will throw if the expected response is not either of "correct" or "incorrect"

    - type: response
      expected: [ correct, incorrect ]

    The following will throw an error if the expected response isn't in English

    - type: language
      expected: English

    The following will throw an error if the response length doesn't fall into the specified bounds

      - type: length
        min: 10
        max: 100

    The following expects a JSON with keys quote and author mandatorily present in the JSON. You can of course skip the key checks

    - type: format
      expected: JSON
      schema:
        required_keys: [quote, author]

    The following expects the response to match a regular expression

    - type: regex
      expected: "[A-Za-z]{10}"
      strict: true

    And with strict false, it will trz to do the damage control and extract whatever it can using the specified regex

    - type: regex
      expected: "[A-Za-z]{10}"
      strict: false

    the above code will extract from Here is a random string : AaUhGGlozQb the value AaUhGGlozQb without throwing any errors!

  • Support for Multiple AI Engines: Configure the library to use different AI models as needed.

  • Pass parameters into the prompt: Pass inline or external parameters to be injected into the prompts

    inputs:
      - type: scalar
        name: author
      - type: scalar
        name: numberOfQuotes
    
    engine: gpt-4-turbo-preview
    role: You are a helpful assistant designed to output motivational quotes
    prompt: "Generate {{numberOfQuotes}} motivational quote by {{author}}"
    
    const response = await askTheAI(filePath, { "author": "Abraham Lincoln", "numberOfQuotes": 3 });

Contributing

We welcome contributions! Please submit an issue or pull request on our GitHub repository if you'd like to contribute.

License

PromptML is MIT licensed.


Notes:

  • Replace placeholders (like Your Name, GitHub repository link, and LICENSE link) with actual data.
  • Consider adding more sections as necessary, such as Configuration, Advanced Usage, API Reference, and Support.
  • If your library has external dependencies, consider adding a section on Requirements.
  • Regularly update your README to reflect changes in your library's functionality and API.