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