Skip to content

Commit

Permalink
fix: add browser environment check for local API calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Sujal Shah committed Nov 25, 2024
1 parent f94165a commit 12dcb8d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,10 @@ const getOllamaBaseUrl = () => {
};

async function getOllamaModels(): Promise<ModelInfo[]> {
if (typeof window === 'undefined') {
return [];
}

try {
const baseUrl = getOllamaBaseUrl();
const response = await fetch(`${baseUrl}/api/tags`);
Expand Down Expand Up @@ -361,6 +365,10 @@ async function getOpenRouterModels(): Promise<ModelInfo[]> {
}

async function getLMStudioModels(): Promise<ModelInfo[]> {
if (typeof window === 'undefined') {
return [];
}

try {
const baseUrl = import.meta.env.LMSTUDIO_API_BASE_URL || 'http://localhost:1234';
const response = await fetch(`${baseUrl}/v1/models`);
Expand Down

0 comments on commit 12dcb8d

Please sign in to comment.