1
0
mirror of https://github.com/coalaura/whiskr.git synced 2025-09-08 17:06:42 +00:00
Files
whiskr/env.go

46 lines
764 B
Go
Raw Normal View History

2025-08-05 03:56:23 +02:00
package main
import (
"errors"
2025-08-14 03:53:14 +02:00
"fmt"
2025-08-05 03:56:23 +02:00
"os"
2025-08-14 03:53:14 +02:00
"strconv"
2025-08-05 03:56:23 +02:00
"github.com/joho/godotenv"
)
2025-08-11 01:16:52 +02:00
var (
Debug bool
2025-08-14 03:53:14 +02:00
MaxIterations int
2025-08-11 01:16:52 +02:00
OpenRouterToken string
)
2025-08-05 03:56:23 +02:00
func init() {
log.MustPanic(godotenv.Load())
2025-08-11 01:16:52 +02:00
Debug = os.Getenv("DEBUG") == "true"
2025-08-14 03:53:14 +02:00
if env := os.Getenv("MAX_ITERATIONS"); env != "" {
iterations, err := strconv.Atoi(env)
if err != nil {
log.Panic(fmt.Errorf("invalid max iterations: %v", err))
}
if iterations < 1 {
log.Panic(errors.New("max iterations has to be 1 or more"))
}
MaxIterations = iterations
} else {
MaxIterations = 3
}
2025-08-11 01:16:52 +02:00
2025-08-05 03:56:23 +02:00
if OpenRouterToken = os.Getenv("OPENROUTER_TOKEN"); OpenRouterToken == "" {
log.Panic(errors.New("missing openrouter token"))
}
2025-08-11 01:16:52 +02:00
if Debug {
2025-08-11 01:59:26 +02:00
log.Warning("Debug mode enabled")
2025-08-11 01:16:52 +02:00
}
2025-08-05 03:56:23 +02:00
}