You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I made a simple tray script to start and stop LibreChat. I don't use docker, so if you are using with docker, this won't work for you.
You'll just need to create two files, and update the places where it has C:\path\to\ and place both the files and the icons in the root folder of your LibreChat installation, then create a shortcut that runs with admin privileges to start the .ahk file.
I haven't actually used the update feature aside from seeing it does properly check the version and tell you if you are up to date (will checkback if it doesn't update properly). Here is link for the tray icons I use.
Double clicking the tray icon toggles hiding/showing the powershell windows after startup, which hide automatically after 5 seconds.
Right click the icon to start, stop, restart librechat.
Probably some bugs, but works okay for now.
Name this one start_librechat.bat and save in root of LibreChat folder:
@echo off
cd /d C:\path\to\LibreChat
REM Optional: Rebuild frontend only when needed
REM call npm run frontend
start "LibreChat Backend" powershell -NoExit -Command "npm run backend"
Install AHK v1.1 and name this one LibreChatTray.ahk or whatever you like:
#SingleInstance, Force
#Persistent
DetectHiddenWindows, On
SetWorkingDir, %A_ScriptDir%
; --- CONFIGURATION ---
LibreChatPath := "C:\path\to\LibreChat"
icon_on := "C:\path\to\LibreChat-icon-on.ico"
icon_off := "C:\path\to\LibreChat-icon-off.ico"
; --- STATE ---
currentVisible := true
LibreChatWinIDs := []
; --- TRAY SETUP ---
Menu, Tray, NoStandard
Menu, Tray, Tip, LibreChat Tray Control
Menu, Tray, Icon, %icon_off%
Menu, Tray, Add, Start LibreChat, StartLibreChat
Menu, Tray, Add, Shutdown LibreChat, StopLibreChat
Menu, Tray, Add, Restart LibreChat, RestartLibreChat
Menu, Tray, Add, Toggle Powershell Visibility, ToggleWindow
Menu, Tray, Add, Check for Updates, CheckForLibreChatUpdate
Menu, Tray, Add, Reload Tray Icon, ReloadTrayIcon
Menu, Tray, Add
Menu, Tray, Add, Exit Tray App, ExitApp
CheckLibreChatStatus()
Menu, Tray, Show
OnMessage(0x404, "TrayDoubleClick")
return
; --- FUNCTIONS ---
CheckLibreChatStatus() {
global
Try {
http := ComObjCreate("WinHttp.WinHttpRequest.5.1")
http.Open("GET", "http://localhost:3080", false)
http.Send()
status := http.Status
} Catch e {
status := 0
}
if (status = 200) {
Menu, Tray, Icon, %icon_on%
} else {
Menu, Tray, Icon, %icon_off%
}
}
GetLocalLibreChatVersion() {
global LibreChatPath
versionFile := LibreChatPath . "\package.json"
if !FileExist(versionFile)
return ""
FileRead, packageContent, %versionFile%
RegExMatch(packageContent, """version"":\s*""(.*?)""", version)
return version1
}
GetLatestLibreChatVersionFromGitHub() {
url := "https://api.github.com/repos/danny-avila/LibreChat/tags"
Try {
http := ComObjCreate("WinHttp.WinHttpRequest.5.1")
http.Open("GET", url, false)
http.SetRequestHeader("User-Agent", "LibreChatTray")
http.Send()
if (http.Status != 200)
return ""
response := http.ResponseText
RegExMatch(response, """name"":\s*""v(.*?)""", version)
return version1
} Catch e {
return ""
}
}
UpdateLibreChat() {
global LibreChatPath
psCommand := "cd `"" . LibreChatPath . "`"; git pull"
RunWait, powershell.exe -NoProfile -ExecutionPolicy Bypass -Command %psCommand%, , Hide
TrayTip, LibreChat Update, LibreChat has been updated., 3, 17
}
CheckForLibreChatUpdate:
current := GetLocalLibreChatVersion()
latest := GetLatestLibreChatVersionFromGitHub()
if (current = "") {
TrayTip, LibreChat Update, Could not detect local version., 3, 17
return
}
if (latest = "") {
TrayTip, LibreChat Update, Could not fetch latest version., 3, 17
return
}
; Normalize both versions by stripping "v" if present
StringReplace, current, current, v
StringReplace, latest, latest, v
if (current = latest) {
TrayTip, LibreChat Update, You are on the latest version (%current%)., 3, 17
} else {
MsgBox, 4, LibreChat Update, You are on version %current%.`nA new version (%latest%) is available.`n`nWould you like to update?
IfMsgBox, Yes
UpdateLibreChat()
}
return
StartLibreChat:
if (LibreChatWinIDs.MaxIndex()) {
TrayTip, LibreChat, Already running., 3, 17
return
}
cmdPath := LibreChatPath . "\start_librechat.bat"
Run, %ComSpec% /c ""%cmdPath%"", %LibreChatPath%
Sleep, 5000
LibreChatWinIDs := []
WinGet, winList, List, ahk_exe powershell.exe
Loop, %winList%
{
id := winList%A_Index%
LibreChatWinIDs.Push(id)
WinHide, ahk_id %id%
}
currentVisible := false
CheckLibreChatStatus()
return
StopLibreChat:
for index, winId in LibreChatWinIDs {
WinClose, ahk_id %winId%
}
LibreChatWinIDs := []
currentVisible := true
RunWait, %ComSpec% /c taskkill /F /IM node.exe,, Hide
CheckLibreChatStatus()
return
RestartLibreChat:
Gosub, StopLibreChat
Sleep, 2000
Gosub, StartLibreChat
return
ToggleWindow:
if (LibreChatWinIDs.Length() = 0) {
TrayTip, LibreChat, LibreChat is not running., 3, 17
return
}
for index, winId in LibreChatWinIDs {
if (currentVisible) {
WinHide, ahk_id %winId%
} else {
WinShow, ahk_id %winId%
WinActivate, ahk_id %winId%
}
}
currentVisible := !currentVisible
CheckLibreChatStatus()
return
ReloadTrayIcon:
Reload
return
TrayDoubleClick(wParam, lParam, msg, hwnd) {
if (lParam = 0x203)
Gosub, ToggleWindow
}
ExitApp:
Gosub, StopLibreChat
ExitApp
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Name this one start_librechat.bat and save in root of LibreChat folder:
Install AHK v1.1 and name this one LibreChatTray.ahk or whatever you like:
Beta Was this translation helpful? Give feedback.
All reactions