附录 C:源码地图

个人公众号

全书引用的所有源码文件的索引,按模块分组。

上一章:附录 B:术语表


顶层文件

文件行数主要内容首次引用
src/agentscope/__init__.py~180包初始化、子模块导入、__all__ch13
src/agentscope/_run_config.py~73_ConfigCls(ContextVar 配置)ch03
src/agentscope/_logging.py~47日志配置ch13
src/agentscope/_version.py~4版本号

message/ — 消息类型

文件行数主要内容首次引用
_message_base.py~240Msgch04
_message_block.py~1307 种 ContentBlock TypedDictch04

module/ — 基础模块

文件行数主要内容首次引用
_state_module.py~150StateModule(序列化)ch14

memory/ — 记忆系统

文件行数主要内容首次引用
_working_memory/_base.py~170MemoryBase 抽象接口ch06
_working_memory/_in_memory_memory.py~305InMemoryMemorych06
_long_term_memory/_long_term_memory_base.py~95LongTermMemoryBasech07

model/ — 模型适配

文件行数主要内容首次引用
_model_base.py~80ChatModelBase 抽象接口ch09
_openai_model.py~795OpenAIChatModelch09
_model_response.py~42ChatResponsech09
_model_usage.py~26ChatUsagech09

formatter/ — 格式转换

文件行数主要内容首次引用
_formatter_base.py~130FormatterBase 抽象接口ch08, ch16
_truncated_formatter_base.py~300带截断的模板方法ch08, ch16
_openai_formatter.py~540OpenAIChatFormatterch08
_anthropic_formatter.py~355AnthropicChatFormatterch16

tool/ — 工具系统

文件行数主要内容首次引用
_toolkit.py~1685Toolkitch10, ch17, ch18
_response.py~32ToolResponsech10
_types.py~160RegisteredToolFunction, ToolGroupch10, ch17

agent/ — Agent 实现

文件行数主要内容首次引用
_agent_base.py~775AgentBasech05, ch14
_agent_meta.py~192_AgentMeta 元类 + _wrap_with_hooksch15
_react_agent_base.py~116ReActAgentBase 抽象ch14
_react_agent.py~1140ReActAgent 完整实现ch11

pipeline/ — Pipeline 编排

文件行数主要内容首次引用
_msghub.py~156MsgHubch19
_functional.py~192sequential_pipeline, fanout_pipelinech19
_class.py~90SequentialPipeline, FanoutPipelinech19

tracing/ — 可观测性

文件行数主要内容首次引用
_trace.py~6505 种 trace 装饰器ch20
_setup.py~50setup_tracingch20

_utils/ — 工具函数

文件行数主要内容首次引用
_common.py~500_parse_tool_functionch17

其他模块

目录首次引用备注
rag/ch07RAG 知识库
embedding/ch07向量嵌入
token/ch08Token 计数
session/ch20会话管理
a2a/ch14A2A 协议
realtime/ch14实时语音
mcp/ch17MCP 客户端
evaluate/ch36评估工具
tts/ch11语音合成
plan/ch11规划子系统