make token env var optional with defult value

This commit is contained in:
Artiom Levinton
2024-05-23 13:23:24 +03:00
parent ed1cb1e8fe
commit 89ec802a92
2 changed files with 2 additions and 2 deletions

2
.env
View File

@@ -2,4 +2,4 @@
#VITE_API_BASE=http://localhost:5174 #VITE_API_BASE=http://localhost:5174
#VITE_ENDPOINT_COMPLETIONS=/v1/chat/completions #VITE_ENDPOINT_COMPLETIONS=/v1/chat/completions
#VITE_ENDPOINT_MODELS=/v1/models #VITE_ENDPOINT_MODELS=/v1/models
OPENAI_API_KEY="your-openai-api-key" #OPENAI_API_KEY="your-openai-api-key"

View File

@@ -13,7 +13,7 @@
export const chatsStorage = persisted('chats', [] as Chat[]) export const chatsStorage = persisted('chats', [] as Chat[])
export const latestModelMap = persisted('latestModelMap', {} as Record<Model, Model>) // What was returned when a model was requested export const latestModelMap = persisted('latestModelMap', {} as Record<Model, Model>) // What was returned when a model was requested
export const globalStorage = persisted('global', {} as GlobalSettings) export const globalStorage = persisted('global', {} as GlobalSettings)
const apiKeyFromEnv = import.meta.env.OPENAI_API_KEY const apiKeyFromEnv = import.meta.env.OPENAI_API_KEY || 'some default token'
export const apiKeyStorage = persisted('apiKey', apiKeyFromEnv as string) export const apiKeyStorage = persisted('apiKey', apiKeyFromEnv as string)
export let checkStateChange = writable(0) // Trigger for Chat export let checkStateChange = writable(0) // Trigger for Chat
export let showSetChatSettings = writable(false) // export let showSetChatSettings = writable(false) //