@@ -7,30 +7,24 @@ import (
77)
88
99type Config struct {
10- // Which provider to use: "openai" or "inference"
11- Provider string
12-
13- // Shared/API config
14- APIKey string // For OpenAI or any provider that requires API key
15- Endpoint string // For OpenAI (embeddings endpoint) or inference base URL
16-
17- // Inference API specific (used by providers/inference.go)
18- ServiceToken string // e.g., PHARIA internal service token
19- HTTPTimeoutS int // http timeout seconds (default 30)
10+ // Inference endpoint and auth
11+ Endpoint string // Base URL of the Aleph Alpha inference API
12+ ServiceToken string // PHARIA internal service token
13+ HTTPTimeoutS int // HTTP timeout seconds (default 30)
2014}
2115
22- // NewConfig reads from environment (no extra deps) .
16+ // NewConfig reads from environment variables .
2317func NewConfig () * Config {
2418 timeout := 30
2519 if v := os .Getenv ("EMBEDDING_HTTP_TIMEOUT_SECONDS" ); v != "" {
2620 if n , err := strconv .Atoi (v ); err == nil && n > 0 {
2721 timeout = n
2822 }
2923 }
24+
3025 return & Config {
31- Provider : getenvDefault ("EMBEDDING_PROVIDER" , "openai" ), // "openai" | "inference"
32- APIKey : os .Getenv ("EMBEDDING_API_KEY" ),
33- Endpoint : getenvDefault ("EMBEDDING_ENDPOINT" , "https://api.openai.com/v1/embeddings" ),
26+ // Default should point to Aleph Alpha inference API
27+ Endpoint : getenvDefault ("EMBEDDING_ENDPOINT" , "https://inference-api.product.pharia.com" ),
3428 ServiceToken : os .Getenv ("EMBEDDING_SERVICE_TOKEN" ),
3529 HTTPTimeoutS : timeout ,
3630 }
@@ -43,12 +37,13 @@ func getenvDefault(k, def string) string {
4337 return def
4438}
4539
40+ // Validate ensures required fields are present.
4641func (c * Config ) Validate () error {
47- if c .Provider == "openai" && c . APIKey == "" {
48- return fmt .Errorf ("openai provider requires EMBEDDING_API_KEY " )
42+ if c .Endpoint == "" {
43+ return fmt .Errorf ("embedding: missing EMBEDDING_ENDPOINT " )
4944 }
50- if c .Provider == "inference" && c . ServiceToken == "" {
51- return fmt .Errorf ("inference provider requires EMBEDDING_SERVICE_TOKEN" )
45+ if c .ServiceToken == "" {
46+ return fmt .Errorf ("embedding: missing EMBEDDING_SERVICE_TOKEN" )
5247 }
5348 return nil
5449}
0 commit comments