mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-31 16:39:20 +00:00
Fix IndexError when input_list is Empty in prep_prompts (#5769)
This MR corrects the IndexError arising in prep_prompts method when no documents are returned from a similarity search. Fixes #1733 Co-authored-by: Sam Groenjes <sam.groenjes@darkwolfsolutions.com> Co-authored-by: Bagatur <baskaryan@gmail.com>
This commit is contained in:
parent
c0acbdca1b
commit
2184e3a400
@ -127,6 +127,8 @@ class LLMChain(Chain):
|
||||
) -> Tuple[List[PromptValue], Optional[List[str]]]:
|
||||
"""Prepare prompts from inputs."""
|
||||
stop = None
|
||||
if len(input_list) == 0:
|
||||
return [], stop
|
||||
if "stop" in input_list[0]:
|
||||
stop = input_list[0]["stop"]
|
||||
prompts = []
|
||||
@ -151,6 +153,8 @@ class LLMChain(Chain):
|
||||
) -> Tuple[List[PromptValue], Optional[List[str]]]:
|
||||
"""Prepare prompts from inputs."""
|
||||
stop = None
|
||||
if len(input_list) == 0:
|
||||
return [], stop
|
||||
if "stop" in input_list[0]:
|
||||
stop = input_list[0]["stop"]
|
||||
prompts = []
|
||||
|
Loading…
Reference in New Issue
Block a user