fix template default params
This commit is contained in:
@@ -9,6 +9,7 @@ import ChatGPT, {
|
|||||||
import Message from "./message";
|
import Message from "./message";
|
||||||
import models from "./models";
|
import models from "./models";
|
||||||
import Settings from "./settings";
|
import Settings from "./settings";
|
||||||
|
import getDefaultParams from "./getDefaultParam";
|
||||||
|
|
||||||
export interface TemplateChatStore extends ChatStore {
|
export interface TemplateChatStore extends ChatStore {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -354,8 +355,22 @@ export default function ChatBOX(props: {
|
|||||||
<div
|
<div
|
||||||
className="cursor-pointer rounded bg-green-400 w-fit p-2 m-1 flex flex-col"
|
className="cursor-pointer rounded bg-green-400 w-fit p-2 m-1 flex flex-col"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const newChatStore: any = { ...t };
|
const newChatStore: ChatStore = structuredClone(t);
|
||||||
|
// @ts-ignore
|
||||||
delete newChatStore.name;
|
delete newChatStore.name;
|
||||||
|
if (!newChatStore.apiEndpoint) {
|
||||||
|
newChatStore.apiEndpoint = getDefaultParams(
|
||||||
|
"api",
|
||||||
|
chatStore.apiEndpoint
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (!newChatStore.apiKey) {
|
||||||
|
newChatStore.apiKey = getDefaultParams(
|
||||||
|
"key",
|
||||||
|
chatStore.apiKey
|
||||||
|
);
|
||||||
|
}
|
||||||
|
newChatStore.cost = 0;
|
||||||
setChatStore({ ...newChatStore });
|
setChatStore({ ...newChatStore });
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -342,8 +342,11 @@ export default (props: {
|
|||||||
alert("No template name specified");
|
alert("No template name specified");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const tmp: TemplateChatStore = { name, ...props.chatStore };
|
const tmp: ChatStore = structuredClone(props.chatStore);
|
||||||
props.templates.push(tmp);
|
tmp.history = tmp.history.filter((h) => h.example);
|
||||||
|
// @ts-ignore
|
||||||
|
tmp.name = name;
|
||||||
|
props.templates.push(tmp as TemplateChatStore);
|
||||||
props.setTemplates([...props.templates]);
|
props.setTemplates([...props.templates]);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user