| Name | deepl-haystack JSON |
| Version |
0.3.0
JSON |
| download |
| home_page | None |
| Summary | Haystack integration with DeepL translation services provider. |
| upload_time | 2025-09-02 17:19:19 |
| maintainer | None |
| docs_url | None |
| author | None |
| requires_python | <3.14,>=3.9 |
| license | None |
| keywords |
deepl
haystack
nlp
translation
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
DeepL Haystack Integration
==========================
<p align="left">
<em>Haystack integration with DeepL translation services provider.</em>
</p>
| | |
|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| CI/CD | [](https://github.com/dribia/deepl-haystack/actions/workflows/test.yml) [](https://codecov.io/gh/dribia/deepl-haystack) [](https://github.com/dribia/deepl-haystack/actions/workflows/lint.yml) [](https://github.com/python/mypy) [](https://github.com/astral-sh/ruff) |
| Package | [](https://pypi.org/project/deepl-haystack/)   [](LICENSE) |
---
**Documentation**: [https://haystack.deepset.ai/integrations/deepl](https://haystack.deepset.ai/integrations/deepl)
**Source Code**: [https://github.com/dribia/deepl-haystack](https://github.com/dribia/deepl-haystack)
---
## Installation
This project resides in the Python Package Index (PyPI), so it can easily be installed with `pip`:
```console
pip install deepl-haystack
```
## Usage
The DeepL Haystack integration provides two Haystack components: `DeepLTextTranslator`
and `DeepLDocumentTranslator`. These components can be used to translate text and documents,
respectively, using the DeepL API.
## Examples
To run these examples you'll need a working DeepL API key.
You can get one by signing up at the [DeepL API website](https://www.deepl.com/pro#developer).
### Standalone Text Translation
```python
from haystack.utils import Secret
from deepl_haystack import DeepLTextTranslator
translator = DeepLTextTranslator(
api_key=Secret.from_token("your_api_key_here"), source_lang="EN", target_lang="ES"
)
translated_text = translator.run("Hello, world!")
print(translated_text)
# {'translation': '¡Hola, mundo!', 'meta': {'source_lang': 'EN', 'target_lang': 'ES'}}
```
### Standalone Document Translation
```python
from haystack.dataclasses import Document
from haystack.utils import Secret
from deepl_haystack import DeepLDocumentTranslator
translator = DeepLDocumentTranslator(
api_key=Secret.from_token("your_api_key_here"), source_lang="EN", target_lang="ES"
)
documents_to_translate = [
Document(content="Hello, world!"),
Document(content="Goodbye, Joe!", meta={"name": "Joe"}),
]
translated_documents = translator.run(documents_to_translate)
print("\n".join([f"{doc.content}, {doc.meta}" for doc in translated_documents]))
# ¡Hola, mundo!, {'source_lang': 'EN', 'target_lang': 'ES'}
# ¡Adiós, Joe!, {'name': 'Joe', 'source_lang': 'EN', 'target_lang': 'ES'}
```
### Haystack Pipeline Integration
```python
from haystack import Pipeline
from haystack.components.converters import TextFileToDocument
from haystack.components.writers import DocumentWriter
from haystack.dataclasses.byte_stream import ByteStream
from haystack.document_stores.in_memory import InMemoryDocumentStore
from haystack.utils import Secret
from deepl_haystack import DeepLDocumentTranslator
document_store = InMemoryDocumentStore()
pipeline = Pipeline()
pipeline.add_component(instance=TextFileToDocument(), name="converter")
pipeline.add_component(
instance=DeepLDocumentTranslator(
api_key=Secret.from_token("your_api_key_here"),
target_lang="ES",
),
name="translator",
)
pipeline.add_component(
instance=DocumentWriter(document_store=document_store), name="document_store"
)
pipeline.connect("converter", "translator")
pipeline.connect("translator", "document_store")
pipeline.run({"converter": {"sources": [ByteStream.from_string("Hello world!")]}})
print(document_store.filter_documents())
# [Document(id=..., content: '¡Hola, mundo!', meta: {'source_lang': 'EN', 'language': 'ES'})]
```
## Contributing
[uv](https://docs.astral.sh/uv/) is the best way to interact with this project, to install it,
follow the official [uv installation guide](https://docs.astral.sh/uv/getting-started/installation/).
With `uv` installed, one can install the project dependencies with:
```shell
uv sync
```
Then, to run the project unit tests:
```shell
make test-unit
```
To run the linters (`ruff` and `mypy`):
```shell
make lint
```
To apply all code formatting:
```shell
make format
```
And finally, to run the project integration tests (which actually use the DeepL API),
you should either have the `DEEPL_API_KEY` environment variable set,
or create a `.env` file:
```dotenv
DEEPL_API_KEY=your_api_key_here
```
And run:
```shell
make test-integration
```
## License
`deepl-haystack` is distributed under the terms of the
[MIT](https://opensource.org/license/mit) license.
Check the [LICENSE](./LICENSE) file for further details.
Raw data
{
"_id": null,
"home_page": null,
"name": "deepl-haystack",
"maintainer": null,
"docs_url": null,
"requires_python": "<3.14,>=3.9",
"maintainer_email": "Dribia Data Research <code@dribia.com>",
"keywords": "deepl, haystack, nlp, translation",
"author": null,
"author_email": "Albert Iribarne <iribarne@dribia.com>",
"download_url": "https://files.pythonhosted.org/packages/50/e8/fc83b6f9b290c6de1e354abed0fe37c94b1cca44102ad290286ec8da5995/deepl_haystack-0.3.0.tar.gz",
"platform": null,
"description": "DeepL Haystack Integration\n==========================\n\n<p align=\"left\">\n <em>Haystack integration with DeepL translation services provider.</em>\n</p>\n\n| | |\n|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| CI/CD | [](https://github.com/dribia/deepl-haystack/actions/workflows/test.yml) [](https://codecov.io/gh/dribia/deepl-haystack) [](https://github.com/dribia/deepl-haystack/actions/workflows/lint.yml) [](https://github.com/python/mypy) [](https://github.com/astral-sh/ruff) |\n| Package | [](https://pypi.org/project/deepl-haystack/)   [](LICENSE) |\n---\n\n**Documentation**: [https://haystack.deepset.ai/integrations/deepl](https://haystack.deepset.ai/integrations/deepl)\n\n**Source Code**: [https://github.com/dribia/deepl-haystack](https://github.com/dribia/deepl-haystack)\n\n---\n\n## Installation\n\nThis project resides in the Python Package Index (PyPI), so it can easily be installed with `pip`:\n\n```console\npip install deepl-haystack\n```\n\n## Usage\n\nThe DeepL Haystack integration provides two Haystack components: `DeepLTextTranslator`\nand `DeepLDocumentTranslator`. These components can be used to translate text and documents,\nrespectively, using the DeepL API.\n\n## Examples\n\nTo run these examples you'll need a working DeepL API key.\nYou can get one by signing up at the [DeepL API website](https://www.deepl.com/pro#developer).\n\n### Standalone Text Translation\n\n```python\nfrom haystack.utils import Secret\n\nfrom deepl_haystack import DeepLTextTranslator\n\ntranslator = DeepLTextTranslator(\n api_key=Secret.from_token(\"your_api_key_here\"), source_lang=\"EN\", target_lang=\"ES\"\n)\n\ntranslated_text = translator.run(\"Hello, world!\")\nprint(translated_text)\n# {'translation': '\u00a1Hola, mundo!', 'meta': {'source_lang': 'EN', 'target_lang': 'ES'}}\n```\n\n### Standalone Document Translation\n\n```python\nfrom haystack.dataclasses import Document\nfrom haystack.utils import Secret\n\nfrom deepl_haystack import DeepLDocumentTranslator\n\ntranslator = DeepLDocumentTranslator(\n api_key=Secret.from_token(\"your_api_key_here\"), source_lang=\"EN\", target_lang=\"ES\"\n)\n\ndocuments_to_translate = [\n Document(content=\"Hello, world!\"),\n Document(content=\"Goodbye, Joe!\", meta={\"name\": \"Joe\"}),\n]\n\ntranslated_documents = translator.run(documents_to_translate)\nprint(\"\\n\".join([f\"{doc.content}, {doc.meta}\" for doc in translated_documents]))\n# \u00a1Hola, mundo!, {'source_lang': 'EN', 'target_lang': 'ES'}\n# \u00a1Adi\u00f3s, Joe!, {'name': 'Joe', 'source_lang': 'EN', 'target_lang': 'ES'}\n```\n\n### Haystack Pipeline Integration\n\n```python\nfrom haystack import Pipeline\nfrom haystack.components.converters import TextFileToDocument\nfrom haystack.components.writers import DocumentWriter\nfrom haystack.dataclasses.byte_stream import ByteStream\nfrom haystack.document_stores.in_memory import InMemoryDocumentStore\nfrom haystack.utils import Secret\n\nfrom deepl_haystack import DeepLDocumentTranslator\n\ndocument_store = InMemoryDocumentStore()\n\npipeline = Pipeline()\npipeline.add_component(instance=TextFileToDocument(), name=\"converter\")\npipeline.add_component(\n instance=DeepLDocumentTranslator(\n api_key=Secret.from_token(\"your_api_key_here\"),\n target_lang=\"ES\",\n ),\n name=\"translator\",\n)\npipeline.add_component(\n instance=DocumentWriter(document_store=document_store), name=\"document_store\"\n)\npipeline.connect(\"converter\", \"translator\")\npipeline.connect(\"translator\", \"document_store\")\npipeline.run({\"converter\": {\"sources\": [ByteStream.from_string(\"Hello world!\")]}})\nprint(document_store.filter_documents())\n# [Document(id=..., content: '\u00a1Hola, mundo!', meta: {'source_lang': 'EN', 'language': 'ES'})]\n```\n\n## Contributing\n\n[uv](https://docs.astral.sh/uv/) is the best way to interact with this project, to install it,\nfollow the official [uv installation guide](https://docs.astral.sh/uv/getting-started/installation/).\n\nWith `uv` installed, one can install the project dependencies with:\n\n```shell\nuv sync\n```\n\nThen, to run the project unit tests:\n\n```shell\nmake test-unit\n```\n\nTo run the linters (`ruff` and `mypy`):\n\n```shell\nmake lint\n```\n\nTo apply all code formatting:\n\n```shell\nmake format\n```\n\nAnd finally, to run the project integration tests (which actually use the DeepL API),\nyou should either have the `DEEPL_API_KEY` environment variable set,\nor create a `.env` file:\n\n```dotenv\nDEEPL_API_KEY=your_api_key_here\n```\n\nAnd run:\n\n```shell\nmake test-integration\n```\n\n## License\n\n`deepl-haystack` is distributed under the terms of the\n[MIT](https://opensource.org/license/mit) license.\nCheck the [LICENSE](./LICENSE) file for further details.\n",
"bugtrack_url": null,
"license": null,
"summary": "Haystack integration with DeepL translation services provider.",
"version": "0.3.0",
"project_urls": {
"Bug Tracker": "https://github.com/dribia/deepl-haystack/issues",
"Homepage": "https://github.com/dribia/deepl-haystack",
"Repository": "https://github.com/dribia/deepl-haystack"
},
"split_keywords": [
"deepl",
" haystack",
" nlp",
" translation"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "5c03ba9b1c3eb582f5b8a89d2ea3233527fa0187c985536e3b77066ede82dfaf",
"md5": "8d23f999ecc4035f7bae57e7e1750ea2",
"sha256": "aad96f58bc7d5c02f5b2278fe965ca7e7784ad67f070f03628038b0682c339e0"
},
"downloads": -1,
"filename": "deepl_haystack-0.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8d23f999ecc4035f7bae57e7e1750ea2",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<3.14,>=3.9",
"size": 7885,
"upload_time": "2025-09-02T17:19:18",
"upload_time_iso_8601": "2025-09-02T17:19:18.280509Z",
"url": "https://files.pythonhosted.org/packages/5c/03/ba9b1c3eb582f5b8a89d2ea3233527fa0187c985536e3b77066ede82dfaf/deepl_haystack-0.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "50e8fc83b6f9b290c6de1e354abed0fe37c94b1cca44102ad290286ec8da5995",
"md5": "c7119728edbdc3b55323a9fc5b7cdc1b",
"sha256": "96aa0c953c758d519a5e7e7441a3871f4899795e63e97b9d540d9527565bda43"
},
"downloads": -1,
"filename": "deepl_haystack-0.3.0.tar.gz",
"has_sig": false,
"md5_digest": "c7119728edbdc3b55323a9fc5b7cdc1b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<3.14,>=3.9",
"size": 106607,
"upload_time": "2025-09-02T17:19:19",
"upload_time_iso_8601": "2025-09-02T17:19:19.344090Z",
"url": "https://files.pythonhosted.org/packages/50/e8/fc83b6f9b290c6de1e354abed0fe37c94b1cca44102ad290286ec8da5995/deepl_haystack-0.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-02 17:19:19",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "dribia",
"github_project": "deepl-haystack",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "deepl-haystack"
}