Sujal Shah
commited on
Commit
·
12dcb8d
1
Parent(s):
f94165a
fix: add browser environment check for local API calls
Browse files- app/utils/constants.ts +8 -0
app/utils/constants.ts
CHANGED
@@ -283,6 +283,10 @@ const getOllamaBaseUrl = () => {
|
|
283 |
};
|
284 |
|
285 |
async function getOllamaModels(): Promise<ModelInfo[]> {
|
|
|
|
|
|
|
|
|
286 |
try {
|
287 |
const baseUrl = getOllamaBaseUrl();
|
288 |
const response = await fetch(`${baseUrl}/api/tags`);
|
@@ -361,6 +365,10 @@ async function getOpenRouterModels(): Promise<ModelInfo[]> {
|
|
361 |
}
|
362 |
|
363 |
async function getLMStudioModels(): Promise<ModelInfo[]> {
|
|
|
|
|
|
|
|
|
364 |
try {
|
365 |
const baseUrl = import.meta.env.LMSTUDIO_API_BASE_URL || 'http://localhost:1234';
|
366 |
const response = await fetch(`${baseUrl}/v1/models`);
|
|
|
283 |
};
|
284 |
|
285 |
async function getOllamaModels(): Promise<ModelInfo[]> {
|
286 |
+
if (typeof window === 'undefined') {
|
287 |
+
return [];
|
288 |
+
}
|
289 |
+
|
290 |
try {
|
291 |
const baseUrl = getOllamaBaseUrl();
|
292 |
const response = await fetch(`${baseUrl}/api/tags`);
|
|
|
365 |
}
|
366 |
|
367 |
async function getLMStudioModels(): Promise<ModelInfo[]> {
|
368 |
+
if (typeof window === 'undefined') {
|
369 |
+
return [];
|
370 |
+
}
|
371 |
+
|
372 |
try {
|
373 |
const baseUrl = import.meta.env.LMSTUDIO_API_BASE_URL || 'http://localhost:1234';
|
374 |
const response = await fetch(`${baseUrl}/v1/models`);
|