diff --git a/src/addImage.tsx b/src/addImage.tsx
index ca17057..8ad8a31 100644
--- a/src/addImage.tsx
+++ b/src/addImage.tsx
@@ -24,7 +24,7 @@ export function AddImage({
}: Props) {
const [enableHighResolution, setEnableHighResolution] = useState(true);
const [imageGenPrompt, setImageGenPrompt] = useState("");
- const [imageGenModel, setImageGenModel] = useState("dall-e-2");
+ const [imageGenModel, setImageGenModel] = useState("dall-e-3");
const [imageGenN, setImageGenN] = useState(1);
const [imageGenQuality, setImageGEnQuality] = useState("standard");
const [imageGenResponseFormat, setImageGenResponseFormat] =
diff --git a/src/app.tsx b/src/app.tsx
index 34e385f..b00c96d 100644
--- a/src/app.tsx
+++ b/src/app.tsx
@@ -118,6 +118,9 @@ const STORAGE_NAME_INDEXES = `${STORAGE_NAME}-indexes`;
const STORAGE_NAME_TOTALCOST = `${STORAGE_NAME}-totalcost`;
export const STORAGE_NAME_TEMPLATE = `${STORAGE_NAME}-template`;
export const STORAGE_NAME_TEMPLATE_API = `${STORAGE_NAME_TEMPLATE}-api`;
+export const STORAGE_NAME_TEMPLATE_API_WHISPER = `${STORAGE_NAME_TEMPLATE}-api-whisper`;
+export const STORAGE_NAME_TEMPLATE_API_TTS = `${STORAGE_NAME_TEMPLATE}-api-tts`;
+export const STORAGE_NAME_TEMPLATE_API_IMAGE_GEN = `${STORAGE_NAME_TEMPLATE}-api-image-gen`;
export function addTotalCost(cost: number) {
let totalCost = getTotalCost();
diff --git a/src/chatbox.tsx b/src/chatbox.tsx
index 20cceef..3708c0d 100644
--- a/src/chatbox.tsx
+++ b/src/chatbox.tsx
@@ -7,6 +7,9 @@ import {
ChatStoreMessage,
STORAGE_NAME_TEMPLATE,
STORAGE_NAME_TEMPLATE_API,
+ STORAGE_NAME_TEMPLATE_API_IMAGE_GEN,
+ STORAGE_NAME_TEMPLATE_API_TTS,
+ STORAGE_NAME_TEMPLATE_API_WHISPER,
TemplateAPI,
addTotalCost,
} from "./app";
@@ -23,6 +26,7 @@ import models from "./models";
import Settings from "./settings";
import getDefaultParams from "./getDefaultParam";
import { AddImage } from "./addImage";
+import { ListAPIs } from "./listAPIs";
export interface TemplateChatStore extends ChatStore {
name: string;
@@ -319,6 +323,21 @@ export default function ChatBOX(props: {
localStorage.getItem(STORAGE_NAME_TEMPLATE_API) || "[]"
) as TemplateAPI[]
);
+ const [templateAPIsWhisper, _setTemplateAPIsWhisper] = useState(
+ JSON.parse(
+ localStorage.getItem(STORAGE_NAME_TEMPLATE_API_WHISPER) || "[]"
+ ) as TemplateAPI[]
+ );
+ const [templateAPIsTTS, _setTemplateAPIsTTS] = useState(
+ JSON.parse(
+ localStorage.getItem(STORAGE_NAME_TEMPLATE_API_TTS) || "[]"
+ ) as TemplateAPI[]
+ );
+ const [templateAPIsImageGen, _setTemplateAPIsImageGen] = useState(
+ JSON.parse(
+ localStorage.getItem(STORAGE_NAME_TEMPLATE_API_IMAGE_GEN) || "[]"
+ ) as TemplateAPI[]
+ );
const setTemplates = (templates: TemplateChatStore[]) => {
localStorage.setItem(STORAGE_NAME_TEMPLATE, JSON.stringify(templates));
_setTemplates(templates);
@@ -330,6 +349,27 @@ export default function ChatBOX(props: {
);
_setTemplateAPIs(templateAPIs);
};
+ const setTemplateAPIsWhisper = (templateAPIWhisper: TemplateAPI[]) => {
+ localStorage.setItem(
+ STORAGE_NAME_TEMPLATE_API_WHISPER,
+ JSON.stringify(templateAPIWhisper)
+ );
+ _setTemplateAPIsWhisper(templateAPIWhisper);
+ };
+ const setTemplateAPIsTTS = (templateAPITTS: TemplateAPI[]) => {
+ localStorage.setItem(
+ STORAGE_NAME_TEMPLATE_API_TTS,
+ JSON.stringify(templateAPITTS)
+ );
+ _setTemplateAPIsTTS(templateAPITTS);
+ };
+ const setTemplateAPIsImageGen = (templateAPIImageGen: TemplateAPI[]) => {
+ localStorage.setItem(
+ STORAGE_NAME_TEMPLATE_API_IMAGE_GEN,
+ JSON.stringify(templateAPIImageGen)
+ );
+ _setTemplateAPIsImageGen(templateAPIImageGen);
+ };
return (
@@ -343,6 +383,12 @@ export default function ChatBOX(props: {
setTemplates={setTemplates}
templateAPIs={templateAPIs}
setTemplateAPIs={setTemplateAPIs}
+ templateAPIsWhisper={templateAPIsWhisper}
+ setTemplateAPIsWhisper={setTemplateAPIsWhisper}
+ templateAPIsTTS={templateAPIsTTS}
+ setTemplateAPIsTTS={setTemplateAPIsTTS}
+ templateAPIsImageGen={templateAPIsImageGen}
+ setTemplateAPIsImageGen={setTemplateAPIsImageGen}
/>
)}
!msg.example).length == 0 ||
!chatStore.apiEndpoint ||
!chatStore.apiKey) && (
-
-
{Tr("Saved API templates")}
-
-
- {templateAPIs.map((t, index) => (
-
{
- chatStore.apiEndpoint = t.endpoint;
- chatStore.apiKey = t.key;
- setChatStore({ ...chatStore });
- }}
- >
- {t.name}
-
-
-
-
-
-
- ))}
-
-
+
)}
+
+ {templateAPIsWhisper.length > 0 &&
+ (chatStore.develop_mode ||
+ chatStore.history.filter((msg) => !msg.example).length == 0 ||
+ !chatStore.whisper_api ||
+ !chatStore.whisper_key) && (
+
+ )}
+
+ {templateAPIsTTS.length > 0 &&
+ (chatStore.develop_mode ||
+ chatStore.history.filter((msg) => !msg.example).length == 0 ||
+ !chatStore.tts_api ||
+ !chatStore.tts_key) && (
+
+ )}
+
+ {templateAPIsImageGen.length > 0 &&
+ (chatStore.develop_mode ||
+ chatStore.history.filter((msg) => !msg.example).length == 0 ||
+ !chatStore.image_gen_api ||
+ !chatStore.image_gen_key) && (
+
+ )}
+
{chatStore.history.filter((msg) => !msg.example).length == 0 && (
@@ -722,6 +773,7 @@ export default function ChatBOX(props: {
{Tr("Send")}
{chatStore.whisper_api &&
+ chatStore.whisper_key &&
(chatStore.whisper_key || chatStore.apiKey) && (
+
+
+
+ {props.chatStore.whisper_api && props.chatStore.whisper_key && (
+
+ )}
+ {props.chatStore.tts_api && props.chatStore.tts_key && (
+
+ )}
+ {props.chatStore.image_gen_api && props.chatStore.image_gen_key && (
+
+ )}
+
{Tr("As template")}
- {
- const name = prompt("Give this **API** template a name:");
- if (!name) {
- alert("No template name specified");
- return;
- }
- const tmp: TemplateAPI = {
- name,
- endpoint: props.chatStore.apiEndpoint,
- key: props.chatStore.apiKey,
- };
- props.templateAPIs.push(tmp);
- props.setTemplateAPIs([...props.templateAPIs]);
- }}
- >
- {Tr("As API Template")}
-
{