-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.go
More file actions
44 lines (37 loc) · 833 Bytes
/
Copy pathconfig.go
File metadata and controls
44 lines (37 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"os"
"strconv"
"time"
)
type Config struct {
Port string
GatewayURL string
GatewayKey string
ReadTimeout time.Duration
WriteTimeout time.Duration
IdleTimeout time.Duration
}
func LoadConfig() *Config {
port := os.Getenv("PROXY_PORT")
if port == "" {
port = "18900"
}
// Validate port is numeric
if _, err := strconv.Atoi(port); err != nil {
port = "18900"
}
gatewayURL := os.Getenv("GATEWAY_URL")
if gatewayURL == "" {
gatewayURL = "https://ai-gateway.happycapy.ai/api/v1/chat/completions"
}
gatewayKey := os.Getenv("GATEWAY_KEY")
return &Config{
Port: port,
GatewayURL: gatewayURL,
GatewayKey: gatewayKey,
ReadTimeout: 30 * time.Second,
WriteTimeout: 300 * time.Second, // Long timeout for streaming
IdleTimeout: 120 * time.Second,
}
}