Skip to main content

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 the query value as normal using a standard Haystack Retriever node, which will place your results in results.

  • TranslateAnswer translate the base_lang result stored in results back to the language stored in in_lang and subsequently store it in the out_answer JSON 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)

Source distribution for haystack-translate-node 0.0.1
File Size Uploaded
haystack_translate_node-0.0.1.tar.gz 2.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for haystack-translate-node 0.0.1
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page