fix(gateway): enable PORT env override and fix chat handler typo for Azure compatibility
This commit is contained in:
parent
65eeb4dcf4
commit
0bb6fa4d73
2 changed files with 6 additions and 3 deletions
|
|
@ -744,7 +744,7 @@ func (c *ModelConfig) SetAPIKey(value string) {
|
|||
|
||||
type GatewayConfig struct {
|
||||
Host string `json:"host" env:"PICOCLAW_GATEWAY_HOST"`
|
||||
Port int `json:"port" env:"PICOCLAW_GATEWAY_PORT"`
|
||||
Port int `json:"port" env:"PICOCLAW_GATEWAY_PORT,PORT"`
|
||||
APIKey string `json:"api_key" env:"PICOCLAW_GATEWAY_API_KEY"`
|
||||
ChatEnabled bool `json:"chat_enabled" env:"PICOCLAW_GATEWAY_CHAT_ENABLED"`
|
||||
HotReload bool `json:"hot_reload" env:"PICOCLAW_GATEWAY_HOT_RELOAD"`
|
||||
|
|
|
|||
|
|
@ -63,6 +63,11 @@ type StatusResponse struct {
|
|||
}
|
||||
|
||||
func NewServer(host string, port int) *Server {
|
||||
if envPort := os.Getenv("PORT"); envPort != "" {
|
||||
if _, err := fmt.Sscanf(envPort, "%d", &port); err == nil {
|
||||
logger.Infof("Overriding server port with PORT environment variable: %d", port)
|
||||
}
|
||||
}
|
||||
mux := http.NewServeMux()
|
||||
s := &Server{
|
||||
ready: false,
|
||||
|
|
@ -75,7 +80,6 @@ func NewServer(host string, port int) *Server {
|
|||
mux.HandleFunc("/ready", s.readyHandler)
|
||||
mux.HandleFunc("/reload", s.reloadHandler)
|
||||
mux.HandleFunc("/chat", s.chatHandler)
|
||||
mux.HandleFunc("/cgat", s.chatHandler)
|
||||
|
||||
// Start task cleanup goroutine
|
||||
go s.taskCleanupLoop()
|
||||
|
|
@ -280,7 +284,6 @@ func (s *Server) RegisterOnMux(mux HandlerMux) {
|
|||
mux.HandleFunc("/ready", s.readyHandler)
|
||||
mux.HandleFunc("/reload", s.reloadHandler)
|
||||
mux.HandleFunc("/chat", s.chatHandler)
|
||||
mux.HandleFunc("/cgat", s.chatHandler)
|
||||
mux.HandleFunc("/v1/chat/completions", func(w http.ResponseWriter, r *http.Request) {
|
||||
logger.Error("GATEWAY IS HITTING ITSELF FOR LLM CALLS!")
|
||||
http.Error(w, "GATEWAY LOOP DETECTION", http.StatusLoopDetected)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue