乐于分享
好东西不私藏

RAGFlow源码解析-7、Agent画布系统与组件编排深度解析(第五周)

RAGFlow源码解析-7、Agent画布系统与组件编排深度解析(第五周)

一、Graph基类架构设计

1.1 DSL数据结构定义

源码位置agent/canvas.py:40-77

classGraph:    """        dsl = {            "components": {                "begin": {                    "obj":{                        "component_name""Begin",                        "params": {},                    },                    "downstream": ["answer_0"],                    "upstream": [],                },                "retrieval_0": {                    "obj": {                        "component_name""Retrieval",                        "params": {}                    },                    "downstream": ["generate_0"],                    "upstream": ["answer_0"],                },                "generate_0": {                    "obj": {                        "component_name""Generate",                        "params": {}                    },                    "downstream": ["answer_0"],                    "upstream": ["retrieval_0"],                }            },            "history": [],            "path": ["begin"],            "retrieval": {"chunks": [], "doc_aggs": []},            "globals": {                "sys.query""",                "sys.files": []            }        }        """

DSL结构解析表

字段名
类型
说明
示例
components
dict
组件字典,key为组件ID
{"begin": {...}, "retrieval_0": {...}}
components[id].obj
dict
组件对象定义
{"component_name": "Begin", "params": {}}
components[id].downstream
list
下游组件ID列表
["answer_0"]
components[id].upstream
list
上游组件ID列表
["retrieval_0"]
history
list
对话历史记录
[{"role": "user", "content": "..."}]
path
list
执行路径(已执行组件ID)
["begin", "retrieval_0"]
retrieval
dict
检索结果缓存
{"chunks": [], "doc_aggs": []}
globals
dict
全局变量
{"sys.query": "", "sys.files": []}

组件关系图示例


1.2 Graph初始化与加载

源码位置agent/canvas.py:79-106

def __init__(self, dsl: str, tenant_id=None, task_id=None, custom_header=None):    self.path = []  # 第80行:执行路径初始化    self.components = {}  # 第81行:组件字典初始化    self.error = ""  # 第82行:错误信息    self.dsl = json.loads(dsl)  # 第83行:解析DSL JSON字符串    self._tenant_id = tenant_id  # 第84行:租户ID    self.task_id = task_id if task_id else get_uuid()  # 第85行:任务ID(自动生成UUID)    self.custom_header = custom_header  # 第86行:自定义HTTP头    self._thread_pool = ThreadPoolExecutor(max_workers=5)  # 第87行:线程池(最大5个工作线程)    self.load()  # 第88行:加载组件def load(self):    self.components = self.dsl["components"]  # 第91行:获取组件字典    cpn_nms = set([])  # 第92行:组件名称集合    # 第93-103行:遍历组件并实例化    for k, cpn in self.components.items():        cpn_nms.add(cpn["obj"]["component_name"])  # 第94行:记录组件名称        # 第95-97行:创建参数对象并更新        param = component_class(cpn["obj"]["component_name"] + "Param")()  # 第95行:动态创建参数类        cpn["obj"]["params"]["custom_header"] = self.custom_header        param.update(cpn["obj"]["params"])  # 第97行:更新参数        try:            param.check()  # 第99行:参数校验        except Exception as e:            raise ValueError(self.get_component_name(k) + f": {e}")  # 第101行:抛出校验错误        # 第103行:实例化组件对象        cpn["obj"] = component_class(cpn["obj"]["component_name"])(self, k, param)    self.path = self.dsl["path"]  # 第105行:恢复执行路径

组件加载流程图

关键技术点

  1. 动态参数类创建
    (第95行):component_class(cpn["obj"]["component_name"] + "Param")(),根据组件名称动态创建对应的参数类(如BeginParamRetrievalParam
  2. 参数校验机制
    (第99-101行):param.check()执行参数校验,失败时抛出包含组件名称的详细错误信息
  3. 组件工厂模式
    (第103行):component_class(component_name)根据组件名称动态选择组件类,实现解耦
  4. 线程池预分配
    (第87行):ThreadPoolExecutor(max_workers=5)预分配5个工作线程,用于并发执行组件

1.3 变量系统设计

源码位置agent/canvas.py:162-265

def get_value_with_variable(self, value: str) -> Any:    # 第163行:正则匹配变量表达式 {{变量名}}    pat = re.compile(r"\{* *\{([a-zA-Z:0-9]+@[A-Za-z0-9_.-]+|sys\.[A-Za-z0-9_.]+|env\.[A-Za-z0-9_.]+)\} *\}*")    out_parts = []    last = 0    # 第167-184行:遍历所有匹配项    for m in pat.finditer(value):        out_parts.append(value[last:m.start()])  # 第168行:添加匹配前的文本        key = m.group(1)  # 第169行:提取变量名        v = self.get_variable_value(key)  # 第170行:获取变量值        if v is None:            rep = ""        elif isinstance(v, partial):            # 第173-177行:处理partial函数(延迟执行)            buf = []            for chunk in v():                buf.append(chunk)            rep = "".join(buf)        elif isinstance(v, str):            rep = v        else:            rep = json.dumps(v, ensure_ascii=False)  # 第181行:JSON序列化        out_parts.append(rep)  # 第183行:添加替换值        last = m.end()    out_parts.append(value[last:])  # 第186行:添加剩余文本    return("".join(out_parts))def get_variable_value(self, exp: str) -> Any:    exp = exp.strip("{").strip("}").strip(" ").strip("{").strip("}")  # 第190行:清理花括号    # 第191-192行:全局变量(无@符号)    if exp.find("@") < 0:        return self.globals[exp]    # 第193-204行:组件变量(cpn_id@var_nm格式)    cpn_id, var_nm = exp.split("@")  # 第193行:分割组件ID和变量名    cpn = self.get_component(cpn_id)    if not cpn:        raise Exception(f"Can't find variable: '{cpn_id}@{var_nm}'")    parts = var_nm.split("."1)  # 第197行:分割根键和路径    root_key = parts[0]    rest = parts[1if len(parts) > 1 else ""    root_val = cpn["obj"].output(root_key)  # 第200行:获取组件输出    if not rest:        return root_val    return self.get_variable_param_value(root_val, rest)  # 第204行:递归获取嵌套值def get_variable_param_value(self, obj: Any, path: str) -> Any:    cur = obj    if not path:        return cur    # 第210-232行:遍历路径键    for key in path.split('.'):        if cur is None:            return None        # 第214-218行:字符串尝试JSON解析        if isinstance(cur, str):            try:                cur = json.loads(cur)            except Exception:                return None        # 第220-222行:字典类型        if isinstance(cur, dict):            cur = cur.get(key)            continue        # 第224-230行:列表/元组类型(支持索引访问)        if isinstance(cur, (listtuple)):            try:                idx = int(key)                cur = cur[idx]            except Exception:                return None            continue        cur = getattr(cur, key, None)  # 第232行:对象属性访问    return cur

变量表达式语法表

表达式格式
说明
示例
{{sys.query}}
全局系统变量
当前用户查询
{{sys.files}}
全局文件列表
上传的文件列表
{{env.API_KEY}}
环境变量
系统环境变量
{{retrieval_0@chunks}}
组件输出变量
retrieval_0组件的chunks输出
{{retrieval_0@chunks.0.content}}
嵌套路径访问
第一个chunk的content字段
{{generate_0@output.text}}
对象属性访问
generate_0输出的text属性

变量解析流程图

关键技术点

  1. 正则表达式匹配
    (第163行):\{* *\{([a-zA-Z:0-9]+@[A-Za-z0-9_.-]+|sys\.[A-Za-z0-9_.]+|env\.[A-Za-z0-9_.]+)\} *\}*支持单花括号和双花括号两种格式
  2. partial延迟执行
    (第173-177行):如果变量值是partial函数,延迟执行并收集结果,用于流式输出
  3. 多类型路径访问
    (第210-232行):支持字典、列表、对象属性的统一路径访问语法
  4. 字符串JSON解析
    (第214-218行):遇到字符串类型尝试JSON解析,支持JSON字符串嵌套访问

1.4 组件获取与类型判断

源码位置agent/canvas.py:147-160

def get_component(self, cpn_id) -> Union[Nonedict[strAny]]:    return self.components.get(cpn_id)  # 第148行:获取组件字典def get_component_obj(self, cpn_id) -> ComponentBase:    return self.components.get(cpn_id)["obj"]  # 第151行:获取组件实例对象def get_component_type(self, cpn_id) -> str:    return self.components.get(cpn_id)["obj"].component_name  # 第154行:获取组件类型名称def get_component_input_form(self, cpn_id) -> dict:    return self.components.get(cpn_id)["obj"].get_input_form()  # 第157行:获取组件输入表单def get_tenant_id(self):    return self._tenant_id  # 第160行:获取租户ID

组件访问接口设计


二、Canvas画布系统

2.1 Canvas继承关系

源码位置agent/canvas.py:279-300

class Canvas(Graph):  # 第279行:继承Graph基类    def __init__(self, dsl: str, tenant_id=None, task_id=None, canvas_id=None, custom_header=None):        # 第282-285行:初始化全局变量        self.globals = {            "sys.query""",  # 用户查询            "sys.files": []   # 文件列表        }        self.variables = {}  # 第286行:局部变量字典        # 第287行:调用父类初始化        super().__init__(dsl, tenant_id, task_id, custom_header=custom_header)        self._id = canvas_id  # 第288行:画布ID    def load(self):        super().load()  # 第291行:调用父类加载        # 第292-299行:加载历史和全局变量        self.history = self.dsl["history"]        if "globals" in self.dsl:            self.globals = self.dsl["globals"]        else:            self.globals = {                "sys.query""",                "sys.files": []            }        # 第300-305行:加载变量和检索结果        if "variables" in self.dsl:            self.variables = self.dsl["variables"]        else:            self.variables = {}        self.retrieval = self.dsl["retrieval"]  # 第307行:检索结果        self.memory = self.dsl.get("memory", [])  # 第308行:记忆列表

Canvas扩展字段表

字段名
类型
说明
继承自
globals
dict
全局变量(sys.query、sys.files)
Canvas
variables
dict
局部变量
Canvas
history
list
对话历史
Canvas
retrieval
dict
检索结果缓存
Canvas
memory
list
记忆列表
Canvas
_id
str
画布ID
Canvas
components
dict
组件字典
Graph
path
list
执行路径
Graph
error
str
错误信息
Graph

Canvas继承关系图


2.2 Canvas重置机制

源码位置agent/canvas.py:128-137(Graph.reset)+ Canvas.reset

# Graph.reset (第128-136行)def reset(self):    self.path = []  # 第129行:清空执行路径    for k, cpn in self.components.items():        self.components[k]["obj"].reset()  # 第131行:重置所有组件    try:        REDIS_CONN.delete(f"{self.task_id}-logs")  # 第133行:删除Redis日志        REDIS_CONN.delete(f"{self.task_id}-cancel")  # 第134行:删除取消标志    except Exception as e:        logging.exception(e)# Canvas.reset (推测实现)def reset(self, mem=False):    super().reset()  # 调用父类重置    if not mem:  # 如果不保留记忆        self.history = []  # 清空对话历史        self.retrieval = []  # 清空检索结果        self.memory = []  # 清空记忆    print(self.variables)  # 打印变量(调试用)    # 重置全局系统变量    for k in self.globals.keys():        if k.startswith("sys."):            if isinstance(self.globals[k], str):                self.globals[k] = ""  # 字符串类型清空            elif isinstance(self.globals[k], int):                self.globals[k] = 0  # 整数类型归零            elif isinstance(self.globals[k], list):                self.globals[k] = []  # 列表类型清空

