mirror of
https://github.com/coaidev/coai.git
synced 2025-05-20 05:20:15 +09:00
update gpt4 models
This commit is contained in:
parent
a4a74904a6
commit
9dc85bf860
@ -48,7 +48,7 @@ func NewChatInstanceFromConfig(v string) *ChatInstance {
|
||||
|
||||
func NewChatInstanceFromModel(props *InstanceProps) *ChatInstance {
|
||||
switch props.Model {
|
||||
case globals.GPT4, globals.GPT40314, globals.GPT40613,
|
||||
case globals.GPT4, globals.GPT40314, globals.GPT40613, globals.GPT3Turbo1106, globals.GPT41106Preview,
|
||||
globals.GPT432k, globals.GPT432k0613, globals.GPT432k0314:
|
||||
return NewChatInstanceFromConfig("gpt4")
|
||||
|
||||
@ -62,9 +62,6 @@ func NewChatInstanceFromModel(props *InstanceProps) *ChatInstance {
|
||||
}
|
||||
return NewChatInstanceFromConfig("gpt3")
|
||||
|
||||
case globals.GPT3Turbo1106, globals.GPT41106Preview:
|
||||
return NewChatInstanceFromConfig("preview")
|
||||
|
||||
case globals.Dalle2:
|
||||
return NewChatInstanceFromConfig("image")
|
||||
|
||||
|
@ -41,7 +41,9 @@ function PopupDialog({
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>{title}</DialogTitle>
|
||||
<DialogDescription className={`pt-1.5`}>{description}</DialogDescription>
|
||||
<DialogDescription className={`pt-1.5`}>
|
||||
{description}
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<div className={`pt-1 flex flex-row items-center justify-center`}>
|
||||
<span className={`mr-4 whitespace-nowrap`}>{name}</span>
|
||||
@ -60,12 +62,13 @@ function PopupDialog({
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
onSubmit && onSubmit(value).then((success) => {
|
||||
if (success) {
|
||||
setOpen(false);
|
||||
setValue(defaultValue || "");
|
||||
}
|
||||
});
|
||||
onSubmit &&
|
||||
onSubmit(value).then((success) => {
|
||||
if (success) {
|
||||
setOpen(false);
|
||||
setValue(defaultValue || "");
|
||||
}
|
||||
});
|
||||
}}
|
||||
>
|
||||
{t("confirm")}
|
||||
|
@ -1,8 +1,12 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useToast } from "@/components/ui/use-toast.ts";
|
||||
import { useState } from "react";
|
||||
import {CommonResponse, UserForm, UserResponse} from "@/admin/types.ts";
|
||||
import {getUserList, quotaOperation, subscriptionOperation} from "@/admin/api.ts";
|
||||
import { CommonResponse, UserForm, UserResponse } from "@/admin/types.ts";
|
||||
import {
|
||||
getUserList,
|
||||
quotaOperation,
|
||||
subscriptionOperation,
|
||||
} from "@/admin/api.ts";
|
||||
import { useEffectAsync } from "@/utils/hook.ts";
|
||||
import {
|
||||
Table,
|
||||
@ -30,21 +34,23 @@ import {
|
||||
} from "lucide-react";
|
||||
import { Input } from "@/components/ui/input.tsx";
|
||||
import PopupDialog from "@/components/PopupDialog.tsx";
|
||||
import {getNumber, parseNumber} from "@/utils/base.ts";
|
||||
import { getNumber, parseNumber } from "@/utils/base.ts";
|
||||
|
||||
type OperationMenuProps = {
|
||||
id: number;
|
||||
};
|
||||
|
||||
function doToast(t: any, toast: any, resp: CommonResponse) {
|
||||
if (!resp.status) toast({
|
||||
title: t("admin.operate-failed"),
|
||||
description: t("admin.operate-failed-prompt", { reason: resp.message }),
|
||||
});
|
||||
else toast({
|
||||
title: t("admin.operate-success"),
|
||||
description: t("admin.operate-success-prompt"),
|
||||
});
|
||||
if (!resp.status)
|
||||
toast({
|
||||
title: t("admin.operate-failed"),
|
||||
description: t("admin.operate-failed-prompt", { reason: resp.message }),
|
||||
});
|
||||
else
|
||||
toast({
|
||||
title: t("admin.operate-success"),
|
||||
description: t("admin.operate-success-prompt"),
|
||||
});
|
||||
}
|
||||
|
||||
function OperationMenu({ id }: OperationMenuProps) {
|
||||
@ -56,10 +62,13 @@ function OperationMenu({ id }: OperationMenuProps) {
|
||||
return (
|
||||
<>
|
||||
<PopupDialog
|
||||
title={t("admin.quota-action")} name={t("admin.quota")}
|
||||
title={t("admin.quota-action")}
|
||||
name={t("admin.quota")}
|
||||
description={t("admin.quota-action-desc")}
|
||||
defaultValue={"0"} onValueChange={getNumber}
|
||||
open={quotaOpen} setOpen={setQuotaOpen}
|
||||
defaultValue={"0"}
|
||||
onValueChange={getNumber}
|
||||
open={quotaOpen}
|
||||
setOpen={setQuotaOpen}
|
||||
onSubmit={async (value) => {
|
||||
const quota = parseNumber(value);
|
||||
const resp = await quotaOperation(id, quota);
|
||||
@ -68,10 +77,13 @@ function OperationMenu({ id }: OperationMenuProps) {
|
||||
}}
|
||||
/>
|
||||
<PopupDialog
|
||||
title={t("admin.subscription-action")} name={t("admin.month")}
|
||||
title={t("admin.subscription-action")}
|
||||
name={t("admin.month")}
|
||||
description={t("admin.subscription-action-desc")}
|
||||
defaultValue={"0"} onValueChange={getNumber}
|
||||
open={subscriptionOpen} setOpen={setSubscriptionOpen}
|
||||
defaultValue={"0"}
|
||||
onValueChange={getNumber}
|
||||
open={subscriptionOpen}
|
||||
setOpen={setSubscriptionOpen}
|
||||
onSubmit={async (value) => {
|
||||
const month = parseNumber(value);
|
||||
const resp = await subscriptionOperation(id, month);
|
||||
|
@ -94,10 +94,6 @@ export class Conversation {
|
||||
this.triggerCallback();
|
||||
}
|
||||
|
||||
public auth(): void {
|
||||
this.connection?.reconnect();
|
||||
}
|
||||
|
||||
public getLength(): number {
|
||||
return this.data.length;
|
||||
}
|
||||
|
@ -101,10 +101,6 @@ export class Manager {
|
||||
await this.toggle(dispatch, -1);
|
||||
}
|
||||
|
||||
public async auth(): Promise<void> {
|
||||
this.get(-1)!.auth();
|
||||
}
|
||||
|
||||
public async send(t: any, auth: boolean, props: ChatProps): Promise<boolean> {
|
||||
const id = this.getCurrent();
|
||||
if (!this.conversations[id]) return false;
|
||||
|
@ -28,10 +28,7 @@ export function asyncCaller<T>(fn: (...args: any[]) => Promise<T>) {
|
||||
}
|
||||
|
||||
export function getNumber(value: string, supportNegative = true): string {
|
||||
return value.replace(
|
||||
supportNegative ? /[^-0-9.]/g : /[^0-9.]/g,
|
||||
""
|
||||
);
|
||||
return value.replace(supportNegative ? /[^-0-9.]/g : /[^0-9.]/g, "");
|
||||
}
|
||||
|
||||
export function parseNumber(value: string): number {
|
||||
|
@ -30,9 +30,6 @@ func CanEnableModel(db *sql.DB, user *User, model string) bool {
|
||||
|
||||
func HandleSubscriptionUsage(db *sql.DB, cache *redis.Client, user *User, model string) bool {
|
||||
subscription := user.IsSubscribe(db)
|
||||
if model == globals.GPT41106Preview || model == globals.GPT3Turbo1106 {
|
||||
return true
|
||||
}
|
||||
if globals.IsGPT3TurboModel(model) {
|
||||
// independent channel for subscription users
|
||||
return subscription
|
||||
|
Loading…
Reference in New Issue
Block a user