mirror of
https://github.com/coaidev/coai.git
synced 2025-05-19 04:50:14 +09:00
feat: update charge api
This commit is contained in:
parent
e6f605098a
commit
b0174a5db3
@ -7,6 +7,7 @@ import (
|
||||
"chat/utils"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/spf13/viper"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -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
|
||||
|
@ -8,7 +8,7 @@
|
||||
},
|
||||
"package": {
|
||||
"productName": "chatnio",
|
||||
"version": "3.7.7"
|
||||
"version": "3.7.8"
|
||||
},
|
||||
"tauri": {
|
||||
"allowlist": {
|
||||
|
@ -16,7 +16,6 @@ import {
|
||||
CalendarPlus,
|
||||
Cloud,
|
||||
CloudOff,
|
||||
Cloudy,
|
||||
Gift,
|
||||
ListStart,
|
||||
Plug,
|
||||
|
@ -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);
|
||||
@ -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",
|
||||
@ -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",
|
||||
|
@ -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
|
||||
)
|
||||
|
@ -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)
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user