From be164b20d83bdca23e917bcecc7ef80f0a425ff9 Mon Sep 17 00:00:00 2001 From: Zander Chase <130414180+vowelparrot@users.noreply.github.com> Date: Thu, 29 Jun 2023 10:29:16 -0700 Subject: [PATCH] Accept any single input (#6888) If I upload a dataset with a single input and output column, we should be able to let the chain prepare the input without having to maintain a strict dataset format. --- langchain/client/runner_utils.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/langchain/client/runner_utils.py b/langchain/client/runner_utils.py index 0bb2641523..7141a07ee1 100644 --- a/langchain/client/runner_utils.py +++ b/langchain/client/runner_utils.py @@ -226,9 +226,10 @@ async def _arun_llm_or_chain( ) else: chain = llm_or_chain_factory() - output = await chain.acall( - example.inputs, callbacks=callbacks, tags=tags - ) + inputs_ = example.inputs + if len(inputs_) == 1: + inputs_ = next(iter(inputs_.values())) + output = await chain.acall(inputs_, callbacks=callbacks, tags=tags) outputs.append(output) except Exception as e: logger.warning(f"Chain failed for example {example.id}. Error: {e}") @@ -486,7 +487,10 @@ def run_llm_or_chain( ) else: chain = llm_or_chain_factory() - output = chain(example.inputs, callbacks=callbacks, tags=tags) + inputs_ = example.inputs + if len(inputs_) == 1: + inputs_ = next(iter(inputs_.values())) + output = chain(inputs_, callbacks=callbacks, tags=tags) outputs.append(output) except Exception as e: logger.warning(f"Chain failed for example {example.id}. Error: {e}")