重置流程图


三、组件基类设计

3.1 ComponentBase抽象基类

源码位置agent/component/base.py(推测结构)

class ComponentBase:    component_name = "Base"  # 组件名称(类属性)    def __init__(self, canvas, id, param):        self._canvas = canvas  # 画布引用        self._id = id  # 组件ID        self._param = param  # 参数对象        self._output = {}  # 输出字典        self._error = ""  # 错误信息    def reset(self):        """重置组件状态"""        self._output = {}        self._error = ""    def output(self, key=None):        """获取输出"""        if key is None:            return self._output        return self._output.get(key)    def set_output(self, key, value):        """设置输出"""        self._output[key] = value    def error(self):        """获取错误信息"""        return self._error    def set_error(self, msg):        """设置错误信息"""        self._error = msg    async def invoke(self, **kwargs):        """执行组件(子类必须实现)"""        raise NotImplementedError("Subclasses must implement invoke method")    def get_downstream(self):        """获取下游组件列表"""        cpn = self._canvas.get_component(self._id)        return cpn.get("downstream", [])    def get_upstream(self):        """获取上游组件列表"""        cpn = self._canvas.get_component(self._id)        return cpn.get("upstream", [])    def get_input_form(self):        """获取输入表单定义"""        return {}    def __str__(self):        """序列化为JSON字符串"""        return json.dumps({            "component_name"self.component_name,            "params"self._param.to_dict() if hasattr(self._param, "to_dict"else {}        }, ensure_ascii=False)

