- Remove `api_endpoint` from Settings model and settings UI - Add `--llm-endpoint` / `AETHERA_LLM_ENDPOINT` and `--llm-key` / `AETHERA_LLM_KEY` CLI flags (endpoint is required) - Update client constructor to accept API key parameter - Update tests and documentation to reflect new configuration approach BREAKING CHANGE: LLM endpoint and key must now be provided via `AETHERA_LLM_ENDPOINT` and `AETHERA_LLM_KEY` environment variables or CLI flags instead of the Settings page.
65 lines
1.5 KiB
Go
65 lines
1.5 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path"
|
|
"strconv"
|
|
)
|
|
|
|
const envPrefix = "AETHERA_"
|
|
|
|
type cliParams struct {
|
|
ListenAddr string
|
|
ListenPort int
|
|
DataDir string
|
|
StaticDir string
|
|
SettingsFile string
|
|
LLMEndpoint string
|
|
LLMKey string
|
|
}
|
|
|
|
// getEnvOrDefault returns the value of an environment variable or a default value
|
|
func getEnvOrDefault(key, defaultValue string) string {
|
|
if value := os.Getenv(envPrefix + key); value != "" {
|
|
return value
|
|
}
|
|
return defaultValue
|
|
}
|
|
|
|
// getEnvIntOrDefault returns the integer value of an environment variable or a default value
|
|
func getEnvIntOrDefault(key string, defaultValue int) int {
|
|
if value := os.Getenv(envPrefix + key); value != "" {
|
|
if intVal, err := strconv.Atoi(value); err == nil {
|
|
return intVal
|
|
}
|
|
}
|
|
return defaultValue
|
|
}
|
|
|
|
func (p *cliParams) Validate() error {
|
|
// Require LLM Configuration
|
|
if p.LLMEndpoint == "" {
|
|
return fmt.Errorf("LLM endpoint is required (set AETHERA_LLM_ENDPOINT)")
|
|
}
|
|
|
|
// Ensure Generated Directories
|
|
imgDir := path.Join(p.DataDir, "generated/images")
|
|
if err := os.MkdirAll(imgDir, 0755); err != nil {
|
|
return fmt.Errorf("failed to create images directory: %w", err)
|
|
}
|
|
|
|
// Validate Static Directory
|
|
if p.StaticDir != "" {
|
|
info, err := os.Stat(p.StaticDir)
|
|
if err != nil {
|
|
return fmt.Errorf("failed to access static directory: %w", err)
|
|
}
|
|
if !info.IsDir() {
|
|
return fmt.Errorf("static directory is not a directory: %s", p.StaticDir)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|