@@ -39,6 +39,10 @@ type Config struct {
|
||||
OllamaModel string
|
||||
OllamaEmbeddingModel string
|
||||
OllamaTimeout time.Duration
|
||||
OllamaNumPredict int
|
||||
OllamaKeepAlive time.Duration
|
||||
OllamaThink bool
|
||||
OllamaMaxConcurrent int
|
||||
|
||||
KnowledgeDir string
|
||||
RAGEnabled bool
|
||||
@@ -116,7 +120,11 @@ func Load() (Config, error) {
|
||||
OllamaURL: strings.TrimRight(env("OLLAMA_URL", "http://ollama:11434"), "/"),
|
||||
OllamaModel: env("OLLAMA_MODEL", "qwen3:8b"),
|
||||
OllamaEmbeddingModel: env("OLLAMA_EMBEDDING_MODEL", "embeddinggemma"),
|
||||
OllamaTimeout: envDuration("OLLAMA_TIMEOUT", 120*time.Second),
|
||||
OllamaTimeout: envDuration("OLLAMA_TIMEOUT", 10*time.Minute),
|
||||
OllamaNumPredict: envInt("OLLAMA_NUM_PREDICT", 256),
|
||||
OllamaKeepAlive: envDuration("OLLAMA_KEEP_ALIVE", 10*time.Minute),
|
||||
OllamaThink: envBool("OLLAMA_THINK", false),
|
||||
OllamaMaxConcurrent: envInt("OLLAMA_MAX_CONCURRENT", 1),
|
||||
KnowledgeDir: env("KNOWLEDGE_DIR", "./knowledge"),
|
||||
RAGEnabled: envBool("RAG_ENABLED", true),
|
||||
KnowledgeTopK: envInt("KNOWLEDGE_TOP_K", 3),
|
||||
@@ -213,6 +221,18 @@ func (c Config) Validate() error {
|
||||
if u.Scheme == "http" && !c.GLPIAllowInsecureHTTP {
|
||||
return errors.New("GLPI_URL must use https unless GLPI_ALLOW_INSECURE_HTTP=true")
|
||||
}
|
||||
if c.OllamaTimeout <= 0 {
|
||||
return errors.New("OLLAMA_TIMEOUT must be > 0")
|
||||
}
|
||||
if c.OllamaNumPredict <= 0 || c.OllamaNumPredict > 4096 {
|
||||
return errors.New("OLLAMA_NUM_PREDICT must be between 1 and 4096")
|
||||
}
|
||||
if c.OllamaKeepAlive < 0 {
|
||||
return errors.New("OLLAMA_KEEP_ALIVE must be >= 0")
|
||||
}
|
||||
if c.OllamaMaxConcurrent <= 0 || c.OllamaMaxConcurrent > 32 {
|
||||
return errors.New("OLLAMA_MAX_CONCURRENT must be between 1 and 32")
|
||||
}
|
||||
if len(c.GLPIAllowedStatusIDs) == 0 {
|
||||
return errors.New("GLPI_ALLOWED_STATUS_IDS must contain at least one positive status id")
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package config
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func validConfig() Config {
|
||||
return Config{
|
||||
@@ -20,6 +23,11 @@ func validConfig() Config {
|
||||
KnowledgeAutoReplySources: []string{"internal-kb"},
|
||||
CommunicationLanguage: "de-DE",
|
||||
CommunicationStyle: "formal",
|
||||
OllamaTimeout: time.Minute,
|
||||
OllamaNumPredict: 256,
|
||||
OllamaKeepAlive: 10 * time.Minute,
|
||||
OllamaThink: false,
|
||||
OllamaMaxConcurrent: 1,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user