CreateAiJSON
Back to ListDescription: Generate a parameterized request object with the standard OpenAi parameters
FileMaker Prototype:
Set Variable [$res; ACF_Run("CreateAiJSON"; int_fpenalty; int_maxtokens; string_model; int_prespenalty; float_temperature; float_topP)]
Category: OPENAI
Function source:
Function CreateAiJSON(int fpenalty, int maxtokens, string model, int prespenalty, float temperature, float topP)
JSON Js;
Js = JSON(
"frequency_penalty",fpenalty,
"max_tokens",maxtokens,
"model",model,
"presence_penalty",prespenalty,
"temperature",temperature,
"top_p",topP);
return Js;
End
The CreateAiJSON Function is used in the OpenAI integration functions to create a start-object containing most parameters used in the request to the OpenAI endpoints. It is usually not called directly from FileMaker, but used from inside other ACF functions.
Example
JSON ai_request;
// Parameters:
// CreateAiJSON(int_fpenalty, int_maxtokens, string_model,
// int_prespenalty, float_temperature, float_topP)
ai_request = CreateAiJSON(0, 1000, "gpt-4o-mini", 0, 0.7, 1.0);
// then add the prompt or the messages to the object before submitting it to the endpoint.
This would give the ai_request variable the following content:
{
"frequency_penalty": 0,
"max_tokens": 1000,
"model": "gpt-4o-mini",
"presence_penalty": 0,
"temperature": 0.7,
"top_p": 1.0
} 