Prompts are the input for LLMs, instructions or questions to complete a task or generate a response. Prompt formatting refers to the structure, style and layout used in a prompt. How a prompt is formatted influences the quality and relevance of the generated text. So it is important to format a prompt right.

Prompt Template

In Literal AI, you can create Prompt Templates in the playground or in code. A prompt template is a predefined structure that is used to create prompts. A prompt template is a reusable framework, consisting of instructions to the system and variables. Variables are used to insert specific information, like the question of the user, the context and previous responses by the LLM.

A prompt template in Literal AI can look as follows in code. It consists of a name, messages, tools and LLM model settings. Template Messages and Tools can contain variables, which are written like {{variable}} following the the Mustache prompt templating format.

Prompt Formatting

To use a Prompt Template in your application, you need to format this template with the relevant variables of the thread. With the Literal AI clients, you can format messages in the OpenAI format. This allows you to use prompts with integrations like OpenAI. Combining prompts with integrations (like the OpenAI integration) allows you to log the generations and to track which prompt versions were used to generate them.

Prompt formatting with the clients:

In an application using OpenAI, it can look as follows: