feat: hide ask ai button when key is empty (#1515)

* Add option to hide Ask AI and update dev version

* Fix formatting according to eslint

* Replace option to hide Ask AI with auto hiding based on config

* Fix golangci-lint errors

* Remove showAskAI logic from OpenAPI
This commit is contained in:
João Nuno Mota
2023-04-15 17:54:33 +01:00
committed by GitHub
parent 648634d376
commit 2c328a4540
7 changed files with 57 additions and 30 deletions

View File

@ -56,6 +56,10 @@ func (s *Server) registerSystemRoutes(g *echo.Group) {
},
StorageServiceID: api.DatabaseStorage,
LocalStoragePath: "",
OpenAIConfig: api.OpenAIConfig{
Key: "",
Host: "",
},
}
systemSettingList, err := s.Store.FindSystemSettingList(ctx, &api.SystemSettingFind{})
@ -95,6 +99,13 @@ func (s *Server) registerSystemRoutes(g *echo.Group) {
systemStatus.StorageServiceID = int(baseValue.(float64))
} else if systemSetting.Name == api.SystemSettingLocalStoragePathName {
systemStatus.LocalStoragePath = baseValue.(string)
} else if systemSetting.Name == api.SystemSettingOpenAIConfigName {
openAIConfig := api.OpenAIConfig{}
err := json.Unmarshal([]byte(systemSetting.Value), &openAIConfig)
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to unmarshal system setting open ai config value").SetInternal(err)
}
systemStatus.OpenAIConfig = openAIConfig
}
}