Skip to content

Commit

Permalink
update prize
Browse files Browse the repository at this point in the history
  • Loading branch information
zmh-program committed Oct 24, 2023
1 parent db711fb commit 2c28c9b
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/src/conf.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
10 changes: 7 additions & 3 deletions app/src/dialogs/Subscription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
12 changes: 6 additions & 6 deletions app/src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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: "当前计划",
Expand Down Expand Up @@ -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: "Текущая подписка",
Expand Down
4 changes: 2 additions & 2 deletions auth/subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
2 changes: 2 additions & 0 deletions manager/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
4 changes: 4 additions & 0 deletions utils/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"crypto/tls"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions utils/tokenizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit 2c28c9b

Please sign in to comment.