mirror of
https://github.com/coaidev/coai.git
synced 2025-05-30 02:10:25 +09:00
add 1106 models
This commit is contained in:
parent
032cdc91c1
commit
ed8870460d
@ -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")
|
||||
|
||||
|
@ -3,6 +3,7 @@ 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",
|
||||
@ -10,8 +11,10 @@ export const modelColorMapper: Record<string, string> = {
|
||||
"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",
|
||||
|
||||
|
@ -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);
|
||||
@ -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 },
|
||||
|
||||
@ -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",
|
||||
@ -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",
|
||||
|
@ -2,7 +2,7 @@ package auth
|
||||
|
||||
import (
|
||||
"chat/utils"
|
||||
"encoding/json"
|
||||
"github.com/goccy/go-json"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
|
@ -2,7 +2,7 @@ package auth
|
||||
|
||||
import (
|
||||
"chat/utils"
|
||||
"encoding/json"
|
||||
"github.com/goccy/go-json"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
|
@ -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"
|
||||
)
|
||||
|
||||
|
@ -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
|
||||
@ -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
|
||||
|
@ -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"
|
||||
@ -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"
|
||||
@ -81,6 +83,7 @@ var GPT3TurboArray = []string{
|
||||
GPT3TurboInstruct,
|
||||
GPT3Turbo0613,
|
||||
GPT3Turbo0301,
|
||||
GPT3Turbo1106,
|
||||
}
|
||||
|
||||
var GPT3Turbo16kArray = []string{
|
||||
@ -90,7 +93,7 @@ var GPT3Turbo16kArray = []string{
|
||||
}
|
||||
|
||||
var GPT4Array = []string{
|
||||
GPT4, GPT40314, GPT40613,
|
||||
GPT4, GPT40314, GPT40613, GPT41106Preview,
|
||||
GPT4Vision, GPT4Dalle, GPT4All,
|
||||
}
|
||||
|
||||
@ -148,6 +151,7 @@ var FreeModelArray = []string{
|
||||
GPT3TurboInstruct,
|
||||
GPT3Turbo0613,
|
||||
GPT3Turbo0301,
|
||||
GPT3Turbo1106,
|
||||
GPT3Turbo16k,
|
||||
GPT3Turbo16k0613,
|
||||
GPT3Turbo16k0301,
|
||||
@ -165,6 +169,7 @@ var AllModels = []string{
|
||||
GPT3TurboInstruct,
|
||||
GPT3Turbo0613,
|
||||
GPT3Turbo0301,
|
||||
GPT3Turbo1106,
|
||||
GPT3Turbo16k,
|
||||
GPT3Turbo16k0613,
|
||||
GPT3Turbo16k0301,
|
||||
@ -173,6 +178,7 @@ var AllModels = []string{
|
||||
GPT40613,
|
||||
GPT4Vision,
|
||||
GPT4All,
|
||||
GPT41106Preview,
|
||||
GPT4Dalle,
|
||||
GPT432k,
|
||||
GPT432k0314,
|
||||
|
@ -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 {
|
||||
|
@ -1,8 +1,8 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/goccy/go-json"
|
||||
"math/rand"
|
||||
"regexp"
|
||||
"strconv"
|
||||
|
@ -3,8 +3,8 @@ package utils
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/goccy/go-json"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
@ -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,
|
||||
@ -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
|
||||
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user