otari-haystack 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,244 @@
1
+ # SPDX-FileCopyrightText: 2022-present deepset GmbH <info@deepset.ai>
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
5
+ from dataclasses import replace
6
+ from typing import Any
7
+
8
+ import httpx
9
+ from haystack import Document, component
10
+ from haystack.utils import Secret
11
+ from haystack.utils.requests_utils import async_request_with_retry, request_with_retry
12
+
13
+ from haystack_integrations.common.otari.utils import _warn_if_eu_key_on_default_url
14
+
15
+
16
+ @component
17
+ class OtariRanker:
18
+ """
19
+ Ranks Documents by relevance to a query using an [Otari](https://github.com/mozilla-ai/otari) gateway.
20
+
21
+ It calls the `/rerank` endpoint of the gateway. By default, this component calls the otari.ai gateway. For an
22
+ account in otari.ai's EU region, whose API keys start with `otk_v1_eu_`, set `api_base_url` to
23
+ `"https://eu.api.otari.ai/api/v1"`. To call a gateway you run yourself, set `api_base_url`, for example to
24
+ `"http://localhost:8000/api/v1"`.
25
+
26
+ Name models with a selector the gateway accepts, such as `"cohere:rerank-v3.5"`.
27
+
28
+ ### Usage example
29
+
30
+ ```python
31
+ from haystack import Document
32
+ from haystack_integrations.components.rankers.otari import OtariRanker
33
+
34
+ # Reads the API key from the OTARI_API_KEY environment variable
35
+ ranker = OtariRanker()
36
+ docs = [
37
+ Document(content="The capital of Brazil is Brasilia."),
38
+ Document(content="The capital of France is Paris."),
39
+ ]
40
+ result = ranker.run(query="What is the capital of France?", documents=docs)
41
+ print(result["documents"][0].content)
42
+ # >> The capital of France is Paris.
43
+ ```
44
+ """
45
+
46
+ def __init__(
47
+ self,
48
+ *,
49
+ model: str = "cohere:rerank-v3.5",
50
+ api_key: Secret = Secret.from_env_var("OTARI_API_KEY"),
51
+ api_base_url: str = "https://api.otari.ai/api/v1",
52
+ top_k: int | None = None,
53
+ score_threshold: float | None = None,
54
+ meta_fields_to_embed: list[str] | None = None,
55
+ meta_data_separator: str = "\n",
56
+ max_tokens_per_doc: int | None = None,
57
+ timeout: float = 30.0,
58
+ max_retries: int = 3,
59
+ ) -> None:
60
+ """
61
+ Creates an instance of OtariRanker.
62
+
63
+ :param model: The rerank model selector, for example `"cohere:rerank-v3.5"`.
64
+ The gateway must have the provider configured.
65
+ :param api_key: The Otari API key: a key issued by your gateway, or an otari.ai API key.
66
+ Defaults to the `OTARI_API_KEY` environment variable.
67
+ :param api_base_url: The API root of the Otari gateway, including the `/api/v1` path.
68
+ Defaults to the otari.ai gateway. For an account in otari.ai's EU region, use
69
+ `"https://eu.api.otari.ai/api/v1"`.
70
+ :param top_k: The maximum number of Documents to return. If `None`, all documents are returned.
71
+ :param score_threshold: If set, documents with a relevance score below this value are dropped.
72
+ Applied after `top_k`, so the output may contain fewer than `top_k` documents.
73
+ :param meta_fields_to_embed: List of meta fields that should be concatenated with the document
74
+ content before reranking.
75
+ :param meta_data_separator: Separator used to concatenate the meta fields to the document content.
76
+ :param max_tokens_per_doc: The maximum number of tokens of each document that the model considers.
77
+ Longer documents are truncated. If `None`, the provider's default applies.
78
+ :param timeout: The timeout for each request to the gateway, in seconds.
79
+ :param max_retries: The maximum number of retries after a failed request. Requests are retried on timeouts,
80
+ connection errors, and the HTTP status codes 408, 418, 429, and 503.
81
+
82
+ :raises ValueError: If `top_k` is not > 0.
83
+ """
84
+ if top_k is not None and top_k <= 0:
85
+ msg = f"top_k must be > 0, but got {top_k}"
86
+ raise ValueError(msg)
87
+
88
+ self.model = model
89
+ self.api_key = api_key
90
+ self.api_base_url = api_base_url
91
+ self.top_k = top_k
92
+ self.score_threshold = score_threshold
93
+ self.meta_fields_to_embed = meta_fields_to_embed or []
94
+ self.meta_data_separator = meta_data_separator
95
+ self.max_tokens_per_doc = max_tokens_per_doc
96
+ self.timeout = timeout
97
+ self.max_retries = max_retries
98
+
99
+ self._region_checked = False
100
+
101
+ def _headers(self) -> dict[str, str]:
102
+ """Build the request headers, and warn once if an EU key meets the default URL."""
103
+ if not self._region_checked:
104
+ _warn_if_eu_key_on_default_url(self.api_key, self.api_base_url)
105
+ self._region_checked = True
106
+ return {"Content-Type": "application/json", "Authorization": f"Bearer {self.api_key.resolve_value()}"}
107
+
108
+ def _request_kwargs(self, body: dict[str, Any]) -> dict[str, Any]:
109
+ return {
110
+ "method": "POST",
111
+ "url": f"{self.api_base_url.rstrip('/')}/rerank",
112
+ "json": body,
113
+ "headers": self._headers(),
114
+ "timeout": self.timeout,
115
+ "attempts": self.max_retries + 1,
116
+ }
117
+
118
+ def _prepare_texts(self, documents: list[Document]) -> list[str]:
119
+ """Concatenate each Document's text with the selected meta fields."""
120
+ texts = []
121
+ for doc in documents:
122
+ meta_values = [
123
+ str(doc.meta[key]) for key in self.meta_fields_to_embed if key in doc.meta and doc.meta[key] is not None
124
+ ]
125
+ texts.append(self.meta_data_separator.join([*meta_values, doc.content or ""]))
126
+ return texts
127
+
128
+ def _prepare_request(self, query: str, documents: list[Document], top_k: int | None) -> dict[str, Any]:
129
+ body: dict[str, Any] = {
130
+ "model": self.model,
131
+ "query": query,
132
+ "documents": self._prepare_texts(documents),
133
+ }
134
+ if top_k is not None:
135
+ body["top_n"] = top_k
136
+ if self.max_tokens_per_doc is not None:
137
+ body["max_tokens_per_doc"] = self.max_tokens_per_doc
138
+ return body
139
+
140
+ def _parse_response(
141
+ self,
142
+ response: httpx.Response,
143
+ documents: list[Document],
144
+ score_threshold: float | None,
145
+ ) -> dict[str, list[Document] | dict[str, Any]]:
146
+ try:
147
+ body = response.json()
148
+ except ValueError:
149
+ body = None
150
+
151
+ if response.is_error or not isinstance(body, dict) or "results" not in body:
152
+ # Otari reports errors as {"detail": ...}, with a message or a list of validation errors
153
+ detail = body.get("detail") if isinstance(body, dict) else None
154
+ msg = f"Otari rerank request failed with status code {response.status_code}: {detail or response.text}"
155
+ raise RuntimeError(msg)
156
+
157
+ ranked_docs: list[Document] = []
158
+ for result in body["results"]:
159
+ score = result["relevance_score"]
160
+ if score_threshold is not None and score < score_threshold:
161
+ continue
162
+ ranked_docs.append(replace(documents[result["index"]], score=score))
163
+
164
+ # Otari names the model in rerank responses since 0.18.0; for older gateways, report the requested selector
165
+ meta = {"model": body.get("model") or self.model, "usage": body.get("usage") or {}}
166
+ return {"documents": ranked_docs, "meta": meta}
167
+
168
+ def _resolve_run_params(self, top_k: int | None, score_threshold: float | None) -> tuple[int | None, float | None]:
169
+ if top_k is not None and top_k <= 0:
170
+ msg = f"top_k must be > 0, but got {top_k}"
171
+ raise ValueError(msg)
172
+ resolved_top_k = top_k if top_k is not None else self.top_k
173
+ resolved_score_threshold = score_threshold if score_threshold is not None else self.score_threshold
174
+ return resolved_top_k, resolved_score_threshold
175
+
176
+ @component.output_types(documents=list[Document], meta=dict[str, Any])
177
+ def run(
178
+ self,
179
+ query: str,
180
+ documents: list[Document],
181
+ top_k: int | None = None,
182
+ score_threshold: float | None = None,
183
+ ) -> dict[str, list[Document] | dict[str, Any]]:
184
+ """
185
+ Returns a list of Documents ranked by their relevance to the given query.
186
+
187
+ :param query: Query string.
188
+ :param documents: List of Documents to rank.
189
+ :param top_k: The maximum number of Documents to return. Overrides the value set at initialization.
190
+ :param score_threshold: Minimum relevance score required for a document to be returned. Overrides
191
+ the value set at initialization.
192
+ :returns: A dictionary with:
193
+ - `documents`: Documents sorted from most to least relevant.
194
+ - `meta`: Information about the model and usage.
195
+
196
+ :raises ValueError: If `top_k` is not > 0.
197
+ :raises RuntimeError: If the gateway returns an error.
198
+ :raises httpx.RequestError: If the request still fails to reach the gateway after all retries.
199
+ """
200
+ if not documents:
201
+ return {"documents": [], "meta": {}}
202
+
203
+ top_k, score_threshold = self._resolve_run_params(top_k, score_threshold)
204
+ body = self._prepare_request(query, documents, top_k)
205
+ try:
206
+ response = request_with_retry(**self._request_kwargs(body))
207
+ except httpx.HTTPStatusError as e:
208
+ response = e.response
209
+ return self._parse_response(response, documents, score_threshold)
210
+
211
+ @component.output_types(documents=list[Document], meta=dict[str, Any])
212
+ async def run_async(
213
+ self,
214
+ query: str,
215
+ documents: list[Document],
216
+ top_k: int | None = None,
217
+ score_threshold: float | None = None,
218
+ ) -> dict[str, list[Document] | dict[str, Any]]:
219
+ """
220
+ Asynchronously returns a list of Documents ranked by their relevance to the given query.
221
+
222
+ :param query: Query string.
223
+ :param documents: List of Documents to rank.
224
+ :param top_k: The maximum number of Documents to return. Overrides the value set at initialization.
225
+ :param score_threshold: Minimum relevance score required for a document to be returned. Overrides
226
+ the value set at initialization.
227
+ :returns: A dictionary with:
228
+ - `documents`: Documents sorted from most to least relevant.
229
+ - `meta`: Information about the model and usage.
230
+
231
+ :raises ValueError: If `top_k` is not > 0.
232
+ :raises RuntimeError: If the gateway returns an error.
233
+ :raises httpx.RequestError: If the request still fails to reach the gateway after all retries.
234
+ """
235
+ if not documents:
236
+ return {"documents": [], "meta": {}}
237
+
238
+ top_k, score_threshold = self._resolve_run_params(top_k, score_threshold)
239
+ body = self._prepare_request(query, documents, top_k)
240
+ try:
241
+ response = await async_request_with_retry(**self._request_kwargs(body))
242
+ except httpx.HTTPStatusError as e:
243
+ response = e.response
244
+ return self._parse_response(response, documents, score_threshold)
File without changes
@@ -0,0 +1,64 @@
1
+ Metadata-Version: 2.5
2
+ Name: otari-haystack
3
+ Version: 1.0.0
4
+ Summary: An integration between the Otari LLM gateway and Haystack
5
+ Project-URL: Documentation, https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/otari#readme
6
+ Project-URL: Issues, https://github.com/deepset-ai/haystack-core-integrations/issues
7
+ Project-URL: Source, https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/otari
8
+ Author-email: deepset GmbH <info@deepset.ai>
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE.txt
11
+ Keywords: chat generator,embedder,haystack,llm gateway,otari,ranker
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Classifier: Programming Language :: Python
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Programming Language :: Python :: Implementation :: CPython
21
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
22
+ Requires-Python: >=3.10
23
+ Requires-Dist: haystack-ai>=3.0.0
24
+ Requires-Dist: httpx>=0.27.0
25
+ Requires-Dist: more-itertools>=9.0.0
26
+ Requires-Dist: openai>=1.99.2
27
+ Requires-Dist: pydantic>=2.12.0
28
+ Requires-Dist: tqdm>=4.48.0
29
+ Description-Content-Type: text/markdown
30
+
31
+ # otari-haystack
32
+
33
+ [![PyPI - Version](https://img.shields.io/pypi/v/otari-haystack.svg)](https://pypi.org/project/otari-haystack)
34
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/otari-haystack.svg)](https://pypi.org/project/otari-haystack)
35
+
36
+ - [Integration page](https://haystack.deepset.ai/integrations/otari)
37
+ - [Changelog](https://github.com/deepset-ai/haystack-core-integrations/blob/main/integrations/otari/CHANGELOG.md)
38
+
39
+ ---
40
+
41
+ ## Contributing
42
+
43
+ Refer to the general [Contribution Guidelines](https://github.com/deepset-ai/haystack-core-integrations/blob/main/CONTRIBUTING.md).
44
+
45
+ The integration tests run against a local Otari gateway. To start one, export `OPENAI_API_KEY`, `COHERE_API_KEY`, and
46
+ `ANTHROPIC_API_KEY` for the providers it routes to, and a new API key as `OTARI_API_KEY`, which the gateway accepts and
47
+ the tests send. The gateway doesn't start while one of these is unset; for a provider you don't test, any placeholder
48
+ value works. Then start the gateway and run the integration tests:
49
+
50
+ ```bash
51
+ export OTARI_API_KEY="tk-$(python3 -c 'import secrets; print(secrets.token_urlsafe(48))')"
52
+ docker compose up -d --wait
53
+ hatch run test:integration
54
+ ```
55
+
56
+ Stop the gateway afterward with `docker compose down`.
57
+
58
+ To run the chat generator and embedder tests against otari.ai instead, export an otari.ai API key as `OTARI_API_KEY`
59
+ and the API root of your account's region as `OTARI_API_BASE_URL`, for example `https://eu.api.otari.ai/api/v1`, and
60
+ run:
61
+
62
+ ```bash
63
+ hatch run test:integration -k "(chat_generator or embedder) and not cohere and not anthropic"
64
+ ```
@@ -0,0 +1,18 @@
1
+ haystack_integrations/common/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ haystack_integrations/common/otari/__init__.py,sha256=eHD7xrty2PCky_gG3ty19rpM4WfV32TyytM7gJODwl4,110
3
+ haystack_integrations/common/otari/utils.py,sha256=fxkCNodD3nAN3UYFBh0PDEaxfWfwe1XmUgQaUNN3jek,1071
4
+ haystack_integrations/components/embedders/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ haystack_integrations/components/embedders/otari/__init__.py,sha256=TYhNoEdMZswpPmiqcSQcSI5E6J0m_ssthlrOHKiBzRg,267
6
+ haystack_integrations/components/embedders/otari/document_embedder.py,sha256=vFJ0EyAqh-ARIwsxanNJjV_ASiBJ1TVNxPgc1MRAmF8,11497
7
+ haystack_integrations/components/embedders/otari/text_embedder.py,sha256=wrn6hpQtbCIB7ham_UO7WQO_5ChGuPaV1TGnWJRY5OQ,5353
8
+ haystack_integrations/components/generators/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ haystack_integrations/components/generators/otari/__init__.py,sha256=aVL6rij5LwMpAOhghotBTmLx7YrwB1qx5JA7q-ii7-o,197
10
+ haystack_integrations/components/generators/otari/chat/__init__.py,sha256=crbxOVBJC9-e07P1kULxYdKeo1k07hqKbq8y3i-m1GE,192
11
+ haystack_integrations/components/generators/otari/chat/chat_generator.py,sha256=2hcUoF7GSrSIoXqWvILP8vcYTVYVWviJucg15a7tFa4,27372
12
+ haystack_integrations/components/rankers/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
+ haystack_integrations/components/rankers/otari/__init__.py,sha256=5IshA5SXtLksLCaB6N8pYZfYBIlyThV1yKld2C1Jvd8,170
14
+ haystack_integrations/components/rankers/otari/ranker.py,sha256=UB3cTatwYEOqu1d_wpiVJyN99MykNxSe2IQ64oDL-hs,11036
15
+ otari_haystack-1.0.0.dist-info/METADATA,sha256=Sh9I1D3Hqb9p7I6M88oaMGr1KLZEwz3lAA9CzwtKlf4,2989
16
+ otari_haystack-1.0.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
17
+ otari_haystack-1.0.0.dist-info/licenses/LICENSE.txt,sha256=OrAtTu4aPmrTjKDSTzkSPgo_ji6NOMWO2N9JOTFyAzM,11350
18
+ otari_haystack-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.32.4
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2023-present deepset GmbH
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.