Skip to main content
For the complete documentation index for agents and LLMs, see llms.txt.

TextLanguageRouter

Use TextLanguageRouter to route text strings to different pipeline branches based on their detected language. Text that doesn't match any of the specified languages is sent to an unmatched output.

Key Features

  • Detects the language of a text string and routes it to the matching output
  • Supports any language available in the langdetect library using ISO language codes
  • Creates one named output per language for direct downstream connections
  • Routes non-matching text to a dedicated unmatched output
  • Defaults to English detection if no languages are specified

Configuration

  1. Drag the TextLanguageRouter component onto the canvas from the Component Library.
  2. Click the component to open the configuration panel.
  3. Configure the parameters as needed.

Connections

TextLanguageRouter accepts a single text string as input. It creates one output per language code in languages and an unmatched output for text whose detected language isn't in the list. Connect each output to the appropriate downstream component (for example, separate prompt builders or generators for different languages).

To route documents by language instead of raw text, use DocumentLanguageClassifier followed by MetadataRouter.

Usage Example

components:
TextLanguageRouter:
type: components.routers.text_language_router.TextLanguageRouter
init_parameters:

Parameters

Inputs

ParameterTypeDefaultDescription
textstrA text string to route.

Outputs

The component creates one output per language code in languages, plus an unmatched output for text in languages not in the list.

Init Parameters

These are the parameters you can configure in Pipeline Builder:

ParameterTypeDefaultDescription
languagesOptional[List[str]]NoneA list of ISO language codes. See the supported languages in the langdetect documentation. If not specified, defaults to ["en"].

Run Method Parameters

These are the parameters you can configure for the component's run() method. This means you can pass these parameters at query time through the API, in Playground, or when running a job. For details, see Modify Pipeline Parameters at Query Time.

ParameterTypeDefaultDescription
textstrA text string to route.