Defining Your Home
Part 7 - Let's Build a ChatBot!
Today we'll add another page to our dashboard.
We will dive deeper into JS and at first glance it will look more advanced and a bit messy - but it will be well worth the time, because we will implement a chat interface.
Let's build a bridge between our natural language processor (do) and our frontend dashboard.
I have done a lot of work on traditional LLM agents designed to execute custom scripts, and even writing it on it's own, mostly using Lang Chain.
I however, never gained any trust for it, and don't see much or any potential there to be honest.
My opinion on high power usage LLM agents for private smart home automations is that it can be achieved in cheaper, safer and faster solutions.
Why?
I wanted to build something that not only gives full access to all my (yo) scripts while on the run, but also gave appropriate responses, rendered beautifully right in the chat. Text to speech is of course crucial here as well. At first I was struggling to get a good voice for TTS - I needed it to sound just as good on desktop as on mobile, which seemed really hard to achieve since to my surprise I realized Apple has yet to release Siri on any open API. I ended up using what I already use on desktop, Piper and just create the wav server-side and playing the audio client-side.
My original thought for the chat was to build something that felt like ChatGPT - but faster, more reliable and without the thinking process. In simple terms:
Less thinking - more doing!
But before we start - I'll throw you a video teaser so you know what's what! (turn on your sound)
Ask What Time It Is
Understands 294 Million Phrases - This Is Not One Of Them
Shall we start?
First Thing First
▶ safety firzt!!
Create a strong password and encrypt it within a file, and then set the path for the file.
This password will be used for the dashboard and the API later on in this article.
▶ Configure password
Since we will be executing shell commands from the chat, I added fun and proper authentication to the duckDash.nix module in form of a login screen - and protected the webserver with it.
If you are just following along this article and using my modules, you don't have to do this login page - as it is already implemented into the duckDash module, I just wanted to show it off - since security is major key.
And damnit, I won't lie.. I just love these falling ducks. They really make me smile every time I am prompted for the password.
▶ View Login Screen Code (duckDash.nix)
▶ I use 20x magnification when I code and debug. I use emoji to simplify logs for myself. If you can't handle my code style you can disable most of it on this website by toggling the button in the navbar. Shall duck continue?