Core concepts

Prompts

Prompts define how a large language model behaves.

A Prompt on Humanloop encapsulates the instructions and other configuration for how a large language model should perform a specific task. Each change in any of the following properties creates a new version of the Prompt:

  • the template such as Write a song about {{topic}}
  • the model e.g. gpt-4o
  • all the parameters to the model such as temperature, max_tokens, top_p etc.
  • any tools available to the model

A Prompt is callable in that if you supply the necessary inputs, it will return a response from the model.

Inputs are defined in the template through the double-curly bracket syntax e.g. {{topic}} and the value of the variable will need to be supplied when you call the Prompt to create a generation.

This separation of concerns, keeping configuration separate from the query time data, is crucial for enabling you to experiment with different configurations and evaluate any changes. The Prompt stores the configuration and the query time data are stored in Logs, which can then be re-used in Datasets.

FYI: Prompts have recently been renamed from ‘Projects’. The Project’s “Model Configs” are now just each version of a Prompt. Some of the documentation and APIs may still refer to Projects and Model Configs.

Note that we use a capitalized “Prompt” to refer to the entity in Humanloop, and a lowercase “prompt” to refer to the general concept of input to the model.

1---
2model: gpt-4
3temperature: 1.0
4max_tokens: -1
5provider: openai
6endpoint: chat
7---
8<system>
9 Write a song about {{topic}}
10</system>
An example Prompt, serialized as a Promptfile

Versioning

A Prompt file will have multiple versions as you try out different models, params or templates, but they should all be doing the same task, and in general should be swappable with one-another.

By versioning your Prompts, you can track how adjustments to the template or parameters influence the LLM’s responses. This is crucial for iterative development, as you can pinpoint which versions produce the most relevant or accurate outputs for your specific use case.

When to create a new Prompt

You should create a new Prompt for every different ‘task to be done’ with the LLM. For example each of these tasks are things that can be done by an LLM and should be a separate Prompt File: extractive summary, title creator, outline generator etc.

We’ve seen people find it useful to also create a Prompt called ‘Playground’ where they can free form experiment without concern of breaking anything or making a mess of their other Prompts.

Using Prompts

Prompts are callable as an API. You supply and query-time data such as input values or user messages, and the model will respond with its text output.

TypeScript
1const chatResponse = await humanloop.chatDeployed({
2 project: "song writer",
3 inputs: {
4 topic: "debugging compiler errors",
5 },
6});

You can also use Prompts without proxying all requests through Humanloop.

Serialization (.prompt file)

Our .prompt file format is a serialized version of a model config that is designed to be human-readable and suitable for checking into your version control systems alongside your code. See the .prompt files reference reference for more details.

Format

The .prompt file is heavily inspired by MDX, with model and hyperparameters specified in a YAML header alongside a JSX-inspired format for your Chat Template.

Basic examples

1---
2model: gpt-4
3temperature: 1.0
4max_tokens: -1
5provider: openai
6endpoint: chat
7---
8<system>
9 You are a friendly assistant.
10</system>