free sparkdesk, dalle3 model

This commit is contained in:
Zhang Minghan 2023-11-01 20:56:52 +08:00
parent a0122edc06
commit d978b96485
4 changed files with 20 additions and 26 deletions

View File

@ -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")
}

View File

@ -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:

View File

@ -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"
@ -87,9 +88,8 @@ var GPT3Turbo16kArray = []string{
var GPT4Array = []string{
GPT4,
GPT4Vision,
GPT40314,
GPT40613,
GPT4Vision, Dalle3,
GPT40314, GPT40613,
}
var GPT432kArray = []string{
@ -167,6 +167,7 @@ var AllModels = []string{
GPT40314,
GPT40613,
GPT4Vision,
Dalle3,
GPT432k,
GPT432k0314,
GPT432k0613,

View File

@ -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:
@ -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:
@ -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: