rename proxy handler

This commit is contained in:
Benson Wong
2024-12-17 17:24:41 -08:00
parent 6fe37c3abf
commit 9b4e3f307e

View File

@@ -47,13 +47,13 @@ func New(config *Config) *ProxyManager {
} }
// Set up routes using the Gin engine // Set up routes using the Gin engine
pm.ginEngine.POST("/v1/chat/completions", pm.proxyChatRequestHandler) pm.ginEngine.POST("/v1/chat/completions", pm.proxyOAIHandler)
// Support embeddings // Support embeddings
pm.ginEngine.POST("/v1/embeddings", pm.proxyChatRequestHandler) pm.ginEngine.POST("/v1/embeddings", pm.proxyOAIHandler)
// Support legacy /v1/completions api, see issue #12 // Support legacy /v1/completions api, see issue #12
pm.ginEngine.POST("/v1/completions", pm.proxyChatRequestHandler) pm.ginEngine.POST("/v1/completions", pm.proxyOAIHandler)
pm.ginEngine.GET("/v1/models", pm.listModelsHandler) pm.ginEngine.GET("/v1/models", pm.listModelsHandler)
@@ -235,7 +235,7 @@ func (pm *ProxyManager) upstreamIndex(c *gin.Context) {
c.String(http.StatusOK, html.String()) c.String(http.StatusOK, html.String())
} }
func (pm *ProxyManager) proxyChatRequestHandler(c *gin.Context) { func (pm *ProxyManager) proxyOAIHandler(c *gin.Context) {
bodyBytes, err := io.ReadAll(c.Request.Body) bodyBytes, err := io.ReadAll(c.Request.Body)
if err != nil { if err != nil {
c.AbortWithError(http.StatusBadRequest, fmt.Errorf("invalid JSON")) c.AbortWithError(http.StatusBadRequest, fmt.Errorf("invalid JSON"))