当前位置:首页>python>用 Python 从零打造高级 AI Agent(2026):第一部分

用 Python 从零打造高级 AI Agent(2026):第一部分

  • 2026-02-05 04:25:59
用 Python 从零打造高级 AI Agent(2026):第一部分

如果你问我 2026 年学习 AI Agent 的最佳方式是什么,我会说:绝对是从零自己动手构建。这不仅对学习很重要,如果你要打造一个高效、个性化且健壮的生产级 AI Agent,从零开始往往是最佳选择。比如你能找到的所有 coding agent(如 Claude Code、Codex、Cursor 等),都是针对各自产品定制架构构建的。

当然别误会,LangChain、LangGraph 和 LlamaIndex 等框架在标准任务(例如 RAG 或自动化 workflow)上也很有用。关键是:在把库用到真实复杂任务之前,你需要了解它的能力与局限。

我现在仍然经常用 LangGraph,但更多用于原型阶段。它非常适合做 demo,或用于教学设计模式与 agentic 架构。

在这篇和下一篇文章里,我会手把手带你构建一个具备基础能力并包含若干高级能力的 AI Agent。我还会展示一些常用且实用的设计模式实现。

你可以在这个 Colab 笔记本中找到完整代码并自行尝试:https://colab.research.google.com/drive/1a1hAyRo5f-3ct3a2t0m2C-jdaTymhsSY?usp=sharing


AI Agent 究竟是什么?

AI Agent 的类型很多,如今你几乎到处都能见到。过去的简单 chatbot(如 ChatGPT)现在已经成了拥有工具的 AI Agent——它们可以做网页搜索、推理、生成图像等。Agent 的复杂度取决于它要达成的目标。

例如,一个面向网站访客的客服 agent,可能就是一个带 RAG 工具的 chatbot(以提供准确、最新的回答),再加一个当找不到可靠答案或需要人工介入时自动给人工客服团队起草邮件的工具。

从本质上讲,一个 AI Agent 是这样一个系统,能够:

  1. 感知(Perceive)其环境(理解用户输入)
  2. 推理(Reason)下一步应采取什么行动
  3. 行动(Act),通过使用工具或直接回复
  4. 学习(Learn)结果与反馈(第二部分会讲)

今天我们要构建的,是一个使用 ReAct(Reasoning + Acting)模式,实现前三项能力的基础 agent。

Basic Agent Architecture

架构总览

在编码之前,先理解我们要搭建的结构。本次我们会构建三大组件:

  1. Tool System:管理所有可用工具的灵活注册表
  2. LLM Wrapper:与大语言模型交互的抽象层
  3. Agent Orchestrator:负责整体协调的“大脑”

为什么要这样分层:

  • 工具抽象(Tool Abstraction):通过工具注册表,我们可以在不改动核心逻辑的情况下轻松为 agent 增加新能力。比如你需要一个数据库查询函数?注册一个新工具即可。这就是可扩展性原则的体现,也是所有 Agent 的共性。
  • LLM 与 Agent 分离(LLM/Agent Separation):对生产系统尤为关键。Agent 是 orchestrator,负责管理对话流程、决定何时调用工具、处理整体 workflow。LLM 只是一个提供推理的组件,它像 agent 的“大脑”,但我们需要能够随时“换脑”。

通过解耦,你可以:

  • 在不同 LLM 提供商(Gemini、OpenAI、Claude)之间切换,无需重写 agent 逻辑;
  • 实现失败回退(fallback)策略;
  • 通过任务分配不同模型优化成本;
  • 更易测试:可以独立 mock LLM。

第一步:构建 Tool System

先从基础设施开始。工具是 agent 的“手脚”,让它能与外部世界交互。

Tool 类

首先需要一种方式来表示单个工具:

from typing importDictListCallableAny

classTool:
def__init__(
        self,
        name: str,
        description: str,
        input_schema: Dict[strAny],
        output_schema: Dict[strAny],
        func: Callable[..., Any],
):
self.name = name
self.description = description
self.input_schema = input_schema
self.output_schema = output_schema
self.func = func
def__call__(self, **kwargs):
returnself.func(**kwargs)

每个工具包含五个关键部分:

  • name:唯一标识符
  • description:工具做什么(对 LLM 理解何时使用它至关重要)
  • input_schema:定义工具期望的参数
  • output_schema:工具返回什么
  • func:实际执行工作的函数

