Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
zmh-program committed Oct 31, 2023
1 parent 4d3492d commit 14b04d9
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
27 changes: 27 additions & 0 deletions globals/variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,33 @@ var FreeModelArray = []string{
ZhiPuChatGLMLite,
}

var AllModels = []string{
GPT3Turbo,
GPT3Turbo0613,
GPT3Turbo0301,
GPT3Turbo16k,
GPT3Turbo16k0613,
GPT3Turbo16k0301,
GPT4,
GPT40314,
GPT40613,
GPT432k,
GPT432k0314,
GPT432k0613,
Dalle,
Claude2,
Claude2100k,
ClaudeSlack,
SparkDesk,
ChatBison001,
BingCreative,
BingBalanced,
BingPrecise,
ZhiPuChatGLMPro,
ZhiPuChatGLMStd,
ZhiPuChatGLMLite,
}

func in(value string, slice []string) bool {
for _, item := range slice {
if item == value {
Expand Down
1 change: 1 addition & 0 deletions manager/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ import "github.com/gin-gonic/gin"

func Register(app *gin.Engine) {
app.GET("/chat", ChatAPI)
app.GET("/v1/chat/models", ModelAPI)
app.POST("/v1/chat/completions", TranshipmentAPI)
}
4 changes: 4 additions & 0 deletions manager/transhipment.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ type TranshipmentStreamResponse struct {
Quota float32 `json:"quota"`
}

func ModelAPI(c *gin.Context) {
c.JSON(http.StatusOK, globals.AllModels)
}

func TranshipmentAPI(c *gin.Context) {
username := utils.GetUserFromContext(c)
if username == "" {
Expand Down
4 changes: 4 additions & 0 deletions middleware/throttle.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ var limits = map[string]Limiter{
"/chat": {Duration: 1, Count: 5},
"/conversation": {Duration: 1, Count: 5},
"/invite": {Duration: 7200, Count: 20},
"/v1": {Duration: 1, Count: 600},

"/generation": {Duration: 1, Count: 5},
"/article": {Duration: 1, Count: 5},
}

func GetPrefixMap[T comparable](s string, p map[string]T) *T {
Expand Down

0 comments on commit 14b04d9

Please sign in to comment.