fix: docker prod env variable fix (#1170)

* fix: docker prod env variable fix

* lint and typecheck

* removed hardcoded tag
This commit is contained in:
Anirban Kar
2025-01-25 03:52:26 +05:30
committed by GitHub
parent 5a0489f3c3
commit 660353360f
6 changed files with 63 additions and 20 deletions

View File

@@ -40,7 +40,7 @@ export default class LMStudioProvider extends BaseProvider {
* Running in Server
* Backend: Check if we're running in Docker
*/
const isDocker = process.env.RUNNING_IN_DOCKER === 'true';
const isDocker = process?.env?.RUNNING_IN_DOCKER === 'true' || serverEnv?.RUNNING_IN_DOCKER === 'true';
baseUrl = isDocker ? baseUrl.replace('localhost', 'host.docker.internal') : baseUrl;
baseUrl = isDocker ? baseUrl.replace('127.0.0.1', 'host.docker.internal') : baseUrl;
@@ -58,7 +58,7 @@ export default class LMStudioProvider extends BaseProvider {
}
getModelInstance: (options: {
model: string;
serverEnv: Env;
serverEnv?: Env;
apiKeys?: Record<string, string>;
providerSettings?: Record<string, IProviderSetting>;
}) => LanguageModelV1 = (options) => {
@@ -75,8 +75,9 @@ export default class LMStudioProvider extends BaseProvider {
throw new Error('No baseUrl found for LMStudio provider');
}
const isDocker = process.env.RUNNING_IN_DOCKER === 'true' || serverEnv?.RUNNING_IN_DOCKER === 'true';
if (typeof window === 'undefined') {
const isDocker = process.env.RUNNING_IN_DOCKER === 'true';
baseUrl = isDocker ? baseUrl.replace('localhost', 'host.docker.internal') : baseUrl;
baseUrl = isDocker ? baseUrl.replace('127.0.0.1', 'host.docker.internal') : baseUrl;
}
@@ -84,7 +85,7 @@ export default class LMStudioProvider extends BaseProvider {
logger.debug('LMStudio Base Url used: ', baseUrl);
const lmstudio = createOpenAI({
baseUrl: `${baseUrl}/v1`,
baseURL: `${baseUrl}/v1`,
apiKey: '',
});