Skip to content

Commit

Permalink
feat: update charge api
Browse files Browse the repository at this point in the history
  • Loading branch information
zmh-program committed Dec 20, 2023
1 parent e6f6050 commit b0174a5
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 7 deletions.
17 changes: 13 additions & 4 deletions addition/article/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"chat/utils"
"fmt"
"github.com/gin-gonic/gin"
"github.com/spf13/viper"
"strings"
)

Expand Down Expand Up @@ -48,10 +49,18 @@ func CreateGenerationWorker(c *gin.Context, user *auth.User, model string, promp
titles := ParseTitle(title)
result := make(chan Response, len(titles))

for _, name := range titles {
go func(title string) {
result <- GenerateArticle(c, user, model, hash, title, prompt, enableWeb)
}(name)
if viper.GetBool("accept_concurrent") {
for _, name := range titles {
go func(title string) {
result <- GenerateArticle(c, user, model, hash, title, prompt, enableWeb)
}(name)
}
} else {
go func() {
for _, title := range titles {
result <- GenerateArticle(c, user, model, hash, title, prompt, enableWeb)
}
}()
}

return len(titles), result
Expand Down
2 changes: 1 addition & 1 deletion app/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"package": {
"productName": "chatnio",
"version": "3.7.7"
"version": "3.7.8"
},
"tauri": {
"allowlist": {
Expand Down
1 change: 0 additions & 1 deletion app/src/components/app/MenuBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
CalendarPlus,
Cloud,
CloudOff,
Cloudy,
Gift,
ListStart,
Plug,
Expand Down
18 changes: 17 additions & 1 deletion app/src/conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { getMemory } from "@/utils/memory.ts";
import { Compass, Image, Newspaper } from "lucide-react";
import React from "react";

export const version = "3.7.7";
export const version = "3.7.8";
export const dev: boolean = getDev();
export const deploy: boolean = true;
export let rest_api: string = getRestApi(deploy);
Expand Down Expand Up @@ -41,6 +41,20 @@ export const supportModels: Model[] = [
auth: true,
tag: ["free", "official"],
},
{
id: "gpt-3.5-turbo-fast",
name: "GPT-3.5 Fast",
free: false,
auth: true,
tag: ["official"],
},
{
id: "gpt-3.5-turbo-16k-fast",
name: "GPT-3.5 16K Fast",
free: false,
auth: true,
tag: ["official"],
},
{
id: "gpt-4-0613",
name: "GPT-4",
Expand Down Expand Up @@ -373,6 +387,8 @@ export const modelAvatars: Record<string, string> = {
"gpt-3.5-turbo-0613": "gpt35turbo.png",
"gpt-3.5-turbo-16k-0613": "gpt35turbo16k.webp",
"gpt-3.5-turbo-1106": "gpt35turbo16k.webp",
"gpt-3.5-turbo-fast": "gpt35turbo16k.webp",
"gpt-3.5-turbo-16k-fast": "gpt35turbo16k.webp",
"gpt-4-0613": "gpt4.png",
"gpt-4-1106-preview": "gpt432k.webp",
"gpt-4-vision-preview": "gpt4v.png",
Expand Down
8 changes: 8 additions & 0 deletions globals/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,11 @@ const (
TimesBilling = "times-billing"
TokenBilling = "token-billing"
)

const (
AnonymousType = "anonymous"
NormalType = "normal"
BasicType = "basic" // basic subscription
StandardType = "standard" // standard subscription
ProType = "pro" // pro subscription
)
1 change: 1 addition & 0 deletions manager/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
func Register(app *gin.Engine) {
app.GET("/chat", ChatAPI)
app.GET("/v1/models", ModelAPI)
app.GET("/v1/charge", ChargeAPI)
app.GET("/dashboard/billing/usage", GetBillingUsage)
app.GET("/dashboard/billing/subscription", GetSubscription)
app.POST("/v1/chat/completions", TranshipmentAPI)
Expand Down
4 changes: 4 additions & 0 deletions manager/transhipment.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ func ModelAPI(c *gin.Context) {
c.JSON(http.StatusOK, channel.ConduitInstance.GetModels())
}

func ChargeAPI(c *gin.Context) {
c.JSON(http.StatusOK, channel.ChargeInstance.ListRules())
}

func sendErrorResponse(c *gin.Context, err error, types ...string) {
var errType string
if len(types) > 0 {
Expand Down

0 comments on commit b0174a5

Please sign in to comment.