From d55128d9e99a3f42ee936a37343169bf2d6973a5 Mon Sep 17 00:00:00 2001 From: Andrew <15331990+ahuang11@users.noreply.github.com> Date: Mon, 12 Feb 2024 15:32:02 -0800 Subject: [PATCH 1/2] Do not default by keys if settings.llm is set --- src/funcchain/model/defaults.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/funcchain/model/defaults.py b/src/funcchain/model/defaults.py index ff62c42..4c409c0 100644 --- a/src/funcchain/model/defaults.py +++ b/src/funcchain/model/defaults.py @@ -157,6 +157,9 @@ def univeral_model_selector( model_kwargs.pop("model_name", None) + if settings.llm: + raise ValueError(f"{settings.llm} is unsupported.") + if settings.openai_api_key: from langchain_openai.chat_models import ChatOpenAI From d56d6f0cd238a15c3e606d9841d081c801f12484 Mon Sep 17 00:00:00 2001 From: Andrew <15331990+ahuang11@users.noreply.github.com> Date: Mon, 12 Feb 2024 15:53:12 -0800 Subject: [PATCH 2/2] Faster handling --- src/funcchain/model/defaults.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/funcchain/model/defaults.py b/src/funcchain/model/defaults.py index 4c409c0..5e66c54 100644 --- a/src/funcchain/model/defaults.py +++ b/src/funcchain/model/defaults.py @@ -94,6 +94,9 @@ def univeral_model_selector( Raises: - ModelNotFoundError, when the model is not found. """ + if not isinstance(settings.llm, str) and settings.llm is not None: + return settings.llm + model_name = settings.llm if isinstance(settings.llm, str) else "" model_kwargs.update(settings.model_kwargs()) @@ -157,9 +160,6 @@ def univeral_model_selector( model_kwargs.pop("model_name", None) - if settings.llm: - raise ValueError(f"{settings.llm} is unsupported.") - if settings.openai_api_key: from langchain_openai.chat_models import ChatOpenAI