feat: support multi-language

This commit is contained in:
Li Xin
2025-04-21 19:50:34 +08:00
parent 0d2f93c773
commit b67b04ff5d
6 changed files with 54 additions and 45 deletions

View File

@@ -1,22 +1,23 @@
# Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
# SPDX-License-Identifier: MIT
import logging
import json
from typing import Literal, Annotated
import logging
from typing import Annotated, Literal
from langchain_core.messages import HumanMessage, AIMessage
from langchain_core.tools import tool
from langchain_core.messages import AIMessage, HumanMessage
from langchain_core.runnables import RunnableConfig
from langchain_core.tools import tool
from langgraph.types import Command, interrupt
from src.llms.llm import get_llm_by_type
from src.agents.agents import coder_agent, research_agent
from src.config.agents import AGENT_LLM_MAP
from src.config.configuration import Configuration
from src.prompts.template import apply_prompt_template
from src.llms.llm import get_llm_by_type
from src.prompts.planner_model import Plan, StepType
from src.prompts.template import apply_prompt_template
from src.utils.json_utils import repair_json_output
from src.agents.agents import research_agent, coder_agent
from .types import State
logger = logging.getLogger(__name__)
@@ -117,6 +118,7 @@ def human_feedback_node(
update={
"current_plan": Plan.model_validate(new_plan),
"plan_iterations": plan_iterations,
"locale": new_plan["locale"],
},
goto=goto,
)
@@ -209,7 +211,7 @@ def _execute_agent_step(
agent_input = {
"messages": [
HumanMessage(
content=f"#Task\n\n##title\n\n{step.title}\n\n##description\n\n{step.description}"
content=f"#Task\n\n##title\n\n{step.title}\n\n##description\n\n{step.description}\n\n##locale\n\n{state.get('locale', 'en-US')}"
)
]
}

View File

@@ -2,9 +2,10 @@
# SPDX-License-Identifier: MIT
import operator
from typing import Annotated
from langgraph.graph import MessagesState
from typing import Annotated
from src.prompts.planner_model import Plan
@@ -12,6 +13,7 @@ class State(MessagesState):
"""State for the agent system, extends MessagesState with next field."""
# Runtime Variables
locale: str = "en-US"
observations: Annotated[list[str], operator.add] = []
plan_iterations: int = 0
current_plan: Plan | str = None