haystack_translate_node
An Azure Translation node for Haystack - you will need this configured in your Azure subscription: https://learn.microsoft.com/en-us/azure/cognitive-services/translator/translator-overview
Include in your pipeline as follows:
git clone the repo somewhere, change to the directory, then pip install '.'
Include in your pipeline as follows:
from haystack_translate_node import TranslateAnswer, TranslateQuery
translate_query = TranslateQuery(api_key="<yourapikey>", location="<yourazureregion>", azure_translate_endpoint="<yourazureendpoint>", base_lang="en")
translate_answer = TranslateAnswer(api_key="<yourapikey>", location="<yourazureregion>", azure_translate_endpoint="<yourazureendpoint>", base_lang="en")
pipel = Pipeline()
pipel.add_node(component=translate_query, name="TranslateQuery", inputs=["Query"])
pipel.add_node(component=retriever, name="Retriever", inputs=["TranslateQuery"])
pipel.add_node(component=prompt_node, name="prompt_node", inputs=["Retriever"])
pipel.add_node(component=translate_answer, name="TranslateAnswer", inputs=["prompt_node"])
location, azure_translate_endpoint, and base_lang are optional, and will default to uksouth, https://api.cognitive.microsofttranslator.com/, and en respectively.
-
TranslateQuery will determine the language of the query, and assign it to the
in_langJSON value. -
TranslateQuery will take the original query, in any language, and assign it to the
in_queryJSON value. -
TranslateQuery will overwrite the original
queryJSON value with the translated English value -
You can then query your
base_langcorpus using thequeryvalue as normal using a standard Haystack Retriever node, which will place your results inresults. -
TranslateAnswer translate the
base_langresult stored inresultsback to the language stored inin_langand subsequently store it in theout_answerJSON value.
Release files for haystack-translate-node 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| haystack_translate_node-0.0.1.tar.gz | 2.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| haystack_translate_node-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.5 kB
Release files / haystack_translate_node-0.0.1.tar.gz
| Download URL | haystack_translate_node-0.0.1.tar.gz |
|---|---|
| Size | 2.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ae8ae06037adecbd048fee42b78857e678ad4113430555efa4d407f34410c575
|
|
BLAKE2b-256 checksum How to use checksums |
0bfc098d42ff5913ec814aed87fe08be55b4d3613c5b517ff51adafbb431a12f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|
Release files / haystack_translate_node-0.0.1-py3-none-any.whl
| Download URL | haystack_translate_node-0.0.1-py3-none-any.whl |
|---|---|
| Size | 3.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
db8139aa531f9e24706b606f74a5e69550c941298d4886d80f777976fdeec80c
|
|
BLAKE2b-256 checksum How to use checksums |
88ed6b2310abcdb5117202bbc49ec36b45607320cfba4a8958a689c71ce21cac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|