Thanks to visit codestin.com
Credit goes to github.com

Skip to content

utakamo/oasis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

OpenWrt AI Assistant Application - Oasis (v1.5.2)

Important

Support AI Service

  • OpenAI
  • Ollama

This software provides the ability to link OpenWrt and AI. Based on user input, the AI provides the optimal settings for OpenWrt; the OpenWrt device itself analyzes the information provided by the AI, verifies the validity of that information, and then notifies the user.

Application description
oasis AI chat core software (provides stand-alone CUI-based chat functionality)
luci-app-oasis This is a plugin to use AI chat from within LuCI's WebUI. (base software is oasis)
image

How to install luci-app-oasis

Dependency: oasis, lua-curl-v3, luci-compat

The Oasis package can be found under "oasis-1.5.0" in the Releases section of this GitHub page. It is a device-independent package, but it requires dependency packages such as lua-curl-v3 and luci-compat. Typically, if you install Oasis on an OpenWrt device with an active internet connection, these dependency packages will be downloaded and installed automatically.

If the repository corresponding to the device being used as an OpenWrt device does not include lua-curl-v3 or luci-compat, users will need to build the dependency packages themselves using the OpenWrt Buildroot and install them on the OpenWrt device.

root@OpenWrt:~# opkg update
root@OpenWrt:~# opkg install oasis_1.5.0-r1_all.ipk
root@OpenWrt:~# opkg install luci-app-oasis_1.5.0-r1_all.ipk
root@OpenWrt:~# service rpcd reload

Rebooting the system after installation is also fine.

AI Setting

[Main] ---> [Network] ---> [Oasis] ---> [General Setting] image

Note

If you want to use OpenAI, you need to set the Endpoint to the following URL.
https://api.openai.com/v1/chat/completions

Please create an API Key on your OpenAI account page.
For details, please refer to the OpenAI website.

Note

If you want to use Ollama, you need to set the Ollama parameters (OLLAMA_HOST and OLLAMA_ORIGINS) with the values shown below.

OLLAMA_HOST=0.0.0.0
OLLAMA_ORIGINS=*

Change the Ollama parameter configuration file (Linux) or environment variables (Windows) that exist on the PC where Ollama is installed to the above values.

My technical blog has an introductory page on the above Ollama setup, which describes the setup on Windows and Linux (Japanese Page). https://utakamo.com/article/ai/llm/ollama/setup/index.html#network-support

Ollama Endpoint Format: http://<Your Ollama PC Address>:11434/api/chat

When using Ollama, an API key is typically not required, so nothing needs to be entered in the API Key field on this settings page.

Chat with AI

[Main] ---> [Network] ---> [Oasis] ---> [Chat with AI] image
When chatting with AI for the first time, you can choose what topics to talk about. These options can be freely added or removed by the user in the System Message tab.
image
When a chat with AI begins, it is given a title and displayed in the chat list on the left side. "Users can continue chatting with AI, and if there is chat data from the past, they can select it to resume the conversation. Image
Chat data can be renamed, exported, or deleted. Image

Ask OpenWrt Setting

Oasis is customizing the AI to specialize in OpenWrt. Therefore, it may prompt users to ask about OpenWrt. If a user requests configuration related to OpenWrt, the AI will suggest changes using UCI commands.
Image
When a configuration change is suggested by the AI using UCI commands, the internal system of OpenWrt recognizes that a configuration change has been proposed by the AI. It then notifies the user via a popup to apply the configuration change to the current runtime. The user can accept the configuration change by pressing the Apply button.
Image Image
After applying the settings, if the user can access the WebUI, they will be notified in the Oasis chat screen to finalize the configuration change suggested by the AI. The user can press the Finalize button to approve the configuration change, or press the Rollback button to reject it.
Image

Important

After a configuration change, if the user does not press the Finalize or Rollback button within 5 minutes (default), the configuration will automatically rollback (Rollback monitoring). This ensures that even if there was a configuration error that caused a brick, the system will return to the original, normal settings. Note: If the OpenWrt device is powered off during the rollback monitoring period, the rollback monitoring will resume upon restart.

System Message

In Oasis, users can create and save system messages to use when starting a chat with AI. System messages are preloaded data used by AI to respond to the user. For example, add a message like the following as a system message to instruct the AI to interpret English and Japanese. Image
Enter the instructions for the AI into the text area of 'Create System Message' and press the Add button to add it to the System Message List. This will register a new System Message called 'Translator.' Image
When you return to the Chat with AI tab and start a new chat with the AI, 'Translator' will appear as a topic option. Image
When 'Translator' is selected, the user's English message will be translated into Japanese by the AI. image
In this way, by including instructions or specific knowledge for the AI as system messages, it is possible to modify the AI's behavior toward users. Currently, Oasis adjusts responses related to OpenWrt solely through system messages. As a result, by storing information about OpenWrt settings as knowledge in existing or new system messages, it will become specialized in modifying OpenWrt settings. In particular, Oasis analyzes whether content related to modifying OpenWrt settings (UCI command sequences) found within AI responses can be executed. Then, it notifies the user with a popup.

