Agent 进阶:LangGraph 的应用和实现原理

Agent 进阶:LangGraph 的应用和实现原理

更新时间
Last updated November 14, 2025
AI 占比
Tags
description

LangGraph 是什么?

LangGraph 是由 LangChain 团队开发的一个开源 AI Agent 框架,专门用于构建、部署和管理复杂的生成式 AI Agent 工作流。它基于图架构,能够处理有状态的、多 Agent 应用程序。

核心特性

1. 图架构设计

  • 节点(Nodes):代表工作流中的各个步骤或函数
  • 边(Edges):定义节点之间的连接和执行顺序
  • 状态图(StateGraph):支持循环和条件分支的有状态图结构

2. 状态管理w

  • 持久状态:图的状态可以在整个执行过程中保持和传递
  • 状态更新:每个节点都可以修改和更新全局状态
  • 状态历史:支持保存执行历史记录

3. 人机交互(Human-in-the-loop)

  • 中断机制:可以在指定节点前暂停执行,等待人工输入
  • 反馈循环:支持人工审核和修改工作流
  • 时间旅行:可以回退到之前的状态重新执行

gemini-fullstack

以 "deepseek 公司的发展历程" 为例,整个 agent 的完整工作流程:
flowchart TD __start__ --> generate_query generate_query -.-> web_research web_research <-.-> reflection reflection -.-> finalize_answer finalize_answer --> __end__

🚀 Step 1: 初始化和查询生成 (generate_query)

输入状态:

{ "messages": [{"role": "human", "content": "deepseek 公司的发展历史"}], "search_query": [], "web_research_result": [], "sources_gathered": [], "initial_search_query_count": null, "research_loop_count": 0 }

处理过程:

  1. 配置加载: 系统设置 initial_search_query_count = 3(默认值)
  1. 模型调用: 使用 gemini-2.0-flash 处理查询生成提示:
formatted_prompt = """ Your goal is to generate sophisticated and diverse web search queries... Context: deepseek 公司的发展例子 """
  1. AI 生成查询: Gemini 2.0 Flash 生成结构化输出:

输出状态:

{ "query_list": [ { "query": "DeepSeek AI company founding history development timeline", "rationale": "获取公司成立历史和发展时间线" }, { "query": "DeepSeek AI latest funding rounds investors valuation 2024", "rationale": "了解最新融资情况和投资者信息" }, { "query": "DeepSeek AI products technology achievements milestones", "rationale": "研究公司产品和技术成就" } ] }

🔄 Step 2: 并行搜索分发 (continue_to_web_research)

处理过程:

系统将 3 个查询分发到并行的 web_research 节点:
[ Send("web_research", {"search_query": "DeepSeek AI company founding...", "id": 0}), Send("web_research", {"search_query": "DeepSeek AI latest funding...", "id": 1}), Send("web_research", {"search_query": "DeepSeek AI products...", "id": 2}) ]

🌐 Step 3: 并行 Web 搜索 (web_research × 3)

每个搜索节点的处理过程:

搜索节点 #1 (ID: 0):

# 1. 格式化搜索提示 formatted_prompt = f""" Conduct targeted Google Searches to gather information on "DeepSeek AI company founding history development timeline" Current date: {current_date} """ # 2. 调用 Google Search API response = genai_client.models.generate_content( model="gemini-2.0-flash", contents=formatted_prompt, config={"tools": [{"google_search": {}}], "temperature": 0} ) # 3. 处理搜索结果和引用 resolved_urls = resolve_urls(grounding_chunks, id=0) citations = get_citations(response, resolved_urls) modified_text = insert_citation_markers(response.text, citations)

搜索结果示例:

