Prompt templates allow you to create reusable, parameterized prompts for your AI models. They support system messages, user messages, and assistant messages with variable substitution capabilities.

Template Structure

Basic Components

  1. Name: A unique identifier for your template (required, max 255 characters)
  2. Messages: A list of messages that make up the prompt template
  3. Model Configuration: Settings for the AI model
  4. Variables: Dynamic placeholders that can be substituted with different values

Message Types

System Message
  • Sets the behavior/context for the AI
  • Required content field
  • Example:
{
    "role": "system",
    "content": "You are a helpful assistant."
}
User Message
  • Contains the actual prompt with optional variables
  • Variables are denoted using double curly braces: {{variable_name}}
  • Example:
{
    "role": "user",
    "content": "What is the weather like in {{city}}?"
}
Assistant Message
  • Contains model responses
  • Used for few-shot learning examples
  • Example:
{
    "role": "assistant",
    "content": "The weather in Paris is sunny with a high of 25°C."
}

Model Configuration

You can customize the following parameters:
ParameterDescriptionDefaultRange
model_nameThe AI model to usegpt-4-
temperatureControls response randomness0.70-1
frequency_penaltyPenalizes frequent tokens0-2 to 2
presence_penaltyPenalizes repeated topics0-2 to 2
max_tokensMaximum response length10001-4096
top_pControls response diversity1.00-1

Creating Templates

Using Python SDK

# Import required modules
from fi.prompt import PrompClient, PromptTemplate, SystemMessage, UserMessage, ModelConfig

# Create a simple weather template
template = PromptTemplate(
    name="weather_template",
    messages=[
        SystemMessage(content="You are a weather information assistant."),
        UserMessage(content="What's the weather like in Tokyo?")
    ],
    model_configuration=ModelConfig(
        model_name="gpt-4o",
        temperature=0.5,
        max_tokens=1000,
        top_p=1.0,
        frequency_penalty=0,
        presence_penalty=0
    )
)

# Create the template
prompt_client = PromptClient(template=template)
prompt_client.create()

Using Future AGI Platform

  1. Navigate to the Prompts section
  2. Click “Create New Template”
  3. Fill in the template details:
    • Name
    • System message
    • User messages with variables
    • Model configuration
  4. Save the template

Variables and Dynamic Content

  • Variables make templates reusable across different inputs
  • Use double curly braces: {{variable_name}}
  • Variables are automatically detected from the content
  • Can be used in user messages
  • Example usage:
# Create a template with multiple variables
template = PromptTemplate(
    name="greeting_template",
    messages=[
        SystemMessage(content="You are a friendly assistant."),
        UserMessage(content="Hello, how is the weather in {{city}}?")
    ],
    model_configuration=ModelConfig(model_name="gpt-4")
)
prompt_client = PromptClient(template=template)
prompt_client.create()
prompt_client.run(variables={"city": ["Tokyo", "Paris", "London"]})

Prompt Template Versioning (Step-by-Step)

Use these six small steps to manage prompt-template versions with either the TypeScript or Python SDK.

1️⃣ Build the template definition

Create a PromptTemplate object locally—this holds the prompt messages, variables, and model parameters you plan to version.
import { PromptTemplate, MessageBase, ModelConfig } from "@futureagi/sdk";

const tpl: PromptTemplate = {
  name: "intro-template",
  messages: [
    { role: "system", content: "You are a helpful assistant." } as MessageBase,
    { role: "user", content: "Introduce {{name}} from {{city}}." } as MessageBase,
  ],
  variable_names: { name: ["Ada"], city: ["Berlin"] },
  model_configuration: new ModelConfig({ model_name: "gpt-4o-mini" }),
};

2️⃣ Create draft version 1

Send the template to Future AGI; the backend stores it as draft v1, ready for further edits.
import { Prompt } from "@futureagi/sdk";
const client = new Prompt(tpl);
await client.open();   // creates draft v1 on the server

3️⃣ Update the draft & save

Tweak the draft content in memory and then save—this writes your changes back to the server without locking the version yet.
tpl.messages[1].content = "⭐️ New wording for {{name}} in {{city}}.";
await client.saveCurrentDraft();

4️⃣ Commit v1 and set as default

Freeze the current draft, turning it into an immutable version 1 and optionally making it the live/default version for use.
await client.commitCurrentVersion("Finished v1", true);

5️⃣ Open a new draft version (v2)

Start a fresh draft (v2) so you can iterate without affecting the committed v1.
await client.createNewVersion();  // now on draft v2

6️⃣ Clean-up

If you want to delete the template, you can do so by calling the delete method.
await client.delete();