组件生命周期状态图


3.2 组件参数类设计

参数基类示例

class ComponentParamBase:    def __init__(self):        self.custom_header = None  # 自定义HTTP头    def update(self, params):        """更新参数"""        for k, v in params.items():            if hasattr(self, k):                setattr(self, k, v)    def check(self):        """参数校验(子类可重写)"""        pass    def to_dict(self):        """转换为字典"""        return {k: v for k, v in self.__dict__.items() if not k.startswith('_')}

具体参数类示例(LLMParam)

class LLMParam(ComponentParamBase):    def __init__(self):        super().__init__()        self.llm_id = ""  # LLM模型ID        self.prompt = ""  # 提示词        self.temperature = 0.1  # 温度参数        self.max_tokens = 2048  # 最大token数        self.max_retries = 5  # 最大重试次数        self.delay_after_error = 2.0  # 错误后延迟        self.max_rounds = 5  # 最大轮数        self.tools = []  # 工具列表        self.mcp = []  # MCP服务器列表    def check(self):        """校验参数"""        if not self.llm_id:            raise ValueError("llm_id cannot be empty")        if self.temperature < 0 or self.temperature > 2:            raise ValueError("temperature must be between 0 and 2")

四、核心组件实现

4.1 LLM组件

源码位置agent/component/llm.py(推测结构)

class LLM(ComponentBase):    component_name = "LLM"    def __init__(self, canvas, id, param: LLMParam):        super().__init__(canvas, id, param)        # 创建LLM Bundle        self.chat_mdl = LLMBundle(            canvas.get_tenant_id(),            TenantLLMService.llm_id2llm_type(param.llm_id),            param.llm_id,            max_retries=param.max_retries,            retry_interval=param.delay_after_error,            max_rounds=param.max_rounds        )    async def invoke(self, **kwargs):        """执行LLM调用"""        # 获取上游输出        upstream_output = kwargs.get("input", {})        # 构建提示词(替换变量)        prompt = self._canvas.get_value_with_variable(self._param.prompt)        # 构建消息历史        history = self._canvas.history.copy()        history.append({"role""user""content": prompt})        # 调用LLM        gen_conf = {            "temperature"self._param.temperature,            "max_tokens"self._param.max_tokens        }        ans = ""        async for delta in self.chat_mdl.async_chat_streamly("", history, gen_conf):            if isinstance(delta, str):                ans += delta                yield delta  # 流式输出        # 设置输出        self.set_output("text", ans)        self._canvas.history.append({"role""assistant""content": ans})

LLM组件执行流程图


4.2 Agent组件(带工具)

源码位置agent/component/agent_with_tools.py:83

