Skip to content

Commit

Permalink
add 1106 models
Browse files Browse the repository at this point in the history
  • Loading branch information
zmh-program committed Nov 9, 2023
1 parent 032cdc9 commit ed88704
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 16 deletions.
3 changes: 3 additions & 0 deletions adapter/chatgpt/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ func NewChatInstanceFromModel(props *InstanceProps) *ChatInstance {
}
return NewChatInstanceFromConfig("gpt3")

case globals.GPT3Turbo1106, globals.GPT41106Preview:
return NewChatInstanceFromConfig("preview")

case globals.Dalle2:
return NewChatInstanceFromConfig("image")

Expand Down
3 changes: 3 additions & 0 deletions app/src/admin/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ export const modelColorMapper: Record<string, string> = {
"gpt-3.5-turbo-instruct": "#34bf49",
"gpt-3.5-turbo-0613": "#34bf49",
"gpt-3.5-turbo-0301": "#34bf49",
"gpt-3.5-turbo-1106": "#11ba2b",
dalle: "#e4e5e5",

"gpt-3.5-turbo-16k": "#0abf53",
"gpt-3.5-turbo-16k-0613": "#0abf53",
"gpt-3.5-turbo-16k-0301": "#0abf53",

"gpt-4": "#8e43e7",
"gpt-4-1106-preview": "#8e43e7",
"gpt-4-0613": "#8e43e7",
"gpt-4-0314": "#8e43e7",
"gpt-4-all": "#8e43e7",
"gpt-4-v": "#8e43e7",
"gpt-4-dalle": "#8e43e7",

Expand Down
7 changes: 5 additions & 2 deletions app/src/conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from "@/utils/env.ts";
import { getMemory } from "@/utils/memory.ts";

export const version = "3.6.15rc";
export const version = "3.6.15easter";
export const dev: boolean = getDev();
export const deploy: boolean = true;
export let rest_api: string = getRestApi(deploy);
Expand All @@ -20,8 +20,9 @@ export const supportModels: Model[] = [
// openai models
{ id: "gpt-3.5-turbo-0613", name: "GPT-3.5", free: true, auth: false },
{ id: "gpt-3.5-turbo-16k-0613", name: "GPT-3.5-16k", free: true, auth: true },
{ id: "gpt-3.5-turbo-1106", name: "GPT-3.5 1106", free: true, auth: false },
{ id: "gpt-4-0613", name: "GPT-4", free: false, auth: true },
{ id: "gpt-4-all", name: "GPT-4 Alpha", free: false, auth: true },
{ id: "gpt-4-1106-preview", name: "GPT-4 1106 Preview", free: false, auth: true },
{ id: "gpt-4-v", name: "GPT-4 Vision", free: false, auth: true },
{ id: "gpt-4-dalle", name: "GPT-4 DALLE", free: false, auth: true },

Expand Down Expand Up @@ -59,6 +60,7 @@ export const supportModels: Model[] = [

export const largeContextModels = [
"gpt-3.5-turbo-16k-0613",
"gpt-4-1106-preview",
"gpt-4-all",
"gpt-4-32k-0613",
"claude-1",
Expand All @@ -71,6 +73,7 @@ export const studentModels = ["claude-1-100k", "claude-2-100k"];

export const planModels = [
"gpt-4-0613",
"gpt-4-1106-preview",
"gpt-4-v",
"gpt-4-all",
"gpt-4-dalle",
Expand Down
2 changes: 1 addition & 1 deletion auth/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package auth

import (
"chat/utils"
"encoding/json"
"github.com/goccy/go-json"
"github.com/spf13/viper"
)

Expand Down
2 changes: 1 addition & 1 deletion auth/cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package auth

import (
"chat/utils"
"encoding/json"
"github.com/goccy/go-json"
"github.com/spf13/viper"
)

Expand Down
2 changes: 1 addition & 1 deletion auth/payment.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"chat/admin"
"chat/utils"
"database/sql"
"encoding/json"
"github.com/go-redis/redis/v8"
"github.com/goccy/go-json"
"github.com/spf13/viper"
)

Expand Down
5 changes: 4 additions & 1 deletion auth/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func CanEnableModel(db *sql.DB, user *User, model string) bool {
switch model {
case globals.GPT3Turbo, globals.GPT3TurboInstruct, globals.GPT3Turbo0301, globals.GPT3Turbo0613:
return true
case globals.GPT4, globals.GPT40613, globals.GPT40314:
case globals.GPT4, globals.GPT40613, globals.GPT40314, globals.GPT41106Preview:
return user != nil && user.GetQuota(db) >= 5
case globals.GPT432k, globals.GPT432k0613, globals.GPT432k0314:
return user != nil && user.GetQuota(db) >= 50
Expand All @@ -30,6 +30,9 @@ func CanEnableModel(db *sql.DB, user *User, model string) bool {

func HandleSubscriptionUsage(db *sql.DB, cache *redis.Client, user *User, model string) bool {
subscription := user.IsSubscribe(db)
if model == globals.GPT41106Preview || model == globals.GPT3Turbo1106 {
return true
}
if globals.IsGPT3TurboModel(model) {
// independent channel for subscription users
return subscription
Expand Down
8 changes: 7 additions & 1 deletion globals/variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const (
GPT3TurboInstruct = "gpt-3.5-turbo-instruct"
GPT3Turbo0613 = "gpt-3.5-turbo-0613"
GPT3Turbo0301 = "gpt-3.5-turbo-0301"
GPT3Turbo1106 = "gpt-3.5-turbo-1106"
GPT3Turbo16k = "gpt-3.5-turbo-16k"
GPT3Turbo16k0613 = "gpt-3.5-turbo-16k-0613"
GPT3Turbo16k0301 = "gpt-3.5-turbo-16k-0301"
Expand All @@ -51,6 +52,7 @@ const (
GPT4Dalle = "gpt-4-dalle"
GPT40314 = "gpt-4-0314"
GPT40613 = "gpt-4-0613"
GPT41106Preview = "gpt-4-1106-preview"
GPT432k = "gpt-4-32k"
GPT432k0314 = "gpt-4-32k-0314"
GPT432k0613 = "gpt-4-32k-0613"
Expand Down Expand Up @@ -81,6 +83,7 @@ var GPT3TurboArray = []string{
GPT3TurboInstruct,
GPT3Turbo0613,
GPT3Turbo0301,
GPT3Turbo1106,
}

var GPT3Turbo16kArray = []string{
Expand All @@ -90,7 +93,7 @@ var GPT3Turbo16kArray = []string{
}

var GPT4Array = []string{
GPT4, GPT40314, GPT40613,
GPT4, GPT40314, GPT40613, GPT41106Preview,
GPT4Vision, GPT4Dalle, GPT4All,
}

Expand Down Expand Up @@ -148,6 +151,7 @@ var FreeModelArray = []string{
GPT3TurboInstruct,
GPT3Turbo0613,
GPT3Turbo0301,
GPT3Turbo1106,
GPT3Turbo16k,
GPT3Turbo16k0613,
GPT3Turbo16k0301,
Expand All @@ -165,6 +169,7 @@ var AllModels = []string{
GPT3TurboInstruct,
GPT3Turbo0613,
GPT3Turbo0301,
GPT3Turbo1106,
GPT3Turbo16k,
GPT3Turbo16k0613,
GPT3Turbo16k0301,
Expand All @@ -173,6 +178,7 @@ var AllModels = []string{
GPT40613,
GPT4Vision,
GPT4All,
GPT41106Preview,
GPT4Dalle,
GPT432k,
GPT432k0314,
Expand Down
2 changes: 1 addition & 1 deletion utils/base.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package utils

import (
"encoding/json"
"fmt"
"github.com/goccy/go-json"
)

func Sum[T int | int64 | float32 | float64](arr []T) T {
Expand Down
2 changes: 1 addition & 1 deletion utils/char.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package utils

import (
"encoding/json"
"fmt"
"github.com/goccy/go-json"
"math/rand"
"regexp"
"strconv"
Expand Down
2 changes: 1 addition & 1 deletion utils/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package utils
import (
"bytes"
"crypto/tls"
"encoding/json"
"fmt"
"github.com/goccy/go-json"
"io"
"net/http"
"net/url"
Expand Down
12 changes: 6 additions & 6 deletions utils/tokenizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ func GetWeightByModel(model string) int {
globals.Claude1, globals.Claude1100k,
globals.Claude2, globals.Claude2100k:
return 2
case globals.GPT3Turbo, globals.GPT3Turbo0613,
case globals.GPT3Turbo, globals.GPT3Turbo0613, globals.GPT3Turbo1106,
globals.GPT3Turbo16k, globals.GPT3Turbo16k0613,
globals.GPT4, globals.GPT4Vision, globals.GPT4Dalle, globals.GPT4All, globals.GPT40314, globals.GPT40613,
globals.GPT4, globals.GPT4Vision, globals.GPT4Dalle, globals.GPT4All, globals.GPT40314, globals.GPT40613, globals.GPT41106Preview,
globals.GPT432k, globals.GPT432k0613, globals.GPT432k0314,

globals.SparkDesk, globals.SparkDeskV2, globals.SparkDeskV3,
Expand Down Expand Up @@ -74,10 +74,10 @@ func CountTokenPrice(messages []globals.Message, model string) int {

func CountInputToken(model string, v []globals.Message) float32 {
switch model {
case globals.GPT3Turbo, globals.GPT3Turbo0613, globals.GPT3Turbo0301, globals.GPT3TurboInstruct,
case globals.GPT3Turbo, globals.GPT3Turbo0613, globals.GPT3Turbo0301, globals.GPT3TurboInstruct, globals.GPT3Turbo1106,
globals.GPT3Turbo16k, globals.GPT3Turbo16k0613, globals.GPT3Turbo16k0301:
return 0
case globals.GPT4, globals.GPT4Vision, globals.GPT4All, globals.GPT4Dalle, globals.GPT40314, globals.GPT40613:
case globals.GPT4, globals.GPT4Vision, globals.GPT4All, globals.GPT4Dalle, globals.GPT40314, globals.GPT40613, globals.GPT41106Preview:
return float32(CountTokenPrice(v, model)) / 1000 * 2.1 * 0.6
case globals.GPT432k, globals.GPT432k0613, globals.GPT432k0314:
return float32(CountTokenPrice(v, model)) / 1000 * 4.2
Expand All @@ -104,10 +104,10 @@ func CountInputToken(model string, v []globals.Message) float32 {

func CountOutputToken(model string, t int) float32 {
switch model {
case globals.GPT3Turbo, globals.GPT3Turbo0613, globals.GPT3Turbo0301, globals.GPT3TurboInstruct,
case globals.GPT3Turbo, globals.GPT3Turbo0613, globals.GPT3Turbo0301, globals.GPT3TurboInstruct, globals.GPT3Turbo1106,
globals.GPT3Turbo16k, globals.GPT3Turbo16k0613, globals.GPT3Turbo16k0301:
return 0
case globals.GPT4, globals.GPT4Vision, globals.GPT4All, globals.GPT4Dalle, globals.GPT40314, globals.GPT40613:
case globals.GPT4, globals.GPT4Vision, globals.GPT4All, globals.GPT4Dalle, globals.GPT40314, globals.GPT40613, globals.GPT41106Preview:
return float32(t*GetWeightByModel(model)) / 1000 * 4.3 * 0.6
case globals.GPT432k, globals.GPT432k0613, globals.GPT432k0314:
return float32(t*GetWeightByModel(model)) / 1000 * 8.6
Expand Down

0 comments on commit ed88704

Please sign in to comment.