Problems updating a variable of type Obejct
# 🤝help
r
I have problems when I try to update the value of an object variable after it has already been created. Ex: I created the variable:
dict_test = {'foo': 1, 'bar': 2}
When publishing, the bot recognizes it and works as expected.
dict_test = {'foo': 1, 'bar': 2, 'new': 3}
However, if I update or add other elements inside the variable and publish it, the bot doesn't recognize this update in production. Does anyone know why this happens?
s
Hi, I think it's somehow similar to my question that bots behave differently in production: https://discord.com/channels/1108396290624213082/1246107376021671977 I hope we can get it fixed.
a
Hey @rough-knife-78536 do I understand correctly that you create a variable with default value of
Copy code
{
  "foo": 1,
  "bar": 2
}
and then add another property in the execute card? If so, are you using the bot with webchat?
just remember to use this syntax if it's a workflow variable
Copy code
js
workflow.dict_test = {'foo': 1, 'bar': 2, 'new': 3}
https://cdn.discordapp.com/attachments/1246082728089092128/1246500070774280342/image.png?ex=665c9d27&is=665b4ba7&hm=33e2eb2e872bc24bc39ed987b6db30b39ae70ce2a3e70a38b4d59e67ee4469f0&
@rough-knife-78536 @square-toddler-30705 I tried updating object values with Assistants API bots using Axios async/await, and that works also after publishing. https://cdn.discordapp.com/attachments/1246082728089092128/1246507194707345521/image.png?ex=665ca3ca&is=665b524a&hm=73f8038451b6708c2e5484bb179e04d4e879cf84628ce1b8186b6a4abf5a06b6&
Copy code
js
workflow.response = response.data.data[0].content[0].text.value

workflow.q_and_a_object = {'question': event.preview, 'answer': workflow.response, 'addAnotherValue': "test value"}
r
I'm just adding another key to the dictionary
Yes! I had this same error, the logs showed that the registered key didn't exist.
q
If you can share your chatbot or an example bot file where the error occurs, we can all try to debug and fix it 🛠️
s
Hi @quick-musician-29561 , You tested this in the same card/node. I was using async/await as a real global async function in one node and trying to get the results in another node after some time required for the function to run—it doesn't work in production—at least not now, maybe after some update. I had to use some workaround to solve the delay problem so that bot runs fast for the user, even taking some time to read the data. I didn't have time to test it extensively, but so far it works in a prototype.
q
Thank you for that additional information! 🔥 🛠️ 🫡
@square-toddler-30705 I have done something similar which you described, in my 'Agentic Workflow' projects, using GPT-4o, Claude-3, Mixtral-8x7b, and llama3-8b-8192, and all in different cards and nodes, even in different workflows. I didn't notice any issues updating new values while using those a lot, after publishing too, but maybe I didn't update type Object. I'll have to try those also, thanks again! ⚡
s
Me too, most of the time Array with options. By the way, I have problems copying the notes between workflows - do you know anything about this error?
r
Sorry, here are the steps and logs: - I created the variable by UI
bot.dict_test = {'foo': 1, 'bar': 2}
, published it and tested it (image_1). - I added a new key (
'new_': 3
) to the variable dict_test by UI (image_2) The variable has not been updated! I also sent this variable to whatsapp and received
{'foo': 1, 'bar': 2}
in both cases. https://cdn.discordapp.com/attachments/1246082728089092128/1250088156133462086/image_1.png?ex=6669aad1&is=66685951&hm=6adcbbf713ca3d04d1b67bd07da7ee89f5f5fd60f8cb7db164432ee923201b62& https://cdn.discordapp.com/attachments/1246082728089092128/1250088156372406323/image_2.png?ex=6669aad1&is=66685951&hm=7a482fce72ae0af1e8d8d390c41db72a8db21c9c2a43613a9a517ac18edf418a&
21 Views