mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-02 19:34:04 +00:00
langchain[patch]: Remove proxy imports to langchain_experimental (#31541)
Remove proxy imports to langchain_experimental. Previously, these imports would work if a user manually installed langchain_experimental. However, we want to drop support even for that as langchain_experimental is generally not recommended to be run in production. --------- Co-authored-by: ccurme <chester.curme@gmail.com>
This commit is contained in:
parent
16e5a12806
commit
9ce974247c
@ -219,33 +219,13 @@ def _load_reduce_documents_chain(config: dict, **kwargs: Any) -> ReduceDocuments
|
|||||||
|
|
||||||
|
|
||||||
def _load_llm_bash_chain(config: dict, **kwargs: Any) -> Any:
|
def _load_llm_bash_chain(config: dict, **kwargs: Any) -> Any:
|
||||||
from langchain_experimental.llm_bash.base import LLMBashChain
|
"""Load LLM Bash chain from config dict"""
|
||||||
|
raise NotImplementedError(
|
||||||
llm_chain = None
|
"LLMBash Chain is not available through LangChain anymore. "
|
||||||
if "llm_chain" in config:
|
"The relevant code can be found in langchain_experimental, "
|
||||||
llm_chain_config = config.pop("llm_chain")
|
"but it is not appropriate for production usage due to security "
|
||||||
llm_chain = load_chain_from_config(llm_chain_config, **kwargs)
|
"concerns. Please refer to langchain-experimental repository for more details."
|
||||||
elif "llm_chain_path" in config:
|
)
|
||||||
llm_chain = load_chain(config.pop("llm_chain_path"), **kwargs)
|
|
||||||
# llm attribute is deprecated in favor of llm_chain, here to support old configs
|
|
||||||
elif "llm" in config:
|
|
||||||
llm_config = config.pop("llm")
|
|
||||||
llm = load_llm_from_config(llm_config, **kwargs)
|
|
||||||
# llm_path attribute is deprecated in favor of llm_chain_path,
|
|
||||||
# its to support old configs
|
|
||||||
elif "llm_path" in config:
|
|
||||||
llm = load_llm(config.pop("llm_path"), **kwargs)
|
|
||||||
else:
|
|
||||||
raise ValueError("One of `llm_chain` or `llm_chain_path` must be present.")
|
|
||||||
if "prompt" in config:
|
|
||||||
prompt_config = config.pop("prompt")
|
|
||||||
prompt = load_prompt_from_config(prompt_config)
|
|
||||||
elif "prompt_path" in config:
|
|
||||||
prompt = load_prompt(config.pop("prompt_path"))
|
|
||||||
if llm_chain:
|
|
||||||
return LLMBashChain(llm_chain=llm_chain, prompt=prompt, **config)
|
|
||||||
else:
|
|
||||||
return LLMBashChain(llm=llm, prompt=prompt, **config)
|
|
||||||
|
|
||||||
|
|
||||||
def _load_llm_checker_chain(config: dict, **kwargs: Any) -> LLMCheckerChain:
|
def _load_llm_checker_chain(config: dict, **kwargs: Any) -> LLMCheckerChain:
|
||||||
@ -336,16 +316,12 @@ def _load_map_rerank_documents_chain(
|
|||||||
|
|
||||||
|
|
||||||
def _load_pal_chain(config: dict, **kwargs: Any) -> Any:
|
def _load_pal_chain(config: dict, **kwargs: Any) -> Any:
|
||||||
from langchain_experimental.pal_chain import PALChain
|
raise NotImplementedError(
|
||||||
|
"PALChain is not available through LangChain anymore. "
|
||||||
if "llm_chain" in config:
|
"The relevant code can be found in langchain_experimental, "
|
||||||
llm_chain_config = config.pop("llm_chain")
|
"but it is not appropriate for production usage due to security "
|
||||||
llm_chain = load_chain_from_config(llm_chain_config, **kwargs)
|
"concerns. Please refer to langchain-experimental repository for more details."
|
||||||
elif "llm_chain_path" in config:
|
)
|
||||||
llm_chain = load_chain(config.pop("llm_chain_path"), **kwargs)
|
|
||||||
else:
|
|
||||||
raise ValueError("One of `llm_chain` or `llm_chain_path` must be present.")
|
|
||||||
return PALChain(llm_chain=llm_chain, **config)
|
|
||||||
|
|
||||||
|
|
||||||
def _load_refine_documents_chain(config: dict, **kwargs: Any) -> RefineDocumentsChain:
|
def _load_refine_documents_chain(config: dict, **kwargs: Any) -> RefineDocumentsChain:
|
||||||
@ -399,30 +375,15 @@ def _load_qa_with_sources_chain(config: dict, **kwargs: Any) -> QAWithSourcesCha
|
|||||||
|
|
||||||
|
|
||||||
def _load_sql_database_chain(config: dict, **kwargs: Any) -> Any:
|
def _load_sql_database_chain(config: dict, **kwargs: Any) -> Any:
|
||||||
from langchain_experimental.sql import SQLDatabaseChain
|
"""Load SQL Database chain from config dict."""
|
||||||
|
raise NotImplementedError(
|
||||||
if "database" in kwargs:
|
"SQLDatabaseChain is not available through LangChain anymore. "
|
||||||
database = kwargs.pop("database")
|
"The relevant code can be found in langchain_experimental, "
|
||||||
else:
|
"but it is not appropriate for production usage due to security "
|
||||||
raise ValueError("`database` must be present.")
|
"concerns. Please refer to langchain-experimental repository for more details, "
|
||||||
if "llm_chain" in config:
|
"or refer to this tutorial for best practices: "
|
||||||
llm_chain_config = config.pop("llm_chain")
|
"https://python.langchain.com/docs/tutorials/sql_qa/"
|
||||||
chain = load_chain_from_config(llm_chain_config, **kwargs)
|
)
|
||||||
return SQLDatabaseChain(llm_chain=chain, database=database, **config)
|
|
||||||
if "llm" in config:
|
|
||||||
llm_config = config.pop("llm")
|
|
||||||
llm = load_llm_from_config(llm_config, **kwargs)
|
|
||||||
elif "llm_path" in config:
|
|
||||||
llm = load_llm(config.pop("llm_path"), **kwargs)
|
|
||||||
else:
|
|
||||||
raise ValueError("One of `llm` or `llm_path` must be present.")
|
|
||||||
if "prompt" in config:
|
|
||||||
prompt_config = config.pop("prompt")
|
|
||||||
prompt = load_prompt_from_config(prompt_config)
|
|
||||||
else:
|
|
||||||
prompt = None
|
|
||||||
|
|
||||||
return SQLDatabaseChain.from_llm(llm, database, prompt=prompt, **config)
|
|
||||||
|
|
||||||
|
|
||||||
def _load_vector_db_qa_with_sources_chain(
|
def _load_vector_db_qa_with_sources_chain(
|
||||||
|
Loading…
Reference in New Issue
Block a user