mirror of
https://github.com/hwchase17/langchain
synced 2024-11-06 03:20:49 +00:00
Optimize code (#3412)
Co-authored-by: assert <zhangchengming@kkguan.com>
This commit is contained in:
parent
3d8243ec95
commit
487a57ffe6
@ -40,8 +40,8 @@ class StuffDocumentsChain(BaseCombineDocumentsChain):
|
||||
@root_validator(pre=True)
|
||||
def get_default_document_variable_name(cls, values: Dict) -> Dict:
|
||||
"""Get default document variable name, if not provided."""
|
||||
llm_chain_variables = values["llm_chain"].prompt.input_variables
|
||||
if "document_variable_name" not in values:
|
||||
llm_chain_variables = values["llm_chain"].prompt.input_variables
|
||||
if len(llm_chain_variables) == 1:
|
||||
values["document_variable_name"] = llm_chain_variables[0]
|
||||
else:
|
||||
@ -50,7 +50,6 @@ class StuffDocumentsChain(BaseCombineDocumentsChain):
|
||||
"multiple llm_chain_variables"
|
||||
)
|
||||
else:
|
||||
llm_chain_variables = values["llm_chain"].prompt.input_variables
|
||||
if values["document_variable_name"] not in llm_chain_variables:
|
||||
raise ValueError(
|
||||
f"document_variable_name {values['document_variable_name']} was "
|
||||
|
Loading…
Reference in New Issue
Block a user