deepset-ai / haystack

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.
https://haystack.deepset.ai
Apache License 2.0
17.69k stars 1.92k forks source link

Ensure run Method Returns Dictionary with Annotated Values #6494

Open vblagoje opened 11 months ago

vblagoje commented 11 months ago

Description:

Haystack component developers sometimes forget to adhere to the expected return type of the run method in various components. Specifically, the run method is designed to return a dictionary with values that are annotated on the method.

Issue Details:

Example:

A correct implementation of the run method looks like this:

@component.output_types(documents=List[Document])
def run(self, ...):
    ...
    return {"documents": docs}

However, users often incorrectly implement it as:

@component.output_types(documents=List[Document])
def run(self, ...):
    ...
    return docs
tanaymeh commented 11 months ago

Hi @vblagoje, I would like to take up this issue as my first OS contribution at Haystack, if I am allowed to!

Thanks!

sahusiddharth commented 10 months ago

@vblagoje I went through all the files, all of them are returning dictionaries but the keys have a multitude of key names from answers to replies to values to document_written.

Do you want documents as a key in all return dictionaries?