The BedrockTranslatorAgent
uses Amazon Bedrock’s language models to translate text between different languages.
Key Features
Utilizes Amazon Bedrock’s language models
Supports translation between multiple languages
Allows dynamic setting of source and target languages
Can be used standalone or as part of a ChainAgent
Configurable inference parameters for fine-tuned control
Creating a Bedrock Translator Agent
Basic Example
To create a new BedrockTranslatorAgent
with minimal configuration:
import { BedrockTranslatorAgent, BedrockTranslatorAgentOptions } from ' multi-agent-orchestrator ' ;
const agent = new BedrockTranslatorAgent ( {
description: ' Translates text to English ' ,
targetLanguage: ' English '
from multi_agent_orchestrator.agents import BedrockTranslatorAgent, BedrockTranslatorAgentOptions
agent = BedrockTranslatorAgent ( BedrockTranslatorAgentOptions (
description = ' Translates text to English ' ,
target_language = ' English '
Advanced Example
For more complex use cases, you can create a BedrockTranslatorAgent with custom settings:
import { BedrockTranslatorAgent, BedrockTranslatorAgentOptions, BEDROCK_MODEL_ID_CLAUDE_3_SONNET } from ' multi-agent-orchestrator ' ;
const options : BedrockTranslatorAgentOptions = {
name: ' AdvancedTranslator ' ,
description: ' Advanced translator with custom settings ' ,
sourceLanguage: ' French ' ,
targetLanguage: ' German ' ,
modelId: BEDROCK_MODEL_ID_CLAUDE_3_SONNET ,
const agent = new BedrockTranslatorAgent (options);
from multi_agent_orchestrator.agents import BedrockTranslatorAgent, BedrockTranslatorAgentOptions
from multi_agent_orchestrator.types import BEDROCK_MODEL_ID_CLAUDE_3_SONNET
options = BedrockTranslatorAgentOptions (
name = ' AdvancedTranslator ' ,
description = ' Advanced translator with custom settings ' ,
source_language = ' French ' ,
target_language = ' German ' ,
model_id = BEDROCK_MODEL_ID_CLAUDE_3_SONNET ,
agent = BedrockTranslatorAgent ( options )
Dynamic Language Setting
To set the language during the invocation:
import { MultiAgentOrchestrator, BedrockTranslatorAgent } from ' multi-agent-orchestrator ' ;
const translator = new BedrockTranslatorAgent ( {
name: ' DynamicTranslator ' ,
description: ' Translator with dynamically set languages '
const orchestrator = new MultiAgentOrchestrator ();
orchestrator . addAgent (translator);
async function translateWithDynamicLanguages ( text : string , fromLang : string , toLang : string ) {
translator . setSourceLanguage (fromLang);
translator . setTargetLanguage (toLang);
const response = await orchestrator . routeRequest (
console . log ( ` Translated from ${ fromLang } to ${ toLang } : ` , response);
translateWithDynamicLanguages ( " Hello, world! " , " English " , " French " );
translateWithDynamicLanguages ( " Bonjour le monde! " , " French " , " Spanish " );
from multi_agent_orchestrator.orchestrator import MultiAgentOrchestrator
from multi_agent_orchestrator.agents import BedrockTranslatorAgent, BedrockTranslatorAgentOptions
translator = BedrockTranslatorAgent ( BedrockTranslatorAgentOptions (
name = ' DynamicTranslator ' ,
description = ' Translator with dynamically set languages '
orchestrator = MultiAgentOrchestrator ()
orchestrator. add_agent ( translator )
async def translate_with_dynamic_languages ( text : str , from_lang : str , to_lang : str ) :
translator. set_source_language ( from_lang )
translator. set_target_language ( to_lang )
response = await orchestrator. route_request (
print ( f "Translated from {from_lang} to {to_lang} :" , response )
asyncio. run ( translate_with_dynamic_languages ( " Hello, world! " , " English " , " French " ))
asyncio. run ( translate_with_dynamic_languages ( " Bonjour le monde! " , " French " , " Spanish " ))
Usage with ChainAgent
The BedrockTranslatorAgent
can be effectively used within a ChainAgent
for complex multilingual processing workflows. Here’s an example that demonstrates translating user input and processing it:
import { MultiAgentOrchestrator, ChainAgent, BedrockTranslatorAgent, BedrockLLMAgent } from ' multi-agent-orchestrator ' ;
// Create translator agents
const translatorToEnglish = new BedrockTranslatorAgent ( {
name: ' TranslatorToEnglish ' ,
description: ' Translates input to English ' ,
targetLanguage: ' English '
// Create a processing agent (e.g., a BedrockLLMAgent)
const processor = new BedrockLLMAgent ( {
name: ' EnglishProcessor ' ,
description: ' Processes text in English '
const chainAgent = new ChainAgent ( {
name: ' TranslateProcessTranslate ' ,
description: ' Translates, processes, and translates back ' ,
agents: [translatorToEnglish, processor]
const orchestrator = new MultiAgentOrchestrator ();
orchestrator . addAgent (chainAgent);
// Function to handle user input
async function handleMultilingualInput ( input : string , sourceLanguage : string ) {
translatorToEnglish . setSourceLanguage (sourceLanguage);
const response = await orchestrator . routeRequest (
console . log ( ' Response: ' , response);
handleMultilingualInput ( " Hola, ¿cómo estás? " , " Spanish " );
from multi_agent_orchestrator.orchestrator import MultiAgentOrchestrator
from multi_agent_orchestrator.agents import ChainAgent, BedrockTranslatorAgent, BedrockLLMAgent
from multi_agent_orchestrator.agents import ChainAgentOptions, BedrockTranslatorAgentOptions, BedrockLLMAgentOptions
# Create translator agents
translator_to_english = BedrockTranslatorAgent ( BedrockTranslatorAgentOptions (
name = ' TranslatorToEnglish ' ,
description = ' Translates input to English ' ,
target_language = ' English '
# Create a processing agent (e.g., a BedrockLLMAgent)
processor = BedrockLLMAgent ( BedrockLLMAgentOptions (
description = ' Processes text in English '
chain_agent = ChainAgent ( ChainAgentOptions (
name = ' TranslateProcessTranslate ' ,
description = ' Translates, processes, and translates back ' ,
agents = [ translator_to_english, processor ]
orchestrator = MultiAgentOrchestrator ()
orchestrator. add_agent ( chain_agent )
# Function to handle user input
async def handle_multilingual_input ( input_text : str , source_language : str ) :
translator_to_english. set_source_language ( source_language )
response = await orchestrator. route_request (
print ( ' Response: ' , response )
asyncio. run ( handle_multilingual_input ( " Hola, ¿cómo estás? " , " Spanish " ))
In this example:
The first translator agent converts the input to English.
The processor agent (e.g., a BedrockLLMAgent
) processes the English text.
This setup allows for seamless multilingual processing, where the core logic can be implemented in English while supporting input and output in various languages.
By leveraging the BedrockTranslatorAgent
, you can create sophisticated multilingual applications and workflows, enabling seamless communication and processing across language barriers in your Multi-Agent Orchestrator system.