From a71b6bc41fd80667381a9a790ecdcc99197c29cf Mon Sep 17 00:00:00 2001 From: Willem Jiang Date: Tue, 30 Dec 2025 10:41:29 +0800 Subject: [PATCH] fix(main): Passing the local parameter from the main interactive mode (#791) --- main.py | 7 +++++++ src/workflow.py | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/main.py b/main.py index ae7ba40..a80bd87 100644 --- a/main.py +++ b/main.py @@ -22,6 +22,7 @@ def ask( enable_background_investigation=True, enable_clarification=False, max_clarification_rounds=None, + locale=None, ): """Run the agent workflow with the given question. @@ -33,6 +34,7 @@ def ask( enable_background_investigation: If True, performs web search before planning to enhance context enable_clarification: If False (default), skip clarification; if True, enable multi-turn clarification max_clarification_rounds: Maximum number of clarification rounds (default: None, uses State default=3) + locale: The locale setting (e.g., 'en-US', 'zh-CN') """ asyncio.run( run_agent_workflow_async( @@ -43,6 +45,7 @@ def ask( enable_background_investigation=enable_background_investigation, enable_clarification=enable_clarification, max_clarification_rounds=max_clarification_rounds, + locale=locale, ) ) @@ -71,6 +74,9 @@ def main( choices=["English", "中文"], ).execute() + # Set locale based on language + locale = "en-US" if language == "English" else "zh-CN" + # Choose questions based on language questions = ( BUILT_IN_QUESTIONS if language == "English" else BUILT_IN_QUESTIONS_ZH_CN @@ -105,6 +111,7 @@ def main( enable_background_investigation=enable_background_investigation, enable_clarification=enable_clarification, max_clarification_rounds=max_clarification_rounds, + locale=locale, ) diff --git a/src/workflow.py b/src/workflow.py index d57a21e..41ff5b3 100644 --- a/src/workflow.py +++ b/src/workflow.py @@ -34,6 +34,7 @@ async def run_agent_workflow_async( enable_clarification: bool | None = None, max_clarification_rounds: int | None = None, initial_state: dict | None = None, + locale: str | None = None, ): """Run the agent workflow asynchronously with the given user input. @@ -46,6 +47,7 @@ async def run_agent_workflow_async( enable_clarification: If None, use default from State class (False); if True/False, override max_clarification_rounds: Maximum number of clarification rounds allowed initial_state: Initial state to use (for recursive calls during clarification) + locale: The locale setting (e.g., 'en-US', 'zh-CN') Returns: The final state after the workflow completes @@ -75,6 +77,9 @@ async def run_agent_workflow_async( if max_clarification_rounds is not None: initial_state["max_clarification_rounds"] = max_clarification_rounds + if locale is not None: + initial_state["locale"] = locale + config = { "configurable": { "thread_id": "default", @@ -158,6 +163,7 @@ async def run_agent_workflow_async( enable_clarification=enable_clarification, max_clarification_rounds=max_clarification_rounds, initial_state=current_state, + locale=locale, ) logger.info("Async workflow completed successfully")