Select AI Icon

In Oasis, users can freely change the AI's chat icon to create a sense of familiarity with the AI. oasis-icon01 Click your preferred icon image and press the Select button to apply the setting. oasis-icon02 oasis-icon05 To add your favorite icon image (e.g., png), drag and drop it or click under Upload Icon. oasis-icon03
Pressing the Upload button stores the icon in the OpenWrt device. oasis-icon04

How to install only oasis

Dependency: lua-curl-v3

root@OpenWrt:~# opkg update
root@OpenWrt:~# opkg install oasis_1.5.0-r1_all.ipk
root@OpenWrt:~# service rpcd reload

Commands

Important

Some commands may not be available.

root@OpenWrt:~# oasis
Usage: oasis <command> [[<options>] arguments]...

Options:
 -n <service>           Set the service name
 -u <url>               Set the url or ipaddr for ai service
 -k <api-key>           Set the api-key for ai service
 -m <model>             Set the llm model for ai service

Commands:
 - storage <path> [<chat-max>] (default: chat-max = 30)
 - add [<service> [<url> [<api-key> [<model> [<storage>]]]]]
 - change <service> [<options> <argument>]...
 - select [<service>]
 - delete <service>
 - chat [id=<chat-id>]
 - prompt <message>
 - delchat id=<chat-id>
 - sysrole [[<chat|prompt|call> [<options>] [<system message>]]
 - rename id=<chat-id> <title> 
 - list
 - call <script> <messsage>

Docs
        https://utakamo.com

Usage

Step1: Setting up ai service

  • Example of OpenAI
root@OpenWrt:~# oasis add
Service Name                   >> my-chatgpt
Endpoint(url)                  >> https://api.openai.com/v1/chat/completions
API KEY (leave blank if none)  >> <your_api-key>
LLM MODEL                      >> gpt-3.5-turbo
  • Example of local ai service (Ollama)
root@OpenWrt:~# oasis add
Service Name                   >> my-ollama
Endpoint(url)                  >> http://192.168.3.16:11434/api/chat       
API KEY (leave blank if none)  >>
LLM MODEL                      >> gemma2:2b

Step2: Select AI Service

  • The first service registered with the oasis add command is selected.γ€€
aihelper_select_service01
  • To switch to another AI service, run oasis select . The following is an example of switching the service in use to my-ollama.
aihelper_select_service02

Step3: Example of chat with ai

root@OpenWrt:~# oasis chat
You :Hello!

gemma2:2b
Hello! πŸ‘‹  

How can I help you today? πŸ˜„
Title:ConversationStart  ID:7772532380

You :history
{"messages":[{"content":"Hello!","role":"user"},{"content":"Hello! πŸ‘‹ How can I help you today? 😊 \n","role":"assistant"}],"model":"gemma2:2b"}

You :exit
chat cmd description
exit Terminate the chat with the AI.
history Display the chat history(JSON)

Step4: Load past chats and resume conversation.

Confirm Chat ID

root@OpenWrt:~# oasis list
-----------------------------------------------------
 No. | title                          | id
-----------------------------------------------------
[ 1]: Hello                            5727149461
[ 2]: ConversationStart                7772532380

Resume conversation with the AI by specifying the chat ID.

root@OpenWrt:~# oasis chat id=7772532380
You :Hello!

gemma2:2b
Hello! πŸ‘‹ How can I help you today? 😊

You :

Step5: How to send prompt to AI

root@OpenWrt:~# oasis prompt "Hello!!"
Hello! πŸ‘‹  What can I do for you today? 😊 

root@OpenWrt:~# 

oasis ubus objects and methods

root@OpenWrt:~# ubus -v list oasis
'oasis' @a0b66d2b
        "load_icon_info":{"path":"String"}
        "select_icon":{"using":"String","path":"String"}
        "update_sysmsg":{"target":"String","path":"String","title":"String","message":"String"}
        "load_sysmsg":{"path":"String"}
        "delete_icon":{"target":"String","path":"String"}
        "confirm":{}
        "config":{}
        "load_sysmsg_info":{"path":"String"}
        "add_sysmsg":{"message":"String","path":"String","title":"String"}
        "delete_sysmsg":{"target":"String","path":"String"}
root@OpenWrt:~# ubus -v list oasis.chat
'oasis.chat' @8a301e6e
        "delete":{"id":"String"}
        "list":{}
        "append":{"content2":"String","id":"String","role2":"String","role1":"String","content1":"String"}
        "load":{"id":"String"}
        "create":{"content3":"String","content2":"String","content1":"String","role2":"String","role1":"String","role3":"String"}
root@OpenWrt:~# ubus -v list oasis.title
'oasis.title' @1687aa3a
        "auto_set":{"id":"String"}
        "manual_set":{"id":"String","title":"String"}

Dependency Package

  • lua-curl-v3
  • luci-compat

License

This project is licensed under the MIT License.

Third-party licenses

This project includes the Material Icons font by Google, licensed under the Apache License, Version 2.0.