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