Skip to content

The agent engineering platform.

Better error when running chain without any args (#4294)

Lior Neudorfer65c95f9fb2b8
diff --git a/langchain/chains/base.py b/langchain/chains/base.py
index b4043dfe08..a457934fde 100644
--- a/langchain/chains/base.py
+++ b/langchain/chains/base.py
@@ -238,6 +238,12 @@ class Chain(BaseModel, ABC):
if kwargs and not args:
return self(kwargs, callbacks=callbacks)[self.output_keys[0]]
+ if not kwargs and not args:
+ raise ValueError(
+ "`run` supported with either positional arguments or keyword arguments,"
+ " but none were provided."
+ )
+
raise ValueError(
f"`run` supported with either positional arguments or keyword arguments"
f" but not both. Got args: {args} and kwargs: {kwargs}."