DeepSeek AI 成立于 2023 年,由前阿里巴巴研究员梁文锋创立 [1](<https://vertexaisearch.cloud.google.com/id/0-1>)。 公司专注于大语言模型研发,总部位于杭州 [2](<https://vertexaisearch.cloud.google.com/id/0-2>)。

合并后的状态更新:

{ "search_query": [ "DeepSeek AI company founding history...", "DeepSeek AI latest funding rounds...", "DeepSeek AI products technology..." ], "web_research_result": [ "DeepSeek AI 成立于 2023 年,由前阿里巴巴研究员梁文锋创立...", "DeepSeek AI 在 2024 年完成了 A 轮融资,估值达到 10 亿美元...", "DeepSeek 发布了 DeepSeek-V2 模型,在多项基准测试中表现优异..." ], "sources_gathered": [ {"short_url": "<https://vertexaisearch.cloud.google.com/id/0-1>", "value": "原始URL1"}, {"short_url": "<https://vertexaisearch.cloud.google.com/id/1-1>", "value": "原始URL2"}, // ... 更多信息源 ] }

🤔 Step 4: 反思分析 (reflection)

处理过程:

  1. 循环计数递增: research_loop_count = 1
  1. 使用推理模型: gemini-2.5-flash-preview-04-17 分析现有信息
formatted_prompt = f""" You are analyzing summaries about "deepseek 公司的发展例子" Summaries: {"\\n\\n---\\n\\n".join(web_research_results)} Identify knowledge gaps and determine if more research is needed... """
  1. AI 分析输出:

反思结果:

{ "is_sufficient": false, "knowledge_gap": "缺少 DeepSeek 公司的具体商业化进展、市场竞争地位和未来战略规划信息", "follow_up_queries": [ "DeepSeek AI commercialization strategy market position competitors 2024", "DeepSeek AI future roadmap strategic partnerships business model" ], "research_loop_count": 1, "number_of_ran_queries": 3 }

🔄 Step 5: 研究评估和路由 (evaluate_research)

决策逻辑:

max_research_loops = 2 # 默认配置 current_loops = 1 is_sufficient = false # 条件判断:未达到最大循环次数且信息不充分 if not is_sufficient and current_loops < max_research_loops: return "继续研究" # 启动新的并行搜索

启动第二轮搜索:

[ Send("web_research", {"search_query": "DeepSeek AI commercialization...", "id": 3}), Send("web_research", {"search_query": "DeepSeek AI future roadmap...", "id": 4}) ]

🌐 Step 6: 第二轮 Web 搜索

新的搜索结果累积到状态:

{ "search_query": [ // 第一轮的 3 个查询 + "DeepSeek AI commercialization strategy...", "DeepSeek AI future roadmap strategic..." ], "web_research_result": [ // 第一轮的 3 个结果 + "DeepSeek AI 正在与多家企业合作,推进商业化落地...", "公司计划在 2025 年推出更多行业解决方案..." ], "sources_gathered": [ // 累积了更多信息源 ] }

🤔 Step 7: 第二次反思

反思结果:

{ "is_sufficient": true, "knowledge_gap": "", "follow_up_queries": [], "research_loop_count": 2, "number_of_ran_queries": 5 }

Step 8: 最终答案生成 (finalize_answer)

处理过程:

  1. 使用高级模型: gemini-2.5-pro-preview-05-06 生成最终答案
  1. 整合所有信息: 合并 5 次搜索的结果
formatted_prompt = f""" Generate a high-quality answer about "deepseek 公司的发展例子" Summaries: {"\\n---\\n\\n".join(all_research_results)} """
  1. 引用处理: 将短链接替换为原始 URL,去除未使用的信息源

最终输出:

{ "messages": [ { "role": "assistant", "content": "# DeepSeek AI 公司发展概况\\n\\nDeepSeek AI 是一家成立于 2023 年的中国人工智能公司,专注于大语言模型研发...\\n\\n## 发展历程\\n- **2023年**: 公司成立,由前阿里巴巴研究员梁文锋创立 [参考来源1](原始URL1)\\n- **2024年**: 完成 A 轮融资,估值达到 10 亿美元 [参考来源2](原始URL2)\\n\\n## 技术成就\\n- 发布 DeepSeek-V2 模型,性能表现优异 [参考来源3](原始URL3)\\n...\\n\\n## 商业化进展\\n- 与多家企业建立合作关系 [参考来源4](原始URL4)\\n- 计划 2025 年推出更多行业解决方案 [参考来源5](原始URL5)" } ], "sources_gathered": [ // 只包含实际被引用的信息源 ] }

📊 完整状态变化时间线

步骤
节点
查询数量
循环次数
关键状态变化
1
generate_query
0→3
0
生成初始搜索查询
2-3
web_research×3
3
0
并行搜索,累积结果
4
reflection
3
0→1
识别知识空白
5
evaluate_research
3
1
决定继续研究
6
web_research×2
3→5
1
补充搜索
7
reflection
5
1→2
确认信息充分
8
finalize_answer
5
2
生成最终答案
 

🎯 系统特色体现

  1. 智能查询生成: 自动将"deepseek 公司的发展例子"扩展为多个具体搜索查询
  1. 并行处理: 同时执行多个搜索任务,提高效率
  1. 自适应研究: 通过反思机制自动识别信息不足,启动补充搜索
  1. 完整引用系统: 每个信息点都有明确的来源链接
  1. 智能循环控制: 在信息充分或达到最大循环次数时自动结束
 

deerflow

notion image
 

完整的 Agent 工作流程

1. 前端请求阶段

当用户在界面输入"deepseek 公司的发展历程"时:
前端处理 (web/src/core/store/store.ts):
// 用户消息被添加到状态管理 appendMessage({ id: nanoid(), threadId: THREAD_ID, role: "user", content: "deepseek 公司的发展历程", contentChunks: ["deepseek 公司的发展历程"], resources: [], }); // 发起流式聊天请求 const stream = chatStream("deepseek 公司的发展历程", { thread_id: THREAD_ID, auto_accepted_plan: false, // 需要用户确认计划 enable_background_investigation: true, // 启用背景调研 max_plan_iterations: 3, max_step_num: 5, max_search_results: 10, });

2. 后端 LangGraph 工作流启动

API 入口 (src/server/app.py):
@app.post("/api/chat/stream") async def chat_stream(request: ChatRequest): thread_id = request.thread_id if thread_id == "__default__": thread_id = str(uuid4()) return StreamingResponse( _astream_workflow_generator( request.model_dump()["messages"], thread_id, request.resources, request.max_plan_iterations, request.max_step_num, request.max_search_results, request.auto_accepted_plan, request.interrupt_feedback, request.mcp_settings, request.enable_background_investigation, ), media_type="text/event-stream", )

3. Agent 工作流详细执行

步骤 1: Coordinator(协调员)

职责: 理解用户意图,决定工作流方向
def coordinator_node( state: State, config: RunnableConfig ) -> Command[Literal["planner", "background_investigator", "__end__"]]: """Coordinator node that communicate with customers.""" logger.info("Coordinator talking.") configurable = Configuration.from_runnable_config(config) messages = apply_prompt_template("coordinator", state) response = ( get_llm_by_type(AGENT_LLM_MAP["coordinator"]) .bind_tools([handoff_to_planner]) .invoke(messages) ) logger.debug(f"Current state messages: {state['messages']}") goto = "__end__" locale = state.get("locale", "en-US") # Default locale if not specified if len(response.tool_calls) > 0: goto = "planner" if state.get("enable_background_investigation"): # if the search_before_planning is True, add the web search tool to the planner agent goto = "background_investigator" try: for tool_call in response.tool_calls: if tool_call.get("name", "") != "handoff_to_planner": continue if tool_locale := tool_call.get("args", {}).get("locale"): locale = tool_locale break except Exception as e: logger.error(f"Error processing tool calls: {e}") else: logger.warning( "Coordinator response contains no tool calls. Terminating workflow execution." ) logger.debug(f"Coordinator response: {response}") return Command( update={"locale": locale, "resources": configurable.resources}, goto=goto, )
对于"deepseek 公司的发展历程"
  • 识别语言为中文 (locale: "zh-CN")
  • 判断这是一个需要研究的任务
  • 调用 handoff_to_planner 工具
  • 转向 background_investigator(因为启用了背景调研)

步骤 2: Background Investigator(背景调研员)

职责: 在制定计划前进行初步的信息收集
def background_investigation_node( state: State, config: RunnableConfig ) -> Command[Literal["planner"]]: """Background investigation node that do background search before planning.""" logger.info("Background investigation is searching.") configurable = Configuration.from_runnable_config(config) user_query = state["messages"][0]["content"] logger.info(f"Background investigation user query: {user_query}") search_tool = get_web_search_tool(configurable.max_search_results) search_result = search_tool.invoke({"query": user_query}) logger.info(f"Background investigation search result: {search_result}") return Command( update={"background_investigation_results": search_result}, goto="planner" )
对于"deepseek 公司的发展历程"
  • 使用搜索工具搜索 "deepseek 公司的发展历程"
  • 收集初步信息,包括:
    • DeepSeek 公司基本介绍
    • 成立时间和背景
    • 主要产品和服务
    • 最新动态等
  • 将结果保存到 background_investigation_results

步骤 3: Planner(规划员)

职责: 基于背景调研结果,制定详细的研究计划
def planner_node( state: State, config: RunnableConfig ) -> Command[Literal["human_feedback", "reporter"]]: """Planner node that generate the full plan.""" logger.info("Planner generating full plan") configurable = Configuration.from_runnable_config(config) plan_iterations = state["plan_iterations"] if state.get("plan_iterations", 0) else 0 messages = apply_prompt_template("planner", state, configurable) if ( plan_iterations == 0 and state.get("enable_background_investigation") and state.get("background_investigation_results") ): messages += [ { "role": "user", "content": ( "background investigation results of user query:\\n" + state["background_investigation_results"] + "\\n" ), } ]
对于"deepseek 公司的发展历程",Planner 会制定类似如下的计划
{ "title": "DeepSeek 公司发展历程研究", "thought": "全面研究 DeepSeek 公司从成立到现在的发展轨迹", "steps": [ { "title": "公司背景与成立历程", "description": "研究 DeepSeek 公司的成立背景、创始团队、初期发展", "step_type": "research" }, { "title": "核心产品与技术发展", "description": "调研 DeepSeek 的主要产品线和技术创新", "step_type": "research" }, { "title": "融资与商业发展", "description": "收集融资历程、商业模式、市场表现", "step_type": "research" }, { "title": "最新发展与未来规划", "description": "了解最新动态和未来发展计划", "step_type": "research" } ] }

步骤 4: Human Feedback(人工反馈)

职责: 等待用户确认或修改计划
由于 auto_accepted_plan: false,系统会暂停并向前端发送中断事件:
if isinstance(event_data, dict): if "__interrupt__" in event_data: yield _make_event( "interrupt", { "thread_id": thread_id, "id": event_data["__interrupt__"][0].ns[0], "role": "assistant", "content": event_data["__interrupt__"][0].value, "finish_reason": "interrupt", "options": [ {"text": "Edit plan", "value": "edit_plan"}, {"text": "Start research", "value": "accepted"}, ], }, )
用户看到计划后可以选择
  • "Start research"(开始研究)- 接受计划
  • "Edit plan"(编辑计划)- 修改计划

步骤 5: Research Team(研究团队)

职责: 协调专门的 agent 执行具体研究任务
def research_team_node( state: State, ) -> Command[Literal["planner", "researcher", "coder"]]: """Research team node that collaborates on tasks.""" logger.info("Research team is collaborating on tasks.") current_plan = state.get("current_plan") if not current_plan or not current_plan.steps: return Command(goto="planner") if all(step.execution_res for step in current_plan.steps): return Command(goto="planner") for step in current_plan.steps: if not step.execution_res: break if step.step_type and step.step_type == StepType.RESEARCH: return Command(goto="researcher") if step.step_type and step.step_type == StepType.PROCESSING: return Command(goto="coder") return Command(goto="planner")

步骤 6: Researcher(研究员)

职责: 执行具体的信息收集和研究任务
async def researcher_node( state: State, config: RunnableConfig ) -> Command[Literal["research_team"]]: """Researcher node that do research""" logger.info("Researcher node is researching.") configurable = Configuration.from_runnable_config(config) tools = [get_web_search_tool(configurable.max_search_results), crawl_tool] retriever_tool = get_retriever_tool(state.get("resources", [])) if retriever_tool: tools.insert(0, retriever_tool) logger.info(f"Researcher tools: {tools}") return await _setup_and_execute_agent_step( state, config, "researcher", tools, )
Researcher 会依次执行每个研究步骤
  1. 公司背景与成立历程
      • 搜索 "DeepSeek 公司成立 创始人 背景"
      • 爬取官方网站和新闻报道
      • 收集成立时间、创始团队、初期发展信息
  1. 核心产品与技术发展
      • 搜索 "DeepSeek 产品 AI模型 技术"
      • 调研其 AI 模型、开发工具等产品线
      • 分析技术特点和创新点
  1. 融资与商业发展
      • 搜索 "DeepSeek 融资 投资 商业模式"
      • 收集融资轮次、投资方、估值信息
      • 了解商业化进展
  1. 最新发展与未来规划
      • 搜索最新新闻和公告
      • 了解近期产品发布和战略调整
💡
Researcher 会选择使用什么工具,默认会使用 web search 工具去获取网络知识,也可以自己配置 MCP ,Researcher 就会根据 Researcher Team 的安排,调用 MCP 工具,返回 MCP 工具的结果。

步骤 7: Reporter(报告员)

职责: 整合所有研究结果,生成最终报告
def reporter_node(state: State): """Reporter node that write a final report.""" logger.info("Reporter write final report") current_plan = state.get("current_plan") input_ = { "messages": [ HumanMessage( f"# Research Requirements\\n\\n## Task\\n\\n{current_plan.title}\\n\\n## Description\\n\\n{current_plan.thought}" ) ], "locale": state.get("locale", "en-US"), } invoke_messages = apply_prompt_template("reporter", input_) observations = state.get("observations", []) # Add a reminder about the new report format, citation style, and table usage invoke_messages.append( HumanMessage( content="IMPORTANT: Structure your report according to the format in the prompt. Remember to include:\\n\\n1. Key Points - A bulleted list of the most important findings\\n2. Overview - A brief introduction to the topic\\n3. Detailed Analysis - Organized into logical sections\\n4. Survey Note (optional) - For more comprehensive reports\\n5. Key Citations - List all references at the end\\n\\nFor citations, DO NOT include inline citations in the text. Instead, place all citations in the 'Key Citations' section at the end using the format: `- [Source Title](URL)`. Include an empty line between each citation for better readability.\\n\\nPRIORITIZE USING MARKDOWN TABLES for data presentation and comparison. Use tables whenever presenting comparative data, statistics, features, or options. Structure tables with clear headers and aligned columns. Example table format:\\n\\n| Feature | Description | Pros | Cons |\\n|---------|-------------|------|------|\\n| Feature 1 | Description 1 | Pros 1 | Cons 1 |\\n| Feature 2 | Description 2 | Pros 2 | Cons 2 |", name="system", ) ) for observation in observations: invoke_messages.append( HumanMessage( content=f"Below are some observations for the research task:\\n\\n{observation}", name="observation", ) ) logger.debug(f"Current invoke messages: {invoke_messages}") response = get_llm_by_type(AGENT_LLM_MAP["reporter"]).invoke(invoke_messages) response_content = response.content logger.info(f"reporter response: {response_content}") return {"final_report": response_content}
Reporter 会生成类似这样的最终报告
# DeepSeek 公司发展历程研究报告 ## 关键要点 - DeepSeek 成立于 2023 年,专注于 AI 大模型研发 - 核心产品包括 DeepSeek-V2、DeepSeek Coder 等模型 - 获得多轮融资,估值快速增长 - 在代码生成和数学推理领域表现突出 ## 概述 DeepSeek 是一家专注于人工智能大模型研发的创新公司... ## 详细分析 ### 公司成立与背景 | 时间节点 | 事件 | 重要性 | |---------|------|--------| | 2023年 | DeepSeek 正式成立 | 公司起点 | | 2023年底 | 发布首个模型 | 技术突破 | ### 核心产品发展 ... ## 主要引用来源 - [DeepSeek官网](<https://deepseek.com>) - [DeepSeek融资新闻](...)

4. 前端实时更新

前端接收流式响应 (web/src/core/store/store.ts):
try { for await (const event of stream) { const { type, data } = event; messageId = data.id; let message: Message | undefined; if (type === "tool_call_result") { message = findMessageByToolCallId(data.tool_call_id); } else if (!existsMessage(messageId)) { message = { id: messageId, threadId: data.thread_id, agent: data.agent, role: data.role, content: "", contentChunks: [], isStreaming: true, interruptFeedback, }; appendMessage(message); } message ??= getMessage(messageId); if (message) { message = mergeMessage(message, event); updateMessage(message); } }
整个流程总结
notion image
  1. Coordinator 识别任务和语言
  1. Background Investigator 进行初步信息收集
  1. Planner 制定详细研究计划
  1. Human Feedback 等待用户确认计划
  1. Research Team 协调执行计划
  1. Researcher 依次执行每个研究步骤,使用搜索和爬虫工具
  1. Reporter 整合所有结果生成最终报告
  1. 前端 实时显示每个 agent 的工作进度和结果
 

Coder 节点的详细解析

1. Coder 节点的职责

Coder 节点是专门负责数据处理和计算分析的 agent:
async def coder_node( state: State, config: RunnableConfig ) -> Command[Literal["research_team"]]: """Coder node that do code analysis.""" logger.info("Coder node is coding.") return await _setup_and_execute_agent_step( state, config, "coder", [python_repl_tool], )

2. 何时调用 Coder 节点

Research Team 的路由逻辑
def research_team_node( state: State, ) -> Command[Literal["planner", "researcher", "coder"]]: """Research team node that collaborates on tasks.""" logger.info("Research team is collaborating on tasks.") current_plan = state.get("current_plan") if not current_plan or not current_plan.steps: return Command(goto="planner") if all(step.execution_res for step in current_plan.steps): return Command(goto="planner") for step in current_plan.steps: if not step.execution_res: break if step.step_type and step.step_type == StepType.RESEARCH: return Command(goto="researcher") if step.step_type and step.step_type == StepType.PROCESSING: return Command(goto="coder") return Command(goto="planner")
关键判断
  • 如果步骤的 step_typeStepType.PROCESSING,则调用 coder 节点
  • 如果步骤的 step_typeStepType.RESEARCH,则调用 researcher 节点

3. StepType 的区别

在 Planner 的提示中明确定义了两种步骤类型
## Step Types and Web Search Different types of steps have different web search requirements: 1. **Research Steps** (`need_search: true`): - Retrieve information from the file with the URL with `rag://` or `http://` prefix specified by the user - Gathering market data or industry trends - Finding historical information - Collecting competitor analysis - Researching current events or news - Finding statistical data or reports 2. **Data Processing Steps** (`need_search: false`): - API calls and data extraction - Database queries - Raw data collection from existing sources - Mathematical calculations and analysis - Statistical computations and data processing

4. Coder 的工具:Python REPL

Coder 使用 Python REPL 工具
@tool @log_io def python_repl_tool( code: Annotated[ str, "The python code to execute to do further analysis or calculation." ], ): """Use this to execute python code and do data analysis or calculation. If you want to see the output of a value, you should print it out with `print(...)`. This is visible to the user.""" if not isinstance(code, str): error_msg = f"Invalid input: code must be a string, got {type(code)}" logger.error(error_msg) return f"Error executing code:\\n```python\\n{code}\\n```\\nError: {error_msg}" logger.info("Executing Python code") try: result = repl.run(code) # Check if the result is an error message by looking for typical error patterns if isinstance(result, str) and ("Error" in result or "Exception" in result): logger.error(result) return f"Error executing code:\\n```python\\n{code}\\n```\\nError: {result}" logger.info("Code execution successful") except BaseException as e: error_msg = repr(e) logger.error(error_msg) return f"Error executing code:\\n```python\\n{code}\\n```\\nError: {error_msg}" result_str = f"Successfully executed:\\n```python\\n{code}\\n```\\nStdout: {result}" return result_str

5. 在"deepseek 公司的发展历程"中的应用场景

虽然这个具体问题主要是信息收集,但如果 Planner 设计了需要数据处理的步骤,Coder 会被调用。例如:
可能的 PROCESSING 步骤
{ "title": "融资数据分析与可视化", "description": "分析 DeepSeek 的融资轮次、金额变化趋势,计算增长率并生成图表", "step_type": "processing", "need_search": false }
Coder 会执行类似的代码
import pandas as pd import matplotlib.pyplot as plt # 创建融资数据 funding_data = { '轮次': ['天使轮', 'A轮', 'B轮', 'C轮'], '时间': ['2023-03', '2023-08', '2024-02', '2024-09'], '金额(万美元)': [100, 1000, 5000, 20000] } df = pd.DataFrame(funding_data) # 计算增长率 df['增长率'] = df['金额(万美元)'].pct_change() * 100 # 生成图表 plt.figure(figsize=(10, 6)) plt.plot(df['轮次'], df['金额(万美元)'], marker='o') plt.title('DeepSeek 融资金额变化趋势') plt.ylabel('融资金额(万美元)') plt.xticks(rotation=45) plt.tight_layout() plt.show() print("融资数据分析:") print(df) print(f"\\n总融资金额: {df['金额(万美元)'].sum()} 万美元") print(f"平均增长率: {df['增长率'].mean():.2f}%")

6. 实际案例:从日志中看到的 Coder 使用

从项目的测试日志文件中可以看到 Coder 的实际使用:
data: {"thread_id": "v1Eu9kk2G2mbuo20adFVX", "agent": "coder", "id": "run-b0102609-c639-4fe0-a768-cbcbf03730b8", "role": "assistant", "content": " Python"} event: message_chunk data: {"thread_id": "v1Eu9kk2G2mbuo20adFVX", "agent": "coder", "id": "run-b0102609-c639-4fe0-a768-cbcbf03730b8", "role": "assistant", "content": " approach"} event: message_chunk data: {"thread_id": "v1Eu9kk2G2mbuo20adFVX", "agent": "coder", "id": "run-b0102609-c639-4fe0-a768-cbcbf03730b8", "role": "assistant", "content": "."} event: tool_calls data: {"thread_id": "v1Eu9kk2G2mbuo20adFVX", "agent": "coder", "id": "run-b0102609-c639-4fe0-a768-cbcbf03730b8", "role": "assistant", "tool_calls": [{"name": "python_repl_tool", "args": {}, "id": "call_iGGx0YR6ROwpg18HGlq81A9E", "type": "tool_call"}], "tool_call_chunks": [{"name": "python_repl_tool", "args": "", "id": "call_iGGx0YR6ROwpg18HGlq81A9E", "index": 0, "type": "tool_call_chunk"}]}

7. Coder 与 Researcher 的配合

典型的配合模式
  1. Researcher 收集原始数据和信息
  1. Coder 对收集的数据进行清洗、分析、计算
  1. Researcher 继续收集补充信息
  1. Coder 进行进一步的数据处理和可视化
  1. Reporter 整合所有结果
这种分工使得系统能够处理既需要信息收集又需要数据分析的复杂任务,充分发挥每个 agent 的专长。
 

三家结论对比

gemini fullstack

💡
DeepSeek是一家中国人工智能公司,由梁文锋于2023年5月创立 techtarget pymnts forbes seo,由梁文锋共同创立并担任首席执行官的量化对冲基金高飞(High-Flyer)拥有并提供资金 wikipedia forbes thesciencesurvey。DeepSeek专注于开发人工智能模型,特别是大型语言模型(LLMs),并以其成本效益高和开放源代码的模型而闻名 wikipedia thesciencesurvey techinasia seo muneebdev
DeepSeek的发展历程如下:
  • 2023年5月: DeepSeek AI由梁文锋创立,脱胎于高飞的Fire-Flyer AI研究部门 seo
  • 2023年11月: DeepSeek发布了其首个开源模型DeepSeek Coder,专注于编码相关任务 seo techtarget
  • 2024年初: DeepSeek LLM(670亿参数)推出,引发了与中国主要科技巨头的价格竞争 seo
  • 2024年5月: DeepSeek-V2发布,该模型在性能和训练成本方面有所改进 seo techtarget thesciencesurvey。DeepSeek-V2系列包含4个模型,包括2个基础模型和2个聊天模型 wikipedia
  • 2024年7月: DeepSeek-Coder-V2(2360亿参数)发布,提供128,000个token的上下文窗口,用于处理复杂的编码挑战 techtarget thesciencesurvey
  • 2024年9月: DeepSeek V2.5推出,并于12月进行了修订 wikipedia
  • 2024年11月: DeepSeek-R1-Lite的预览版通过API和聊天形式提供 wikipedia
  • 2024年12月: DeepSeek-V3-Base和DeepSeek-V3(聊天)发布。DeepSeek-V3采用专家混合(MoE)架构,拥有6710亿参数,上下文长度为128,000 techtarget
  • 2025年1月20日: DeepSeek发布了基于DeepSeek-R1模型的同名聊天机器人,并在iOS和Android平台免费提供 wikipedia。DeepSeek发布了其R1大型语言模型,其成本远低于其他供应商,并以开源许可提供,允许免费使用 techtarget。DeepSeek-R1基于DeepSeek-V3,专注于高级推理任务,在性能上直接与OpenAI的o1模型竞争,同时保持显著较低的成本结构 seo techtarget iiss。该模型与DeepSeek-V3一样,拥有6710亿参数,上下文长度为128,000 techtarget
  • 2025年1月27日: DeepSeek在美国iOS App Store的免费应用下载量超过ChatGPT,导致英伟达股价下跌18% wikipedia。DeepSeek报告称其服务遭受了大规模恶意攻击,迫使公司暂时限制新用户注册 techtarget
  • 2025年3月24日: DeepSeek根据MIT许可发布了DeepSeek-V3-0324 wikipedia
  • 2025年5月: R1-0528模型发布,作为原始R1模型的更新版本 techtarget datacamp
  • 2025年初(预计): DeepSeek-R2预计将推出,有望在多语言推理、代码生成和多模态能力方面取得重大进展 deepseek
DeepSeek的模型以其成本效益和开放性而受到全球认可 forbes wikipedia pymnts。该公司已迅速成为全球AI领域的重要参与者 techtarget pymnts forbes seo。DeepSeek的成功被形容为AI领域的“斯普特尼克时刻”,挑战了美国科技巨头的统治地位 techtarget iiss theceomagazine hyperight newspaceeconomy veritis bittime straive techtarget bruegel thesciencesurvey bain wikipedia
 

deerflow

# DeepSeek 公司发展历程报告 ## 关键要点 * DeepSeek 由一群来自顶尖中国大学的年轻人才创立,致力于通过技术创新实现通用人工智能(AGI)。 * 公司专注于开发先进的大型语言模型(LLM),如 DeepSeek LLM 和 DeepSeek Coder,并在开源社区中积极贡献。 * DeepSeek 获得了阿里巴巴集团和红杉中国的投资,证明了其在人工智能市场的潜力。 * DeepSeek 采取完全开源战略,通过开放模型、研究方法和结果来吸引反馈,并实现迭代优化。 * DeepSeek 的未来发展战略以实现 AGI、优化成本效益以及促进社区驱动的创新为中心。 * 目前没有关于 DeepSeek 在人工智能伦理和安全方面的实践的具体信息。 --- ## 概述 本报告旨在分析 DeepSeek 公司的发展历程,涵盖其早期发展、组织结构、技术研发方向、融资情况、市场竞争格局以及未来发展战略。DeepSeek 是一家新兴的人工智能公司,专注于开发大型语言模型和推动人工智能技术的创新与普及。通过对 DeepSeek 的发展历程进行深入研究,可以更好地了解该公司在人工智能领域的影响和潜力。 --- ## 详细分析 ### 早期发展 由于 DeepSeek 公司成立时间较短,公开的早期发展信息有限。目前已知的信息如下: * DeepSeek 成立于 2023 年,由梁文峰创立,旨在实现人类水平的人工智能。[<https://blog.csdn.net/qq_30776829/article/details/145476794>] * 公司的成立愿景是通过自下而上的技术创新,克服资源和数据效率瓶颈。[<https://blog.csdn.net/qq_30776829/article/details/145476794>] ### 组织结构与核心团队 DeepSeek 的组织结构类似于 OpenAI,强调人才发展和资源灵活性。核心团队由来自清华大学和北京大学等顶尖中国大学的年轻人才组成,他们在自然语言处理(NLP)、深度学习和代码学习方面拥有强大的技术背景。主要团队成员包括: * 高华座 * 曾望丁 * 邵志弘 * 朱其浩 (负责代码生成模型) * 王培漪 * 郭大亚 (负责数学推理模型) * 戴大麦 (负责语言模型迭代) * 赵成刚 (负责训练和推理效率) * 吴宇 (负责后训练优化) DeepSeek 的招聘逻辑优先考虑 "年轻的高潜力人才",通常是 1998 年左右出生且工作经验少于五年的人才。[<https://blog.csdn.net/qq_30776829/article/details/145476794>] ![Image of Deepseek核心团队曝光!](<https://i-blog.csdnimg.cn/img_convert/afd24b0a1dec888456fc8bd17563292c.png>) ![Image of 企业官网](<https://i-blog.csdnimg.cn/img_convert/e978776f45212e2c35170e41182fee3f.png>) ![Image of 团队信息](<https://i-blog.csdnimg.cn/img_convert/367b5b7dc70781c171758075ba83afa4.png>) ### 技术研发方向与突破 DeepSeek 专注于开发先进的大型语言模型(LLM),如 DeepSeek LLM 和 DeepSeek Coder。 * DeepSeek-V3 在各项评估中超越了其他开源模型,并且可以与 GPT-4o 和 Claude-3.5-Sonnet 等顶级闭源模型相媲美。训练 DeepSeek V3 的成本约为 600 万美元。 * DeepSeek-R1 在 Chatbot Arena 排行榜上名列第三,在代码和数学等技术要求高的领域表现出色。[<https://blog.csdn.net/qq_30776829/article/details/145476794>] * R1 模型通过强化学习展示了增强的推理能力,以一小部分成本实现了与 OpenAI 的 o1 模型相当的性能。[<https://blog.csdn.net/qq_30776829/article/details/145476794>] ![Image of 深度思考(R1)模式](<https://i-blog.csdnimg.cn/img_convert/b6eadbc1054e90589292d85bb87db9d4.png>) ### 开源社区参与 DeepSeek 采取完全开源战略,这推动了开放性、协作和技术生态系统的发展。它使用 MIT 许可证来促进技术采用和协作。[<https://devpress.csdn.net/v1/article/detail/145114487>] 公司公开分享模型、研究方法和结果,以吸引反馈并进行迭代优化。他们发布了关键的代码库,如 Flash MLA 和 DeepEP,与全球开发者社区分享研究进展。 ### 融资情况 DeepSeek 获得了阿里巴巴集团和红杉中国的投资。[<https://blog.csdn.net/qq_30776829/article/details/145476794>] 虽然关于融资轮次(金额、日期和估值)的具体细节很少,但他们吸引阿里巴巴和红杉资本等主要投资者的能力突显了其在人工智能市场的潜力。 ### 市场竞争 DeepSeek 的主要重点是开发大型语言模型(LLM),这使其与 OpenAI(GPT 模型)、Google(Gemini)和其他开发类似模型的人工智能公司直接竞争。[<https://blog.csdn.net/qq_30776829/article/details/145476794>] ### 未来发展战略 DeepSeek 旨在通过根本的技术创新实现通用人工智能(AGI)。[<https://blog.csdn.net/qq_30776829/article/details/145476794>] 他们专注于软硬件协同优化以降低训练成本,并在训练/推理效率和后训练优化方面取得进展,这表明其战略重点在于成本效益和性能。[<https://devpress.csdn.net/v1/article/detail/146065647>] ### 人工智能伦理与安全 搜索结果中没有关于 DeepSeek 的人工智能伦理和安全实践的具体信息。 信息未提供 --- ## 关键引文 - [Deepseek核心团队曝光!- CSDN博客](<https://blog.csdn.net/qq_30776829/article/details/145476794>) - [Deepseek+HR丨组织架构图自动生成工具如何保持实时更新 - 三茅网](<https://m.hrloo.com/news/335894.html>) - [杭州深度求索人工智能基础技术研究有限公司_百度百科](<https://baike.baidu.com/item/杭州深度求索人工智能基础技术研究有限公司/64541110>) - [Deepseek+HR丨组织架构图自动生成工具如何保持实时更新 - 三茅网](<https://m.hrloo.com/news/335894.html>) - [DeepSeek简介、创始人及背景、团队成员、核心产品、主营业务、招聘要求条件及薪资等 - 征贤令-中国首家泛国际人才招聘平台](<https://zhengxianling.com/index.php?m=article&c=show&id=254>) - [Deepseek的发展与成就原创 - CSDN博客](<https://blog.csdn.net/2502_91001683/article/details/146073883>) - [Deepseek技术浅析(一) - 技术栈 - jishuzhan.net](<https://jishuzhan.net/article/1884904467271258114>) - [DeepSeek的未来发展方向明确吗?其技术创新能否持续呢?合理面对 ...](<https://insight.xiaoduoai.com/ai-efficiency-improvement/is-deepseeks-future-development-direction-clear-can-its-technological-innovation-continue-facing-challenges-rationally-will-lead-to-broad-development-prospects.html>) - [开源社区对DeepSeek生态的贡献评估-天下数据](<https://www.idcbest.com/idcnews/11013584.html>) - [DeepSeek,重磅宣布 - 观察者网](<https://www.guancha.cn/politics/2025_02_21_765888.shtml>) - [5万字详解:深度求索(DeepSeek)开源周报告 - 知乎](<https://zhuanlan.zhihu.com/p/27127875284>) - [排名Top 5 的DeepSeek 相关开源项目](<https://deepseek.csdn.net/67aaf5f582931a478c54324e.html>) - [深度求索 - 维基百科,自由的百科全书](<https://zh.wikipedia.org/wiki/深度求索>) - [DeepSeek横空出世是对全球人工智能发展格局的一次重塑 中国用行动证明开放创新的浪潮无法阻挡](<https://www.thepaper.cn/newsDetail_forward_30101579>)

deepchat

💡
<think>嗯,用户想了解DeepSeek公司的发展历程,这个问题很清晰明确。从用户提供的搜索结果来看,有多篇相关文章详细记载了这家AI公司从创立到2025年初的发展轨迹。
注意到网页3和网页5都提到DeepSeek成立于2023年7月17日,由幻方量化联合创始人梁文峰创立,专注大语言模型研发[3][5]。而关键的技术突破集中在2023年11月到2025年1月期间,根据网页1和网页4的记载:
最早在2023年11月2日发布首个开源模型DeepSeek Coder[1],标志着技术探索的开端。2024年1月密集推出三个重要产品:采用GQA架构的DeepSeek LLM、创新细粒度专家分割的DeepSeek MoE[4],以及2月5日专攻数学推理的DeepSeek Math[4]。
真正引起行业震动的是2024年5月7日发布的DeepSeek V2,其采用的多头潜在注意力(MLA)技术显著降低了推理成本[4]。同年12月26日推出的V3版本更进一步,通过FP8混合精度训练框架实现近乎零开销的跨节点通信[4]。
最新里程碑是2025年1月的DeepSeek R1,这个强化学习驱动的模型无需监督微调就能达到与OpenAI闭源模型相当的推理能力[4]。整个过程呈现出清晰的技术演进路线:从基础架构探索→混合专家优化→高效推理突破→强化学习驱动。
用户可能不仅想了解时间线,更关注技术突破的意义。比如网页4特别强调DeepSeek MoE通过专家级/设备级平衡损失解决传统MoE负载不均问题,这种创新使16B版本能在单40GB内存GPU上部署,极大降低了使用门槛。
考虑到用户提供的资料截止2025年2月,而今天是2025年6月12日,可以补充说明近四个月可能有新进展,但搜索结果尚未覆盖。整体回复将按技术代际划分阶段,突出各阶段核心技术突破与行业影响。 </think>
根据提供的搜索结果,DeepSeek(杭州深度求索人工智能基础技术研究有限公司)的发展历程如下,按时间和技术演进分为四个阶段:

⚙️ 一、初创与技术探索(2023年7月 - 2023年11月)

  • 2023年7月17日:公司由幻方量化联合创始人梁文峰创立,专注于大语言模型(LLM)研发[3][5]。
  • 2023年11月2日:发布首个开源模型 DeepSeek Coder,标志技术探索的起点[1]。

🔬 二、架构创新与模型迭代(2024年1月 - 2024年5月)

  1. 2024年1月
      • 推出 DeepSeek LLM(密集模型):采用分组查询注意力(GQA)优化推理成本,67B模型性能超越LLaMA-2 70B[4]。
      • 发布 DeepSeek MoE:创新细粒度专家分割(Fine-Grained Expert Segmentation)和共享专家隔离技术,解决传统MoE负载不均衡问题[4]。
  1. 2024年2月5日:推出数学推理模型 DeepSeek Math,通过数学预训练、监督微调和强化学习(GRPO算法)提升数学能力,120B模型性能直逼GPT-4[4]。
  1. 2024年5月7日:发布 DeepSeek V2,核心创新包括:
      • 多头潜在注意力(MLA):显著降低推理时KV缓存开销;
      • 无辅助损失的负载均衡策略:优化专家路由效率;
      • 支持长上下文扩展(基于YaRN)[4]。

🚀 三、高效训练与推理突破(2024年12月 - 2025年1月)

  1. 2024年12月26日:推出 DeepSeek V3,关键技术包括:
      • FP8混合精度训练框架:大幅降低训练成本;
      • 多Token预测(MTP):加速推理生成;
      • 通过知识蒸馏提升小模型性能[4]。
  1. 2025年1月:发布强化学习驱动的 DeepSeek R1
      • DeepSeek-R1-Zero:无需监督微调即具备卓越推理能力,与OpenAI模型性能相当;
      • 提炼出6个蒸馏模型,显著提升小模型效率[4]。

🌟 四、技术影响与开源贡献

  • DeepSeek系列模型在开源社区推动LLM高效训练与部署,例如MoE架构优化使16B模型可在单40GB GPU运行[4]。
  • 截至2025年2月,公司已形成从基础模型(LLM)→专业领域模型(Math)→高效推理模型(V2/V3)→强化学习模型(R1)的全栈技术体系[1][4]。

💡 以上信息综合自多篇行业报道与技术分析[1][3][4][5],时间跨度为2023年7月至2025年1月。2025年2月后的进展需关注官方最新动态。