PitchHut
Log in / Sign up
One Prompt
39 views
Streamline your prompt engineering with structure and reliability.
Pitch

One Prompt is a powerful library designed to enhance prompt engineering with XML-based templates, variable management, and robust error handling. With full TypeScript support and zero-loss serialization, it ensures your prompts are structured, valid, and reliable, making your development process more efficient.

Description

OnePrompt is a powerful library designed to enhance the practice of prompt engineering by providing a structured, validated, and reliable framework. This innovative library offers a unique XML-based approach, enabling developers to manage their prompts with clarity and efficiency.

Key Features

  • XML-based Template Definition: Create prompts that are clear, structured, and self-documenting, making them easy to understand and maintain.
  • Variable Management: Seamlessly manage both required and optional variables, complete with default values, to simplify prompt creation.
  • Robust Error Handling: Benefit from clear and actionable error messages to quickly identify and resolve issues.
  • Zero-Loss Serialization: Ensure perfect round-trips between parsing and serialization, safeguarding the integrity of your prompt data.
  • Type-Safe API: Enjoy full TypeScript support, enhancing type safety and developer confidence.

Quick Start Example

Begin utilizing OnePrompt with just a few lines of code. Here's a basic example of rendering a prompt:

import { OnePrompt } from 'oneprompt';

const promptXmlString = `
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
  <title>AI Assistant</title>
</metadata>

<variables>
  <var name="name" required="true" />
  <var name="expertise" required="false">general knowledge</var>
</variables>

<template>
You are an AI assistant specialized in {{expertise}}.
Your user's name is {{name}}.
</template>
`;

const rendered = OnePrompt.render(promptXmlString, {
  name: "Alice",
  expertise: "quantum physics" // optional
});

Prompt Structure

OnePrompt prompts are composed of three main sections:

  1. Metadata: Offers a title and optional descriptions that enhance the context of the prompt.

    <metadata>
      <title>My Prompt</title>
      <description>Optional description</description>
    </metadata>
    
  2. Variables: Define both required and optional variables.

    <variables>
      <var name="user" required="true" />
      <var name="mode" required="false">friendly</var>
    </variables>
    
  3. Template: The actual prompt template with placeholders for variables.

    <template>
    Hello {{user}}! I'll be {{mode}} in our interaction.
    </template>
    

Error Handling and Validation

OnePrompt provides functional methods for validating and processing prompts. For instance, you can validate a prompt structure easily:

const prompt = {
  metadata: { title: "Test Prompt" },
  variables: [
    { name: "user", required: true },
    { name: "style", required: false, default: "casual" }
  ],
  template: "Hello {{user}}, this is a {{style}} message."
};

OnePrompt.validate(prompt); // Will throw if invalid

The Value Proposition

As AI applications grow in complexity, OnePrompt addresses the challenges faced by developers in managing prompts. This library:

  • Enhances error management: By enforcing structure and validation.
  • Promotes reusability: Makes prompts easier to use in multiple contexts with a clear interface.
  • Facilitates collaboration: The XML-based format makes it easier for teams to work together on prompt design and documentation.

By integrating software engineering best practices into prompt engineering, OnePrompt empowers developers to create efficient, maintainable, and error-free prompts with ease. Whether you are developing complex AI solutions or simple applications, OnePrompt stands ready to streamline your workflow.