Skip to content

Commit

Permalink
feat: aiproxy probe (#5229)
Browse files Browse the repository at this point in the history
* feat: aiproxy probe

* fix: aiproxy use startup probe
  • Loading branch information
zijiren233 authored Nov 22, 2024
1 parent 26bb340 commit f9dc424
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 8 deletions.
8 changes: 6 additions & 2 deletions service/aiproxy/controller/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ import (
"github.com/gin-gonic/gin"
)

type StatusData struct {
StartTime int64 `json:"startTime"`
}

func GetStatus(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"success": true,
"message": "",
"data": gin.H{
"start_time": common.StartTime,
"data": &StatusData{
StartTime: common.StartTime,
},
})
}
1 change: 1 addition & 0 deletions service/aiproxy/controller/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ func RetrieveModel(c *gin.Context) {
Code: "model_not_found",
},
})
return
}
c.JSON(200, model)
}
9 changes: 9 additions & 0 deletions service/aiproxy/deploy/manifests/deploy.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,14 @@ spec:
ports:
- containerPort: 3000
imagePullPolicy: Always
startupProbe:
httpGet:
port: 3000
path: /api/status
initialDelaySeconds: 5
periodSeconds: 3
failureThreshold: 30
successThreshold: 1
timeoutSeconds: 1
serviceAccountName: default
automountServiceAccountToken: false
8 changes: 5 additions & 3 deletions service/aiproxy/relay/adaptor/ali/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ func ConvertRequest(request *model.GeneralOpenAIRequest) *model.GeneralOpenAIReq
if request.TopP != nil && *request.TopP >= 1 {
*request.TopP = 0.9999
}
if request.StreamOptions == nil {
request.StreamOptions = &model.StreamOptions{}
if request.Stream {
if request.StreamOptions == nil {
request.StreamOptions = &model.StreamOptions{}
}
request.StreamOptions.IncludeUsage = true
}
request.StreamOptions.IncludeUsage = true
return request
}

Expand Down
10 changes: 7 additions & 3 deletions service/aiproxy/router/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@ import (
)

func SetAPIRouter(router *gin.Engine) {
apiRouter := router.Group("/api")
api := router.Group("/api")
if env.Bool("GZIP_ENABLED", false) {
apiRouter.Use(gzip.Gzip(gzip.DefaultCompression))
api.Use(gzip.Gzip(gzip.DefaultCompression))
}

healthRouter := api.Group("")
healthRouter.GET("/status", controller.GetStatus)

apiRouter := api.Group("")
apiRouter.Use(middleware.AdminAuth)
{
apiRouter.GET("/status", controller.GetStatus)
apiRouter.GET("/models", controller.BuiltinModels)
apiRouter.GET("/models/price", controller.ModelPrice)
apiRouter.GET("/models/enabled", controller.EnabledModels)
Expand Down

0 comments on commit f9dc424

Please sign in to comment.