add guard to ensure ls-real-model-name is set in context

This commit is contained in:
Benson Wong
2025-07-21 22:59:41 -07:00
parent 36e25125e8
commit cce0bc6aa1

View File

@@ -366,6 +366,11 @@ func (pm *ProxyManager) proxyOAIHandler(c *gin.Context) {
}
realModelName := c.GetString("ls-real-model-name") // Should be set in MetricsMiddleware
if realModelName == "" {
pm.sendErrorResponse(c, http.StatusInternalServerError, "ls-real-model-name not set")
return
}
processGroup, _, err := pm.swapProcessGroup(realModelName)
if err != nil {
pm.sendErrorResponse(c, http.StatusInternalServerError, fmt.Sprintf("error swapping process group: %s", err.Error()))