internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: deepset-ai/haystack

Issue:
init param overrides run param for metafieldranker
**Describe the bug**
When you use the Metafield ranker which is instantiated with a weight > 0 but you want to use weight = 0 in the run method, the init param overrides the run param due to the way we set the parameter [here](https://github.com/deepset-ai/haystack/blob/main/haystack/components/rankers/meta_field.py#L194)


**Expected behavior**
The parameter of the run method should always override the value of the init param.

**To Reproduce**
```
from haystack.components.rankers.meta_field import MetaFieldRanker
from haystack import Document

FILES = [
    Document(
        content="Document 1",
        score=0.9,
        meta={
            "feedback": 1,
        },
    ),
    Document(
        content="Document 2",
        score=0.6,
        meta={
            "feedback": 2,
        },
    )
]

ranker = MetaFieldRanker(meta_field="feedback",
                         weight=1,
                         top_k=5,
                         ranking_mode="reciprocal_rank_fusion",
                         sort_order="descending",
                         meta_value_type="int")

results = ranker.run(documents=FILES, weight=0)
print(results)
```

**FAQ Check**
- [x] Have you had a look at [our new FAQ page](https://docs.haystack.deepset.ai/docs/faq)?




Discussion:

Resolving patch:
diff --git a/haystack/components/rankers/meta_field.py b/haystack/components/rankers/meta_field.py
--- a/haystack/components/rankers/meta_field.py
+++ b/haystack/components/rankers/meta_field.py
@@ -191,7 +191,7 @@ def run(
             return {"documents": []}
 
         top_k = top_k or self.top_k
-        weight = weight or self.weight
+        weight = weight if weight is not None else self.weight
         ranking_mode = ranking_mode or self.ranking_mode
         sort_order = sort_order or self.sort_order
         meta_value_type = meta_value_type or self.meta_value_type


Test patch:
Repository: deepset-ai/haystack

Issue:
WeaviateDocumentStore Timeout Config Documentation Misleading
**Describe the bug**
The [documentation](https://github.com/deepset-ai/haystack/blob/553badc2151b8c874bdcb37fd5b785999d45dd88/haystack/document_stores/weaviate.py#L107C1-L107C102) for the `WeaviateDocumentStore` `timeout_config` isn't the same as the documentation provided in the [Weaviate documentation](https://weaviate-python-client.readthedocs.io/en/stable/weaviate.html#weaviate.Client.timeout_config) for the Weaviate client. I think instead of `(retries, time out seconds)` it should be `(connect timeout, read timeout)`. 


**Error message**
NA

**Expected behavior**
NA

**Additional context**

**To Reproduce**
NA

**FAQ Check**
- [*] Have you had a look at [our new FAQ page](https://docs.haystack.deepset.ai/docs/faq)?

**System:**
NA



Discussion:
I had a quick look and think you are right.
This is related to Haystack 1.x, where Weaviate was an optional dependency.

In Haystack 2.0, it is a separate integration: https://docs.haystack.deepset.ai/docs/weaviatedocumentstore

If you want to open a PR against the v1.x branch to fix this docstring, you are welcome!

Resolving patch:
diff --git a/haystack/document_stores/weaviate.py b/haystack/document_stores/weaviate.py
--- a/haystack/document_stores/weaviate.py
+++ b/haystack/document_stores/weaviate.py
@@ -104,7 +104,7 @@ def __init__(
         :param host: Weaviate server connection URL for storing and processing documents and vectors.
                              For more details, see [Weaviate installation](https://weaviate.io/developers/weaviate/current/getting-started/installation.html).
         :param port: The port of the Weaviate instance.
-        :param timeout_config: The Weaviate timeout config as a tuple of (retries, time out seconds).
+        :param timeout_config: The Weaviate timeout config as a tuple of (connect timeout, read timeout).
         :param username: The Weaviate username (standard authentication using http_auth).
         :param password: Weaviate password (standard authentication using http_auth).
         :param scope: The scope of the credentials when using the OIDC Resource Owner Password or Client Credentials authentication flow.


Test patch:
Repository: deepset-ai/haystack

Issue:
`HuggingFaceTGIChatGenerator` does not work properly in a Pipeline
**Describe the bug**
Reported on Discord, reproducible.
[Our example in docs](https://docs.haystack.deepset.ai/docs/huggingfacetgichatgenerator#in-a-pipeline) is broken.

**To Reproduce**
```python
from haystack.components.builders import DynamicChatPromptBuilder
from haystack.components.generators.chat import HuggingFaceTGIChatGenerator
from haystack.dataclasses import ChatMessage
from haystack.utils import Secret
from haystack import Pipeline

# no parameter init, we don't use any runtime template variables
prompt_builder = DynamicChatPromptBuilder()
llm = HuggingFaceTGIChatGenerator(model="meta-llama/Llama-2-70b-chat-hf", token=Secret.from_token("..."))

pipe = Pipeline()
pipe.add_component("prompt_builder", prompt_builder)
pipe.add_component("llm", llm)
pipe.connect("prompt_builder.prompt", "llm.messages")
location = "Berlin"
messages = [ChatMessage.from_system("Always respond in German even if some input data is in other languages."),
            ChatMessage.from_user("Tell me about {{location}}")]
pipe.run(data={"prompt_builder": {"template_variables":{"location": location}, "prompt_source": messages}})
```

**Error message**
```
AttributeError                            Traceback (most recent call last)
[<ipython-input-6-4084a601c8bf>](https://localhost:8080/#) in <cell line: 13>()
     11 pipe = Pipeline()
     12 pipe.add_component("prompt_builder", prompt_builder)
---> 13 pipe.add_component("llm", llm)
     14 pipe.connect("prompt_builder.prompt", "llm.messages")
     15 location = "Berlin"

[/usr/local/lib/python3.10/dist-packages/haystack/core/pipeline/pipeline.py](https://localhost:8080/#) in add_component(self, name, instance)
    291             name,
    292             instance=instance,
--> 293             input_sockets=instance.__haystack_input__._sockets_dict,  # type: ignore[attr-defined]
    294             output_sockets=instance.__haystack_output__._sockets_dict,  # type: ignore[attr-defined]
    295             visits=0,

AttributeError: 'HuggingFaceTGIChatGenerator' object has no attribute '__haystack_input__'
```

**System:**
 - Haystack version (commit or version number): 2.0.0



Discussion:
This happens because the  `@component` decorator is missing

Resolving patch:
diff --git a/haystack/components/generators/chat/hugging_face_tgi.py b/haystack/components/generators/chat/hugging_face_tgi.py
--- a/haystack/components/generators/chat/hugging_face_tgi.py
+++ b/haystack/components/generators/chat/hugging_face_tgi.py
@@ -16,6 +16,7 @@
 logger = logging.getLogger(__name__)
 
 
+@component
 class HuggingFaceTGIChatGenerator:
     """
     Enables text generation using HuggingFace Hub hosted chat-based LLMs. This component is designed to seamlessly


Test patch:
Repository: deepset-ai/haystack

Issue:
[1.x] Support json mode for OpenAI
**Is your feature request related to a problem? Please describe.**
OpenAI supports [json mode](https://platform.openai.com/docs/guides/text-generation/json-mode) to constrain the model to only output valid json.

**Describe the solution you'd like**
Be able to set `model_kwargs={"response_format": { "type": "json_object" }}` in the `PromptNode` to have it only generate valid json.

**Additional context**
Implementation-wise might be as simple as adding the keyword to the OAI [invocation context kwargs list](https://github.com/deepset-ai/haystack/blob/f389dcf8c97d6bafda9609440c3fff61ed804a90/haystack/nodes/prompt/invocation_layer/open_ai.py#L77). But not fully sure.



Discussion:

Resolving patch:
diff --git a/haystack/nodes/prompt/invocation_layer/open_ai.py b/haystack/nodes/prompt/invocation_layer/open_ai.py
--- a/haystack/nodes/prompt/invocation_layer/open_ai.py
+++ b/haystack/nodes/prompt/invocation_layer/open_ai.py
@@ -95,6 +95,8 @@ def __init__(
                 "stream",
                 "stream_handler",
                 "moderate_content",
+                "seed",
+                "response_format",
             ]
             if key in kwargs
         }
@@ -150,6 +152,12 @@ def _prepare_invoke(self, *args, **kwargs):
             "frequency_penalty": kwargs_with_defaults.get("frequency_penalty", 0),
             "logit_bias": kwargs_with_defaults.get("logit_bias", {}),
         }
+        response_format = kwargs_with_defaults.get("response_format", None)
+        if response_format:
+            base_payload["response_format"] = response_format
+        seed = kwargs_with_defaults.get("seed", None)
+        if seed:
+            base_payload["seed"] = seed
 
         return (prompt, base_payload, kwargs_with_defaults, stream, moderation)
 


Test patch:
Repository: deepset-ai/haystack

Issue:
Add e2e tests for pipeline evaluation for 2.x
Test eval for 2.x with tiny dataset, check dataframes, isolated, integrated eval (migrate existing integration tests to e2e tests for 2.x)


Discussion:
Hi @julian-risch! I’m one of the founders of Sweep, a github app that solves issues by writing pull requests. 
This looks like a good issue for Sweep https://github.com/sweepai/sweep to try. It might need a bit more detail though. 
We have onboarding [instructions here](https://github.com/sweepai/sweep/blob/main/README.md#-getting-started), I’m also happy to help you onboard directly :)

Resolving patch:
diff --git a/haystack/evaluation/eval_run_result.py b/haystack/evaluation/eval_run_result.py
--- a/haystack/evaluation/eval_run_result.py
+++ b/haystack/evaluation/eval_run_result.py
@@ -119,8 +119,8 @@ def comparative_individual_scores_report(self, other: "BaseEvaluationRunResult")
             this_name = f"{this_name}_first"
             other_name = f"{other_name}_second"
 
-        if self.inputs != other.inputs:
-            warn(f"The inputs to the two evaluation results differ; using the inputs of '{this_name}'.")
+        if self.inputs.keys() != other.inputs.keys():
+            warn(f"The input columns differ between the results; using the input columns of '{this_name}'.")
 
         pipe_a_df = self.to_pandas()
         pipe_b_df = other.to_pandas()


Test patch:
Repository: deepset-ai/haystack

Issue:
PDFMinerToDocument buggy output
**Describe the bug**
Connecting a pdfminer coverter to a document writer i.e `pipeline.connect('converter.document', 'writer.documents') does not work.

The PDFMinerToDocument output_type does not match the returned json key:

https://github.com/deepset-ai/haystack/blob/d0da31a04718409cf50eee8605f01b766311b873/haystack/components/converters/pdfminer.py#L119

https://github.com/deepset-ai/haystack/blob/d0da31a04718409cf50eee8605f01b766311b873/haystack/components/converters/pdfminer.py#L164
document `!=` documents


**To Reproduce**
```python
pipeline = Pipeline()
document_store = InMemoryDocumentStore
pipeline.add_component("converter", PDFMinerToDocument())
pipeline.add_component("writer", DocumentWriter(document_store=document_store))
pipeline.connect("converter.document", "writer.documents")
response = pipeline.run({"converter": {"sources": ['some.pdf']}})
print(response['writer']['documents_written'])
```

**Error message**
`KeyError: 'writer'`

**Expected behavior**
The writer node is able to use documents from the previous converter node.

**FAQ Check**
- [x] Have you had a look at [our new FAQ page](https://docs.haystack.deepset.ai/docs/faq)?

**System:**
 - OS: NixOS
 - Haystack version (commit): d0da31a04718409cf50eee8605f01b766311b873
 - DocumentStore: InMemoryDocumentStore



Discussion:
Oh, you are right!

Would you like to open a PR to fix this?

Resolving patch:
diff --git a/haystack/components/converters/pdfminer.py b/haystack/components/converters/pdfminer.py
--- a/haystack/components/converters/pdfminer.py
+++ b/haystack/components/converters/pdfminer.py
@@ -116,7 +116,7 @@ def __converter(self, extractor) -> Document:
 
         return Document(content=concat)
 
-    @component.output_types(document=List[Document])
+    @component.output_types(documents=List[Document])
     def run(
         self,
         sources: List[Union[str, Path, ByteStream]],


Test patch:
Repository: deepset-ai/haystack

Issue:
docs: Add usage examples to DocumentSplitter and TextCleaner docstrings
The docstring of the DocumentSplitter component and of the TextCleaner component should contain a usage example starting with 

```python
```python
from haystack import Document, Pipeline
...
```
just like all other Haystack components. Currently the usage examples are missing for these two components.


Discussion:

Resolving patch:
diff --git a/haystack/components/preprocessors/document_splitter.py b/haystack/components/preprocessors/document_splitter.py
--- a/haystack/components/preprocessors/document_splitter.py
+++ b/haystack/components/preprocessors/document_splitter.py
@@ -18,6 +18,17 @@ class DocumentSplitter:
     Splitting documents with long texts is a common preprocessing step during indexing.
     This allows Embedders to create significant semantic representations
     and avoids exceeding the maximum context length of language models.
+
+    Usage example:
+    ```python
+    from haystack import Document
+    from haystack.components.preprocessors import DocumentSplitter
+
+    doc = Document(content="Moonlight shimmered softly, wolves howled nearby, night enveloped everything.")
+
+    splitter = DocumentSplitter(split_by="word", split_length=3, split_overlap=0)
+    result = splitter.run(documents=[doc])
+    ```
     """
 
     def __init__(
diff --git a/haystack/components/preprocessors/text_cleaner.py b/haystack/components/preprocessors/text_cleaner.py
--- a/haystack/components/preprocessors/text_cleaner.py
+++ b/haystack/components/preprocessors/text_cleaner.py
@@ -18,6 +18,16 @@ class TextCleaner:
     and remove numbers.
 
     This is useful to clean up text data before evaluation.
+
+    Usage example:
+    ```python
+    from haystack.components.preprocessors import TextCleaner
+
+    text_to_clean = "1Moonlight shimmered softly, 300 Wolves howled nearby, Night enveloped everything."
+
+    cleaner = TextCleaner(convert_to_lowercase=True, remove_punctuation=False, remove_numbers=True)
+    result = cleaner.run(texts=[text_to_clean])
+    ```
     """
 
     def __init__(


Test patch:
Repository: deepset-ai/haystack

Issue:
[V2.2.0] ChatPromptBuilder is not export
**Describe the bug**
v2.2.0 => ChatPromptBuilder is not export

**Error message**
<img width="1102" alt="image" src="https://github.com/deepset-ai/haystack/assets/15232298/b9372767-42f5-464c-832f-cca38a00cf60">




Discussion:
Hello!
Thanks for reporting this. We will take care of it.

In the meantime, you can import the component as follows:
`from haystack.components.builders.chat_prompt_builder import ChatPromptBuilder`

Resolving patch:
diff --git a/haystack/components/builders/__init__.py b/haystack/components/builders/__init__.py
--- a/haystack/components/builders/__init__.py
+++ b/haystack/components/builders/__init__.py
@@ -3,8 +3,9 @@
 # SPDX-License-Identifier: Apache-2.0
 
 from haystack.components.builders.answer_builder import AnswerBuilder
+from haystack.components.builders.chat_prompt_builder import ChatPromptBuilder
 from haystack.components.builders.dynamic_chat_prompt_builder import DynamicChatPromptBuilder
 from haystack.components.builders.dynamic_prompt_builder import DynamicPromptBuilder
 from haystack.components.builders.prompt_builder import PromptBuilder
 
-__all__ = ["AnswerBuilder", "PromptBuilder", "DynamicPromptBuilder", "DynamicChatPromptBuilder"]
+__all__ = ["AnswerBuilder", "PromptBuilder", "DynamicPromptBuilder", "DynamicChatPromptBuilder", "ChatPromptBuilder"]


Test patch:
Repository: deepset-ai/haystack

Issue:
Cannot specify model version for  `SentenceTransformer` embedding retriever
**Describe the bug**
Sentence transformer models do not allow version to be specified.

**Error message**
When passing a `model_version` argument to `nodes.EmbeddingRetriever`, it ignores this and only downloads the latest version of the `sentence-transformer` model from huggingface (or from cache).


**Expected behavior**
Download the specified version.

**Additional context**
This is due to not propagating the `revision` argument to `SentenceTransformer()`, via `_SentenceTransformersEmbeddingEncoder`

[Here](https://github.com/deepset-ai/haystack/blob/v1.26.x/haystack/nodes/retriever/_embedding_encoder.py#L138), we should have passed the version: 

```
self.embedding_model = SentenceTransformer(
    retriever.embedding_model, 
    device=str(retriever.devices[0]), 
    use_auth_token=retriever.use_auth_token, 
    revision=retriever.model_version,
)
```

**To Reproduce**

```
from haystack import nodes


nodes.EmbeddingRetriever(
    embedding_model="sentence-transformers/multi-qa-mpnet-base-dot-v1",
    model_version="39c51f707d95c3c40f68b47f1df9ae52319da356",
    model_format="sentence_transformers",
)
```
Check cache to see what models were downloaded: 
```
ls -al ~/.cache/huggingface/hub/models--sentence-transformers--multi-qa-mpnet-base-dot-v1/snapshots
>> 3af7c6da5b3e1bea796ef6c97fe237538cbe6e7f  # latest version, not specified version
```

**FAQ Check**
- [x] Have you had a look at [our new FAQ page](https://docs.haystack.deepset.ai/docs/faq)?

**System:**
 - OS: Mac
 - GPU/CPU: both
 - Haystack version (commit or version number): 1.26
 - DocumentStore: N/A
 - Reader: N/A
 - Retriever: `EmbeddingRetriever`



Discussion:
I am happy to open an MR for this

Resolving patch:
diff --git a/haystack/nodes/retriever/_embedding_encoder.py b/haystack/nodes/retriever/_embedding_encoder.py
--- a/haystack/nodes/retriever/_embedding_encoder.py
+++ b/haystack/nodes/retriever/_embedding_encoder.py
@@ -135,7 +135,10 @@ def __init__(self, retriever: "EmbeddingRetriever"):
         # e.g. 'roberta-base-nli-stsb-mean-tokens'
         torch_and_transformers_import.check()
         self.embedding_model = SentenceTransformer(
-            retriever.embedding_model, device=str(retriever.devices[0]), use_auth_token=retriever.use_auth_token
+            retriever.embedding_model,
+            device=str(retriever.devices[0]),
+            use_auth_token=retriever.use_auth_token,
+            revision=retriever.model_version,
         )
         self.batch_size = retriever.batch_size
         self.embedding_model.max_seq_length = retriever.max_seq_len


Test patch:
Repository: deepset-ai/haystack

Issue:
Fix `CacheChecker` Component to use new filters internally
**Describe the bug**

The `CacheChecker` Component internally creates Document Store filters that are in turn passed to the `filter_documents` method. 

The filters syntax used is the old legacy one, that must be updated to use the new syntax.

**Additional context**

This has been discovered with deepset-ai/haystack-core-integrations#810



Discussion:

Resolving patch:
diff --git a/haystack/components/caching/cache_checker.py b/haystack/components/caching/cache_checker.py
--- a/haystack/components/caching/cache_checker.py
+++ b/haystack/components/caching/cache_checker.py
@@ -108,7 +108,7 @@ def run(self, items: List[Any]):
         misses = []
 
         for item in items:
-            filters = {self.cache_field: item}
+            filters = {"field": self.cache_field, "operator": "==", "value": item}
             found = self.document_store.filter_documents(filters=filters)
             if found:
                 found_documents.extend(found)


Test patch:
diff --git a/test/components/caching/test_url_cache_checker.py b/test/components/caching/test_url_cache_checker.py
--- a/test/components/caching/test_url_cache_checker.py
+++ b/test/components/caching/test_url_cache_checker.py
@@ -7,6 +7,7 @@
 from haystack.testing.factory import document_store_class
 from haystack.document_stores.in_memory import InMemoryDocumentStore
 from haystack.components.caching.cache_checker import CacheChecker
+from unittest.mock import MagicMock
 
 
 class TestCacheChecker:
@@ -82,3 +83,11 @@ def test_run(self):
         checker = CacheChecker(docstore, cache_field="url")
         results = checker.run(items=["https://example.com/1", "https://example.com/5"])
         assert results == {"hits": [documents[0], documents[2]], "misses": ["https://example.com/5"]}
+
+    def test_filters_syntax(self):
+        mocked_docstore_class = document_store_class("MockedDocumentStore")
+        mocked_docstore_class.filter_documents = MagicMock()
+        checker = CacheChecker(document_store=mocked_docstore_class(), cache_field="url")
+        checker.run(items=["https://example.com/1"])
+        valid_filters_syntax = {"field": "url", "operator": "==", "value": "https://example.com/1"}
+        mocked_docstore_class.filter_documents.assert_any_call(filters=valid_filters_syntax)
Repository: NVIDIA/NeMo

Issue:
Tacotron2 bug when batch dimension is 1
**Describe the bug**

Training (or just passing input with ground-truth spectrogram) Tacotron2 with a batch dimension of 1 does not work due to a dimension problem when aggregating the gate outputs.

The line here
https://github.com/NVIDIA/NeMo/blob/d01b7bbc3fdb1bbf14789f71b8f368cf0aa8f86b/nemo/collections/tts/modules/tacotron2.py#L256
should have ```unsqueeze``` instead of ```squeeze``` when the batch dimension is 1.

(I didn't want to submit a pull request as I'm not familiar with the conventions of the project)



Discussion:

Resolving patch:
diff --git a/nemo/collections/tts/modules/tacotron2.py b/nemo/collections/tts/modules/tacotron2.py
--- a/nemo/collections/tts/modules/tacotron2.py
+++ b/nemo/collections/tts/modules/tacotron2.py
@@ -321,7 +321,7 @@ def train_forward(self, *, memory, decoder_inputs, memory_lengths):
             mel_output, gate_output, attention_weights = self.decode(decoder_input)
 
             mel_outputs += [mel_output.squeeze(1)]
-            gate_outputs += [gate_output.squeeze()]
+            gate_outputs += [gate_output]
             alignments += [attention_weights]
 
         mel_outputs, gate_outputs, alignments = self.parse_decoder_outputs(mel_outputs, gate_outputs, alignments)


Test patch: