Introduction

JigsawStack Prompt Engine is a powerfult API built from the ground up to execute any prompt or instruction seamlessly. It intelligently selects the best model from a cluster of state-of-the-art models, allowing you to focus on results without worrying about GPUs, tokens, or rate limits.

prompt engine

The Prompt Engine takes in three things: the prompt, dynamic variables, and the output structure you expect every single time you run the prompt. The last two are optional. The Prompt Engine automatically enhances the initial prompt to improve accuracy, reduce token usage, and prevent output structure breakage.

The Prompt Engine can be utilized in two ways:

  1. Creating and running a reusable prompt (recommended)
  2. Executing a prompt directly
prompt engine

For better reliability and prompt optimization, it is recommended to first Create a Prompt and then Run the Prompt

The Prompt

This is the instruction that should be executed. It can be of two forms:

  1. Basic prompt: Has no dynamic variables. i.e Tell me about the leaning tower of Pisa!
  2. Dynamic prompt: Has dynamic variables. i.e Tell me about { item }

Prompt return type

The Prompt Engine supports 3 types of return types:

  1. String
{
    prompt: "Tell me about {item}",
    inputs: [
      {
        key: "item",
        optional: false,
        initial_value: "Leaning Tower of Pisa",
      },
    ],
    return_prompt: "Return the result in a markdown format",
  }
  1. Array<object>

{
    prompt: "Tell me a story about {item}",
    inputs: [
      {
        key: "item",
        optional: false,
        initial_value: "Leaning Tower of Pisa",
      },
    ],
    return_prompt: [{ excerpt: "short story text", summary: "summary of story" }],
  }
  1. Object
{
    prompt: "Tell me a story about {item}",
    inputs: [
      {
        key: "item",
        optional: false,
        initial_value: "Leaning Tower of Pisa",
      },
    ],
    return_prompt: { excerpt: "short story text", summary: "summary of story" },
  }

Dynamic Inputs

These are variables that can be used within the prompt to add data dynamically.

Here is an example:

{
    prompt: "Tell me a story about {item}",
    inputs: [
      {
        key: "item", // dynamic prompt
        optional: false,
        initial_value: "Leaning Tower of Pisa",
      },
    ],
    return_prompt: { excerpt: "short story text", summary: "summary of story" },
  }
  • key: This is the name of the variable.
  • optional: Controls whether the variable is optional.
  • initial_value: This is the initial value of the variable.

How to use inject an input while running the prompt:

const result = await jigsawstack.prompt_engine.run({
  id: "e58d762a-9a00-4907-8cab-5ce6221bb6df",
  input_values: {
    item: "Leaning Tower of Pisa",
  },
});