__call__ 方法让 Tool 实例可像普通函数一样调用:tool(a=5, b=3)

Tool Registry

现在我们需要一个中心化的地方来管理所有工具。

from typing importUnionLiteral
from pydantic import BaseModel

classToolRegistry:
def__init__(self):
self.tools: Dict[str, Tool] = {}
defregister(self, tool: Tool):
self.tools[tool.name] = tool
defget(self, name: str) -> Tool:
if name notinself.tools.keys():
raise ValueError(f"Tool '{name}' not found")
returnself.tools[name]
deflist_tools(self) -> List[Dict[strAny]]:
return [
            {
"name": tool.name,
"description": tool.description,
"input_schema": tool.input_schema.model_json_schema(),
            }
for tool inself.tools.values()
        ]
defget_tool_call_args_type(self) -> Union[BaseModel]:
        input_args_models = [tool.input_schema for tool inself.tools.values()]
        tool_call_args = Union[tuple(input_args_models)]
return tool_call_args
defget_tool_names(self) -> Literal[None]:
returnLiteral[*self.tools.keys()]

Registry 是所有能力的中央目录。我们主要用它来注册和获取工具。

  • list_tools()
    :告诉 LLM 它能做什么
    该方法生成所有可用工具的机器可读描述。当我们把它放到 system prompt 中,LLM 就知道自己能访问哪些能力。返回类似:
[
{
"name":"add",
"description":"Add two numbers",
"input_schema":{
"type":"object",
"properties":{
"a":{"type":"integer"},
"b":{"type":"integer"}
},
"required":["a","b"]
}
},
{
"name":"multiply",
"description":"Multiply two numbers",
"input_schema":{...}
}
]

这个 JSON schema 明确告诉 LLM 如何调用每个工具。没有它,LLM 可能会“幻觉”出不存在的工具名,或以错误格式传参。

  • get_tool_call_args_type()
    :运行时校验
    该方法创建所有可能工具参数 schema 的 Union 类型。在 Python typing 中,Union 表示“其中之一”。如果你有两个工具,就会得到:Union[ToolAddArgs, ToolMultiplyArgs]

为什么重要?当 LLM 返回一次 tool 调用时,Pydantic 会校验参数是否匹配这些 schema 中的某一个。如果 LLM 尝试传 {"a": "five", "b": 3}(把 int 写成了字符串),Pydantic 会在工具执行前捕获错误。这能防止运行时异常并提供清晰反馈。

注:我们使用 Pydantic,因为它正在成为 LLM API 进行 tool 调用与结构化输出的事实标准。当然,如果你想用简易 JSON,也能轻易在 Pydantic 与 JSON 之间转换。

  • get_tool_names()
    :防止幻觉
    该方法生成仅包含有效工具名的 Literal 类型:Literal["add", "multiply"]。这是一个强约束:LLM 只能返回 Registry 中真实存在的工具名。

没有它,LLM 可能会自信地调用一个你从未创建过的“divide”。有了结构化输出与 Literal 约束后,LLM 被迫从允许的集合中选择;如果试图使用无效名称,API 会拒绝响应并让模型重试。

这三个方法共同打造了稳健的类型安全体系,弥合了 LLM 的概率世界与 Python 代码的确定世界之间的鸿沟,把模糊请求转化为可验证、可执行的函数调用。

下面看看如何使用工具抽象类与 Registry 来创建并注册新工具。

注册我们的第一个工具

先创建两个简单工具来演示系统:

defadd(a: int, b: int) -> int:
return a + b

defmultiply(a: int, b: int) -> int:
return a * b

以上就是执行期会被调用的工具函数。

接下来用 Pydantic 定义每个工具的输入 schema:

classToolAddArgs(BaseModel):
    a: int
    b: int

classToolMultiplyArgs(BaseModel):
    a: int
    b: int

然后实例化工具 Registry 并注册工具:

registry = ToolRegistry()

registry.register(
    Tool(
        name="add",
        description="Add two numbers",
        input_schema=ToolAddArgs,
        output_schema={"result""int"},
        func=add,
    )
)
registry.register(
    Tool(
        name="multiply",
        description="Multiply two numbers",
        input_schema=ToolMultiplyArgs,
        output_schema={"result""int"},
        func=multiply,
    )
)

第二步:用 Pydantic 实现类型安全

你可能会想:“为什么不用普通字典或 JSON?”这是关于结构化输出与类型安全的问题。

在与 LLM 协作时,最大挑战之一是确保它返回的数据格式能被你的代码可靠处理。即使在 2026 年,我们已经有了在工具使用上训练良好的可靠 LLM,但“幻觉”依然是未解难题,所以我们需要类型与结构校验。

Pydantic 模型就像契约,它们可以:

  1. 自动校验输入数据;
  2. 在数据无效时提供清晰错误信息;
  3. 为 IDE 自动补全提供更好开发体验;
  4. 生成现代 LLM 可用的 JSON schema,用于结构化输出。

定义 Agent 可能采取的动作:

# Get type-safe tool names and arguments
ToolNameLiteral = registry.get_tool_names()
ToolArgsUnion = registry.get_tool_call_args_type()

classToolCall(BaseModel):
    action: Literal["tool"]
    thought: str
    tool_name: ToolNameLiteral
    args: ToolArgsUnion
classFinalAnswer(BaseModel):
    action: Literal["final"]
    answer: str
LLMResponse = Union[ToolCall, FinalAnswer]

这个结构强制实现 ReAct 模式。LLM 必须:

  • 选择一个 action 类型("tool" 或 "final")
  • 如果调用工具:提供思考过程(thought)、工具名和有效参数
  • 如果给出最终答案:提供答案文本

ToolNameLiteral 确保 LLM 只能调用真实存在的工具;ToolArgsUnion 确保参数匹配对应工具期望的 schema。


第三步:LLM Wrapper

现在集成 Google 的 Gemini API。我在教程中常用 Gemini,因为它提供免费的 API 配额。当然你也可以用其他提供商;你只需要按其 API 文档改写此类即可。

import json
from google import genai
from google.genai import types

classGeminiLLM:
def__init__(self, client, tool_registry, model="gemini-2.5-flash"):
self.client = client
self.model = model
self.tool_registry = tool_registry
self.system_instruction = self._create_system_instruction()

System Prompt

System prompt 用来教 Agent“如何”行为。这里我们使用一个简单的 system prompt,但在实际产品中它会复杂得多。这是最关键的部分之一:

def_create_system_instruction(self) -> str:
    tools_description = json.dumps(
self.tool_registry.list_tools(),
        indent=2
    )

    system_prompt = """
You are a conversational AI agent that can interact with external tools.
CRITICAL RULES (MUST FOLLOW):
- You are NOT allowed to perform operations internally that could be performed by an available tool.
- If a tool exists that can perform any part of the task, you MUST use that tool.
- You MUST NOT skip tools, even for simple or obvious steps.
- You MUST NOT combine multiple operations into a single step unless a tool explicitly supports it.
- You may ONLY produce a final answer when no available tool can further advance the task.
TOOL USAGE RULES:
- Each tool call must perform exactly ONE meaningful operation.
- If the task requires multiple operations, you MUST call tools sequentially.
- If multiple tools could apply, choose the most specific one.
RESPONSE FORMAT (STRICT):
- You MUST respond ONLY in valid JSON.
- Never include explanations outside JSON.
- You must choose exactly one action per response.
Tool call format:
{
  "action": "tool",
  "thought": "...",
  "tool_name": "...",
  "inputs": { ... }
}
Final answer format:
{
  "action": "final",
  "answer": "..."
}"""
 + "\\n\\nAvailable tools with description:\\n" + tools_description
return system_prompt

为什么规则要这么严格?

LLM 受到“尽量有帮助”的训练,常会尝试在内部做运算或推理。但我们希望 Agent 具备可观测性与可靠性。强制它在每一步都使用工具,可以让我们:

  • 记录并调试每一步;
  • 在不改动 Agent 的前提下替换工具实现;
  • 独立测试工具;
  • 保留清晰的审计轨迹。

这就是 ReAct 模式的精髓:显式的推理(“thought”)+ 显式的动作(“tool_name” + “args”)。

为 Gemini 格式化对话历史

不同 LLM 提供商的消息格式不同。下面将通用历史记录转换为 Gemini 所需格式:

def_format_gemini_chat_history(self, history: list[dict]) -> list:
    formatted_history = []
for message in history:
if message["role"] == "user":
            formatted_history.append(types.Content(
                    role="user",
                    parts=[
                        types.Part.from_text(text=message["content"])
                    ]
                )
            )
if message["role"] == "assistant":
            formatted_history.append(types.Content(
                    role="model",
                    parts=[
                        types.Part.from_text(text=message["content"])
                    ]
                )
            )
if message["role"] == "tool":
            formatted_history.append(types.Content(
                    role="tool",
                    parts=[
                        types.Part.from_function_response(
                            name=message["tool_name"],
                            response={'result': message["tool_response"]},
                        )
                    ]
                )
            )
return formatted_history

这种抽象很关键。我们的 Agent 使用简单、与提供商无关的消息格式,每个 LLM wrapper 自己处理各自的格式细节。

启用结构化输出的响应生成

最后,以结构化输出方式调用 LLM:

defgenerate(selfhistory: list[dict]) -> str:
    gemini_history_format = self._format_gemini_chat_history(history)
    response = self.client.models.generate_content(
        model=self.model,
        contents=gemini_history_format,
        config=types.GenerateContentConfig(
            temperature=0,
            response_mime_type="application/json",
            response_schema=LLMResponse,
            system_instruction=self.system_instruction,
            automatic_function_calling=types.AutomaticFunctionCallingConfig(disable=True)
        ),
    )
return response.text

关键参数:

  • temperature=0:我们希望确定性、稳定的行为;
  • response_mime_type="application/json":强制 JSON 输出;
  • response_schema=LLMResponse:用我们的 Pydantic 模型进行校验;
  • 关闭 automatic_function_calling:我们希望手动控制工具执行。

第四步:Agent Orchestrator

现在把一切整合起来。Agent 负责管理对话循环:

classAgent:
def__init__(self, llm, tool_registry, max_steps=5):
self.llm = llm
self.tool_registry = tool_registry
self.history = []
self.max_steps = max_steps

max_steps 用来防止死循环,这是 agent 卡住时的安全机制。

ReAct 循环

核心逻辑如下:

defrun(self, user_input: str):
self.history.append({"role""user""content": user_input})
for step inrange(self.max_steps):
# Get LLM decision
        llm_output = self.llm.generate(self.history)
        action = json.loads(llm_output)
if action["action"] == "tool":
# Record the thought process
self.history.append(
                {"role""assistant""content": llm_output}
            )
# Execute the tool
            tool = self.tool_registry.get(action["tool_name"])
            result = tool(**action["args"])
# Record the result
            observation = f"Tool {tool.name} returned: {result}"
self.history.append(
                {"role""tool""tool_name": tool.name, "tool_response": result}
            )
continue
if action["action"] == "final":
self.history.append(
                {"role""assistant""content": llm_output}
            )
return action["answer"]
raise RuntimeError("Agent did not terminate within max_steps")

循环解析:

  1. 把用户输入加入历史,Agent 需要上下文;
  2. LLM 基于完整上下文生成一次决策;
  3. 如果是 tool 调用:
    • 记录决策(thought);
    • 执行工具;
    • 记录结果(observation);
    • 继续下一轮;
  4. 如果是 final 答案:结束;
  5. 安全检查:超过最大步数则报错。

第五步:整合运行

初始化并创建一个简单的对话界面:

from google import genai

# Initialize the client (you'll need your API key)
client = genai.Client(api_key=GEMINI_API_KEY)
# Create LLM and Agent
llm = GeminiLLM(client, registry)
agent = Agent(llm, registry)
defchat_with_agent(agent: Agent):
print("Welcome! Type 'exit' to quit.\n")
whileTrue:
        user_input = input("You: ")
if user_input.lower() in ["exit""quit""q"]:
print("Goodbye!")
break
try:
            response = agent.run(user_input)
print(f"Agent: {response}")
except RuntimeError as e:
print(f"Agent error: {e}")
except Exception as e:
print(f"Unexpected error: {e}")
# Start chatting
chat_with_agent(agent)

示例:看看 Agent 的表现

问它:“What is 5 plus 3, then multiply the result by 2?”(5 加 3,然后把结果乘以 2?)

步骤 1:LLM 收到问题并回应:

{
"action""tool",
"thought""I need to first add 5 and 3",
"tool_name""add",
"args": {"a"5"b"3}
}

步骤 2:Agent 执行 add(5, 3) → 返回 8

步骤 3:LLM 看到结果后回应:

{
"action""tool",
"thought""Now I need to multiply 8 by 2",
"tool_name""multiply",
"args": {"a"8"b"2}
}

步骤 4:Agent 执行 multiply(8, 2) → 返回 16

步骤 5:LLM 回应:

{
"action""final",
"answer""The result is 16"
}

注意 agent 如何把任务拆解为离散步骤、每一步都使用工具,并提供清晰解释。这种透明性让 AI Agent 更易调试且更值得信赖。


为什么这种架构很重要

你可能会想:“对一个简单计算器来说,这似乎是很多样板代码。”没错!但这套基础恰恰强大之处在于:

1. 可扩展性(Extensibility)

想加一个天气 API?写个函数然后注册即可:

classWeatherArgs(BaseModel):
city: str

defget_weather(city: str) -> str:
# API call here
return f"Weather in {city}: Sunny, 72°F"
registry.register(Tool(
    name="get_weather",
    description="Get current weather for a city",
    input_schema=WeatherArgs,
    output_schema={"weather""str"},
    func=get_weather
))

无需改动 agent 逻辑。LLM 会从 system prompt 自动“学习”新工具。

2. 提供商灵活性(Provider Flexibility)

需要从 Gemini 切换到 OpenAI?实现一个相同接口的 OpenAILLM 类:

classOpenAILLM:
def__init__(self, client, tool_registry, model="gpt-4"):
# Similar structure, different API calls
        pass
defgenerate(selfhistory: list[dict]) -> str:
# OpenAI-specific implementation
            pass
# Swap it in
llm = OpenAILLM(openai_client, registry)
agent = Agent(llm, registry)  # Everything else stays the same!

3. 可测试性(Testability)

你可以分别测试每个组件:

  • 单测工具本身;
  • mock LLM 来测试 agent 逻辑;
  • 做端到端验证整体流程。

4. 可观测性(Observability)

每一步都记录在历史中。你可以:

  • 记录全部 tool 调用用于调试;
  • 分析哪些工具最常被使用;
  • 找出 agent 的薄弱环节;
  • 构建分析仪表盘。

我们已经完成了什么

在这篇文章中,我们构建了一个基础 AI Agent,具备:

  • 模块化的工具系统;
  • 类型安全的结构化输出;
  • 与提供商无关的 LLM 集成;
  • ReAct 推理模式;
  • 清晰的关注点分离。

但这只是开始。我们的 agent 仍然是无状态(对话间无记忆)、没有人工把关、可观测性也有限。


下一步:第二部分

在下一篇中,我们会为这个 agent 增添生产级能力:

  1. Long-term Memory:用向量数据库记住过往对话,从交互中学习
  2. Human-in-the-Loop(HITL):在关键动作上暂停并等待人工批准
  3. Advanced Observability:日志、链路追踪与监控
  4. Error Recovery:优雅处理工具失败并实现重试逻辑

这些特性对生产系统至关重要。

自己动手试试

最好的学习方式就是动手构建。拿这份代码来:

  • 增加你自己的工具(API、数据库查询、文件操作)
  • 试验不同的 system prompt
  • 尝试不同的 LLM 提供商
  • 故意“整坏”它看看会发生什么!

完整代码都在这个 Colab 笔记本里,马上开玩:https://colab.research.google.com/drive/1a1hAyRo5f-3ct3a2t0m2C-jdaTymhsSY?usp=sharing


最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-02-07 12:16:38 HTTP/2.0 GET : https://f.mffb.com.cn/a/471087.html
  2. 运行时间 : 0.350247s [ 吞吐率:2.86req/s ] 内存消耗:4,720.62kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=85a15d936b7077344c42932df77008c8
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.001078s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001595s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.015893s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.023168s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.001457s ]
  6. SELECT * FROM `set` [ RunTime:0.008927s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.001854s ]
  8. SELECT * FROM `article` WHERE `id` = 471087 LIMIT 1 [ RunTime:0.009293s ]
  9. UPDATE `article` SET `lasttime` = 1770437799 WHERE `id` = 471087 [ RunTime:0.006060s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000702s ]
  11. SELECT * FROM `article` WHERE `id` < 471087 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.003311s ]
  12. SELECT * FROM `article` WHERE `id` > 471087 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.019819s ]
  13. SELECT * FROM `article` WHERE `id` < 471087 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.024348s ]
  14. SELECT * FROM `article` WHERE `id` < 471087 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.055684s ]
  15. SELECT * FROM `article` WHERE `id` < 471087 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.015530s ]
0.354159s