perplexity-haystack 0.1.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.
- haystack_integrations/components/embedders/perplexity/__init__.py +12 -0
- haystack_integrations/components/embedders/perplexity/document_embedder.py +165 -0
- haystack_integrations/components/embedders/perplexity/text_embedder.py +140 -0
- haystack_integrations/components/embedders/py.typed +0 -0
- haystack_integrations/components/generators/perplexity/__init__.py +9 -0
- haystack_integrations/components/generators/perplexity/chat/__init__.py +9 -0
- haystack_integrations/components/generators/perplexity/chat/chat_generator.py +175 -0
- haystack_integrations/components/generators/py.typed +0 -0
- haystack_integrations/components/websearch/perplexity/__init__.py +9 -0
- haystack_integrations/components/websearch/perplexity/perplexity_websearch.py +191 -0
- haystack_integrations/components/websearch/py.typed +0 -0
- perplexity_haystack-0.1.0.dist-info/METADATA +41 -0
- perplexity_haystack-0.1.0.dist-info/RECORD +15 -0
- perplexity_haystack-0.1.0.dist-info/WHEEL +4 -0
- perplexity_haystack-0.1.0.dist-info/licenses/LICENSE.txt +201 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2022-present deepset GmbH <info@deepset.ai>
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
from haystack_integrations.components.embedders.perplexity.document_embedder import (
|
|
6
|
+
PerplexityDocumentEmbedder,
|
|
7
|
+
)
|
|
8
|
+
from haystack_integrations.components.embedders.perplexity.text_embedder import (
|
|
9
|
+
PerplexityTextEmbedder,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
__all__ = ["PerplexityDocumentEmbedder", "PerplexityTextEmbedder"]
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2022-present deepset GmbH <info@deepset.ai>
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
import importlib.metadata
|
|
6
|
+
from typing import Any, ClassVar
|
|
7
|
+
|
|
8
|
+
from haystack import component, default_from_dict, default_to_dict
|
|
9
|
+
from haystack.components.embedders import OpenAIDocumentEmbedder
|
|
10
|
+
from haystack.utils.auth import Secret
|
|
11
|
+
|
|
12
|
+
_INTEGRATION_SLUG = "haystack"
|
|
13
|
+
_PACKAGE_NAME = "perplexity-haystack"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _attribution_header() -> str:
|
|
17
|
+
try:
|
|
18
|
+
version = importlib.metadata.version(_PACKAGE_NAME)
|
|
19
|
+
except importlib.metadata.PackageNotFoundError:
|
|
20
|
+
version = "unknown"
|
|
21
|
+
return f"{_INTEGRATION_SLUG}/{version}"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _http_client_kwargs_with_attribution(
|
|
25
|
+
http_client_kwargs: dict[str, Any] | None,
|
|
26
|
+
) -> dict[str, Any]:
|
|
27
|
+
kwargs = dict(http_client_kwargs or {})
|
|
28
|
+
headers = dict(kwargs.get("headers", {}))
|
|
29
|
+
headers["X-Pplx-Integration"] = _attribution_header()
|
|
30
|
+
kwargs["headers"] = headers
|
|
31
|
+
return kwargs
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@component
|
|
35
|
+
class PerplexityDocumentEmbedder(OpenAIDocumentEmbedder):
|
|
36
|
+
"""
|
|
37
|
+
A component for computing Document embeddings using Perplexity models.
|
|
38
|
+
|
|
39
|
+
The embedding of each Document is stored in the `embedding` field of the Document.
|
|
40
|
+
For supported models, see the
|
|
41
|
+
[Perplexity Embeddings API reference](https://docs.perplexity.ai/api-reference/embeddings-post).
|
|
42
|
+
|
|
43
|
+
Usage example:
|
|
44
|
+
```python
|
|
45
|
+
from haystack import Document
|
|
46
|
+
from haystack_integrations.components.embedders.perplexity import PerplexityDocumentEmbedder
|
|
47
|
+
|
|
48
|
+
doc = Document(content="I love pizza!")
|
|
49
|
+
|
|
50
|
+
document_embedder = PerplexityDocumentEmbedder()
|
|
51
|
+
|
|
52
|
+
result = document_embedder.run([doc])
|
|
53
|
+
print(result['documents'][0].embedding)
|
|
54
|
+
```
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
SUPPORTED_MODELS: ClassVar[list[str]] = [
|
|
58
|
+
"pplx-embed-v1-0.6b",
|
|
59
|
+
"pplx-embed-v1-4b",
|
|
60
|
+
]
|
|
61
|
+
"""A list of models supported by the Perplexity Embeddings API.
|
|
62
|
+
See https://docs.perplexity.ai/api-reference/embeddings-post for the current list of model IDs."""
|
|
63
|
+
|
|
64
|
+
def __init__(
|
|
65
|
+
self,
|
|
66
|
+
*,
|
|
67
|
+
api_key: Secret = Secret.from_env_var("PERPLEXITY_API_KEY"),
|
|
68
|
+
model: str = "pplx-embed-v1-0.6b",
|
|
69
|
+
api_base_url: str | None = "https://api.perplexity.ai/v1",
|
|
70
|
+
prefix: str = "",
|
|
71
|
+
suffix: str = "",
|
|
72
|
+
batch_size: int = 32,
|
|
73
|
+
progress_bar: bool = True,
|
|
74
|
+
meta_fields_to_embed: list[str] | None = None,
|
|
75
|
+
embedding_separator: str = "\n",
|
|
76
|
+
timeout: float | None = None,
|
|
77
|
+
max_retries: int | None = None,
|
|
78
|
+
http_client_kwargs: dict[str, Any] | None = None,
|
|
79
|
+
) -> None:
|
|
80
|
+
"""
|
|
81
|
+
Creates a PerplexityDocumentEmbedder component.
|
|
82
|
+
|
|
83
|
+
:param api_key:
|
|
84
|
+
The Perplexity API key.
|
|
85
|
+
:param model:
|
|
86
|
+
The name of the model to use.
|
|
87
|
+
:param api_base_url:
|
|
88
|
+
The Perplexity API base URL.
|
|
89
|
+
:param prefix:
|
|
90
|
+
A string to add to the beginning of each text.
|
|
91
|
+
:param suffix:
|
|
92
|
+
A string to add to the end of each text.
|
|
93
|
+
:param batch_size:
|
|
94
|
+
Number of Documents to encode at once.
|
|
95
|
+
:param progress_bar:
|
|
96
|
+
Whether to show a progress bar or not. Can be helpful to disable in production deployments to keep
|
|
97
|
+
the logs clean.
|
|
98
|
+
:param meta_fields_to_embed:
|
|
99
|
+
List of meta fields that should be embedded along with the Document text.
|
|
100
|
+
:param embedding_separator:
|
|
101
|
+
Separator used to concatenate the meta fields to the Document text.
|
|
102
|
+
:param timeout:
|
|
103
|
+
Timeout for Perplexity client calls. If not set, it defaults to either the `OPENAI_TIMEOUT` environment
|
|
104
|
+
variable, or 30 seconds.
|
|
105
|
+
:param max_retries:
|
|
106
|
+
Maximum number of retries to contact Perplexity after an internal error.
|
|
107
|
+
If not set, it defaults to either the `OPENAI_MAX_RETRIES` environment variable, or set to 5.
|
|
108
|
+
:param http_client_kwargs:
|
|
109
|
+
A dictionary of keyword arguments to configure a custom `httpx.Client`or `httpx.AsyncClient`.
|
|
110
|
+
For more information, see the [HTTPX documentation](https://www.python-httpx.org/api/#client).
|
|
111
|
+
"""
|
|
112
|
+
super(PerplexityDocumentEmbedder, self).__init__( # noqa: UP008
|
|
113
|
+
api_key=api_key,
|
|
114
|
+
model=model,
|
|
115
|
+
dimensions=None,
|
|
116
|
+
api_base_url=api_base_url,
|
|
117
|
+
organization=None,
|
|
118
|
+
prefix=prefix,
|
|
119
|
+
suffix=suffix,
|
|
120
|
+
batch_size=batch_size,
|
|
121
|
+
progress_bar=progress_bar,
|
|
122
|
+
meta_fields_to_embed=meta_fields_to_embed,
|
|
123
|
+
embedding_separator=embedding_separator,
|
|
124
|
+
timeout=timeout,
|
|
125
|
+
max_retries=max_retries,
|
|
126
|
+
http_client_kwargs=_http_client_kwargs_with_attribution(http_client_kwargs),
|
|
127
|
+
)
|
|
128
|
+
self.http_client_kwargs = http_client_kwargs
|
|
129
|
+
self.timeout = timeout
|
|
130
|
+
self.max_retries = max_retries
|
|
131
|
+
|
|
132
|
+
def to_dict(self) -> dict[str, Any]:
|
|
133
|
+
"""
|
|
134
|
+
Serializes the component to a dictionary.
|
|
135
|
+
|
|
136
|
+
:returns:
|
|
137
|
+
Dictionary with serialized data.
|
|
138
|
+
"""
|
|
139
|
+
return default_to_dict(
|
|
140
|
+
self,
|
|
141
|
+
api_key=self.api_key.to_dict(),
|
|
142
|
+
model=self.model,
|
|
143
|
+
api_base_url=self.api_base_url,
|
|
144
|
+
prefix=self.prefix,
|
|
145
|
+
suffix=self.suffix,
|
|
146
|
+
batch_size=self.batch_size,
|
|
147
|
+
progress_bar=self.progress_bar,
|
|
148
|
+
meta_fields_to_embed=self.meta_fields_to_embed,
|
|
149
|
+
embedding_separator=self.embedding_separator,
|
|
150
|
+
timeout=self.timeout,
|
|
151
|
+
max_retries=self.max_retries,
|
|
152
|
+
http_client_kwargs=self.http_client_kwargs,
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
@classmethod
|
|
156
|
+
def from_dict(cls, data: dict[str, Any]) -> "PerplexityDocumentEmbedder":
|
|
157
|
+
"""
|
|
158
|
+
Deserializes the component from a dictionary.
|
|
159
|
+
|
|
160
|
+
:param data:
|
|
161
|
+
Dictionary to deserialize from.
|
|
162
|
+
:returns:
|
|
163
|
+
Deserialized component.
|
|
164
|
+
"""
|
|
165
|
+
return default_from_dict(cls, data)
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2022-present deepset GmbH <info@deepset.ai>
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
import importlib.metadata
|
|
6
|
+
from typing import Any, ClassVar
|
|
7
|
+
|
|
8
|
+
from haystack import component, default_from_dict, default_to_dict
|
|
9
|
+
from haystack.components.embedders import OpenAITextEmbedder
|
|
10
|
+
from haystack.utils.auth import Secret
|
|
11
|
+
|
|
12
|
+
_INTEGRATION_SLUG = "haystack"
|
|
13
|
+
_PACKAGE_NAME = "perplexity-haystack"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _attribution_header() -> str:
|
|
17
|
+
try:
|
|
18
|
+
version = importlib.metadata.version(_PACKAGE_NAME)
|
|
19
|
+
except importlib.metadata.PackageNotFoundError:
|
|
20
|
+
version = "unknown"
|
|
21
|
+
return f"{_INTEGRATION_SLUG}/{version}"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _http_client_kwargs_with_attribution(
|
|
25
|
+
http_client_kwargs: dict[str, Any] | None,
|
|
26
|
+
) -> dict[str, Any]:
|
|
27
|
+
kwargs = dict(http_client_kwargs or {})
|
|
28
|
+
headers = dict(kwargs.get("headers", {}))
|
|
29
|
+
headers["X-Pplx-Integration"] = _attribution_header()
|
|
30
|
+
kwargs["headers"] = headers
|
|
31
|
+
return kwargs
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@component
|
|
35
|
+
class PerplexityTextEmbedder(OpenAITextEmbedder):
|
|
36
|
+
"""
|
|
37
|
+
A component for embedding strings using Perplexity models.
|
|
38
|
+
|
|
39
|
+
For supported models, see the
|
|
40
|
+
[Perplexity Embeddings API reference](https://docs.perplexity.ai/api-reference/embeddings-post).
|
|
41
|
+
|
|
42
|
+
Usage example:
|
|
43
|
+
```python
|
|
44
|
+
from haystack_integrations.components.embedders.perplexity.text_embedder import PerplexityTextEmbedder
|
|
45
|
+
|
|
46
|
+
text_to_embed = "I love pizza!"
|
|
47
|
+
text_embedder = PerplexityTextEmbedder()
|
|
48
|
+
print(text_embedder.run(text_to_embed))
|
|
49
|
+
```
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
SUPPORTED_MODELS: ClassVar[list[str]] = [
|
|
53
|
+
"pplx-embed-v1-0.6b",
|
|
54
|
+
"pplx-embed-v1-4b",
|
|
55
|
+
]
|
|
56
|
+
"""A list of models supported by the Perplexity Embeddings API.
|
|
57
|
+
See https://docs.perplexity.ai/api-reference/embeddings-post for the current list of model IDs."""
|
|
58
|
+
|
|
59
|
+
def __init__(
|
|
60
|
+
self,
|
|
61
|
+
*,
|
|
62
|
+
api_key: Secret = Secret.from_env_var("PERPLEXITY_API_KEY"),
|
|
63
|
+
model: str = "pplx-embed-v1-0.6b",
|
|
64
|
+
api_base_url: str | None = "https://api.perplexity.ai/v1",
|
|
65
|
+
prefix: str = "",
|
|
66
|
+
suffix: str = "",
|
|
67
|
+
timeout: float | None = None,
|
|
68
|
+
max_retries: int | None = None,
|
|
69
|
+
http_client_kwargs: dict[str, Any] | None = None,
|
|
70
|
+
) -> None:
|
|
71
|
+
"""
|
|
72
|
+
Creates a PerplexityTextEmbedder component.
|
|
73
|
+
|
|
74
|
+
:param api_key:
|
|
75
|
+
The Perplexity API key.
|
|
76
|
+
:param model:
|
|
77
|
+
The name of the Perplexity embedding model to be used.
|
|
78
|
+
:param api_base_url:
|
|
79
|
+
The Perplexity API base URL.
|
|
80
|
+
:param prefix:
|
|
81
|
+
A string to add to the beginning of each text.
|
|
82
|
+
:param suffix:
|
|
83
|
+
A string to add to the end of each text.
|
|
84
|
+
:param timeout:
|
|
85
|
+
Timeout for Perplexity client calls. If not set, it defaults to either the `OPENAI_TIMEOUT` environment
|
|
86
|
+
variable, or 30 seconds.
|
|
87
|
+
:param max_retries:
|
|
88
|
+
Maximum number of retries to contact Perplexity after an internal error.
|
|
89
|
+
If not set, it defaults to either the `OPENAI_MAX_RETRIES` environment variable, or set to 5.
|
|
90
|
+
:param http_client_kwargs:
|
|
91
|
+
A dictionary of keyword arguments to configure a custom `httpx.Client`or `httpx.AsyncClient`.
|
|
92
|
+
For more information, see the [HTTPX documentation](https://www.python-httpx.org/api/#client).
|
|
93
|
+
"""
|
|
94
|
+
|
|
95
|
+
super(PerplexityTextEmbedder, self).__init__( # noqa: UP008
|
|
96
|
+
api_key=api_key,
|
|
97
|
+
model=model,
|
|
98
|
+
dimensions=None,
|
|
99
|
+
api_base_url=api_base_url,
|
|
100
|
+
organization=None,
|
|
101
|
+
prefix=prefix,
|
|
102
|
+
suffix=suffix,
|
|
103
|
+
timeout=timeout,
|
|
104
|
+
max_retries=max_retries,
|
|
105
|
+
http_client_kwargs=_http_client_kwargs_with_attribution(http_client_kwargs),
|
|
106
|
+
)
|
|
107
|
+
self.http_client_kwargs = http_client_kwargs
|
|
108
|
+
self.timeout = timeout
|
|
109
|
+
self.max_retries = max_retries
|
|
110
|
+
|
|
111
|
+
def to_dict(self) -> dict[str, Any]:
|
|
112
|
+
"""
|
|
113
|
+
Serializes the component to a dictionary.
|
|
114
|
+
|
|
115
|
+
:returns:
|
|
116
|
+
Dictionary with serialized data.
|
|
117
|
+
"""
|
|
118
|
+
return default_to_dict(
|
|
119
|
+
self,
|
|
120
|
+
api_key=self.api_key.to_dict(),
|
|
121
|
+
model=self.model,
|
|
122
|
+
api_base_url=self.api_base_url,
|
|
123
|
+
prefix=self.prefix,
|
|
124
|
+
suffix=self.suffix,
|
|
125
|
+
timeout=self.timeout,
|
|
126
|
+
max_retries=self.max_retries,
|
|
127
|
+
http_client_kwargs=self.http_client_kwargs,
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
@classmethod
|
|
131
|
+
def from_dict(cls, data: dict[str, Any]) -> "PerplexityTextEmbedder":
|
|
132
|
+
"""
|
|
133
|
+
Deserializes the component from a dictionary.
|
|
134
|
+
|
|
135
|
+
:param data:
|
|
136
|
+
Dictionary to deserialize from.
|
|
137
|
+
:returns:
|
|
138
|
+
Deserialized component.
|
|
139
|
+
"""
|
|
140
|
+
return default_from_dict(cls, data)
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2022-present deepset GmbH <info@deepset.ai>
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
from haystack_integrations.components.generators.perplexity.chat.chat_generator import (
|
|
6
|
+
PerplexityChatGenerator,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
__all__ = ["PerplexityChatGenerator"]
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2022-present deepset GmbH <info@deepset.ai>
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
from haystack_integrations.components.generators.perplexity.chat.chat_generator import (
|
|
6
|
+
PerplexityChatGenerator,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
__all__ = ["PerplexityChatGenerator"]
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2022-present deepset GmbH <info@deepset.ai>
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
import importlib.metadata
|
|
6
|
+
from typing import Any, ClassVar
|
|
7
|
+
|
|
8
|
+
from haystack import component, default_from_dict
|
|
9
|
+
from haystack.components.generators.chat import OpenAIResponsesChatGenerator
|
|
10
|
+
from haystack.core.serialization import generate_qualified_class_name
|
|
11
|
+
from haystack.dataclasses import StreamingCallbackT
|
|
12
|
+
from haystack.tools import ToolsType, deserialize_tools_or_toolset_inplace
|
|
13
|
+
from haystack.utils import deserialize_callable
|
|
14
|
+
from haystack.utils.auth import Secret
|
|
15
|
+
|
|
16
|
+
_INTEGRATION_SLUG = "haystack"
|
|
17
|
+
_PACKAGE_NAME = "perplexity-haystack"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _attribution_header() -> str:
|
|
21
|
+
try:
|
|
22
|
+
version = importlib.metadata.version(_PACKAGE_NAME)
|
|
23
|
+
except importlib.metadata.PackageNotFoundError:
|
|
24
|
+
version = "unknown"
|
|
25
|
+
return f"{_INTEGRATION_SLUG}/{version}"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _perplexity_headers(extra_headers: dict[str, Any] | None = None) -> dict[str, Any]:
|
|
29
|
+
return {
|
|
30
|
+
**(extra_headers or {}),
|
|
31
|
+
"X-Pplx-Integration": _attribution_header(),
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _with_default_headers(client: Any, headers: dict[str, Any]) -> Any:
|
|
36
|
+
with_options = getattr(client, "with_options", None)
|
|
37
|
+
if with_options is not None:
|
|
38
|
+
return with_options(default_headers=headers)
|
|
39
|
+
|
|
40
|
+
client._custom_headers = {**getattr(client, "_custom_headers", {}), **headers}
|
|
41
|
+
return client
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
@component
|
|
45
|
+
class PerplexityChatGenerator(OpenAIResponsesChatGenerator):
|
|
46
|
+
"""
|
|
47
|
+
Completes chats using Perplexity models.
|
|
48
|
+
|
|
49
|
+
Powered by the Perplexity Agent API (`POST /v1/agent`, OpenAI Responses-compatible).
|
|
50
|
+
See the [Perplexity Agent API quickstart](https://docs.perplexity.ai/docs/agent-api/quickstart)
|
|
51
|
+
for details.
|
|
52
|
+
|
|
53
|
+
It uses the [ChatMessage](https://docs.haystack.deepset.ai/docs/chatmessage) format in input and output.
|
|
54
|
+
You can customize generation by passing Perplexity Agent API parameters through `generation_kwargs`.
|
|
55
|
+
|
|
56
|
+
### Usage example
|
|
57
|
+
```python
|
|
58
|
+
from haystack.dataclasses import ChatMessage
|
|
59
|
+
from haystack_integrations.components.generators.perplexity import PerplexityChatGenerator
|
|
60
|
+
|
|
61
|
+
messages = [ChatMessage.from_user("What's Natural Language Processing?")]
|
|
62
|
+
|
|
63
|
+
client = PerplexityChatGenerator()
|
|
64
|
+
response = client.run(messages)
|
|
65
|
+
print(response)
|
|
66
|
+
```
|
|
67
|
+
"""
|
|
68
|
+
|
|
69
|
+
SUPPORTED_MODELS: ClassVar[list[str]] = [
|
|
70
|
+
"openai/gpt-5.5",
|
|
71
|
+
"openai/gpt-5.4",
|
|
72
|
+
"openai/gpt-4o",
|
|
73
|
+
"anthropic/claude-sonnet-4-6",
|
|
74
|
+
"xai/grok-4-1",
|
|
75
|
+
"google/gemini-3-flash-preview",
|
|
76
|
+
]
|
|
77
|
+
"""A non-exhaustive list of Agent API models supported by this component.
|
|
78
|
+
See https://docs.perplexity.ai/docs/agent-api/models for the full and current list."""
|
|
79
|
+
|
|
80
|
+
def __init__(
|
|
81
|
+
self,
|
|
82
|
+
*,
|
|
83
|
+
api_key: Secret = Secret.from_env_var("PERPLEXITY_API_KEY"),
|
|
84
|
+
model: str = "openai/gpt-5.4",
|
|
85
|
+
api_base_url: str | None = "https://api.perplexity.ai/v1",
|
|
86
|
+
streaming_callback: StreamingCallbackT | None = None,
|
|
87
|
+
organization: str | None = None,
|
|
88
|
+
generation_kwargs: dict[str, Any] | None = None,
|
|
89
|
+
tools: ToolsType | list[dict[str, Any]] | None = None,
|
|
90
|
+
tools_strict: bool = False,
|
|
91
|
+
timeout: float | None = None,
|
|
92
|
+
extra_headers: dict[str, Any] | None = None,
|
|
93
|
+
max_retries: int | None = None,
|
|
94
|
+
http_client_kwargs: dict[str, Any] | None = None,
|
|
95
|
+
) -> None:
|
|
96
|
+
"""
|
|
97
|
+
Initialize the PerplexityChatGenerator component.
|
|
98
|
+
|
|
99
|
+
:param api_key:
|
|
100
|
+
The Perplexity API key.
|
|
101
|
+
:param model:
|
|
102
|
+
The Perplexity Agent API model to use.
|
|
103
|
+
:param api_base_url:
|
|
104
|
+
The Perplexity API base URL.
|
|
105
|
+
:param streaming_callback:
|
|
106
|
+
A callback function called when a new token is received from the stream.
|
|
107
|
+
:param organization:
|
|
108
|
+
Organization ID forwarded to the OpenAI-compatible client.
|
|
109
|
+
:param generation_kwargs:
|
|
110
|
+
Additional parameters sent directly to the Perplexity Agent API.
|
|
111
|
+
:param tools:
|
|
112
|
+
A list of Haystack tools, a Toolset, or OpenAI-compatible tool definitions.
|
|
113
|
+
:param tools_strict:
|
|
114
|
+
Whether to enable strict schema adherence for Haystack tool calls.
|
|
115
|
+
:param timeout:
|
|
116
|
+
Timeout for Perplexity API calls.
|
|
117
|
+
:param extra_headers:
|
|
118
|
+
Additional HTTP headers to include in requests to the Perplexity API.
|
|
119
|
+
:param max_retries:
|
|
120
|
+
Maximum number of retries to contact Perplexity after an internal error.
|
|
121
|
+
:param http_client_kwargs:
|
|
122
|
+
A dictionary of keyword arguments to configure a custom `httpx.Client` or `httpx.AsyncClient`.
|
|
123
|
+
"""
|
|
124
|
+
self.extra_headers = extra_headers
|
|
125
|
+
super(PerplexityChatGenerator, self).__init__( # noqa: UP008
|
|
126
|
+
api_key=api_key,
|
|
127
|
+
model=model,
|
|
128
|
+
streaming_callback=streaming_callback,
|
|
129
|
+
api_base_url=api_base_url,
|
|
130
|
+
organization=organization,
|
|
131
|
+
generation_kwargs=generation_kwargs,
|
|
132
|
+
timeout=timeout,
|
|
133
|
+
max_retries=max_retries,
|
|
134
|
+
tools=tools,
|
|
135
|
+
tools_strict=tools_strict,
|
|
136
|
+
http_client_kwargs=http_client_kwargs,
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
default_headers = _perplexity_headers(extra_headers)
|
|
140
|
+
self.client = _with_default_headers(self.client, default_headers)
|
|
141
|
+
self.async_client = _with_default_headers(self.async_client, default_headers)
|
|
142
|
+
|
|
143
|
+
def to_dict(self) -> dict[str, Any]:
|
|
144
|
+
"""
|
|
145
|
+
Serialize this component to a dictionary.
|
|
146
|
+
|
|
147
|
+
:returns:
|
|
148
|
+
The serialized component as a dictionary.
|
|
149
|
+
"""
|
|
150
|
+
data = super(PerplexityChatGenerator, self).to_dict() # noqa: UP008
|
|
151
|
+
data["type"] = generate_qualified_class_name(type(self))
|
|
152
|
+
data["init_parameters"]["extra_headers"] = self.extra_headers
|
|
153
|
+
return data
|
|
154
|
+
|
|
155
|
+
@classmethod
|
|
156
|
+
def from_dict(cls, data: dict[str, Any]) -> "PerplexityChatGenerator":
|
|
157
|
+
"""
|
|
158
|
+
Deserialize this component from a dictionary.
|
|
159
|
+
|
|
160
|
+
:param data: The dictionary representation of this component.
|
|
161
|
+
:returns:
|
|
162
|
+
The deserialized component instance.
|
|
163
|
+
"""
|
|
164
|
+
tools = data["init_parameters"].get("tools")
|
|
165
|
+
if tools and (
|
|
166
|
+
(isinstance(tools, dict) and tools.get("type") == "haystack.tools.toolset.Toolset")
|
|
167
|
+
or (isinstance(tools, list) and tools[0].get("type") == "haystack.tools.tool.Tool")
|
|
168
|
+
):
|
|
169
|
+
deserialize_tools_or_toolset_inplace(data["init_parameters"], key="tools")
|
|
170
|
+
|
|
171
|
+
serialized_callback_handler = data.get("init_parameters", {}).get("streaming_callback")
|
|
172
|
+
if serialized_callback_handler:
|
|
173
|
+
data["init_parameters"]["streaming_callback"] = deserialize_callable(serialized_callback_handler)
|
|
174
|
+
|
|
175
|
+
return default_from_dict(cls, data)
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2022-present deepset GmbH <info@deepset.ai>
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
from haystack_integrations.components.websearch.perplexity.perplexity_websearch import (
|
|
6
|
+
PerplexityWebSearch,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
__all__ = ["PerplexityWebSearch"]
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2022-present deepset GmbH <info@deepset.ai>
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
import importlib.metadata
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
import httpx
|
|
9
|
+
from haystack import Document, component, logging
|
|
10
|
+
from haystack.utils import Secret
|
|
11
|
+
|
|
12
|
+
logger = logging.getLogger(__name__)
|
|
13
|
+
|
|
14
|
+
PERPLEXITY_SEARCH_URL = "https://api.perplexity.ai/search"
|
|
15
|
+
_INTEGRATION_SLUG = "haystack"
|
|
16
|
+
_PACKAGE_NAME = "perplexity-haystack"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _attribution_header() -> str:
|
|
20
|
+
try:
|
|
21
|
+
version = importlib.metadata.version(_PACKAGE_NAME)
|
|
22
|
+
except importlib.metadata.PackageNotFoundError:
|
|
23
|
+
version = "unknown"
|
|
24
|
+
return f"{_INTEGRATION_SLUG}/{version}"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@component
|
|
28
|
+
class PerplexityWebSearch:
|
|
29
|
+
"""
|
|
30
|
+
A component that uses Perplexity to search the web and return results as Haystack Documents.
|
|
31
|
+
|
|
32
|
+
This component wraps the Perplexity Search API, enabling web search queries that return
|
|
33
|
+
structured documents with content and links.
|
|
34
|
+
|
|
35
|
+
You need a Perplexity API key from [perplexity.ai](https://www.perplexity.ai/).
|
|
36
|
+
|
|
37
|
+
### Usage example
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
from haystack_integrations.components.websearch.perplexity import PerplexityWebSearch
|
|
41
|
+
from haystack.utils import Secret
|
|
42
|
+
|
|
43
|
+
websearch = PerplexityWebSearch(
|
|
44
|
+
api_key=Secret.from_env_var("PERPLEXITY_API_KEY"),
|
|
45
|
+
top_k=5,
|
|
46
|
+
)
|
|
47
|
+
result = websearch.run(query="What is Haystack by deepset?")
|
|
48
|
+
documents = result["documents"]
|
|
49
|
+
links = result["links"]
|
|
50
|
+
```
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
def __init__(
|
|
54
|
+
self,
|
|
55
|
+
*,
|
|
56
|
+
api_key: Secret = Secret.from_env_var("PERPLEXITY_API_KEY"),
|
|
57
|
+
top_k: int | None = 10,
|
|
58
|
+
search_params: dict[str, Any] | None = None,
|
|
59
|
+
timeout: float = 30.0,
|
|
60
|
+
) -> None:
|
|
61
|
+
"""
|
|
62
|
+
Initialize the PerplexityWebSearch component.
|
|
63
|
+
|
|
64
|
+
:param api_key:
|
|
65
|
+
API key for Perplexity. Defaults to the `PERPLEXITY_API_KEY` environment variable.
|
|
66
|
+
:param top_k:
|
|
67
|
+
Maximum number of results to return. Maps to the `max_results` API parameter (1-20).
|
|
68
|
+
:param search_params:
|
|
69
|
+
Additional parameters passed to the Perplexity Search API.
|
|
70
|
+
See the [Perplexity Search API reference](https://docs.perplexity.ai/api-reference/search-post)
|
|
71
|
+
for available options. Supported keys include: `max_tokens_per_page`, `country`,
|
|
72
|
+
`search_recency_filter`, `search_domain_filter`, `search_language_filter`,
|
|
73
|
+
`last_updated_after_filter`, `last_updated_before_filter`,
|
|
74
|
+
`search_after_date_filter`, `search_before_date_filter`.
|
|
75
|
+
:param timeout:
|
|
76
|
+
Request timeout in seconds.
|
|
77
|
+
"""
|
|
78
|
+
self.api_key = api_key
|
|
79
|
+
self.top_k = top_k
|
|
80
|
+
self.search_params = search_params
|
|
81
|
+
self.timeout = timeout
|
|
82
|
+
self._client: httpx.Client | None = None
|
|
83
|
+
self._async_client: httpx.AsyncClient | None = None
|
|
84
|
+
|
|
85
|
+
def _build_headers(self) -> dict[str, str]:
|
|
86
|
+
return {
|
|
87
|
+
"Authorization": f"Bearer {self.api_key.resolve_value()}",
|
|
88
|
+
"Content-Type": "application/json",
|
|
89
|
+
"X-Pplx-Integration": _attribution_header(),
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
def _build_body(self, query: str, search_params: dict[str, Any] | None) -> dict[str, Any]:
|
|
93
|
+
params = (search_params if search_params is not None else self.search_params or {}).copy()
|
|
94
|
+
if "max_results" not in params and self.top_k is not None:
|
|
95
|
+
params["max_results"] = self.top_k
|
|
96
|
+
body: dict[str, Any] = {"query": query}
|
|
97
|
+
body.update({k: v for k, v in params.items() if v is not None})
|
|
98
|
+
return body
|
|
99
|
+
|
|
100
|
+
def warm_up(self) -> None:
|
|
101
|
+
"""
|
|
102
|
+
Initialize the sync and async HTTP clients.
|
|
103
|
+
|
|
104
|
+
Called automatically on first use. Can be called explicitly to avoid cold-start latency.
|
|
105
|
+
"""
|
|
106
|
+
if self._client is None:
|
|
107
|
+
self._client = httpx.Client(timeout=self.timeout)
|
|
108
|
+
if self._async_client is None:
|
|
109
|
+
self._async_client = httpx.AsyncClient(timeout=self.timeout)
|
|
110
|
+
|
|
111
|
+
@component.output_types(documents=list[Document], links=list[str])
|
|
112
|
+
def run(
|
|
113
|
+
self,
|
|
114
|
+
query: str,
|
|
115
|
+
search_params: dict[str, Any] | None = None,
|
|
116
|
+
) -> dict[str, list[Document] | list[str]]:
|
|
117
|
+
"""
|
|
118
|
+
Search the web using Perplexity and return results as Documents.
|
|
119
|
+
|
|
120
|
+
:param query: Search query string.
|
|
121
|
+
:param search_params:
|
|
122
|
+
Optional per-run override of search parameters.
|
|
123
|
+
If provided, fully replaces the init-time `search_params`.
|
|
124
|
+
:returns: A dictionary with:
|
|
125
|
+
- `documents`: List of Documents containing search result content.
|
|
126
|
+
- `links`: List of URLs from the search results.
|
|
127
|
+
"""
|
|
128
|
+
if self._client is None:
|
|
129
|
+
self.warm_up()
|
|
130
|
+
|
|
131
|
+
response = self._client.post( # type: ignore[union-attr]
|
|
132
|
+
PERPLEXITY_SEARCH_URL,
|
|
133
|
+
headers=self._build_headers(),
|
|
134
|
+
json=self._build_body(query, search_params),
|
|
135
|
+
)
|
|
136
|
+
response.raise_for_status()
|
|
137
|
+
return self._parse_response(response.json())
|
|
138
|
+
|
|
139
|
+
@component.output_types(documents=list[Document], links=list[str])
|
|
140
|
+
async def run_async(
|
|
141
|
+
self,
|
|
142
|
+
query: str,
|
|
143
|
+
search_params: dict[str, Any] | None = None,
|
|
144
|
+
) -> dict[str, list[Document] | list[str]]:
|
|
145
|
+
"""
|
|
146
|
+
Asynchronously search the web using Perplexity and return results as Documents.
|
|
147
|
+
|
|
148
|
+
:param query: Search query string.
|
|
149
|
+
:param search_params:
|
|
150
|
+
Optional per-run override of search parameters.
|
|
151
|
+
If provided, fully replaces the init-time `search_params`.
|
|
152
|
+
:returns: A dictionary with:
|
|
153
|
+
- `documents`: List of Documents containing search result content.
|
|
154
|
+
- `links`: List of URLs from the search results.
|
|
155
|
+
"""
|
|
156
|
+
if self._async_client is None:
|
|
157
|
+
self.warm_up()
|
|
158
|
+
|
|
159
|
+
response = await self._async_client.post( # type: ignore[union-attr]
|
|
160
|
+
PERPLEXITY_SEARCH_URL,
|
|
161
|
+
headers=self._build_headers(),
|
|
162
|
+
json=self._build_body(query, search_params),
|
|
163
|
+
)
|
|
164
|
+
response.raise_for_status()
|
|
165
|
+
return self._parse_response(response.json())
|
|
166
|
+
|
|
167
|
+
@staticmethod
|
|
168
|
+
def _parse_response(response: dict[str, Any]) -> dict[str, Any]:
|
|
169
|
+
"""
|
|
170
|
+
Convert a Perplexity search response to Haystack Documents and links.
|
|
171
|
+
|
|
172
|
+
:param response: Perplexity search response dictionary.
|
|
173
|
+
:returns: Dictionary with `documents` and `links` keys.
|
|
174
|
+
"""
|
|
175
|
+
documents: list[Document] = []
|
|
176
|
+
links: list[str] = []
|
|
177
|
+
|
|
178
|
+
for result in response.get("results", []):
|
|
179
|
+
url = result.get("url", "")
|
|
180
|
+
title = result.get("title", "")
|
|
181
|
+
snippet = result.get("snippet", "")
|
|
182
|
+
meta = {"title": title, "url": url}
|
|
183
|
+
for optional_key in ("date", "last_updated"):
|
|
184
|
+
value = result.get(optional_key)
|
|
185
|
+
if value is not None:
|
|
186
|
+
meta[optional_key] = value
|
|
187
|
+
documents.append(Document(content=snippet, meta=meta))
|
|
188
|
+
if url:
|
|
189
|
+
links.append(url)
|
|
190
|
+
|
|
191
|
+
return {"documents": documents, "links": links}
|
|
File without changes
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: perplexity-haystack
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Haystack integration for Perplexity Web Search
|
|
5
|
+
Project-URL: Documentation, https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/perplexity#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/perplexity
|
|
8
|
+
Author-email: deepset GmbH <info@deepset.ai>
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE.txt
|
|
11
|
+
Keywords: AI Search,Haystack,Perplexity,Web Search
|
|
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>=2.24.1
|
|
24
|
+
Requires-Dist: httpx>=0.27.0
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# perplexity-haystack
|
|
28
|
+
|
|
29
|
+
[](https://pypi.org/project/perplexity-haystack)
|
|
30
|
+
[](https://pypi.org/project/perplexity-haystack)
|
|
31
|
+
|
|
32
|
+
- [Integration page](https://haystack.deepset.ai/integrations/perplexity)
|
|
33
|
+
- [Changelog](https://github.com/deepset-ai/haystack-core-integrations/blob/main/integrations/perplexity/CHANGELOG.md)
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Contributing
|
|
38
|
+
|
|
39
|
+
Refer to the general [Contribution Guidelines](https://github.com/deepset-ai/haystack-core-integrations/blob/main/CONTRIBUTING.md).
|
|
40
|
+
|
|
41
|
+
To run integration tests locally, you need to export the `PERPLEXITY_API_KEY` environment variable.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
haystack_integrations/components/embedders/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
haystack_integrations/components/embedders/perplexity/__init__.py,sha256=urlizaaYLxiBdkcyNUtVHlOHyMXR0-c4SVgdvUGw550,411
|
|
3
|
+
haystack_integrations/components/embedders/perplexity/document_embedder.py,sha256=elxQNI74tb3MKzdugECqFzJ54LV6JmPFVizURQOGrkE,5970
|
|
4
|
+
haystack_integrations/components/embedders/perplexity/text_embedder.py,sha256=FMWm02dCJqWHP8sogFeJ4Gl0BqFs9dfVRXqhJhL5mdo,4760
|
|
5
|
+
haystack_integrations/components/generators/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
haystack_integrations/components/generators/perplexity/__init__.py,sha256=PXu_E8nogOoVD73ftOD7tQT31O-DmWLNf5TTK5UCvr4,270
|
|
7
|
+
haystack_integrations/components/generators/perplexity/chat/__init__.py,sha256=PXu_E8nogOoVD73ftOD7tQT31O-DmWLNf5TTK5UCvr4,270
|
|
8
|
+
haystack_integrations/components/generators/perplexity/chat/chat_generator.py,sha256=n-IWj6IAgFDWvir72rhG-slGXeApc8o26YV3JKni0po,6819
|
|
9
|
+
haystack_integrations/components/websearch/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
+
haystack_integrations/components/websearch/perplexity/__init__.py,sha256=toNidyIAFqV6-IDr-cbgTLyclrTCAIWi9PiXDJ2yXZo,262
|
|
11
|
+
haystack_integrations/components/websearch/perplexity/perplexity_websearch.py,sha256=4ajbIZGrOMwshTVwuS3Vu1D2uH6bKZY2PXqrGSKH4JQ,7121
|
|
12
|
+
perplexity_haystack-0.1.0.dist-info/METADATA,sha256=VIiP4f9NH9LhDBGnG0ni38mAVIzE8jLaje3FjnOooQs,2000
|
|
13
|
+
perplexity_haystack-0.1.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
14
|
+
perplexity_haystack-0.1.0.dist-info/licenses/LICENSE.txt,sha256=OrAtTu4aPmrTjKDSTzkSPgo_ji6NOMWO2N9JOTFyAzM,11350
|
|
15
|
+
perplexity_haystack-0.1.0.dist-info/RECORD,,
|
|
@@ -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.
|