From 2c28c9b9e6aefcc186f06229c852f8fe5b7afb5e Mon Sep 17 00:00:00 2001 From: Zhang Minghan Date: Tue, 24 Oct 2023 11:01:11 +0800 Subject: [PATCH] update prize --- app/src/conf.ts | 2 +- app/src/dialogs/Subscription.tsx | 10 +++++++--- app/src/i18n.ts | 12 ++++++------ auth/subscription.go | 4 ++-- manager/chat.go | 2 ++ utils/net.go | 4 ++++ utils/tokenizer.go | 4 ++-- 7 files changed, 24 insertions(+), 14 deletions(-) diff --git a/app/src/conf.ts b/app/src/conf.ts index 87fa0612..f4c896da 100644 --- a/app/src/conf.ts +++ b/app/src/conf.ts @@ -1,7 +1,7 @@ import axios from "axios"; import { Model } from "./conversation/types.ts"; -export const version = "3.5.1"; +export const version = "3.5.2"; export const dev: boolean = window.location.hostname === "localhost"; export const deploy: boolean = true; export let rest_api: string = "http://localhost:8094"; diff --git a/app/src/dialogs/Subscription.tsx b/app/src/dialogs/Subscription.tsx index e085b65f..d2ebe6f1 100644 --- a/app/src/dialogs/Subscription.tsx +++ b/app/src/dialogs/Subscription.tsx @@ -45,11 +45,15 @@ import { Badge } from "../components/ui/badge.tsx"; import { buySubscription } from "../conversation/addition.ts"; function calc_prize(month: number): number { - if (month >= 12) { - return 8 * month * 0.8; + const base = 32 * month; + if (month >= 36) { + return base * 0.7; + } else if (month >= 12) { + return base * 0.8; } else if (month >= 6) { - return 8 * month * 0.9; + return base * 0.9; } + return 8 * month; } diff --git a/app/src/i18n.ts b/app/src/i18n.ts index 856e624c..9df0b94b 100644 --- a/app/src/i18n.ts +++ b/app/src/i18n.ts @@ -102,14 +102,14 @@ const resources = { free: "Free", "free-price": "Free Forever", pro: "Pro", - "pro-price": "8 CNY/Month", + "pro-price": "32 CNY/Month", "free-gpt3": "GPT-3.5 (16k) Free Forever", "free-dalle": "5 free quotas per day", "free-web": "web searching feature", "free-conversation": "conversation storage", "free-api": "API calls", "pro-gpt4": "GPT-4 50 requests per day", - "pro-dalle": "50 quotas per day", + "pro-dalle": "2000 quotas per day", "pro-service": "Priority Service Support", "pro-thread": "Concurrency Increase", current: "Current Plan", @@ -287,14 +287,14 @@ const resources = { free: "免费版", "free-price": "永久免费", pro: "专业版", - "pro-price": "8 元/月", + "pro-price": "32 元/月", "free-gpt3": "GPT-3.5 (16k) 永久免费", "free-dalle": "每日 5 次免费绘图", "free-web": "联网搜索功能", "free-conversation": "对话存储记录", "free-api": "API 调用", "pro-gpt4": "GPT-4 每日请求 50 次", - "pro-dalle": "每日 50 次绘图", + "pro-dalle": "每日 2000 次绘图", "pro-service": "优先服务支持", "pro-thread": "并发数提升", current: "当前计划", @@ -476,14 +476,14 @@ const resources = { free: "Бесплатно", "free-price": "Бесплатно навсегда", pro: "Профессиональный", - "pro-price": "8 CNY/месяц", + "pro-price": "32 CNY/месяц", "free-gpt3": "GPT-3.5 (16k) бесплатно навсегда", "free-dalle": "5 бесплатных квот в день", "free-web": "веб-поиск", "free-conversation": "хранение разговоров", "free-api": "API вызовы", "pro-gpt4": "GPT-4 50 запросов в день", - "pro-dalle": "50 квот в день", + "pro-dalle": "2000 квот в день", "pro-service": "Приоритетная служба поддержки", "pro-thread": "Увеличение параллелизма", current: "Текущая подписка", diff --git a/auth/subscription.go b/auth/subscription.go index b2523454..334e9407 100644 --- a/auth/subscription.go +++ b/auth/subscription.go @@ -9,7 +9,7 @@ import ( ) func CountSubscriptionPrize(month int) float32 { - base := 8 * float32(month) + base := 32 * float32(month) if month >= 36 { return base * 0.7 } else if month >= 12 { @@ -51,7 +51,7 @@ func CanEnableSubscription(db *sql.DB, cache *redis.Client, user *User) bool { func GetDalleUsageLimit(db *sql.DB, user *User) int { if user.IsSubscribe(db) { - return 50 + return 2000 } return 5 } diff --git a/manager/chat.go b/manager/chat.go index eb211951..bf927af6 100644 --- a/manager/chat.go +++ b/manager/chat.go @@ -128,6 +128,8 @@ func ChatHandler(conn *Connection, user *auth.User, instance *conversation.Conve }) if err != nil && err.Error() != "signal" { + fmt.Println(fmt.Sprintf("caught error from chat handler: %s (instance: %s, client: %s)", err, model, conn.GetCtx().ClientIP())) + CollectQuota(conn.GetCtx(), user, buffer.GetQuota(), reversible) conn.Send(globals.ChatSegmentResponse{ Message: err.Error(), diff --git a/utils/net.go b/utils/net.go index 9bff9a51..8a85c031 100644 --- a/utils/net.go +++ b/utils/net.go @@ -4,6 +4,7 @@ import ( "bytes" "crypto/tls" "encoding/json" + "fmt" "io" "net/http" "net/url" @@ -119,6 +120,9 @@ func EventSource(method string, uri string, headers map[string]string, body inte if err != nil { return err } + if res.StatusCode >= 400 { + return fmt.Errorf("request failed with status: %s", res.Status) + } defer res.Body.Close() for { diff --git a/utils/tokenizer.go b/utils/tokenizer.go index aa04da48..48bbaf43 100644 --- a/utils/tokenizer.go +++ b/utils/tokenizer.go @@ -105,7 +105,7 @@ func CountInputToken(model string, v []globals.Message) float32 { case globals.GPT3Turbo16k: return 0 case globals.GPT4: - return float32(CountTokenPrice(v, model)) / 1000 * 2.1 * 0.5 + return float32(CountTokenPrice(v, model)) / 1000 * 2.1 case globals.GPT432k: return float32(CountTokenPrice(v, model)) / 1000 * 4.2 case globals.SparkDesk: @@ -130,7 +130,7 @@ func CountOutputToken(model string, t int) float32 { case globals.GPT3Turbo16k: return 0 case globals.GPT4: - return float32(t*GetWeightByModel(model)) / 1000 * 4.3 * 0.5 + return float32(t*GetWeightByModel(model)) / 1000 * 4.3 case globals.GPT432k: return float32(t*GetWeightByModel(model)) / 1000 * 8.6 case globals.SparkDesk: