refactor!: move LLM configuration from in-app settings to CLI/env vars

- 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.
This commit is contained in:
2026-05-01 23:30:34 -04:00
parent 54e24cb304
commit 74b8d43032
13 changed files with 47 additions and 71 deletions

View File

@@ -28,14 +28,18 @@ type API struct {
store store.Store
client *client.Client
dataDir string
llmEndpoint string
llmKey string
generationManager *generationManager
}
func New(s store.Store, dataDir string, logger *logrus.Logger) *API {
func New(s store.Store, dataDir string, logger *logrus.Logger, llmEndpoint, llmKey string) *API {
return &API{
store: s,
dataDir: dataDir,
logger: logger.WithField("service", "api"),
llmEndpoint: llmEndpoint,
llmKey: llmKey,
generationManager: newGenerationManager(),
}
}
@@ -68,24 +72,6 @@ func (a *API) PostSettings(w http.ResponseWriter, r *http.Request) {
return
}
if apiEndpoint := newSettings.APIEndpoint; apiEndpoint != "" {
baseURL, err := url.Parse(apiEndpoint)
if err != nil {
errMsg := fmt.Sprintf("Invalid API Endpoint URL: %q", baseURL)
log.WithError(err).Error(errMsg)
http.Error(w, errMsg, http.StatusBadRequest)
return
}
testClient := client.NewClient(baseURL)
if _, err := testClient.GetModels(r.Context()); err != nil {
log.WithError(err).Error("failed to access configured API endpoint")
http.Error(w, "API endpoint inaccessible", http.StatusBadRequest)
return
}
a.client = nil
}
if err := a.store.SaveSettings(&newSettings); err != nil {
log.WithError(err).Error("failed to save settings")
http.Error(w, "Failed to save application settings", http.StatusInternalServerError)
@@ -516,20 +502,13 @@ func (a *API) getClient() (*client.Client, error) {
return a.client, nil
}
// Get Settings & Validate Endpoint
settings, err := a.store.GetSettings()
if err != nil {
return nil, fmt.Errorf("failed to retrieve application settings: %w", err)
} else if settings.APIEndpoint == "" {
return nil, errors.New("no API endpoint configured in settings")
}
baseURL, err := url.Parse(settings.APIEndpoint)
// Parse LLM Endpoint from Config
baseURL, err := url.Parse(a.llmEndpoint)
if err != nil {
return nil, fmt.Errorf("invalid API endpoint URL: %w", err)
}
a.client = client.NewClient(baseURL)
a.client = client.NewClient(baseURL, a.llmKey)
return a.client, nil
}