buddy fix
This commit is contained in:
49
scratch/buddyconfig/main.go
Normal file
49
scratch/buddyconfig/main.go
Normal file
@@ -0,0 +1,49 @@
|
||||
// Would this server switch Nearle Buddy on?
|
||||
//
|
||||
// APP_ENV=production go run ./scratch/buddyconfig
|
||||
//
|
||||
// Reads the configuration exactly as `main.go` does — same files, same order,
|
||||
// same defaults — and reports whether the assistant would be built. Prints a
|
||||
// verdict and, when the answer is no, the name of the variable that is missing.
|
||||
// Never a value: this exists to be run against production configuration.
|
||||
//
|
||||
// Connects to nothing. `config.Load` reads and validates; the database, the
|
||||
// model and the queue are all somebody else's job.
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"nearle/config"
|
||||
"nearle/utils"
|
||||
)
|
||||
|
||||
func main() {
|
||||
cfg, err := config.Load()
|
||||
if err != nil {
|
||||
fmt.Println("configuration is not valid:")
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Printf("APP_ENV %s\n", cfg.AppEnv)
|
||||
fmt.Printf("sessions can issue %t\n", utils.WebTokenConfigured())
|
||||
|
||||
if !cfg.Assistant.Enabled() {
|
||||
fmt.Printf("assistant OFF — %s\n", cfg.Assistant.Why())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// The gateway itself, built the way the facade builds it. Enabled() passing
|
||||
// and NewChat returning nil would be a disagreement worth catching here
|
||||
// rather than at the first question somebody asks.
|
||||
chat, err := utils.NewChat(cfg.Assistant)
|
||||
if err != nil || chat == nil {
|
||||
fmt.Printf("assistant OFF — gateway not built: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Printf("assistant ON — provider %s, balanced tier %s\n",
|
||||
cfg.Assistant.Provider, cfg.Assistant.ModelFor(utils.TierBalanced))
|
||||
}
|
||||
Reference in New Issue
Block a user