Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified
raw
history blame contribute delete
580 Bytes
import { t } from "@lingui/macro";
import { OpenAI } from "openai";
import { useOpenAiStore } from "@/client/stores/openai";
export const openai = () => {
const { apiKey, baseURL } = useOpenAiStore.getState();
if (!apiKey) {
throw new Error(
t`Your OpenAI API Key has not been set yet. Please go to your account settings to enable OpenAI Integration.`,
);
}
if (baseURL) {
return new OpenAI({
apiKey,
baseURL,
dangerouslyAllowBrowser: true,
});
}
return new OpenAI({
apiKey,
dangerouslyAllowBrowser: true,
});
};