RETURN TO BLOGS

Getting Started with ChatGPT as a Claris Developer

by Cristos Lianides-Chin - Platform Architect

Large language models (LLMs), such as ChatGPT, can be used to easily generate text, translate languages, and even write code. In this article, we will take a look at two ways you can use OpenAI’s GPT-4 model to write a custom function that reverses a string in Claris FileMaker. We will also discuss some important Information Security considerations.

What URL Should I Use to Access ChatGPT?

First, there’s chat.openai.com, which is home to ChatGPT, a consumer-level product. It’s a freemium product, meaning a free tier is available. However, if you use it frequently, consider upgrading to the paid version, ChatGPT Plus.

In contrast, http://platform.openai.com/playground is an API interface that requires an account with a payment method, such as a credit card, attached. It has better data privacy terms than ChatGPT, is generally cheaper than ChatGPT Plus, and is what we would recommend for most developers.

Do you need an account to use these products?

Yes, setting up an account is free and required for ChatGPT. You will need a payment method to use the OpenAI API, but we’ve found our average cost for personal/developer use is less than $10/month, and you only pay for what you use (not a subscription fee).

How do you get started?

To use ChatGPT, you can start asking it questions. For example, to write a custom function that reverses a string in FileMaker, you could ask ChatGPT, “How can I write a Claris FileMaker custom function to reverse a string?”

  1. Go to https://chat.openai.com
  2. Create an account (free)/ sign in with an account
  3. (currently, Plus members only) At the top of the page, choose GPT-4. Free tier users can only use GPT-3.5, which is good for many other applications, but is prone to more issues with Claris FileMaker syntax – such as trying to call built-in Claris FileMaker functions that seem plausible but don’t actually exist.
  4. Write How can I write a Claris FileMaker custom function to reverse a string? into the prompt – if you’re using GPT-4, it is much slower than GPT-3.5, but worth the wait to get better code.

You may notice that, if you used GPT-3.5 to answer this question, the calculation doesn’t work in Claris FileMaker due to a syntax error in the While() function. This is a common problem with GPT-3.5, which is the only model available without paying for ChatGPT Plus.

How do I access GPT-4 without ChatGPT Plus?

Fortunately, you can access GPT-4, a much more accurate model, using the OpenAI API Playground. Not only is this more cost-effective than the subscription fee, it also gives you a better look “under the hood” for when you’re building your own large language model integrations in Claris FileMaker.

To use the OpenAI Playground, you will need to set up an API account – there are other tutorials on that process that you can reference, if needed. Once you’ve done that, you can enter your query into the Playground’s interface. For instance, to write a custom function that reverses a string in Claris FileMaker, you could enter the same query as you did with ChatGPT.

  1. Go to https://platform.openai.com/playground
  2. Create an account / sign in with an account (including registering for an API key)
  3. From the Mode dropdown, choose Chat
  4. From the Model dropdown, choose GPT-4 and set the Maximum length to 2048 (this will allow you to get a longer output).
  5. Enter your question – be patient, it might take a minute for the response to print fully.
  6. PRO TIP: If you forgot to update your Maximum length slider, your text might get cut short. In that case, just update the slider and click Submit again and GPT-4 will pick up where it left off!

Phrasing your question matters

Large language models can be sensitive to even minor changes in how you phrase your question. Try these variations to see some other kinds of responses you can get from ChatGPT.

Variation 1: How can I write a FileMaker custom function to reverse a string?

API Transcript

Creating a custom function in FileMaker to reverse a string involves creating a recursive function. The concept is that the function will continually call itself, each time subtracting one character from the string, until the string is empty. At that point, it will return the reversed string.

Here is a simple example of a custom function to reverse a string:

  1. Open your FileMaker database, then select File > Manage > Custom Functions.
  2. Click the New button to create a new custom function.
  3. Name your function (for example, “ReverseString”), and set the function parameters. In this case, we need one parameter, which will be our input string. Let’s call it text.
  4. In the function body, write the following calculation:

If (
Length ( text ) > 0 ;
ReverseString ( Right ( text ; Length ( text ) - 1 ) ) & Left ( text ; 1 ) ;
text
)

Click OK to save your custom function.

Now you can use your custom function in your FileMaker calculations like this:

ReverseString ( "Hello, World!" )

This will return !dlroW ,olleH.

The function works by checking if the length of the string text is greater than 0. If it is, the function calls itself with the string minus the first character (using Right and Length), then appends the first character of the string (using Left). If the length of the string is not greater than 0 (i.e., the string is empty), it simply returns the string, which will be empty. This forms the base case for the recursion, stopping the function from calling itself indefinitely.

It’s important to note that FileMaker’s recursion limit is 10,000 iterations. So, if you try to reverse a string longer than 10,000 characters, it will cause a stack overflow error.

Variation 2: Write a FileMaker custom function to reverse a string. Code only.

API Transcript
Sure, here’s a simple recursive custom function to reverse a string in FileMaker. Let’s call it ReverseString.

 
If ( Length ( inputString ) > 1 ; ReverseString ( Right ( inputString ; Length ( inputString ) - 1 ) ) & Left ( inputString ; 1 ) ; inputString )

 

This function works by recursively removing the first character from the string and appending it to the end of the reversed remaining string until there are no more characters left to reverse. The Length ( inputString ) > 1 condition is used to end the recursion when there’s only one character left in the string.

To use this function in FileMaker:

  1. Go to File > Manage > Custom Functions
  2. Click New to create a new custom function.
  3. Name the function ReverseString and add a parameter called inputString.
  4. Paste the code into the function body and click OK.Now, you can call this function in your scripts or calculations as ReverseString ( yourString )

Variation 3: You are a Senior FileMaker developer mentoring a new developer. Write a FileMaker custom function to reverse a string. Explain how it works

API Transcript

As a Senior FileMaker developer, I would suggest using a recursive custom function to reverse a string. Here’s the custom function definition:

Function Name: ReverseString
Parameters: inputString

Function Definition:
If (
Length ( inputString ) > 0;
ReverseString ( Right ( inputString ; Length ( inputString ) - 1 ) ) & Left ( inputString ; 1 );
""
)

Explanation:

  1. The custom function is named “ReverseString” and takes one parameter, “inputString”, which is the string we want to reverse.
  2. The function uses the “If” function to check if the length of the “inputString” is greater than 0. If it is, the function performs the reversal process, otherwise, it returns an empty string.
  3. In the reversal process, the function calls itself recursively by passing the “Right” function as an argument. The “Right” function takes two parameters: the “inputString” and the length of the “inputString” minus 1. This effectively removes the first character from the “inputString” and passes the rest of the string to the next recursive call.
  4. The “&” operator is used to concatenate the result of the recursive call with the first character of the “inputString”, which is obtained using the “Left” function. The “Left” function takes two parameters: the “inputString” and the number 1, indicating that we want to extract the first character from the “inputString”.
  5. The recursion continues until the length of the “inputString” becomes 0, at which point the function returns an empty string, and the concatenated characters are returned in reverse order.

By using this custom function, a new Claris FileMaker developer can easily reverse any given string. To use the function, simply call it by providing the desired string as an argument:

ReverseString ( “Hello, World!” ) // Returns “!dlroW ,olleH”

What are the limitations of Large Language Models?

Large language models are prone to a problem called “hallucination” in AI circles (or “confabulation”), where they’ll make up something that sounds plausible but isn’t actually true. When applied to FileMaker code, this means that sometimes GPT-4 will think that a custom function – or a non-existent function – is a native FileMaker feature, and implement it in its code.

It’s important that you thoroughly review and test any code you get from GPT-4 before implementing it in a production system. A later post in this series will outline some ways that you can even use GPT-4 to help generate test cases for the code you get from it.

Also, GPT-4 is significantly better at producing FileMaker-related code than GPT-3.5, so whenever you have the choice, you should opt for GPT-4. Code from GPT-3.5 will require more modification.

What should you keep in mind from a privacy perspective?

As with any technology that involves user data, it’s important to consider the security and privacy implications of using OpenAI’s products. For example, you should always ensure that your API key is kept secure and that you don’t share it with unauthorized individuals.

When using ChatGPT, we consider that any information we share may wind up as part of a public dataset. We strongly recommend you only use sample data and do not post code fragments with sensitive information (such as API keys, login credentials, or important business rules such as commission calculation).

The OpenAI Playground falls under the API retention rules, which are more privacy-preserving as of this writing. However, make sure that you review OpenAI’s terms of service and privacy policy to understand how they handle user data, and if it meets your organization’s Third Party Risk Management policies.

Subscribe to get the latest in your inbox.

This field is for validation purposes and should be left unchanged.

Leave a comment

Your email address will not be published. Required fields are marked *

Your email address will not be published. Required fields are marked *

Built with you in mind

Speak to one of our expert consultants about making sense of your data today. During
this free consultation, we'll address your questions, learn more about your business, and
make some immediate recommendations.

REQUEST A TOUR GET A FREE CONSULTATION

Stay in touch!

This field is for validation purposes and should be left unchanged.