mirror of
https://github.com/coaidev/coai.git
synced 2025-05-21 22:10:12 +09:00
feat: update charge api
This commit is contained in:
parent
e6f605098a
commit
b0174a5db3
@ -7,6 +7,7 @@ import (
|
|||||||
"chat/utils"
|
"chat/utils"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/spf13/viper"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -48,10 +49,18 @@ func CreateGenerationWorker(c *gin.Context, user *auth.User, model string, promp
|
|||||||
titles := ParseTitle(title)
|
titles := ParseTitle(title)
|
||||||
result := make(chan Response, len(titles))
|
result := make(chan Response, len(titles))
|
||||||
|
|
||||||
for _, name := range titles {
|
if viper.GetBool("accept_concurrent") {
|
||||||
go func(title string) {
|
for _, name := range titles {
|
||||||
result <- GenerateArticle(c, user, model, hash, title, prompt, enableWeb)
|
go func(title string) {
|
||||||
}(name)
|
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
|
return len(titles), result
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
},
|
},
|
||||||
"package": {
|
"package": {
|
||||||
"productName": "chatnio",
|
"productName": "chatnio",
|
||||||
"version": "3.7.7"
|
"version": "3.7.8"
|
||||||
},
|
},
|
||||||
"tauri": {
|
"tauri": {
|
||||||
"allowlist": {
|
"allowlist": {
|
||||||
|
@ -16,7 +16,6 @@ import {
|
|||||||
CalendarPlus,
|
CalendarPlus,
|
||||||
Cloud,
|
Cloud,
|
||||||
CloudOff,
|
CloudOff,
|
||||||
Cloudy,
|
|
||||||
Gift,
|
Gift,
|
||||||
ListStart,
|
ListStart,
|
||||||
Plug,
|
Plug,
|
||||||
|
@ -12,7 +12,7 @@ import { getMemory } from "@/utils/memory.ts";
|
|||||||
import { Compass, Image, Newspaper } from "lucide-react";
|
import { Compass, Image, Newspaper } from "lucide-react";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export const version = "3.7.7";
|
export const version = "3.7.8";
|
||||||
export const dev: boolean = getDev();
|
export const dev: boolean = getDev();
|
||||||
export const deploy: boolean = true;
|
export const deploy: boolean = true;
|
||||||
export let rest_api: string = getRestApi(deploy);
|
export let rest_api: string = getRestApi(deploy);
|
||||||
@ -41,6 +41,20 @@ export const supportModels: Model[] = [
|
|||||||
auth: true,
|
auth: true,
|
||||||
tag: ["free", "official"],
|
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",
|
id: "gpt-4-0613",
|
||||||
name: "GPT-4",
|
name: "GPT-4",
|
||||||
@ -373,6 +387,8 @@ export const modelAvatars: Record<string, string> = {
|
|||||||
"gpt-3.5-turbo-0613": "gpt35turbo.png",
|
"gpt-3.5-turbo-0613": "gpt35turbo.png",
|
||||||
"gpt-3.5-turbo-16k-0613": "gpt35turbo16k.webp",
|
"gpt-3.5-turbo-16k-0613": "gpt35turbo16k.webp",
|
||||||
"gpt-3.5-turbo-1106": "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-0613": "gpt4.png",
|
||||||
"gpt-4-1106-preview": "gpt432k.webp",
|
"gpt-4-1106-preview": "gpt432k.webp",
|
||||||
"gpt-4-vision-preview": "gpt4v.png",
|
"gpt-4-vision-preview": "gpt4v.png",
|
||||||
|
@ -29,3 +29,11 @@ const (
|
|||||||
TimesBilling = "times-billing"
|
TimesBilling = "times-billing"
|
||||||
TokenBilling = "token-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) {
|
func Register(app *gin.Engine) {
|
||||||
app.GET("/chat", ChatAPI)
|
app.GET("/chat", ChatAPI)
|
||||||
app.GET("/v1/models", ModelAPI)
|
app.GET("/v1/models", ModelAPI)
|
||||||
|
app.GET("/v1/charge", ChargeAPI)
|
||||||
app.GET("/dashboard/billing/usage", GetBillingUsage)
|
app.GET("/dashboard/billing/usage", GetBillingUsage)
|
||||||
app.GET("/dashboard/billing/subscription", GetSubscription)
|
app.GET("/dashboard/billing/subscription", GetSubscription)
|
||||||
app.POST("/v1/chat/completions", TranshipmentAPI)
|
app.POST("/v1/chat/completions", TranshipmentAPI)
|
||||||
|
@ -84,6 +84,10 @@ func ModelAPI(c *gin.Context) {
|
|||||||
c.JSON(http.StatusOK, channel.ConduitInstance.GetModels())
|
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) {
|
func sendErrorResponse(c *gin.Context, err error, types ...string) {
|
||||||
var errType string
|
var errType string
|
||||||
if len(types) > 0 {
|
if len(types) > 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user