class Agent(LLM, ToolBase):    component_name = "Agent"    def __init__(self, canvas, id, param: LLMParam):        LLM.__init__(self, canvas, id, param)        # 第89-93行:加载工具        self.tools = {}        for idx, cpn in enumerate(self._param.tools):            cpn = self._load_tool_obj(cpn)            original_name = cpn.get_meta()["function"]["name"]            indexed_name = f"{original_name}_{idx}"  # 工具名添加索引后缀            self.tools[indexed_name] = cpn        # 第96-102行:创建LLM Bundle        self.chat_mdl = LLMBundle(            self._canvas.get_tenant_id(),            TenantLLMService.llm_id2llm_type(self._param.llm_id),            self._param.llm_id,            max_retries=self._param.max_retries,            retry_interval=self._param.delay_after_error,            max_rounds=self._param.max_rounds,            verbose_tool_use=True  # 详细工具使用日志        )        # 第103-107行:构建工具元数据        self.tool_meta = []        for indexed_name, tool_obj in self.tools.items():            original_meta = tool_obj.get_meta()            indexed_meta = deepcopy(original_meta)            indexed_meta["function"]["name"] = indexed_name            self.tool_meta.append(indexed_meta)        # 第109-117行:加载MCP工具        for mcp in self._param.mcp:            _, mcp_server = MCPServerService.get_by_id(mcp["mcp_id"])            custom_header = self._param.custom_header            tool_call_session = MCPToolCallSession(mcp_server, mcp_server.variables, custom_header)            for tnm, meta in mcp["tools"].items():                # 添加MCP工具到tool_meta                # ...

Agent工具调用流程图

关键技术点

  1. 工具名索引化
    (第92行):indexed_name = f"{original_name}_{idx}"防止工具名冲突,支持同名工具多次使用
  2. MCP工具集成
    (第109-117行):支持从MCP服务器动态加载工具,扩展工具生态
  3. verbose_tool_use
    (第101行):启用详细工具使用日志,便于调试工具调用流程
  4. 多继承设计
    (第83行):class Agent(LLM, ToolBase)继承LLM和ToolBase,复用LLM调用和工具管理逻辑

4.3 Retrieval检索组件

推测实现

class Retrieval(ComponentBase):    component_name = "Retrieval"    def __init__(self, canvas, id, param: RetrievalParam):        super().__init__(canvas, id, param)        self.retrieval_mdl = LLMBundle(            canvas.get_tenant_id(),            LLMType.EMBEDDING,            param.embd_id        )    async def invoke(self, **kwargs):        """执行检索"""        # 获取查询(替换变量)        query = self._canvas.get_value_with_variable(self._param.query)        # 调用检索器        from rag.nlp import search        dealer = search.Dealer(settings.docStoreConn)        ranks = await dealer.retrieval(            question=query,            embd_mdl=self.retrieval_mdl,            tenant_ids=[self._canvas.get_tenant_id()],            kb_ids=self._param.kb_ids,            page=1,            page_size=self._param.top_n,            similarity_threshold=self._param.similarity_threshold,            vector_similarity_weight=self._param.vector_similarity_weight        )        # 设置输出        self.set_output("chunks", ranks["chunks"])        self.set_output("doc_aggs", ranks["doc_aggs"])        # 缓存到canvas        self._canvas.retrieval = ranks

4.4 Categorize分类组件

推测实现

class Categorize(ComponentBase):    component_name = "Categorize"    def __init__(self, canvas, id, param: CategorizeParam):        super().__init__(canvas, id, param)        self.chat_mdl = LLMBundle(            canvas.get_tenant_id(),            LLMType.CHAT,            param.llm_id        )    async def invoke(self, **kwargs):        """执行分类"""        # 获取输入文本        input_text = self._canvas.get_value_with_variable(self._param.input)        # 构建分类提示词        categories = self._param.categories  # 分类列表        prompt = f"请将以下文本分类到以下类别之一:{', '.join(categories)}\n\n文本:{input_text}\n\n类别:"        # 调用LLM        history = [{"role""user""content": prompt}]        ans = ""        async for delta in self.chat_mdl.async_chat_streamly("", history, {}):            if isinstance(delta, str):                ans += delta        # 解析分类结果        category = self._parse_category(ans, categories)        # 设置输出        self.set_output("category", category)        # 动态设置下游组件(根据分类结果)        downstream_map = self._param.category_to_downstream        downstream = downstream_map.get(category, self.get_downstream())        # 更新组件的downstream        cpn = self._canvas.get_component(self._id)        cpn["downstream"] = [downstream]

