Skip to content

Commit 36248b9

Browse files
committed
feat: add matmaster_set_lang callback to set language before agent execution
1 parent fe86de0 commit 36248b9

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

agents/matmaster_agent/agent.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from agents.matmaster_agent.MrDice_agent.agent import init_MrDice_agent
1515
from agents.matmaster_agent.apex_agent.agent import init_apex_agent
1616
from agents.matmaster_agent.base_agents.io_agent import HandleFileUploadLlmAgent
17-
from agents.matmaster_agent.callback import matmaster_prepare_state, matmaster_check_transfer
17+
from agents.matmaster_agent.callback import matmaster_prepare_state, matmaster_check_transfer, matmaster_set_lang
1818
from agents.matmaster_agent.chembrain_agent.agent import init_chembrain_agent
1919
from agents.matmaster_agent.constant import MATMASTER_AGENT_NAME
2020
from agents.matmaster_agent.llm_config import MatMasterLlmConfig
@@ -76,7 +76,7 @@ def __init__(self, llm_config):
7676
global_instruction=GlobalInstruction,
7777
instruction=AgentInstruction,
7878
description=AgentDescription,
79-
before_agent_callback=matmaster_prepare_state,
79+
before_agent_callback=[matmaster_prepare_state, matmaster_set_lang],
8080
after_model_callback=matmaster_check_transfer,
8181
)
8282

agents/matmaster_agent/callback.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ async def matmaster_prepare_state(callback_context: CallbackContext) -> Optional
3838
callback_context.state['invocation_id_with_tool_call'] = callback_context.state.get('invocation_id_with_tool_call',
3939
None)
4040

41+
42+
async def matmaster_set_lang(callback_context: CallbackContext) -> Optional[types.Content]:
4143
user_content = callback_context.user_content.parts[0].text
4244
prompt = get_user_content_lang().format(user_content=user_content)
4345
response = litellm.completion(model='azure/gpt-4o', messages=[{'role': 'user', 'content': prompt}],

0 commit comments

Comments
 (0)