mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-05 07:02:13 +08:00
33 lines
1010 B
Python
33 lines
1010 B
Python
# Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
from langgraph.prebuilt import create_react_agent
|
|
|
|
from src.prompts import apply_prompt_template
|
|
from src.tools import (
|
|
crawl_tool,
|
|
python_repl_tool,
|
|
web_search_tool,
|
|
)
|
|
|
|
from src.llms.llm import get_llm_by_type
|
|
from src.config.agents import AGENT_LLM_MAP
|
|
|
|
|
|
# Create agents using configured LLM types
|
|
def create_agent(agent_name: str, agent_type: str, tools: list, prompt_template: str):
|
|
"""Factory function to create agents with consistent configuration."""
|
|
return create_react_agent(
|
|
name=agent_name,
|
|
model=get_llm_by_type(AGENT_LLM_MAP[agent_type]),
|
|
tools=tools,
|
|
prompt=lambda state: apply_prompt_template(prompt_template, state),
|
|
)
|
|
|
|
|
|
# Create agents using the factory function
|
|
research_agent = create_agent(
|
|
"researcher", "researcher", [web_search_tool, crawl_tool], "researcher"
|
|
)
|
|
coder_agent = create_agent("coder", "coder", [python_repl_tool], "coder")
|