Skip to content

Commit 5a377e8

Browse files
authored
Merge pull request #679 from SchrodingersCattt/dev-gmy
feat: enhance translation accuracy by vocabulary dict
2 parents 7c7e312 + 6dc8a9d commit 5a377e8

3 files changed

Lines changed: 40 additions & 4 deletions

File tree

agents/matmaster_agent/core_agents/comp_agents/recommend_summary_agent/agent.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@
5858
from agents.matmaster_agent.locales import i18n
5959
from agents.matmaster_agent.logger import PrefixFilter
6060
from agents.matmaster_agent.model import ToolCallInfoSchema
61-
from agents.matmaster_agent.prompt import GLOBAL_INSTRUCTION, GLOBAL_SCHEMA_INSTRUCTION
61+
from agents.matmaster_agent.prompt import (
62+
GLOBAL_INSTRUCTION,
63+
GLOBAL_SCHEMA_INSTRUCTION,
64+
get_vocabulary_enforce_prompt,
65+
)
6266
from agents.matmaster_agent.state import RECOMMEND_PARAMS
6367
from agents.matmaster_agent.sub_agents.tools import ALL_TOOLS
6468
from agents.matmaster_agent.utils.event_utils import (
@@ -334,9 +338,11 @@ async def _run_events(self, ctx: InvocationContext) -> AsyncGenerator[Event, Non
334338

335339
# TODO: needs a better way to handle customized summary prompt
336340
if ALL_TOOLS[current_step_tool_name].get('summary_prompt') is not None:
337-
self.summary_agent.instruction = ALL_TOOLS[current_step_tool_name].get(
338-
'summary_prompt'
341+
custom_prompt = ALL_TOOLS[current_step_tool_name].get('summary_prompt')
342+
self.summary_agent.instruction = (
343+
f"{custom_prompt}\n\n{get_vocabulary_enforce_prompt()}"
339344
)
345+
340346
if current_step['status'] != PlanStepStatusEnum.SUBMITTED:
341347
async for summary_event in self.summary_agent.run_async(ctx):
342348
yield summary_event

agents/matmaster_agent/core_agents/comp_agents/recommend_summary_agent/subagent_summary_agent/prompt.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
from agents.matmaster_agent.prompt import HUMAN_FRIENDLY_FORMAT_REQUIREMENT
1+
from agents.matmaster_agent.prompt import (
2+
HUMAN_FRIENDLY_FORMAT_REQUIREMENT,
3+
get_vocabulary_enforce_prompt,
4+
)
25

36

47
def get_subagent_summary_prompt() -> str:
@@ -11,6 +14,7 @@ def get_subagent_summary_prompt() -> str:
1114
3. Providing expert commentary on the implications of the results
1215
4. Provide domain-specific considerations that contextualize the results (without actionable advices).
1316
17+
{get_vocabulary_enforce_prompt()}
1418
1519
# Format Requirements:
1620
{HUMAN_FRIENDLY_FORMAT_REQUIREMENT}

agents/matmaster_agent/prompt.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,32 @@ def get_naming_rules_text():
143143
- Exception: If discussing a commercial product specifically sold under a trade name (e.g., "Sigma-Aldrich ZIF-8"), use the trade name but reference the scientific name in parentheses.
144144
"""
145145

146+
DOMAIN_SPECIFIC_VOCABULARY = {
147+
'deep potential': '深度学习势函数',
148+
'Deep Potential Molecular Dynamics': '深度学习势分子动力学',
149+
'DPMD': '深度学习势分子动力学',
150+
'DPA': 'DPA预训练原子间势函数',
151+
}
152+
153+
154+
def get_vocabulary_enforce_prompt() -> str:
155+
mapping_list = '\n'.join(
156+
[f' - "{eng}" → "{chn}"' for eng, chn in DOMAIN_SPECIFIC_VOCABULARY.items()]
157+
)
158+
159+
return f"""
160+
### DOMAIN-SPECIFIC VOCABULARY STANDARDS
161+
To ensure professional consistency, you strictly MUST adhere to the following terminology rules **based on your output language**:
162+
163+
**Condition A: If you are responding in CHINESE (中文):**
164+
You MUST translate the following terms into their designated Chinese equivalents:
165+
{mapping_list}
166+
167+
**Condition B: If you are responding in ENGLISH:**
168+
You MUST use the original English terms (e.g., "Deep Potential", "DPMD"). **DO NOT** use the Chinese translations in English sentences.
169+
"""
170+
171+
146172
STRUCTURE_BUILDING_SAVENAME = """
147173
Rules (MUST follow, no exceptions):
148174
1. ASCII letters/digits/underscores only; no spaces or symbols.

0 commit comments

Comments
 (0)