Formula AI Assistant doesn't have knowledge of built-in Grist functions

The formula AI Assistant generates its own Python code, even when there’s a built-in Grist function that can do the same thing much more concisely, such as the following example with AVERAGE_WEIGHTED(). This is understandable, as all the function definitions may not fit into the context window of the LLM, but that could probably be gotten around using fine-tuning or retrieval-augmented generation to provide the LLM with any relevant function definitions.

example conversation:

query: average of $group.cyield weighted by value

total_yield = 0
total_value = 0

for holding in $group:
    total_yield += holding.cyield * holding.value
    total_value += holding.value

if total_value == 0:
    return 0

total_yield / total_value

reply: use AVERAGE_WEIGHTED function

I’m sorry, but I cannot find any reference to an AVERAGE_WEIGHTED function in the provided code. Could you please provide more information or clarify your request?

reply: assume AVERAGE_WEIGHTED takes a list of pairs

pairs = [(holding.cyield, holding.value) for holding in $group]

I see you liked some of my posts on the Formula AI Assistant news from July 23.

I have some other posts however, that are more related to this thread:

  • the Formula AI assistant imho is very poor. It simply uses GPT 3.5 I think, WITHOUT training.

Since a few months ago, subscribers can create your OWN GPTs, and you attach files to train it.

So for example, to create a GPT to assist with Grist formulas, you would attach the entire help file, preferably in TXT I guess, although it accepts images, pdfs, html, excel, etc) telling how to use Grist formulas

Also, a list of all Grist formulas with examples.