diff --git a/.env b/.env index 38f7106..ad398d2 100644 --- a/.env +++ b/.env @@ -2,3 +2,4 @@ #VITE_API_BASE=http://localhost:5174 #VITE_ENDPOINT_COMPLETIONS=/v1/chat/completions #VITE_ENDPOINT_MODELS=/v1/models +#OPENAI_API_KEY="your-openai-api-key" diff --git a/src/lib/Storage.svelte b/src/lib/Storage.svelte index bb2198d..1a40bc6 100644 --- a/src/lib/Storage.svelte +++ b/src/lib/Storage.svelte @@ -13,7 +13,8 @@ export const chatsStorage = persisted('chats', [] as Chat[]) export const latestModelMap = persisted('latestModelMap', {} as Record) // What was returned when a model was requested export const globalStorage = persisted('global', {} as GlobalSettings) - export const apiKeyStorage = persisted('apiKey', '' as string) + const apiKeyFromEnv = import.meta.env.OPENAI_API_KEY || '' + export const apiKeyStorage = persisted('apiKey', apiKeyFromEnv as string) export let checkStateChange = writable(0) // Trigger for Chat export let showSetChatSettings = writable(false) // export let submitExitingPromptsNow = writable(false) // for them to go now. Will not submit anything in the input