Skip to content

Commit a71b6bc

Browse files
authored
fix(main): Passing the local parameter from the main interactive mode (bytedance#791)
1 parent 893ff82 commit a71b6bc

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

main.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def ask(
2222
enable_background_investigation=True,
2323
enable_clarification=False,
2424
max_clarification_rounds=None,
25+
locale=None,
2526
):
2627
"""Run the agent workflow with the given question.
2728
@@ -33,6 +34,7 @@ def ask(
3334
enable_background_investigation: If True, performs web search before planning to enhance context
3435
enable_clarification: If False (default), skip clarification; if True, enable multi-turn clarification
3536
max_clarification_rounds: Maximum number of clarification rounds (default: None, uses State default=3)
37+
locale: The locale setting (e.g., 'en-US', 'zh-CN')
3638
"""
3739
asyncio.run(
3840
run_agent_workflow_async(
@@ -43,6 +45,7 @@ def ask(
4345
enable_background_investigation=enable_background_investigation,
4446
enable_clarification=enable_clarification,
4547
max_clarification_rounds=max_clarification_rounds,
48+
locale=locale,
4649
)
4750
)
4851

@@ -71,6 +74,9 @@ def main(
7174
choices=["English", "中文"],
7275
).execute()
7376

77+
# Set locale based on language
78+
locale = "en-US" if language == "English" else "zh-CN"
79+
7480
# Choose questions based on language
7581
questions = (
7682
BUILT_IN_QUESTIONS if language == "English" else BUILT_IN_QUESTIONS_ZH_CN
@@ -105,6 +111,7 @@ def main(
105111
enable_background_investigation=enable_background_investigation,
106112
enable_clarification=enable_clarification,
107113
max_clarification_rounds=max_clarification_rounds,
114+
locale=locale,
108115
)
109116

110117

src/workflow.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ async def run_agent_workflow_async(
3434
enable_clarification: bool | None = None,
3535
max_clarification_rounds: int | None = None,
3636
initial_state: dict | None = None,
37+
locale: str | None = None,
3738
):
3839
"""Run the agent workflow asynchronously with the given user input.
3940
@@ -46,6 +47,7 @@ async def run_agent_workflow_async(
4647
enable_clarification: If None, use default from State class (False); if True/False, override
4748
max_clarification_rounds: Maximum number of clarification rounds allowed
4849
initial_state: Initial state to use (for recursive calls during clarification)
50+
locale: The locale setting (e.g., 'en-US', 'zh-CN')
4951
5052
Returns:
5153
The final state after the workflow completes
@@ -75,6 +77,9 @@ async def run_agent_workflow_async(
7577
if max_clarification_rounds is not None:
7678
initial_state["max_clarification_rounds"] = max_clarification_rounds
7779

80+
if locale is not None:
81+
initial_state["locale"] = locale
82+
7883
config = {
7984
"configurable": {
8085
"thread_id": "default",
@@ -158,6 +163,7 @@ async def run_agent_workflow_async(
158163
enable_clarification=enable_clarification,
159164
max_clarification_rounds=max_clarification_rounds,
160165
initial_state=current_state,
166+
locale=locale,
161167
)
162168

163169
logger.info("Async workflow completed successfully")

0 commit comments

Comments
 (0)