|
|
|
@ -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."""
|
|
|
|
|
if "document_variable_name" not in values:
|
|
|
|
|
llm_chain_variables = values["llm_chain"].prompt.input_variables
|
|
|
|
|
if "document_variable_name" not in values:
|
|
|
|
|
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 "
|
|
|
|
|