load api base url from env;

This commit is contained in:
ryanhex53
2023-03-21 08:44:09 +08:00
parent bd719a9480
commit 5e5a7a7473
5 changed files with 17 additions and 4 deletions

View File

@@ -144,7 +144,7 @@
// Send API request
/*
// Not working yet: a way to get the response as a stream
await fetchEventSource("https://api.openai.com/v1/chat/completions", {
await fetchEventSource(import.meta.env.VITE_API_BASE + "/v1/chat/completions", {
method: "POST",
headers: {
Authorization:
@@ -185,7 +185,7 @@
}, {})
}
response = await (
await fetch('https://api.openai.com/v1/chat/completions', {
await fetch(import.meta.env.VITE_API_BASE + '/v1/chat/completions', {
method: 'POST',
headers: {
Authorization: `Bearer ${$apiKeyStorage}`,
@@ -275,7 +275,7 @@
// Load available models from OpenAI
const allModels = (await (
await fetch('https://api.openai.com/v1/models', {
await fetch(import.meta.env.VITE_API_BASE + '/v1/models', {
method: 'GET',
headers: {
Authorization: `Bearer ${$apiKeyStorage}`,