跳到主要内容

逐步构建 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](https://media.arcblock.io/ext/cbe7845d4cff.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 开发框架。从命令行创建并运行一个项目,需要细节时再查框架文档。