分类组件流程图


4.5 Switch分支组件

推测实现

class Switch(ComponentBase):    component_name = "Switch"    def __init__(self, canvas, id, param: SwitchParam):        super().__init__(canvas, id, param)    async def invoke(self, **kwargs):        """执行分支判断"""        # 获取条件变量        condition_var = self._canvas.get_value_with_variable(self._param.condition)        # 遍历条件分支        for case in self._param.cases:            # 评估条件            if self._evaluate_condition(condition_var, case["condition"]):                # 匹配成功,设置下游组件                cpn = self._canvas.get_component(self._id)                cpn["downstream"] = [case["downstream"]]                self.set_output("matched"case["condition"])                return        # 无匹配,使用默认分支        if self._param.default_downstream:            cpn = self._canvas.get_component(self._id)            cpn["downstream"] = [self._param.default_downstream]            self.set_output("matched""default")    def _evaluate_condition(self, value, condition):        """评估条件"""        # 支持多种条件类型:等于、包含、正则匹配等        if condition.startswith("=="):            return value == condition[2:].strip()        elif condition.startswith("contains:"):            return condition[9:].strip() in str(value)        elif condition.startswith("regex:"):            return bool(re.match(condition[6:].strip(), str(value)))        else:            return value == condition

4.6 Loop循环组件

推测实现

class Loop(ComponentBase):    component_name = "Loop"    def __init__(self, canvas, id, param: LoopParam):        super().__init__(canvas, id, param)    async def invoke(self, **kwargs):        """执行循环"""        # 获取循环变量        items = self._canvas.get_value_with_variable(self._param.items)        if not isinstance(items, (listtuple)):            items = [items]        # 设置循环上下文        self._canvas.variables[f"{self._id}_index"] = 0        self._canvas.variables[f"{self._id}_items"] = items        # 设置下游为循环体第一个组件        cpn = self._canvas.get_component(self._id)        cpn["downstream"] = [self._param.loop_body]        self.set_output("count"len(items))

五、工具系统设计

5.1 ToolBase工具基类

源码位置agent/tools/base.py:126(推测)

class ToolBase:    def __init__(self, canvas, id, param):        self._canvas = canvas        self._id = id        self._param = param    def get_meta(self) -> dict:        """获取工具元数据(OpenAI function calling格式)"""        raise NotImplementedError("Subclasses must implement get_meta")    async def invoke(self, arguments: dict):        """执行工具"""        raise NotImplementedError("Subclasses must implement invoke")    def _load_tool_obj(self, tool_config):        """加载工具对象"""        tool_name = tool_config["component_name"]        tool_param = component_class(tool_name + "Param")()        tool_param.update(tool_config["params"])        return component_class(tool_name)(self._canvas, self._id, tool_param)

工具元数据格式

{  "type": "function",  "function": {    "name": "search_web",    "description": "搜索网络获取信息",    "parameters": {      "type": "object",      "properties": {        "query": {          "type": "string",          "description": "搜索查询词"        },        "top_k": {          "type": "integer",          "description": "返回结果数量",          "default": 5        }      },      "required": ["query"]    }  }}

5.2 内置工具示例

WebSearch工具

class WebSearch(ToolBase):    def get_meta(self) -> dict:        return {            "type""function",            "function": {                "name""web_search",                "description""搜索网络获取实时信息",                "parameters": {                    "type""object",                    "properties": {                        "query": {"type""string""description""搜索查询"},                        "top_k": {"type""integer""default"5}                    },                    "required": ["query"]                }            }        }    async def invoke(self, arguments: dict):        query = arguments["query"]        top_k = arguments.get("top_k"5)        # 调用搜索API        results = await self._search(query, top_k)        return {            "results": results,            "count"len(results)        }

六、完整Agent执行流程

