#Saving long text responses from AI in a helper? Alternatives?

1 messages · Page 1 of 1 (latest)

misty cedar
#

Hello everybody. I just integrated simple Mistral AI ask & response and now want to save the last reply into a textfield or similar to be displayed in HA. Unfortunately the input_text only accepts 255 characters. Are there any ways how I can save a longer response from the AI and save it in a field to then display in HA? Thx in advance!

misty cedar
#

FOund a way:

  • enable python_scripts in configuration.yaml
  • create a python script to update a entities attribute to a given value
  • create a custom sensor with attribute in the configuration.yaml
  • In a script or automation use the python script to set that sensors attribute to a value of your choice regardless of length
topaz karma
#

You could just use a trigger-based template sensor. No need for Python.

#

Usually the easiest way to make a sensor that can be updated on demand is to use a trigger based template sensor with a custom event as the trigger. Then when you want to update that sensor you just fire that custom event along with the data you want to update it with

misty cedar
#

Okay. I now want do the same (save text of a length more than 255 characters) in a custom integration. Shipping a trigger with an integration is not a thing, or is it? This is my first integration and I am kinda lost. I got the REST call done and can also get responses, but I want to store that response.

misty cedar
topaz karma
misty cedar
misty cedar
#

From what I could gather maybe I could use aiofiles. Gonna give it a shot