Direkte DeepSeek- und Mistral-Anbindung mit versionierten Aktionsprofilen, Budgetreservierung, Tokenabrechnung und administrativen Qualitätsprüfungen ersetzen die Flowise-Abhängigkeit im regulären Betrieb. 840 geprüfte A1-Aufgaben mit geschützter Testauswertung und konkreten offenen Arbeitsaufträgen ergänzen den Kurs. Inhalts- und Sprachbewertung bleiben von Azure-Aussprachewerten getrennt; historische Aufgaben und Antworten bleiben erhalten. Echte Wort- und Phonemmessungen werden mit Herkunft, Aktualität und Nachweisdichte gebündelt. Go bestimmt Trainingsziele und Wiederholungen, das Modell formuliert dazu passende Nachsprechübungen. Profilansicht und Auswahlgründe werden angezeigt. Validierung: Go-Race-Tests mit lokaler PostgreSQL-Integration, go vet, Web-Build, Audit aller 840 Aufgaben und drei Browser-Smokes mit lokalen Modell-/Speech-Fixtures bestanden. Keine Produktionsänderungen oder Live-Aufrufe.
85 lines
2.6 KiB
Go
85 lines
2.6 KiB
Go
package config
|
|
|
|
import (
|
|
"log/slog"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
type Config struct {
|
|
PronunciationStrategy string
|
|
CourseTaskMode string
|
|
DeepSeekAPIKey string
|
|
MistralAPIKey string
|
|
Port string
|
|
DatabaseURL string
|
|
RedisURL string
|
|
JWTSecret string
|
|
CORSOrigins []string
|
|
AzureSpeechKey string
|
|
AzureRegion string
|
|
AzureMock bool
|
|
FlowiseBaseURL string
|
|
FlowiseChatflow string
|
|
FlowiseAPIKey string
|
|
FlowiseCourseChatflow string
|
|
FlowiseCourseAPIKey string
|
|
FlowiseCourseTeacher string
|
|
FlowiseCourseTeacherAPIKey string
|
|
DebugEnabled bool
|
|
DebugVerbose bool
|
|
LogLevel slog.Level
|
|
}
|
|
|
|
func Load() Config {
|
|
return Config{
|
|
PronunciationStrategy: env("PRONUNCIATION_STRATEGY", "statistical"),
|
|
CourseTaskMode: env("COURSE_TASK_MODE", "bank"),
|
|
DeepSeekAPIKey: os.Getenv("DEEPSEEK_API_KEY"),
|
|
MistralAPIKey: os.Getenv("MISTRAL_API_KEY"),
|
|
Port: env("API_PORT", "8080"),
|
|
DatabaseURL: env("DATABASE_URL", "postgres://speech:speech_dev_password@localhost:5432/speech?sslmode=disable"),
|
|
RedisURL: env("REDIS_URL", "redis://localhost:6379"),
|
|
JWTSecret: env("APP_JWT_SECRET", "dev-secret-change-me"),
|
|
CORSOrigins: splitCSV(env("CORS_ORIGINS", "http://localhost:5173,http://localhost:8080")),
|
|
AzureSpeechKey: os.Getenv("AZURE_SPEECH_KEY"),
|
|
AzureRegion: os.Getenv("AZURE_SPEECH_REGION"),
|
|
AzureMock: strings.EqualFold(env("AZURE_ENABLE_MOCK", "true"), "true"),
|
|
DebugEnabled: strings.EqualFold(env("DEBUG_ENABLED", "false"), "true"),
|
|
DebugVerbose: strings.EqualFold(env("DEBUG_VERBOSE", "false"), "true"),
|
|
LogLevel: parseLogLevel(env("LOG_LEVEL", "info")),
|
|
}
|
|
}
|
|
|
|
func env(key, fallback string) string {
|
|
if value := strings.TrimSpace(os.Getenv(key)); value != "" {
|
|
return value
|
|
}
|
|
return fallback
|
|
}
|
|
|
|
func splitCSV(value string) []string {
|
|
parts := strings.Split(value, ",")
|
|
out := make([]string, 0, len(parts))
|
|
for _, part := range parts {
|
|
part = strings.TrimSpace(part)
|
|
if part != "" {
|
|
out = append(out, part)
|
|
}
|
|
}
|
|
return out
|
|
}
|
|
|
|
func parseLogLevel(value string) slog.Level {
|
|
switch strings.ToLower(strings.TrimSpace(value)) {
|
|
case "debug":
|
|
return slog.LevelDebug
|
|
case "warn", "warning":
|
|
return slog.LevelWarn
|
|
case "error":
|
|
return slog.LevelError
|
|
default:
|
|
return slog.LevelInfo
|
|
}
|
|
}
|