Skip to main content

Installation

The Python package is installed as futureagi but imported as fi.

Template structure

Basic components

  • Name: unique identifier (required)
  • Messages: ordered list of messages
  • Model configuration: model + generation params
  • Variables: dynamic placeholders used in messages

Message types

  • System: sets behavior/context
  • User: contains the prompt; supports variables like {{var}}
  • Assistant: few-shot examples or expected outputs

Model configuration fields

model_name, temperature, frequency_penalty, presence_penalty, max_tokens, top_p, response_format, tool_choice, tools

Placeholders and compile

Add a placeholder message (type="placeholder", name="...") in your template. At compile time, supply an array of messages for that key; {{var}} variables are substituted in all message contents.

Create templates


Versioning (step-by-step)

  • Build the template (see above)
  • Create draft v1 (JS/TS: await client.open(); Python: client.create())
  • Update draft & save (JS/TS: saveCurrentDraft(); Python: save_current_draft())
  • Commit v1 and set default (JS/TS: commitCurrentVersion("msg", true); Python: commit_current_version)
  • Open a new draft (JS/TS: createNewVersion(); Python: create_new_version())
  • Delete if needed (JS/TS: delete(); Python: delete())

Labels (deployment control)

  • System labels: Production, Staging, Development (predefined by backend)
  • Custom labels: create explicitly and assign to versions
  • Name-based APIs: manage by names (no IDs needed)
  • Draft safety: cannot assign labels to drafts; assignments are queued and applied on commit

Assign labels

Remove labels

List labels and mappings


Fetch by name + label (or version)

  • Precedence: version > label
  • Python default: if no label is provided, defaults to “production”
  • Return type: get_template_by_name() returns a Prompt object (not a PromptTemplate). You can call .compile() directly on it.

A/B testing with labels (compile -> OpenAI gpt‑4o)

Fetch two labeled versions of the same template (e.g., prod-a and prod-b), randomly select one, compile variables, and send the compiled messages to OpenAI.
The compile() API replaces {{var}} in string contents and preserves structured contents. Ensure your template contains the variables you pass (e.g., {{name}}, {{city}}).
For analytics, attach the selected label/version to your logs or tracing so A/B results can be compared.

Compile output format

The compile() method returns messages in a provider-agnostic format. Each message contains structured content that you may need to convert for your target LLM provider. Output structure:
The content field contains a stringified list of content parts. This format supports multimodal content (text, images, etc.) and is intentionally provider-agnostic. Write an adapter function to convert to your target provider’s format.

OpenAI adapter example