mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-04 04:07:54 +00:00
Fix chains/loading.py error messages (#11688)
- **Description:** make the error messages consistent in chains/loading.py - **Dependencies:** None
This commit is contained in:
parent
18ebce2032
commit
93bb19f69a
@ -80,7 +80,7 @@ def _load_stuff_documents_chain(config: dict, **kwargs: Any) -> StuffDocumentsCh
|
|||||||
elif "llm_chain_path" in config:
|
elif "llm_chain_path" in config:
|
||||||
llm_chain = load_chain(config.pop("llm_chain_path"))
|
llm_chain = load_chain(config.pop("llm_chain_path"))
|
||||||
else:
|
else:
|
||||||
raise ValueError("One of `llm_chain` or `llm_chain_config` must be present.")
|
raise ValueError("One of `llm_chain` or `llm_chain_path` must be present.")
|
||||||
|
|
||||||
if not isinstance(llm_chain, LLMChain):
|
if not isinstance(llm_chain, LLMChain):
|
||||||
raise ValueError(f"Expected LLMChain, got {llm_chain}")
|
raise ValueError(f"Expected LLMChain, got {llm_chain}")
|
||||||
@ -109,7 +109,7 @@ def _load_map_reduce_documents_chain(
|
|||||||
elif "llm_chain_path" in config:
|
elif "llm_chain_path" in config:
|
||||||
llm_chain = load_chain(config.pop("llm_chain_path"))
|
llm_chain = load_chain(config.pop("llm_chain_path"))
|
||||||
else:
|
else:
|
||||||
raise ValueError("One of `llm_chain` or `llm_chain_config` must be present.")
|
raise ValueError("One of `llm_chain` or `llm_chain_path` must be present.")
|
||||||
|
|
||||||
if not isinstance(llm_chain, LLMChain):
|
if not isinstance(llm_chain, LLMChain):
|
||||||
raise ValueError(f"Expected LLMChain, got {llm_chain}")
|
raise ValueError(f"Expected LLMChain, got {llm_chain}")
|
||||||
@ -295,7 +295,7 @@ def _load_map_rerank_documents_chain(
|
|||||||
elif "llm_chain_path" in config:
|
elif "llm_chain_path" in config:
|
||||||
llm_chain = load_chain(config.pop("llm_chain_path"))
|
llm_chain = load_chain(config.pop("llm_chain_path"))
|
||||||
else:
|
else:
|
||||||
raise ValueError("One of `llm_chain` or `llm_chain_config` must be present.")
|
raise ValueError("One of `llm_chain` or `llm_chain_path` must be present.")
|
||||||
return MapRerankDocumentsChain(llm_chain=llm_chain, **config)
|
return MapRerankDocumentsChain(llm_chain=llm_chain, **config)
|
||||||
|
|
||||||
|
|
||||||
@ -320,7 +320,7 @@ def _load_refine_documents_chain(config: dict, **kwargs: Any) -> RefineDocuments
|
|||||||
initial_llm_chain = load_chain(config.pop("initial_llm_chain_path"))
|
initial_llm_chain = load_chain(config.pop("initial_llm_chain_path"))
|
||||||
else:
|
else:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"One of `initial_llm_chain` or `initial_llm_chain_config` must be present."
|
"One of `initial_llm_chain` or `initial_llm_chain_path` must be present."
|
||||||
)
|
)
|
||||||
if "refine_llm_chain" in config:
|
if "refine_llm_chain" in config:
|
||||||
refine_llm_chain_config = config.pop("refine_llm_chain")
|
refine_llm_chain_config = config.pop("refine_llm_chain")
|
||||||
@ -329,7 +329,7 @@ def _load_refine_documents_chain(config: dict, **kwargs: Any) -> RefineDocuments
|
|||||||
refine_llm_chain = load_chain(config.pop("refine_llm_chain_path"))
|
refine_llm_chain = load_chain(config.pop("refine_llm_chain_path"))
|
||||||
else:
|
else:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"One of `refine_llm_chain` or `refine_llm_chain_config` must be present."
|
"One of `refine_llm_chain` or `refine_llm_chain_path` must be present."
|
||||||
)
|
)
|
||||||
if "document_prompt" in config:
|
if "document_prompt" in config:
|
||||||
prompt_config = config.pop("document_prompt")
|
prompt_config = config.pop("document_prompt")
|
||||||
|
Loading…
Reference in New Issue
Block a user