Save Records as JSONL
Saves records to a specified JSONL file.
See also
Options
-
Format for fine-tuning specifies the output format for the JSONL file:
-
On: Creates a JSONL file suited for AI model fine-tuning with a messages array structure containing system, user, and assistant prompts from the table and fields you specify.
-
Off: Creates a JSONL file format with a messages array structure containing an assistant prompt specified by Completion Field, a user prompt with data from all other fields in the table you specify. It also contains a predefined system prompt.
-
-
Table specifies a table occurrence to export from based on the current found set of records.
-
Specify output file defines a list of one or more paths and filenames for the JSONL file to save as. Paths must use one of the
file
path prefixes. The script step searches the list and uses the first path and filename it can successfully save to. See Creating file paths. -
Create folders specifies whether to create new folders that you specify in the output file path.
Options available only when Format for fine-tuning is On:
-
System Prompt is a text expression that specifies system-level instructions that define the AI model's role and behavior. This prompt sets the context for how the model should respond.
-
User Prompt is a text expression that specifies user input or questions that will be used as training examples for the AI model.
-
Assistant Prompt is a text expression that specifies the expected AI assistant responses that correspond to the user prompts.
Options available only when Format for fine-tuning is Off:
-
Completion Field specifies the field in Table containing expected assistant responses or answers for training.
Compatibility
Product | Supported |
FileMaker Pro | Yes |
FileMaker Go | No |
FileMaker WebDirect | No |
FileMaker Server | Yes |
FileMaker Cloud | Yes |
FileMaker Data API | Yes |
Custom Web Publishing | Yes |
Originated in version
22.0
Description
This script step exports records from a FileMaker table to a file in the JSON Lines (JSONL) format. JSONL is a structured text file format where each line contains a separate, complete JSON object. A primary use for this format is as training data to fine-tune an AI model.
For each record in the current found set (or for each related record if Table specifies a related table), the script step saves a JSON object on a single line in the output file. The format depends on the Format for fine-tuning option.
Note Though shown below as multiple lines for clarity, each JSON object is on a single line in the JSONL file.
If Format for fine-tuning is | Output format is |
---|---|
On |
Copy
where:
|
Off |
Copy
where:
|
Notes
-
Field types are handled as follows:
-
Text and number fields are saved as JSON strings and numbers, respectively.
-
Date and time fields are saved as strings with the system locale formats used when the FileMaker Pro file was created.
-
Container fields are not supported and are skipped when the Format for fine-tuning option is Off. If this option is On, the name of the file in the container field is exported as a string, if present.
-
Calculation fields are saved based on their result type.
-
-
When the Format for fine-tuning option is On:
-
System Prompt is optional. If it isn't specified or if its specified data is an empty value, the object for the system role is omitted in the JSONL file.
-
User Prompt and Assistant Prompt are required. If their values are empty, the
content
values for the user and assistantroles
are empty strings.
-
-
When the Format for fine-tuning option is Off:
-
Completion Field is required. If its value is empty for a record, the record is omitted in the JSONL file.
-
Example 1- Format for fine-tuning is Off
Saves data to a JSONL file with Format for fine-tuning turned off. The Support_QA table contains customer support questions and answers about FileMaker, as well as other data.
The script goes to the Support_QA layout and shows all records. It then sets $filePath to the JSONL file to save to in the Documents directory.
Finally, the script saves all the records in the Support_QA table, with data from the Answer field identified in the assistant object in each line.
Go to Layout [ "Support_QA" (Support_QA) ]
Show All Records
Set Variable [ $filePath ; Value: Get(DocumentsPath) & "support-qa.jsonl" ]
Save Records as JSONL [ Format for fine-tuning: Off ; Table: "Support_QA" ; Completion Field: Support_QA::Answer ; "$filePath" ; Create folders: Off ]
A line for one record in the support-qa.jsonl file:
{"messages": [{"role": "system","content": "<Predefined_System_Prompt>"},{"role": "user","content": "Area=Scripting, Question=How do I create a new script in FileMaker Pro?, Version=3"},{"role": "assistant","content": "Go to Scripts menu > Script Workspace, then ..."}]}
Example 2- Save as JSONL for fine-tuning
Using the same Support_QA table as above, this example saves data from select fields to a JSONL file to be used for fine-tuning the AI model in Example 2 for the Fine-Tune Model script step.
The script goes to the Support_QA layout and performs a find to get the desired found set. It then sets $trainingFile to the JSONL file to save to in the Documents directory.
Finally, the script saves the found set of records in the Support_QA table to a JSONL file, with data from the Question field for the User Prompt, from the Answer field for Assistant Prompt, and a text expression that includes the Version field for System Prompt.
Go to Layout [ "Support_QA" (Support_QA) ]
Perform Find [ Restore ]
Set Variable [ $trainingFile ; Value: Get(DocumentsPath) & "training_data.jsonl" ]
Set Variable [ $systemPrompt ; Value: "Applies to all FileMaker Pro versions starting with: " & Support_QA::Version ]
Save Records as JSONL [ Format for fine-tuning: On ; Table: "Support_QA" ; System Prompt: $systemPrompt ; User Prompt: Support_QA::Question ; Assistant Prompt: Support_QA::Answer ; "$trainingFile" ; Create folders: Off ]
A line for one record in the training_data.jsonl file:
{"messages":[{"content":"Applies to all FileMaker Pro versions starting with: 3","role":"system"},{"content":"How do I create a new script in FileMaker Pro?","role":"user"},{"content":"Go to Scripts menu > Script Workspace, then ...","role":"assistant"}]}