mirror of
https://github.com/Yidadaa/ChatGPT-Next-Web.git
synced 2025-09-05 15:06:53 +08:00
feat: 1) Present 'maxtokens' as properties tied to a single model. 2) Remove the original author's implementation of the send verification logic and replace it with a user input validator. Pre-verification 3) Provides the ability to pull the 'User Visible modellist' provided by 'provider' 4) Provider-related parameters are passed in the constructor of 'providerClient'. Not passed in the 'chat' method
This commit is contained in:
@@ -37,6 +37,8 @@ type Error =
|
||||
error: false;
|
||||
};
|
||||
|
||||
type Validate = (v: any) => Error | Promise<Error>;
|
||||
|
||||
export interface ListItemProps {
|
||||
title: string;
|
||||
subTitle?: string;
|
||||
@@ -44,7 +46,7 @@ export interface ListItemProps {
|
||||
className?: string;
|
||||
onClick?: () => void;
|
||||
nextline?: boolean;
|
||||
validator?: (v: any) => Error | Promise<Error>;
|
||||
validator?: Validate | Validate[];
|
||||
}
|
||||
|
||||
export const ListContext = createContext<
|
||||
@@ -92,7 +94,15 @@ export function ListItem(props: ListItemProps) {
|
||||
}, []);
|
||||
|
||||
const handleValidate = useCallback((v: any) => {
|
||||
const insideValidator = validator || (() => {});
|
||||
let insideValidator;
|
||||
if (!validator) {
|
||||
insideValidator = () => {};
|
||||
} else if (Array.isArray(validator)) {
|
||||
insideValidator = (v: any) =>
|
||||
Promise.race(validator.map((validate) => validate(v)));
|
||||
} else {
|
||||
insideValidator = validator;
|
||||
}
|
||||
|
||||
Promise.resolve(insideValidator(v)).then((result) => {
|
||||
if (result && result.error) {
|
||||
|
Reference in New Issue
Block a user