Skip to content

Commit

Permalink
fix: v1 route
Browse files Browse the repository at this point in the history
  • Loading branch information
zijiren233 committed Jan 5, 2025
1 parent 9ce8d3f commit b92a620
Showing 1 changed file with 58 additions and 56 deletions.
114 changes: 58 additions & 56 deletions service/aiproxy/router/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,73 +9,75 @@ import (
)

func SetRelayRouter(router *gin.Engine) {
router.Use(
// https://platform.openai.com/docs/api-reference/introduction
v1Router := router.Group("/v1")
v1Router.Use(
middleware.CORS(),
middleware.TokenAuth,
)
// https://platform.openai.com/docs/api-reference/introduction
modelsRouter := router.Group("/v1/models")

modelsRouter := v1Router.Group("/models")
{
modelsRouter.GET("", controller.ListModels)
modelsRouter.GET("/:model", controller.RetrieveModel)
}
dashboardRouter := router.Group("/v1/dashboard")
dashboardRouter := v1Router.Group("/dashboard")
{
dashboardRouter.GET("/billing/subscription", controller.GetSubscription)
dashboardRouter.GET("/billing/usage", controller.GetUsage)
}
relayV1Router := router.Group("/v1")
relayV1Router.Use(middleware.Distribute)
relayRouter := v1Router.Group("")
relayRouter.Use(middleware.Distribute)
{
relayV1Router.POST("/completions", controller.NewRelay(relaymode.Completions))
relayV1Router.POST("/chat/completions", controller.NewRelay(relaymode.ChatCompletions))
relayV1Router.POST("/edits", controller.NewRelay(relaymode.Edits))
relayV1Router.POST("/images/generations", controller.NewRelay(relaymode.ImagesGenerations))
relayV1Router.POST("/images/edits", controller.RelayNotImplemented)
relayV1Router.POST("/images/variations", controller.RelayNotImplemented)
relayV1Router.POST("/embeddings", controller.NewRelay(relaymode.Embeddings))
relayV1Router.POST("/engines/:model/embeddings", controller.NewRelay(relaymode.Embeddings))
relayV1Router.POST("/audio/transcriptions", controller.NewRelay(relaymode.AudioTranscription))
relayV1Router.POST("/audio/translations", controller.NewRelay(relaymode.AudioTranslation))
relayV1Router.POST("/audio/speech", controller.NewRelay(relaymode.AudioSpeech))
relayV1Router.POST("/rerank", controller.NewRelay(relaymode.Rerank))
relayV1Router.GET("/files", controller.RelayNotImplemented)
relayV1Router.POST("/files", controller.RelayNotImplemented)
relayV1Router.DELETE("/files/:id", controller.RelayNotImplemented)
relayV1Router.GET("/files/:id", controller.RelayNotImplemented)
relayV1Router.GET("/files/:id/content", controller.RelayNotImplemented)
relayV1Router.POST("/fine_tuning/jobs", controller.RelayNotImplemented)
relayV1Router.GET("/fine_tuning/jobs", controller.RelayNotImplemented)
relayV1Router.GET("/fine_tuning/jobs/:id", controller.RelayNotImplemented)
relayV1Router.POST("/fine_tuning/jobs/:id/cancel", controller.RelayNotImplemented)
relayV1Router.GET("/fine_tuning/jobs/:id/events", controller.RelayNotImplemented)
relayV1Router.DELETE("/models/:model", controller.RelayNotImplemented)
relayV1Router.POST("/moderations", controller.NewRelay(relaymode.Moderations))
relayV1Router.POST("/assistants", controller.RelayNotImplemented)
relayV1Router.GET("/assistants/:id", controller.RelayNotImplemented)
relayV1Router.POST("/assistants/:id", controller.RelayNotImplemented)
relayV1Router.DELETE("/assistants/:id", controller.RelayNotImplemented)
relayV1Router.GET("/assistants", controller.RelayNotImplemented)
relayV1Router.POST("/assistants/:id/files", controller.RelayNotImplemented)
relayV1Router.GET("/assistants/:id/files/:fileId", controller.RelayNotImplemented)
relayV1Router.DELETE("/assistants/:id/files/:fileId", controller.RelayNotImplemented)
relayV1Router.GET("/assistants/:id/files", controller.RelayNotImplemented)
relayV1Router.POST("/threads", controller.RelayNotImplemented)
relayV1Router.GET("/threads/:id", controller.RelayNotImplemented)
relayV1Router.POST("/threads/:id", controller.RelayNotImplemented)
relayV1Router.DELETE("/threads/:id", controller.RelayNotImplemented)
relayV1Router.POST("/threads/:id/messages", controller.RelayNotImplemented)
relayV1Router.GET("/threads/:id/messages/:messageId", controller.RelayNotImplemented)
relayV1Router.POST("/threads/:id/messages/:messageId", controller.RelayNotImplemented)
relayV1Router.GET("/threads/:id/messages/:messageId/files/:filesId", controller.RelayNotImplemented)
relayV1Router.GET("/threads/:id/messages/:messageId/files", controller.RelayNotImplemented)
relayV1Router.POST("/threads/:id/runs", controller.RelayNotImplemented)
relayV1Router.GET("/threads/:id/runs/:runsId", controller.RelayNotImplemented)
relayV1Router.POST("/threads/:id/runs/:runsId", controller.RelayNotImplemented)
relayV1Router.GET("/threads/:id/runs", controller.RelayNotImplemented)
relayV1Router.POST("/threads/:id/runs/:runsId/submit_tool_outputs", controller.RelayNotImplemented)
relayV1Router.POST("/threads/:id/runs/:runsId/cancel", controller.RelayNotImplemented)
relayV1Router.GET("/threads/:id/runs/:runsId/steps/:stepId", controller.RelayNotImplemented)
relayV1Router.GET("/threads/:id/runs/:runsId/steps", controller.RelayNotImplemented)
relayRouter.POST("/completions", controller.NewRelay(relaymode.Completions))
relayRouter.POST("/chat/completions", controller.NewRelay(relaymode.ChatCompletions))
relayRouter.POST("/edits", controller.NewRelay(relaymode.Edits))
relayRouter.POST("/images/generations", controller.NewRelay(relaymode.ImagesGenerations))
relayRouter.POST("/images/edits", controller.RelayNotImplemented)
relayRouter.POST("/images/variations", controller.RelayNotImplemented)
relayRouter.POST("/embeddings", controller.NewRelay(relaymode.Embeddings))
relayRouter.POST("/engines/:model/embeddings", controller.NewRelay(relaymode.Embeddings))
relayRouter.POST("/audio/transcriptions", controller.NewRelay(relaymode.AudioTranscription))
relayRouter.POST("/audio/translations", controller.NewRelay(relaymode.AudioTranslation))
relayRouter.POST("/audio/speech", controller.NewRelay(relaymode.AudioSpeech))
relayRouter.POST("/rerank", controller.NewRelay(relaymode.Rerank))
relayRouter.GET("/files", controller.RelayNotImplemented)
relayRouter.POST("/files", controller.RelayNotImplemented)
relayRouter.DELETE("/files/:id", controller.RelayNotImplemented)
relayRouter.GET("/files/:id", controller.RelayNotImplemented)
relayRouter.GET("/files/:id/content", controller.RelayNotImplemented)
relayRouter.POST("/fine_tuning/jobs", controller.RelayNotImplemented)
relayRouter.GET("/fine_tuning/jobs", controller.RelayNotImplemented)
relayRouter.GET("/fine_tuning/jobs/:id", controller.RelayNotImplemented)
relayRouter.POST("/fine_tuning/jobs/:id/cancel", controller.RelayNotImplemented)
relayRouter.GET("/fine_tuning/jobs/:id/events", controller.RelayNotImplemented)
relayRouter.DELETE("/models/:model", controller.RelayNotImplemented)
relayRouter.POST("/moderations", controller.NewRelay(relaymode.Moderations))
relayRouter.POST("/assistants", controller.RelayNotImplemented)
relayRouter.GET("/assistants/:id", controller.RelayNotImplemented)
relayRouter.POST("/assistants/:id", controller.RelayNotImplemented)
relayRouter.DELETE("/assistants/:id", controller.RelayNotImplemented)
relayRouter.GET("/assistants", controller.RelayNotImplemented)
relayRouter.POST("/assistants/:id/files", controller.RelayNotImplemented)
relayRouter.GET("/assistants/:id/files/:fileId", controller.RelayNotImplemented)
relayRouter.DELETE("/assistants/:id/files/:fileId", controller.RelayNotImplemented)
relayRouter.GET("/assistants/:id/files", controller.RelayNotImplemented)
relayRouter.POST("/threads", controller.RelayNotImplemented)
relayRouter.GET("/threads/:id", controller.RelayNotImplemented)
relayRouter.POST("/threads/:id", controller.RelayNotImplemented)
relayRouter.DELETE("/threads/:id", controller.RelayNotImplemented)
relayRouter.POST("/threads/:id/messages", controller.RelayNotImplemented)
relayRouter.GET("/threads/:id/messages/:messageId", controller.RelayNotImplemented)
relayRouter.POST("/threads/:id/messages/:messageId", controller.RelayNotImplemented)
relayRouter.GET("/threads/:id/messages/:messageId/files/:filesId", controller.RelayNotImplemented)
relayRouter.GET("/threads/:id/messages/:messageId/files", controller.RelayNotImplemented)
relayRouter.POST("/threads/:id/runs", controller.RelayNotImplemented)
relayRouter.GET("/threads/:id/runs/:runsId", controller.RelayNotImplemented)
relayRouter.POST("/threads/:id/runs/:runsId", controller.RelayNotImplemented)
relayRouter.GET("/threads/:id/runs", controller.RelayNotImplemented)
relayRouter.POST("/threads/:id/runs/:runsId/submit_tool_outputs", controller.RelayNotImplemented)
relayRouter.POST("/threads/:id/runs/:runsId/cancel", controller.RelayNotImplemented)
relayRouter.GET("/threads/:id/runs/:runsId/steps/:stepId", controller.RelayNotImplemented)
relayRouter.GET("/threads/:id/runs/:runsId/steps", controller.RelayNotImplemented)
}
}

0 comments on commit b92a620

Please sign in to comment.