Skip to content

Commit 684fea3

Browse files
committed
chore: minor improvements
1 parent 6eed142 commit 684fea3

3 files changed

Lines changed: 13 additions & 45 deletions

File tree

pkg/embedding/client.go

Lines changed: 0 additions & 26 deletions
This file was deleted.

pkg/embedding/configs.go

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,24 @@ import (
77
)
88

99
type 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.
2317
func 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.
4641
func (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
}

pkg/embedding/fx_module.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ var FXModule = fx.Module(
1919
fx.Provide(
2020
NewConfig, // -> *Config
2121
NewInferenceProvider, // -> Provider
22-
NewClient, // -> *Client
2322
),
2423

2524
fx.Invoke(RegisterEmbeddingLifecycle),

0 commit comments

Comments
 (0)