:mag: AI orchestration framework to build customizable, production-ready LLM applications. Connect components (models, vector DBs, file converters) to pipelines or agents that can interact with your data. With advanced retrieval methods, it's best suited for building RAG, question answering, semantic search or conversational agent chatbots.
If a user calls component.set_input_types() or component.set_input_type() in a Component's init method the inputs will be added even if the Component doesn't define a run method that accepts **kwargs.
Expected behavior
Setting an input in a Component init that has a run that doesn't accept **kwargs must fail.
To Reproduce
This sould fail:
@component
class Foo:
def __init__(self):
component.set_input_types(self, y=int)
@component.output_types(output=int)
def run(self, x: int):
return {"output": x}
print(Foo())
# <__main__.Foo object at 0x106190500>
# Inputs:
# - y: int
# - x: int
# Outputs:
# - output: int
This should fail too:
@component
class Bar:
def __init__(self):
component.set_input_type(self, "y", int)
@component.output_types(output=int)
def run(self, x: int):
return {"output": x}
print(Bar())
# <__main__.Bar object at 0x13998ea80>
# Inputs:
# - y: int
# - x: int
# Outputs:
# - output: int
This is correct instead:
@component
class Baz:
def __init__(self):
component.set_input_type(self, "y", int)
@component.output_types(output=int)
def run(self, x: int, **kwargs):
return {"output": x + kwargs.get("y")}
print(Baz())
# <__main__.Baz object at 0x13998ec30>
# Inputs:
# - y: int
# - x: int
# Outputs:
# - output: int
Describe the bug
If a user calls
component.set_input_types()
orcomponent.set_input_type()
in a Component's init method the inputs will be added even if the Component doesn't define arun
method that accepts**kwargs
.Expected behavior
Setting an input in a Component init that has a
run
that doesn't accept**kwargs
must fail.To Reproduce
This sould fail:
This should fail too:
This is correct instead: