Blank cell instead of True/False and AI assistant doesn't work

I haven’t used Grist in a while, and I’ve never embedded this much Python before, so I’m wondering if there’s some basic thing I’m doing wrong.

This code (with data substituted for the variables) runs on PythonAnywhere, so the basic logic is correct. (Or does that suggest that assigning values to the variables is wrong?)

$Activation_Date has the value 2001-01-01.
$Deactivation_Date has the value 2100-12-31.
date.today() is currently returning the value 2025-04-29.

I want the column to display True or False.
Currently, it is blank!

I thought I would ask the AI assistant to make the code for me. It claims it did, but it lied to me. There is no code in the cell.

I solved the original problem. I needed a “return” statement at the end of my code. I forgot that the return statement inside the function only gives that value to the statement that called it. I still needed to provide a return statement outside of the function.

That doesn’t answer the second problem of why the AI assistant told me it created the code for me and put it in the column when it did not.

Hi @Mojosam.

Does the “Test” column from your screenshots have an ID of “Test2”? If not, the assistant may have confused it with a different column and updated that one instead. Otherwise, it may have hallucinated the response (not clear why).

It can also sometimes suggest formulas which are valid Python code, but don’t actually fit what Grist is expecting (just the body with a return, as you pointed out). You can expect improvements over time as we work on tweaking the prompt, but in general, there’s always a chance the AI will get something wrong.

George

I added “Test2” after my first post. I wanted to see what the AI could generate, but I didn’t want it to overwrite the original column.

I found the “AI mistake”. I already had a “Test2” column (I had hidden it to get it out of the way). The newer, visible “Test2” column was recorded by Grist as “$Test2_2”. The AI inserted its code into the real (hidden) “Test2”.

1 Like