Skip to content

New Share your ideas with the AWTRIX community. Keep your creations together in your account.

Sign in

Which AWTRIX do you have? Choose it once and the Hub shows what runs on it.

ModuleAWTRIX NG

AI Toolkit

On an AWTRIX display
AI Toolkit shown on an AWTRIX display
AI Toolkit · by Blueforcer

For your scripts

Chat with an AI, give it tools and hold spoken conversations from your own scripts.

A module, not an app: it shows nothing by itself and adds functions that your scripts import.

Which AWTRIX do you have? See below where it runs, or choose your device.
Topic
Miscellaneous
Includes
Module

Runs on

  • Does not run on 32×8 (TC001 & DIY) Needs a voice that reads text aloud and an AWTRIX that listens and answers.
  • Runs on 52×16 (TC002) Voice: choose this app under System → Voice assistant on your AWTRIX.
  • Does not run on 32×8 with AWTRIX 3 (TC001 & DIY) Made for AWTRIX NG.

Choose your display in the next step.

Send to AWTRIX

Choose your AWTRIX

AI ToolkitAWTRIX NG module

Install this script on your AWTRIX NG. Its icons and sounds are installed with it.

Your AWTRIX’s local address, for example 192.168.178.39 or awtrix.local.

The name shown in your AWTRIX script list. Use letters, digits, hyphens or underscores.

Connection & device login

Connect your phone or computer to the same network as your AWTRIX. Allow local network access if your browser asks.

Use the device’s IP address, without a page path such as /#/apps.

If your AWTRIX requires a login, the username and password fields will appear when you connect.

Sign in to the Hub to install scripts. Attached files are installed separately.

Script description

Chat, tools and spoken conversations for your own scripts, in a few lines of Berry. The module knows no services, models or prompts: your script brings all of that, so it fits any service that speaks the OpenAI format, online or on your own computer.

import ai

var chat = ai.chat({'url': url, 'model': model, 'key': '{secret:openai_key}', 'system': 'Answer briefly.'})
chat.tool('get_time', 'Tells the time', {}, / args, done -> done({'hour': hour(), 'minute': minute()}))
chat.ask('What time is it?', / text, status -> self.show(text, status))

chat keeps the conversation, runs the tools the model asks for, and hands you the final answer. chat.cancel() drops an open question and chat.forget() starts over. A failed request gives nil and a status, and chat.detail holds the service's own message.

On a TC002, ai.converse runs the whole spoken loop and tells you what to draw:

ai.converse(chat, {'hear': {'url': stt_url, 'language': 'en'}, 'followup': true, 'wait': 5},
            / state, talk -> self.changed(state, talk))

state is listening, thinking, speaking, done or error. On error, talk.failed names the step and talk.status the reason. ai.hear and ai.say do one step on their own.

To use it, add this line to your script's header, with the twelve characters at the end of this page's address as the ID. Installing your script then fetches the module too:

# @requires ai <id>

Needs AWTRIX NG 1.2.3 or newer. It takes about 23 KB of memory, which is a lot on a TC001. Lumen Assistant is a complete app built on it.

More scripts in Miscellaneous

Something wrong with this script? Report it.