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

61 lines
1.1 KiB
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 (
2025-08-14 17:08:45 +02:00
Debug bool
CleanContent bool
MaxIterations int
2025-08-11 01:16:52 +02:00
OpenRouterToken string
2025-08-14 17:08:45 +02:00
ExaToken string
2025-08-11 01:16:52 +02:00
)
2025-08-05 03:56:23 +02:00
func init() {
log.MustPanic(godotenv.Load())
2025-08-14 17:08:45 +02:00
// enable debug logs & prints
2025-08-11 01:16:52 +02:00
Debug = os.Getenv("DEBUG") == "true"
2025-08-14 03:53:14 +02:00
2025-08-14 17:08:45 +02:00
if Debug {
log.Warning("Debug mode enabled")
}
// de-ai assistant response content
CleanContent = os.Getenv("DEBUG") == "true"
// maximum amount of iterations per turn
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-14 17:08:45 +02:00
// openrouter token used for all completions & model list
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
2025-08-14 17:08:45 +02:00
// optional exa token used for search tools
if ExaToken = os.Getenv("EXA_TOKEN"); ExaToken == "" {
log.Warning("missing exa token, web search unavailable")
2025-08-11 01:16:52 +02:00
}
2025-08-05 03:56:23 +02:00
}