FIx default API base
This commit is contained in:
parent
42a09d2efc
commit
42788a2911
|
@ -18,6 +18,9 @@
|
|||
import { replace } from 'svelte-spa-router'
|
||||
import SvelteMarkdown from 'svelte-markdown'
|
||||
|
||||
// This makes it possible to override the OpenAI API base URL in the .env file
|
||||
const apiBase = import.meta.env.VITE_API_BASE || 'https://api.openai.com'
|
||||
|
||||
export let params = { chatId: '' }
|
||||
const chatId: number = parseInt(params.chatId)
|
||||
let updating: boolean = false
|
||||
|
@ -145,7 +148,7 @@
|
|||
// Send API request
|
||||
/*
|
||||
// Not working yet: a way to get the response as a stream
|
||||
await fetchEventSource(import.meta.env.VITE_API_BASE + "/v1/chat/completions", {
|
||||
await fetchEventSource(apiBase + "/v1/chat/completions", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization:
|
||||
|
@ -186,7 +189,7 @@
|
|||
}, {})
|
||||
}
|
||||
response = await (
|
||||
await fetch(import.meta.env.VITE_API_BASE + '/v1/chat/completions', {
|
||||
await fetch(apiBase + '/v1/chat/completions', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Authorization: `Bearer ${$apiKeyStorage}`,
|
||||
|
|
|
@ -5,10 +5,6 @@ import purgecss from '@fullhuman/postcss-purgecss'
|
|||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig(({ command, mode, ssrBuild }) => {
|
||||
// Load env file based on `mode` in the current working directory.
|
||||
const env = loadEnv(mode, process.cwd())
|
||||
// Set default api base url
|
||||
env.VITE_API_BASE = 'https://api.openai.com'
|
||||
// Only run PurgeCSS in production builds
|
||||
if (command === 'build') {
|
||||
return {
|
||||
|
|
Loading…
Reference in New Issue