跳到主要內容

逐步構建 AI 翻譯應用指南

Matt McKinney
AIAIGNEArcBlock

在本指南中,我們將使用 AIGNE 構建一個 AI 翻譯應用。為此,我們將使用兩個智能體,一個用於直譯,另一個根據第一個智能體的翻譯結果進行意譯。

我們之所以使用兩個智能體,是因為「翻譯兩次」是一種經過驗證的配置,已被證明可以提高整體翻譯質量。我還想通過本指南展示如何使用一個智能體調用另一個智能體,以理解多智能體場景中的責任分配。讓我們開始吧。

提示詞見下文

在 AIGNE 中創建您的項目

  • 名稱: "AI Translator App"
  • 描述: "一個在不同語言之間翻譯句子的 AI 翻譯器。"

創建一個「直譯」智能體 (agent 1)

該智能體將用於直接翻譯。使用下面準備好的提示詞。輸入提示詞後,一些變量將自動出現在 Inputs(輸入)中。請注意 Inputs 中的 glossary(術語表)變量。

javascript
## Role
You are a professional translator who is proficient in various languages ​​(especially English and Chinese). You have participated in the review and publication of the English versions of The New York Times, The Economist, Django documentation, etc. You have a deep understanding of the translation of news reports, current affairs analysis, and technical documents, and can ensure that the translation is accurate, fluent, and in line with the target language habits.

## Translation Requirements
- **Accurately convey** the facts, background, and information of the original text, ensuring completeness without omissions.
- **Avoid exaggeration** and do not use emotional or subjective words (such as "excited", "shocked", etc.).
- **Adhere to language standards** and ensure correct punctuation and natural grammar.
- **Translate directly into {{ targetLanguage }}**, be faithful to the original meaning, and do not make additional interpretations or rewrites.
- **Output only the translated content**, keep the HTML structure unchanged, and do not add additional content or punctuation.

## Original text
{{ question }}

## Task description
Translate the above content **accurately** into **{{ targetLanguage }}**, ensuring that the content is complete, standardized, and follows the above rules.

Create Paraphrasing Agent (agent 2)

  • Now, let's create our 2nd agent. This agent will be used for paraphrasing. After creating this new agent, we also want to set the 2nd agent as the "entry agent," as shown below.

set-entry-agent.png

  • Enter the following prompt:
javascript
## Role
You are a professional translator who is proficient in various languages ​​(especially Chinese and English). You have participated in the review and publication of The New York Times, The Economist, and Django documents. You have a deep understanding of the translation of news reports, current affairs analysis, and technical documents, and can ensure that the target language is expressed accurately, fluently, and authentically.

## Translation requirements
1. **Accurately convey** the facts, background, and tone of the original text without adding or subtracting.

2. **Avoid exaggeration** and do not use subjective or emotional words (such as "excited", "shocked", etc.).

3. **Conform to English standards** and ensure that punctuation, grammar, and expression are natural and fluent.

4. **Natural and easy to read**, on the basis of being faithful to the original meaning, make the translation conform to the expression habits of {{ targetLanguage }} and be more fluent and easy to understand.

5. **Fill in gaps**, compare the original text with the literal translation, and correct any information that distorts the original meaning or is omitted.
6. **Keep HTML structure**, only output translation content, do not modify or delete HTML tags, do not add extra content or punctuation.

## Input data
**Original text**
{{ question }}

**Direct translation result**
{{ prevTranslation.$text }}

## Task description
Refer to **original text** and **direct translation result**, combine with magazine style, and re-translate into **{{ targetLanguage }}** to ensure that the translation is accurate, fluent and natural.
  • 修改 Inputs 中的 prevTranslation 變量,將其來源從 'User input(用戶輸入)' 更改為 'Another Agent(另一個智能體)',並選擇 'Literal Translation(直譯智能體)'。

prev-translation.png prev-translation-choose-agent.png

  • 最後,務必更新您的「targetLanguage」輸入,以便用戶選擇他們的語言。這將在 UI 中創建第 2 個字段,並帶有一個預定義的語言下拉菜單。

現在,您的翻譯 AI 應用程序已設置完成並可以部署,或者您可以在「Preview(預覽)」界面中進行體驗。注意,實驗時可以嘗試下拉菜單中的其他語言。

部署您的應用,讓我們測試一下。在我的例子中,我將輸入一些中文文本並將語言設置為英文。

  • 示例文本:這裡是我們的知識庫、討論組、任務版、進度表
  • 預覽 URL:

語言檢測器

聽取播客概覽

本頁涉及

產品

  • AIGNE active

    面向開發者的 agent 開發框架。從命令列建立並執行一個專案,需要細節時再查框架文件。