New AI architecture: Gladys becomes a real AI agent đŸ€–

Hello! I tried creating scenes, but it didn’t work out:

The log is huge, but the last line says
 > data: { status: 500, error_code: â€č SERVER_ERROR â€ș } Edit: It crashed
 I’ll leave it alone. It’s Saturday, maybe it’s the weekend for it too!

Thanks for the feedback, it’s funny your prompt made the AI completely hallucinate, all its attempts were wrong (device_get_state instead of creating a scene)

Try sending a message again but maybe be more explicit?

Well, I’ve rephrased, discussed, argued but to no avail.

Here’s a small excerpt

There were several issues. First, I have a bathroom and a main switch that share the same name. Then, devices with multiple features were problematic. Finally, it didn’t understand how to â€č wait â€ș.

In the end, there’s always something that doesn’t work, but I haven’t found out what yet


Edit:

Then I have the list of all the devices in the house

ending with

Thanks for this detailed feedback!

I’ll check if there’s a modeling issue in the scene schema that could explain this bug.

Useful tip: the AI is limited to 5 consecutive autonomous iterations to avoid infinite loops. So when tool calls stop and don’t resume, there’s no need to wait: if you no longer see « Gladys is writing Â», there’s no background processing going on.

As soon as a response from Gladys appears, it means the execution is complete. In your example, we often see 4 tool calls followed by a final response.

Generally speaking, is your instance large? How many devices? How many scenes?

I wonder if the model isn’t hallucinating a bit in your case, because in any case, it should create a scene and not device_get_state


So there’s no point in waiting. I’ll make a note :innocent:

There are about fifty sensor and switch values and about fifty scenes (most are very short).

I tried again this morning. I had to restart Gladys because the chat wasn’t responding. Then, indeed, 4 get device states (the last one isn’t useful) and then nothing. The chat no longer responds to my messages. Gladys isn’t actually crashed.

This time, nothing appeared in the logs.

Nothing is urgent, have a good Sunday!

I’m investigating tomorrow!

@GBoulvin I managed to reproduce the issue, and I’ve fixed the bug. It will be included in the next version of Gladys. The scene schema sent to the AI wasn’t clear enough :slight_smile:

In addition, I improved error handling. If the AI model sends an empty response, an error message will be displayed in the chat! This will prevent the « non-responses Â» you experienced :slight_smile:

I asked the AI by voice to create a scene with sunset as the trigger, with a 20-minute delay for turning on an LED strip. In the end, the scene doesn’t include the action, even though it was mentioned in the response message. Is this normal?

Hi @Jluc :slight_smile:

Thanks for testing and your feedback!

I think this is related to the bug that @GBoulvin encountered above.

I’ve made a fix that will go out today, and with the fix it seems to work:

A different attempt was triggered:

@StephaneB I fixed that, it will be in the next version of Gladys:

Easier to see what the AI is doing via Telegram :slight_smile:

Good evening everyone,
The forum is very active, and that’s great. I can’t keep up with everything anymore, so I have a question about AI. As it has made a lot of progress, I wanted to know if Gladys could retrieve values read by a camera interpreted by the AI to send them to Node Red? Basically, I’m trying to retrieve the values of my pH and Redox by asking the AI to analyze my camera, which is pointed at my devices. I ask the AI to read the values (which works quite well) and sends them back to me on Telegram. I would have liked to retrieve them in Node Red to be able to threshold them. Is this possible? :grinning:

In my opinion, you shouldn’t send them directly to Telegram. I will go through one or more MQTT devices and then send them via Telegram.

Hi @Psoy :slight_smile:

This isn’t possible right now, but it should be fairly easy to add!

I think we could give the AI a new tool to set a sensor value, which you could then read in the scene and send to Node-RED. What do you think?

If you like the idea, could you create a feature request? :slight_smile:

good evening @pierre-gilles
thanks for your reply, but what do you mean by: giving the AI a new tool to define a sensor value? ; in my case, it would be like reading a license plate, interpreting it and comparing it with a list of authorized plates to open a gate for example with a scene. Basically, it’s about retrieving a value read by a camera and making it a variable that we can test. I mentioned Node-RED, but with a scene, that would already be great

Good evening @mutmut
I didn’t express myself well, I meant, when I use the « ask the AI Â» function in the scenes, that the values were sent to Telegram, in the message. I agree with you, we should create an Mqtt device to retrieve these values. I described in the following message what I wanted to do more clearly, I hope. Thanks for your answer

Gladys’s AI agent has a set of tools that allow it to interact with your Gladys instance.

This is what you see in the chat when you ask it a question, for example:

Here, the action device_get_state is a tool that the AI used to retrieve the state of a device before answering you.

We could imagine adding a new tool, for example sensor_set_state, which would allow the AI to write a value to a virtual sensor.

In this case, your scene could work like this:

  1. Ask the AI to read the pH value displayed by the camera, then save it in a virtual sensor pH-camera-reading that you would have created beforehand via the Virtual Device MQTT integration.
  2. Retrieve the value of this sensor in Gladys.
  3. Perform the processing of your choice: comparison with a threshold, sending a notification, triggering a scenario, etc.

This seems to be an interesting use case. If you like the idea, I invite you to open a feature request to add this new tool to the AI agent :slightly_smiling_face:

Could this use case also be used for a thermostat for example? This would allow you to adjust it directly :ok_hand:

Thanks @pierre-gilles.
Explained like that, I understand and that’s exactly it,

Here, the action `device_get_state` is a tool that the AI.

I always use Telegram and I hadn’t seen this line in the discussion
I’m making a feature request,
I’ll take inspiration from your explanation to make the feature request, it will be clearer
Thanks again :wink:.

Hello @guim31
I imagine that after reading your thermostat with a camera, the virtual sensor retrieves this value. After that, I think we can manipulate it, increment it, threshold it, or pass it as an argument in « control a device Â»