6.1 Canvas.run执行流程

推测实现

async def run(self, **kwargs):    """执行画布"""    # 初始化执行路径    if not self.path:        self.path.append("begin")    # 执行第一个组件    cpn_obj = self.get_component_obj(self.path[0])    async for _ in cpn_obj.invoke(**kwargs):        pass  # 消费流式输出    if cpn_obj.error():        self.error = "[ERROR]" + cpn_obj.error()        return    # 循环执行下游组件    idx = len(self.path) - 1    cpn_obj = self.get_component_obj(self.path[idx])    idx += 1    self.path.extend(cpn_obj.get_downstream())    while idx < len(self.path) and not self.error:        last_cpn = self.get_component_obj(self.path[idx - 1])        cpn_obj = self.get_component_obj(self.path[idx])        # 执行组件(传递上游输出)        async for _ in cpn_obj.invoke(**last_cpn.output()):            pass        if cpn_obj.error():            self.error = "[ERROR]" + cpn_obj.error()            break        idx += 1        self.path.extend(cpn_obj.get_downstream())    # 返回最终输出    if not self.error:        return self.get_component_obj(self.path[-1]).output()    return {}

完整执行流程图


七、设计模式与技术决策总结

7.1 核心设计模式统计表

设计模式
应用位置
实现细节
目的
模板方法
Graph/Canvas生命周期
固定流程:初始化→加载→执行→重置
标准化画布生命周期
工厂模式
component_class函数
根据component_name动态创建组件
解耦组件创建与使用
策略模式
Categorize/Switch组件
根据条件动态选择下游组件
支持分支流程
迭代器模式
Loop组件
遍历items执行循环体
支持循环流程
多继承
Agent(LLM, ToolBase)
继承LLM和ToolBase
复用LLM调用和工具管理
装饰器模式
get_value_with_variable
正则替换变量表达式
实现变量插值
观察者模式
流式输出yield
组件yield增量输出
支持流式响应

7.2 技术决策对比表

技术点
方案A
方案B
选择理由
DSL格式
JSON字符串
Python字典
JSON跨语言通用,便于前端编辑
变量语法
{{变量名}}
${变量名}
双花括号避免与Shell冲突
组件通信
output字典传递
全局消息队列
output字典简单直接,易于调试
工具调用
OpenAI function calling
自定义工具协议
OpenAI格式标准化,生态兼容
流式输出
Python generator yield
回调函数
yield更Pythonic,支持async for
错误处理
组件_error字段
异常抛出
_error字段不中断流程,支持部分失败

7.3 性能优化关键点

Canvas优化

  1. 线程池预分配
    (第87行):ThreadPoolExecutor(max_workers=5)避免动态创建线程开销
  2. 组件实例复用
    (第103行):组件在load时创建,后续执行复用实例,避免重复初始化
  3. Redis日志删除
    (第133-134行):reset时删除Redis日志和取消标志,释放内存

变量系统优化

  1. 正则预编译
    (第163行):re.compile预编译正则表达式,提升匹配性能
  2. partial延迟执行
    (第173-177行):流式输出使用partial延迟执行,避免提前计算
  3. 路径递归解析
    (第210-232行):支持嵌套路径一次解析,避免多次调用

组件执行优化

  1. 下游动态扩展
    (推测):self.path.extend(cpn_obj.get_downstream())支持条件分支动态添加下游
  2. 流式输出消费
    (推测):async for _ in cpn_obj.invoke()消费流式输出,避免内存堆积
  3. 错误中断
    (推测):组件报错立即break,避免无效下游执行

八、源码行号索引表

8.1 Graph/Canvas核心方法

方法名
行号范围
关键功能
Graph.__init__
79-88
DSL解析、线程池初始化
Graph.load
90-105
组件实例化、参数校验
Graph.__str__
107-126
DSL序列化
Graph.reset
128-136
重置组件、删除Redis日志
Graph.get_value_with_variable
162-187
变量插值替换
Graph.get_variable_value
189-204
变量值获取
Graph.get_variable_param_value
206-233
嵌套路径解析
Canvas.__init__
281-288
全局变量初始化
Canvas.load
290-308
加载历史、检索结果

