change: apply max url query in settings

This commit is contained in:
2024-01-19 22:15:32 +08:00
parent e3162cac0d
commit 78f0b1000a

View File

@@ -14,6 +14,7 @@ import p from "preact-markdown";
import { isVailedJSON } from "./message"; import { isVailedJSON } from "./message";
import { SetAPIsTemplate } from "./setAPIsTemplate"; import { SetAPIsTemplate } from "./setAPIsTemplate";
import { autoHeight } from "./textarea"; import { autoHeight } from "./textarea";
import getDefaultParams from "./getDefaultParam";
const TTS_VOICES: string[] = [ const TTS_VOICES: string[] = [
"alloy", "alloy",
@@ -55,7 +56,7 @@ const SelectModel = (props: {
onChange={(event: any) => { onChange={(event: any) => {
const model = event.target.value as string; const model = event.target.value as string;
props.chatStore.model = model; props.chatStore.model = model;
props.chatStore.maxTokens = models[model].maxToken; props.chatStore.maxTokens = getDefaultParams('max', models[model].maxToken);
props.setChatStore({ ...props.chatStore }); props.setChatStore({ ...props.chatStore });
}} }}
> >
@@ -95,14 +96,14 @@ const Input = (props: {
chatStore: ChatStore; chatStore: ChatStore;
setChatStore: (cs: ChatStore) => void; setChatStore: (cs: ChatStore) => void;
field: field:
| "apiKey" | "apiKey"
| "apiEndpoint" | "apiEndpoint"
| "whisper_api" | "whisper_api"
| "whisper_key" | "whisper_key"
| "tts_api" | "tts_api"
| "tts_key" | "tts_key"
| "image_gen_api" | "image_gen_api"
| "image_gen_key"; | "image_gen_key";
help: string; help: string;
}) => { }) => {
const [hideInput, setHideInput] = useState(true); const [hideInput, setHideInput] = useState(true);
@@ -202,13 +203,13 @@ const Number = (props: {
chatStore: ChatStore; chatStore: ChatStore;
setChatStore: (cs: ChatStore) => void; setChatStore: (cs: ChatStore) => void;
field: field:
| "totalTokens" | "totalTokens"
| "maxTokens" | "maxTokens"
| "maxGenTokens" | "maxGenTokens"
| "tokenMargin" | "tokenMargin"
| "postBeginIndex" | "postBeginIndex"
| "presence_penalty" | "presence_penalty"
| "frequency_penalty"; | "frequency_penalty";
readOnly: boolean; readOnly: boolean;
help: string; help: string;
}) => { }) => {
@@ -296,8 +297,7 @@ export default (props: {
location.pathname + location.pathname +
`?key=${encodeURIComponent( `?key=${encodeURIComponent(
props.chatStore.apiKey props.chatStore.apiKey
)}&api=${encodeURIComponent(props.chatStore.apiEndpoint)}&mode=${ )}&api=${encodeURIComponent(props.chatStore.apiEndpoint)}&mode=${props.chatStore.streamMode ? "stream" : "fetch"
props.chatStore.streamMode ? "stream" : "fetch"
}&model=${props.chatStore.model}&sys=${encodeURIComponent( }&model=${props.chatStore.model}&sys=${encodeURIComponent(
props.chatStore.systemMessageContent props.chatStore.systemMessageContent
)}`; )}`;