JGrana
Very Senior Member
I have done a major re-write of an addon I created called - chatai
This addon will allow you to ask questions of Googles Gemini or Anthropics Claude from your routers CLI.
It also supports an analyze file mode - especially useful for log files and small shell scripts.
Here is the github Readme:
/usr/sbin/curl --retry 3 "https://raw.githubusercontent.com/JGrana01/chatai/master/chatai" -o "/jffs/scripts/chatai" && chmod 0755 /jffs/scripts/chatai && /jffs/scripts/chatai install
Install will check for Entware (and bail of not found), check and install the apps jq and fold, then setup a default chatai.conf file in /jffs/addons/chatai.
Before actually using chatai for the first time, you will need to get an API_KEY from Google and/or Anthropic.
Get the API key for Googles Gemini from https://aistudio.google.com/app/apikey
Get the API key for Anthropics Claude by going to this website:
https://console.anthropic.com/login
Setup a user account using your email address, then go to your Dashboard and select API Keys
Edit the /jffs/addons/chatai/chatai.conf file and put the api key string in the line:
GAPI_KEY="Put your API key here" # Google Gemini API key
CAPI_KEY="Put your API key here" # Anthropics Claude API
You only need one of the AI API keys for chatai to work. It depends on which AI bot you want to converse with.Googles Gemini is the default. This can be overriden either in the command line or in the chatai.conf file.If you want answers from both, you will need both companies API key.
Usage: chatai [gemini|claude|both] [analyze filename] [log] [show] [help] [install] [uninstall] [update]
gemini - use Googles Gemini for chat (default)
claude - use Anthropics Claude for chat
both - use both AI and display the results in different color output
analyze filename - analyze the suppled filename contents
log - log the session for later viewing
show - show all the saved chat log sessions
help - show this message
install - install chatai and create addon dir and config file
uninstall - remove chatai and its directory, chatlogs and config file
update - check for and optionally update
claude - use Anthropics Claude for the session (overrides .conf file WHICHAI setting)
both - show answers from both AI bots. Geminis output will be cyan and Claude in blue (overrides .conf file WHICHAI setting)
analyze filename - rather then start a chat session, send filename to AI for analysys.
log - record a session of the chat session. This will show the questions and responses. The files at date/time stamped and stored in /jffs/addons/chatai/logs.
show - display all the latest log sessions (using the Linux "more" command)
help - show a help screen
install - install chatai, create the addons directory and create a chatai.conf file
uninstall - remove chatai and its directories and files (including log files!!!)
update - check github for a new version. If so, offer to install it.
Here is a typical /jffs/addons/chatai/chatai.conf file
#
# chatai conf file
#
GAPI_KEY="AIzaSyB1y4Nn4rwrSVxH0a3KE7_XXXXXXXX8" # Put Google Gemini API key here ;-)
CAPI_KEY="sk-ant-api03-PQGJE_F-LlsovCnChPXBGag_sioN8aX8JAkaM2-XyTFgZq4kZnTp8zFY-p6G6kCUE7wytdyoZXXXXXXXXXXw-z6CFJgAA" # Put Anthropics Cl
WHICHAI="0" # which ai bot - 0: Gemini 1: Claude 2: both
LOGDIR="$SCRIPTDIR/logs" # location to store chat log sessions
NUMLOGS="5" # number of log sessions to save for later viewing
MAXLINES="200" # Maximum number of lines in a file to analyze
# use caution in making it too large...
MAXSIZE="32767" # Maximum number of characters in any request
ALWAYSTRIM="0" # always trim to MAZLINES any file for analysis
# 0: Ask if triming needed 1: Always trim the file
GAPI_KEY - the key created by you when you asked for a Gemini API key
CAPI_KEY - the key created by you when to setup Antropics Claude developer
WHICHAI - set to 0 (default) for Gemini, 1 for Claude or 2 to have both respond to your questions or analysis
LOGDIR - where you want chatai to store log files of the session. Default is in the /jffs/addons/chatai/log
NUMLOGS - the number of log files to store at a time. Its a circular method - a new log file overrides the oldest
MAXLINES - the maximium number of lines of text to send. This can be increased - but should be cautiously - more lines - more tokens used.
MAXSIZE - this is the maximium number of characters to send. Again, can be increased - more dependent on shell variable length
ALWAYSTRIM - If a file for analysys is greater than MAXLINES, either ask if it should be trimmed (0) or just trim it without prompting (1)
This addon will allow you to ask questions of Googles Gemini or Anthropics Claude from your routers CLI.
It also supports an analyze file mode - especially useful for log files and small shell scripts.
Here is the github Readme:
chatai
chatai will start an interactive "chat" session with either Googles Gemini AI or Anthropics Claude (or both at once) bots.chatai also supports an analyze mode for files such as log files, small shell scripts etc.Installation
For Asuswrt-merlin based routers running Entware, using your preferred SSH client/terminal, copy and paste the following command, then press Enter:/usr/sbin/curl --retry 3 "https://raw.githubusercontent.com/JGrana01/chatai/master/chatai" -o "/jffs/scripts/chatai" && chmod 0755 /jffs/scripts/chatai && /jffs/scripts/chatai install
Install will check for Entware (and bail of not found), check and install the apps jq and fold, then setup a default chatai.conf file in /jffs/addons/chatai.
Before actually using chatai for the first time, you will need to get an API_KEY from Google and/or Anthropic.
Get the API key for Googles Gemini from https://aistudio.google.com/app/apikey
Get the API key for Anthropics Claude by going to this website:
https://console.anthropic.com/login
Setup a user account using your email address, then go to your Dashboard and select API Keys
Edit the /jffs/addons/chatai/chatai.conf file and put the api key string in the line:
GAPI_KEY="Put your API key here" # Google Gemini API key
CAPI_KEY="Put your API key here" # Anthropics Claude API
You only need one of the AI API keys for chatai to work. It depends on which AI bot you want to converse with.Googles Gemini is the default. This can be overriden either in the command line or in the chatai.conf file.If you want answers from both, you will need both companies API key.
Command and Command Line Arguments
chatai (Ver 0.3.2) - start an interactive chat session with Googles Gemini or Anthropics Claude AIUsage: chatai [gemini|claude|both] [analyze filename] [log] [show] [help] [install] [uninstall] [update]
gemini - use Googles Gemini for chat (default)
claude - use Anthropics Claude for chat
both - use both AI and display the results in different color output
analyze filename - analyze the suppled filename contents
log - log the session for later viewing
show - show all the saved chat log sessions
help - show this message
install - install chatai and create addon dir and config file
uninstall - remove chatai and its directory, chatlogs and config file
update - check for and optionally update
Command Line Options
gemini - (default) use Google Gemini for the chat session (overrides .conf file WHICHAI setting)claude - use Anthropics Claude for the session (overrides .conf file WHICHAI setting)
both - show answers from both AI bots. Geminis output will be cyan and Claude in blue (overrides .conf file WHICHAI setting)
analyze filename - rather then start a chat session, send filename to AI for analysys.
log - record a session of the chat session. This will show the questions and responses. The files at date/time stamped and stored in /jffs/addons/chatai/logs.
show - display all the latest log sessions (using the Linux "more" command)
help - show a help screen
install - install chatai, create the addons directory and create a chatai.conf file
uninstall - remove chatai and its directories and files (including log files!!!)
update - check github for a new version. If so, offer to install it.
Here is a typical /jffs/addons/chatai/chatai.conf file
#
# chatai conf file
#
GAPI_KEY="AIzaSyB1y4Nn4rwrSVxH0a3KE7_XXXXXXXX8" # Put Google Gemini API key here ;-)
CAPI_KEY="sk-ant-api03-PQGJE_F-LlsovCnChPXBGag_sioN8aX8JAkaM2-XyTFgZq4kZnTp8zFY-p6G6kCUE7wytdyoZXXXXXXXXXXw-z6CFJgAA" # Put Anthropics Cl
WHICHAI="0" # which ai bot - 0: Gemini 1: Claude 2: both
LOGDIR="$SCRIPTDIR/logs" # location to store chat log sessions
NUMLOGS="5" # number of log sessions to save for later viewing
MAXLINES="200" # Maximum number of lines in a file to analyze
# use caution in making it too large...
MAXSIZE="32767" # Maximum number of characters in any request
ALWAYSTRIM="0" # always trim to MAZLINES any file for analysis
# 0: Ask if triming needed 1: Always trim the file
GAPI_KEY - the key created by you when you asked for a Gemini API key
CAPI_KEY - the key created by you when to setup Antropics Claude developer
WHICHAI - set to 0 (default) for Gemini, 1 for Claude or 2 to have both respond to your questions or analysis
LOGDIR - where you want chatai to store log files of the session. Default is in the /jffs/addons/chatai/log
NUMLOGS - the number of log files to store at a time. Its a circular method - a new log file overrides the oldest
MAXLINES - the maximium number of lines of text to send. This can be increased - but should be cautiously - more lines - more tokens used.
MAXSIZE - this is the maximium number of characters to send. Again, can be increased - more dependent on shell variable length
ALWAYSTRIM - If a file for analysys is greater than MAXLINES, either ask if it should be trimmed (0) or just trim it without prompting (1)