8.2 组件核心方法(推测)

方法名
关键功能
ComponentBase.__init__
绑定canvas、id、param
ComponentBase.reset
清空output和error
ComponentBase.invoke
执行组件(子类实现)
ComponentBase.get_downstream
获取下游组件列表
LLM.invoke
LLM调用、流式输出
Agent.__init__
加载工具、创建LLMBundle
Retrieval.invoke
向量检索
Categorize.invoke
分类判断、动态下游
Switch.invoke
条件分支

九、学习建议与实践路径

9.1 理论学习顺序

9.2 实践调试建议

调试变量解析

# 在agent/canvas.py:170添加日志v = self.get_variable_value(key)print(f"[DEBUG] 变量解析:key={key}, value={v}, type={type(v)}")

调试组件执行

# 在组件invoke方法开始添加日志async def invoke(self, **kwargs):    print(f"[DEBUG] 组件执行:id={self._id}, name={self.component_name}, kwargs={kwargs}")    # ...

调试工具调用

# 在agent/component/agent_with_tools.py工具调用处添加日志tool_result = await tool.invoke(arguments)print(f"[DEBUG] 工具调用:tool={tool_name}, args={arguments}, result={tool_result}")

十、常见问题与解决方案

10.1 变量解析问题

问题1:变量未找到错误

原因:变量表达式中的组件ID不存在或变量名错误

解决方案

# 检查变量表达式格式# 正确:{{retrieval_0@chunks}}# 错误:{{retrieval_0@chunk}}(变量名错误)# 在canvas.py:196添加详细错误信息if not cpn:    available_cpn_ids = list(self.components.keys())    raise Exception(f"Can't find variable: '{cpn_id}@{var_nm}'. Available components: {available_cpn_ids}")

问题2:嵌套路径解析失败

原因:路径中的键不存在或类型不匹配

解决方案

# 在canvas.py:232添加路径解析日志cur = getattr(cur, key, None)if cur is None:    logging.warning(f"路径解析失败:path={path}, current_key={key}, available_keys={dir(obj) ifhasattr(obj, '__dict__'elselist(obj.keys()) ifisinstance(obj, dictelse []}")

10.2 组件执行问题

问题1:组件无限循环

原因:组件下游形成环,如A→B→A

解决方案

# 在执行循环中添加路径检测visited = set()while idx < len(self.path) and not self.error:    cpn_id = self.path[idx]    if cpn_id in visited:        raise Exception(f"检测到循环依赖:组件{cpn_id}已执行过")    visited.add(cpn_id)    # ...

问题2:流式输出未消费

原因:组件yield输出但调用者未消费

解决方案

# 确保使用async for消费流式输出async for _ in cpn_obj.invoke(**kwargs):    pass  # 必须消费,否则流式输出丢失

10.3 工具调用问题

问题1:工具名冲突

原因:多个工具同名,导致调用错误

解决方案

# 已实现:工具名索引化(agent_with_tools.py:92)indexed_name = f"{original_name}_{idx}"# 例如:search_web_0, search_web_1

问题2:MCP工具加载失败

原因:MCP服务器未启动或配置错误

解决方案

# 检查MCP服务器状态docker exec ragflow-container curl http://mcp-server:port/health# 检查MCP配置docker exec ragflow-container cat /ragflow/conf/mcp_config.yaml

十一、扩展阅读与参考资源

11.1 官方文档

  • OpenAI Function Calling
    : https://platform.openai.com/docs/guides/function-calling
  • LangChain Agents
    : https://python.langchain.com/docs/modules/agents/
  • MCP协议
    : https://modelcontextprotocol.io/

11.2 源码关联文件

文件路径
关联内容
agent/component/__init__.py
组件类注册和导出
agent/tools/__init__.py
工具类注册和导出
api/apps/canvas_app.py
Canvas HTTP API接口
api/db/services/canvas_service.py
Canvas数据库服务
rag/llm/chat_model.py
LLM Bundle和聊天模型

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