Skip to content

Commit 01f5e3c

Browse files
feat: enhance translation accuracy by vocabulary dict
1 parent f9224ac commit 01f5e3c

3 files changed

Lines changed: 36 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: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,28 @@ 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+
vocab_list = '\n'.join(
156+
[
157+
f'- "{k}" MUST be translated/referred to as "{v}"'
158+
for k, v in DOMAIN_SPECIFIC_VOCABULARY.items()
159+
]
160+
)
161+
return f"""
162+
### DOMAIN-SPECIFIC VOCABULARY STANDARDS
163+
To ensure professional consistency in Materials Science, you strictly MUST adhere to the following terminology translations:
164+
{vocab_list}
165+
"""
166+
167+
146168
STRUCTURE_BUILDING_SAVENAME = """
147169
Rules (MUST follow, no exceptions):
148170
1. ASCII letters/digits/underscores only; no spaces or symbols.

0 commit comments

Comments
 (0)