Skip to content

Commit

Permalink
free sparkdesk, dalle3 model
Browse files Browse the repository at this point in the history
  • Loading branch information
zmh-program committed Nov 1, 2023
1 parent a0122ed commit d978b96
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 26 deletions.
21 changes: 7 additions & 14 deletions adapter/chatgpt/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,17 @@ func NewChatInstanceFromConfig(v string) *ChatInstance {

func NewChatInstanceFromModel(props *InstanceProps) *ChatInstance {
switch props.Model {
case globals.GPT4,
globals.GPT4Vision,
globals.GPT40314,
globals.GPT40613:
case globals.GPT4, globals.GPT40314, globals.GPT40613:
return NewChatInstanceFromConfig("gpt4")

case globals.GPT432k,
globals.GPT432k0613,
globals.GPT432k0314:
case globals.GPT432k, globals.GPT432k0613, globals.GPT432k0314:
return NewChatInstanceFromConfig("32k")

case globals.GPT3Turbo,
globals.GPT3TurboInstruct,
globals.GPT3Turbo0613,
globals.GPT3Turbo0301,
globals.GPT3Turbo16k,
globals.GPT3Turbo16k0301,
globals.GPT3Turbo16k0613:
case globals.GPT4Vision, globals.Dalle3:
return NewChatInstanceFromConfig("reverse")

case globals.GPT3Turbo, globals.GPT3TurboInstruct, globals.GPT3Turbo0613, globals.GPT3Turbo0301,
globals.GPT3Turbo16k, globals.GPT3Turbo16k0301, globals.GPT3Turbo16k0613:
if props.Plan {
return NewChatInstanceFromConfig("subscribe")
}
Expand Down
4 changes: 2 additions & 2 deletions auth/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ func CanEnableModel(db *sql.DB, user *User, model string) bool {
case globals.GPT3Turbo, globals.GPT3TurboInstruct, globals.GPT3Turbo0301, globals.GPT3Turbo0613,
globals.Claude2:
return true
case globals.GPT4, globals.GPT4Vision, globals.GPT40613, globals.GPT40314:
case globals.GPT4, globals.GPT40613, globals.GPT40314:
return user != nil && user.GetQuota(db) >= 5
case globals.GPT432k, globals.GPT432k0613, globals.GPT432k0314:
return user != nil && user.GetQuota(db) >= 50
case globals.SparkDesk, globals.SparkDeskV2, globals.SparkDeskV3:
return user != nil && user.GetQuota(db) >= 1
return user != nil // && user.GetQuota(db) >= 1 free now
case globals.Claude2100k:
return user != nil && user.GetQuota(db) >= 1
case globals.ZhiPuChatGLMPro, globals.ZhiPuChatGLMStd:
Expand Down
7 changes: 4 additions & 3 deletions globals/variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const (
GPT432k0314 = "gpt-4-32k-0314"
GPT432k0613 = "gpt-4-32k-0613"
Dalle = "dalle"
Dalle3 = "gpt-4-dalle"
Claude2 = "claude-1" // claude v1.3
Claude2100k = "claude-2"
ClaudeSlack = "claude-slack"
Expand Down Expand Up @@ -87,9 +88,8 @@ var GPT3Turbo16kArray = []string{

var GPT4Array = []string{
GPT4,
GPT4Vision,
GPT40314,
GPT40613,
GPT4Vision, Dalle3,
GPT40314, GPT40613,
}

var GPT432kArray = []string{
Expand Down Expand Up @@ -167,6 +167,7 @@ var AllModels = []string{
GPT40314,
GPT40613,
GPT4Vision,
Dalle3,
GPT432k,
GPT432k0314,
GPT432k0613,
Expand Down
14 changes: 7 additions & 7 deletions utils/tokenizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func GetWeightByModel(model string) int {
return 3 * 10
case globals.GPT3Turbo, globals.GPT3Turbo0613,
globals.GPT3Turbo16k, globals.GPT3Turbo16k0613,
globals.GPT4, globals.GPT4Vision, globals.GPT40314, globals.GPT40613,
globals.GPT4, globals.GPT4Vision, globals.Dalle3, globals.GPT40314, globals.GPT40613,

globals.SparkDesk, globals.SparkDeskV2, globals.SparkDeskV3,
globals.QwenTurbo, globals.QwenPlus, globals.QwenTurboNet, globals.QwenPlusNet:
Expand Down Expand Up @@ -98,14 +98,14 @@ func CountInputToken(model string, v []globals.Message) float32 {
case globals.GPT3Turbo, globals.GPT3Turbo0613, globals.GPT3Turbo0301, globals.GPT3TurboInstruct,
globals.GPT3Turbo16k, globals.GPT3Turbo16k0613, globals.GPT3Turbo16k0301:
return 0
case globals.GPT4, globals.GPT4Vision, globals.GPT40314, globals.GPT40613:
case globals.GPT4, globals.GPT4Vision, globals.Dalle3, globals.GPT40314, globals.GPT40613:
return float32(CountTokenPrice(v, model)) / 1000 * 2.1
case globals.GPT432k, globals.GPT432k0613, globals.GPT432k0314:
return float32(CountTokenPrice(v, model)) / 1000 * 4.2
case globals.SparkDesk:
return float32(CountTokenPrice(v, model)) / 1000 * 0.15
return 0 // float32(CountTokenPrice(v, model)) / 1000 * 0.15 free now
case globals.SparkDeskV2, globals.SparkDeskV3:
return float32(CountTokenPrice(v, model)) / 1000 * 0.3
return 0 // float32(CountTokenPrice(v, model)) / 1000 * 0.3 free now
case globals.Claude2:
return 0
case globals.Claude2100k:
Expand All @@ -128,14 +128,14 @@ func CountOutputToken(model string, t int) float32 {
case globals.GPT3Turbo, globals.GPT3Turbo0613, globals.GPT3Turbo0301, globals.GPT3TurboInstruct,
globals.GPT3Turbo16k, globals.GPT3Turbo16k0613, globals.GPT3Turbo16k0301:
return 0
case globals.GPT4, globals.GPT4Vision, globals.GPT40314, globals.GPT40613:
case globals.GPT4, globals.GPT4Vision, globals.Dalle3, globals.GPT40314, globals.GPT40613:
return float32(t*GetWeightByModel(model)) / 1000 * 4.3
case globals.GPT432k, globals.GPT432k0613, globals.GPT432k0314:
return float32(t*GetWeightByModel(model)) / 1000 * 8.6
case globals.SparkDesk:
return float32(t*GetWeightByModel(model)) / 1000 * 0.15
return 0 // float32(t*GetWeightByModel(model)) / 1000 * 0.15 free now
case globals.SparkDeskV2, globals.SparkDeskV3:
return float32(t*GetWeightByModel(model)) / 1000 * 0.3
return 0 // float32(t*GetWeightByModel(model)) / 1000 * 0.3 free now
case globals.Claude2:
return 0
case globals.Claude2100k:
Expand Down

0 comments on commit d978b96

Please sign in to comment.