Skip to content

Commit 01342b3

Browse files
committed
feat(api): support MAIN_MODEL_BASE_URL for main model
1 parent eb353da commit 01342b3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

nemoguardrails/server/api.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,13 @@ def _get_rails(config_ids: List[str], model_name: Optional[str] = None) -> LLMRa
313313
if not engine:
314314
engine = "openai"
315315
log.warning("MAIN_MODEL_ENGINE not set, defaulting to 'openai'. ")
316-
main_model = Model(model=model_name, type="main", engine=engine)
316+
317+
parameters = {}
318+
base_url = os.environ.get("MAIN_MODEL_BASE_URL")
319+
if base_url:
320+
parameters["base_url"] = base_url
321+
322+
main_model = Model(model=model_name, type="main", engine=engine, parameters=parameters)
317323
full_llm_rails_config = _update_models_in_config(full_llm_rails_config, main_model)
318324

319325
llm_rails = LLMRails(config=full_llm_rails_config, verbose=True)

0 commit comments

Comments
 (0)