An Azure Translate node for Deepset Haystack
Project description
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_lang
JSON value. -
TranslateQuery will take the original query, in any language, and assign it to the
in_query
JSON value. -
TranslateQuery will overwrite the original
query
JSON value with the translated English value -
You can then query your
base_lang
corpus using thequery
value as normal using a standard Haystack Retriever node, which will place your results inresults
. -
TranslateAnswer translate the
base_lang
result stored inresults
back to the language stored inin_lang
and subsequently store it in theout_answer
JSON value.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file haystack_translate_node-0.0.1.tar.gz
.
File metadata
- Download URL: haystack_translate_node-0.0.1.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae8ae06037adecbd048fee42b78857e678ad4113430555efa4d407f34410c575 |
|
MD5 | 899d959ae5f783523d8a05da7a061d35 |
|
BLAKE2b-256 | 0bfc098d42ff5913ec814aed87fe08be55b4d3613c5b517ff51adafbb431a12f |
File details
Details for the file haystack_translate_node-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: haystack_translate_node-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | db8139aa531f9e24706b606f74a5e69550c941298d4886d80f777976fdeec80c |
|
MD5 | e266c757b83ea1356389f8c667e9e97e |
|
BLAKE2b-256 | 88ed6b2310abcdb5117202bbc49ec36b45607320cfba4a8958a689c71ce21cac |