Configure Prompt Template

Sets up a prompt template to use by name in other AI script steps, given a model provider and predefined prompts you can customize.

Options 

Options available only when Template Type is SQL Query:

  • SQL Prompt is a text expression to define for how the model should construct SQL queries.

  • Natural Language Prompt is a text expression to explain how the model should provide its response.

Option available only when Template Type is Find Request:

  • Find Request Prompt is a text expression to define how the model should construct find requests. The predefined prompt includes the JSON format for a find request (the same as used by the FileMaker Data API), date and time formats, as well as other rules.

Option available only when Template Type is RAG Prompt:

  • RAG Prompt is a text expression to explain how the model should respond to a prompt sent to a RAG space on the AI Model Server.

Compatibility 

Product Supported
FileMaker Pro Yes
FileMaker Go Yes
FileMaker WebDirect Yes
FileMaker Server Yes
FileMaker Cloud Yes
FileMaker Data API Yes
Custom Web Publishing Yes

Originated in version 

22.0

Description 

This script step sets up a prompt template that you reference by name in the AI script steps that can use a prompt template. The predefined prompts in this script step are the same prompts that are used in the other AI script steps when they don't specify a prompt template. Prompt templates allow you to perform prompt engineering, customizing how prompts are structured and formatted for different model providers and use cases, and provide more consistent behavior across your AI scripts.

Prompt templates work by defining reusable prompt structures that incorporate template constants—placeholders that are dynamically replaced at runtime with actual values when the template is used in one of the AI script steps. The available constants to use in a particular template depend on the Template Type:

Constant Replaced with In prompts

:schema:

The database schema in Data Definition Language (DDL) format for the specified tables.

SQL Prompt
Natural Language Prompt
Find Request Prompt

:question:

The user's natural language question or prompt.

SQL Prompt
Natural Language Prompt
Find Request Prompt
RAG Prompt

:context:

The context information specified by the context_prompt key in the script step's Parameters option. For example, the Parameters option can be an expression that tells the model how to treat references to "today" using today's date in the system date format:

"{ \"context_prompt\": \"Treat 'today' as " & Get(CurrentDate) & "\"}"

Find Request Prompt
RAG Prompt

:sql_query:

The SQL query generated by the model.

Natural Language Prompt

:sql_results:

The results returned from executing the SQL query.

Natural Language Prompt

:date_format:

The system date format. Useful in prompts where you specify what date format the model should use.

Find Request Prompt

When an AI script step uses a template, the script step replaces the constants with the appropriate values based on the current context and operation being performed.

When this script step runs, the prompt template is available only to scripts in the current file for the duration of the current FileMaker client session.

Notes 

  • If a prompt template with the specified name already exists, this script step replaces it with the new configuration.

  • Prompt template names are case-sensitive. "MyTemplate" and "mytemplate" are treated as different templates.

  • If an AI script step references a prompt template name that doesn't exist, the error message "The requested template was not found." is returned.

  • If an AI script step uses a prompt template configured for a different model provider than the one specified in the AI account, an error is returned indicating the model provider mismatch.

  • Prompt template constants that are not applicable to the current operation are left unchanged in the prompt text.

Example 1 

Configures an AI account, then configures a prompt template for how the model should present its natural language response when referenced by a Perform SQL Query by Natural Language script step. The query asks a question about data in the Contacts table, which has data in Name and Company fields.

Copy
Configure AI Account [ Account Name: "my-account" ; Model Provider: OpenAI ; API key: Global::API_Key ]

Configure Prompt Template [ Template Name: "whimsical" ; Model Provider: OpenAI ; Template Type: SQL Query ; Natural Language Prompt: "The answer should be returned in plain text, not in JSON.¶ Respond in a light, whimsical tone." ]

Go to Layout [ "Contacts" (Contacts) ; Animation: None ]

Perform SQL Query by Natural Language [ Account Name: "my-account" ; Model: "gpt-4o" ; Prompt: "Which company does Alea work for?" ; Options specified: From list ; Action: Query ; Data Tables: From list ; Tables... ; Stream ; Prompt Template Name: "whimsical" ; Response Target: Contacts::Response ]

Possible response stored in the Contacts::Response field:

Alea, the illustrious individual in question, works for none other than Acme Anvils!

Example 2 

Configures an AI account, then configures a prompt template with extra information about how to find exact matches in a find request when referenced by a Perform Find by Natural Language script step. Adds to the predefined value for Find Request Prompt a rule for how to specify an exact match for an entire field using == (the first part of the predefined prompt is omitted for brevity) The prompt in the Perform Find by Natural Language script step asks for an exact match and returns the find request as JSON in the Response field.

Copy
Configure AI Account [ Account Name: "my-account" ; Model Provider: OpenAI ; API key: Global::API_Key ]

Configure Prompt Template [ Template Name: "find-exact" ; Model Provider: OpenAI ; Template Type: Find Request ; Find Request Prompt: "...10. To find items that match the entire fieldX value exactly, use this format: { \"fieldX\": \"==\" }" ]

Go to Layout [ "Contacts" (Contacts) ; Animation: None ]

Perform Find by Natural Language [ Account Name: "my-account" ; Model: "gpt-4o" ; Prompt: "Find contacts whose name is exactly Alea" ; Get: Find Request as JSON ; Response Target: Contacts::Response ; Prompt Template Name: "find-exact" ]

Possible find request returned in the Response field:

Copy
{"layouts":"Contacts","query":[{"Contacts::Name":"==Alea"}],"sort":[]}