From 707a445a3354b946e5a5c98bce1177c93f45b284 Mon Sep 17 00:00:00 2001 From: franktip Date: Mon, 23 Dec 2024 16:44:13 -0500 Subject: [PATCH] make LLMORPHEUS_LLM_PROVIDER optional --- src/model/Model.ts | 2 +- src/util/code-utils.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/model/Model.ts b/src/model/Model.ts index 8030ed1..82713ea 100644 --- a/src/model/Model.ts +++ b/src/model/Model.ts @@ -25,7 +25,7 @@ export class Model implements IModel { ); protected static LLMORPHEUS_LLM_PROVIDER = JSON.parse( - getEnv("LLMORPHEUS_LLM_PROVIDER") + getEnv("LLMORPHEUS_LLM_PROVIDER", false) ); protected instanceOptions: PostOptions; diff --git a/src/util/code-utils.ts b/src/util/code-utils.ts index 77aae08..0eaafed 100644 --- a/src/util/code-utils.ts +++ b/src/util/code-utils.ts @@ -141,9 +141,13 @@ export function prevPosition(code: string, line: number, column: number) { } } -export function getEnv(name: string): string { +/** + * Get the environment variable with the given name. If the variable is not set and enforce is true, the process will exit. + * (for optional variables, set enforce to false) + */ +export function getEnv(name: string, enforce: boolean = true): string { const value = process.env[name]; - if (!value) { + if (!value && enforce) { console.error(`Please set the ${name} environment variable.`); process.exit(1); }