From db24545fc0f92e23e4d782531948b054d90b11fb Mon Sep 17 00:00:00 2001 From: Hari Krishna Date: Mon, 18 Aug 2025 14:25:06 +0000 Subject: [PATCH 1/2] feat: add local AI availability check at server startup --- backend/go-app/main.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/backend/go-app/main.go b/backend/go-app/main.go index 4e4cce58..11d4473d 100755 --- a/backend/go-app/main.go +++ b/backend/go-app/main.go @@ -1159,6 +1159,7 @@ func handleInfo(resp http.ResponseWriter, request *http.Request) { ActiveApps: activatedAppIds, Theme: userInfo.Theme, OrgStatus: parsedStatus, + AIEnabled: org.LocalAIEnabled, } returnData, err := json.Marshal(returnValue) @@ -5479,6 +5480,23 @@ func initHandlers() { r.Use(shuffle.RequestMiddleware) http.Handle("/", r) + + go func() { + log.Printf("[DEBUG] Starting AI availability check for all organizations") + activeOrgs, err := shuffle.GetAllOrgs(ctx) + if err != nil { + log.Printf("[ERROR] Error getting organizations for AI availability check: %s", err) + return + } + + for _, org := range activeOrgs { + if len(org.Id) == 0 { + continue + } + + go shuffle.CheckAndUpdateAIAvailability(ctx, org.Id) + } + }() } // Had to move away from mux, which means Method is fucked up right now. From 85357f1b9b8096582d956d33420f4ee31380c18c Mon Sep 17 00:00:00 2001 From: Hari Krishna Date: Fri, 22 Aug 2025 12:40:03 +0000 Subject: [PATCH 2/2] simplified AI enable check for self hosted models --- backend/go-app/main.go | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/backend/go-app/main.go b/backend/go-app/main.go index f57dcdcd..51a1a856 100755 --- a/backend/go-app/main.go +++ b/backend/go-app/main.go @@ -1135,6 +1135,8 @@ func handleInfo(resp http.ResponseWriter, request *http.Request) { } } + aiEnabled := os.Getenv("OPENAI_API_URL") != "" && os.Getenv("AI_MODEL") != "" + returnValue := shuffle.HandleInfo{ Success: true, Username: userInfo.Username, @@ -1159,7 +1161,7 @@ func handleInfo(resp http.ResponseWriter, request *http.Request) { ActiveApps: activatedAppIds, Theme: userInfo.Theme, OrgStatus: parsedStatus, - AIEnabled: org.LocalAIEnabled, + AIEnabled: aiEnabled, } returnData, err := json.Marshal(returnValue) @@ -5481,23 +5483,6 @@ func initHandlers() { r.Use(shuffle.RequestMiddleware) http.Handle("/", r) - - go func() { - log.Printf("[DEBUG] Starting AI availability check for all organizations") - activeOrgs, err := shuffle.GetAllOrgs(ctx) - if err != nil { - log.Printf("[ERROR] Error getting organizations for AI availability check: %s", err) - return - } - - for _, org := range activeOrgs { - if len(org.Id) == 0 { - continue - } - - go shuffle.CheckAndUpdateAIAvailability(ctx, org.Id) - } - }() } // Had to move away from mux, which means Method is fucked up right now.