mirror of
https://github.com/coalaura/whiskr.git
synced 2025-09-08 17:06:42 +00:00
better searching
This commit is contained in:
20
env.go
20
env.go
@@ -2,14 +2,16 @@ package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
var (
|
||||
Debug bool
|
||||
NoOpen bool
|
||||
MaxIterations int
|
||||
OpenRouterToken string
|
||||
)
|
||||
|
||||
@@ -17,7 +19,21 @@ func init() {
|
||||
log.MustPanic(godotenv.Load())
|
||||
|
||||
Debug = os.Getenv("DEBUG") == "true"
|
||||
NoOpen = os.Getenv("NO_OPEN") == "true"
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
if OpenRouterToken = os.Getenv("OPENROUTER_TOKEN"); OpenRouterToken == "" {
|
||||
log.Panic(errors.New("missing openrouter token"))
|
||||
|
Reference in New Issue
Block a user