技能 langchain-architecture
📦

langchain-architecture

安全

使用 LangChain 构建 LLM 应用

也可从以下获取: sickn33,wshobson

本技能帮助开发者使用 LangChain 框架模式(代理、链、记忆和工具集成)设计和实现生产级 LLM 应用。

支持: Claude Codex Code(CC)
🥉 74 青铜
1

下载技能 ZIP

2

在 Claude 中上传

前往 设置 → 功能 → 技能 → 上传技能

3

开启并开始使用

测试它

正在使用“langchain-architecture”。 How do I choose the right memory type for my LangChain agent?

预期结果:

对于 10 条消息以下的短对话,使用 ConversationBufferMemory 存储所有消息。对于较长的对话,使用 ConversationSummaryMemory 总结旧消息。对于跟踪特定实体,使用 ConversationEntityMemory。对于语义检索相关历史记录,使用 VectorStoreRetrieverMemory。

正在使用“langchain-architecture”。 Create a multi-step chain that extracts entities, analyzes them, and generates a summary.

预期结果:

使用 SequentialChain 和三个 LLMChain 组件:extract_prompt 提取实体,analyze_prompt 分析实体,summary_prompt 生成最终摘要。设置 output_variables 以捕获所有中间和最终输出。

安全审计

安全
v1 • 2/25/2026

All 27 static findings are false positives. The skill contains Python code examples in markdown documentation. The scanner incorrectly identified 'external_commands' (markdown code blocks), 'weak cryptographic algorithm' (agent type constants containing 'DESCRIPTION'), and 'network reconnaissance' (use case descriptions). This is educational documentation about LangChain with no executable code, network requests, or cryptographic operations.

1
已扫描文件
351
分析行数
3
发现项
1
审计总数
低风险问题 (3)
External Commands Detection (False Positive)
Scanner detected 'Ruby/shell backtick execution' at 20 locations. These are Python code examples within markdown code blocks (e.g., `from langchain.agents import...`). No shell command execution exists.
Weak Cryptographic Algorithm Detection (False Positive)
Scanner flagged 'weak cryptographic algorithm' at 6 locations. These are LangChain AgentType constants (CONVERSATIONAL_REACT_DESCRIPTION, ZERO_SHOT_REACT_DESCRIPTION) - not cryptographic algorithms.
Network Reconnaissance Detection (False Positive)
Scanner flagged 'network reconnaissance' at SKILL.md:24. The line describes 'Building autonomous AI agents with tool access' - a legitimate use case, not network reconnaissance.
审计者: claude

质量评分

38
架构
100
可维护性
87
内容
50
社区
99
安全
91
规范符合性

你能构建什么

AI 应用开发者

构建使用 LLM 代理的工具访问功能,以自动化多步工作流的应用程序

数据工程师

创建将内部文档与 LLM 功能相结合的 RAG 管道,用于智能查询

ML 工程师

设计具有适当记忆管理、错误处理和可观测性的生产就绪 LLM 系统

试试这些提示

基础代理设置
创建一个可以使用搜索工具和计算器的简单 LangChain 代理。展示如何初始化代理、添加工具和运行查询。
RAG 实现
展示如何使用 LangChain 构建检索增强生成系统。包括文档加载、文本分割、向量存储创建和问答链。
记忆配置
解释 LangChain 中的不同记忆类型,并展示实现 ConversationBufferMemory、ConversationSummaryMemory 和 ConversationEntityMemory 的代码。
生产部署
将 LangChain 应用程序部署到生产的最佳实践是什么?包括错误处理、用于监控的回调、速率限制和测试策略。

最佳实践

  • 在将用户输入传递给 LLM 链之前,始终验证和清理用户输入以防止提示注入
  • 在代理和链执行周围使用 try-catch 块实现适当的错误处理
  • 使用回调在生产中记录和监控令牌使用、延迟和错误

避免

  • 不要超过上下文窗口限制 - 实现适当的记忆截断或摘要
  • 避免使用定义不佳的工具描述 - 代理依赖描述来选择正确的工具
  • 不要跳过输入验证 - 在链或提示中使用所有用户输入之前进行验证

常见问题

什么是 LangChain?
LangChain 是一个用于构建 LLM 应用的框架。它提供了链(调用序列)、代理(使用 LLM 决定行动的系统)、记忆(上下文存储)和工具(代理可以调用的函数)的抽象。
使用此技能需要 API 密钥吗?
是的,本技能帮助您设计 LangChain 应用程序,但您需要 OpenAI API 密钥或其他 LLM 提供商密钥才能实际运行代码示例。
代理和链有什么区别?
链是预定的一系列步骤。代理使用 LLM 动态决定采取哪些行动,使其在复杂任务中更加灵活。
如何为我的代理添加记忆?
导入您需要的记忆类型(如 ConversationBufferMemory),使用 memory_key 初始化它,并在调用 initialize_agent 时通过 memory 参数将其传递给代理。
LangChain 中的 RAG 是什么?
RAG(检索增强生成)将文档检索与 LLM 生成相结合。使用文档加载器、文本分割器、向量存储和 RetrievalQA 链来构建此功能。
我可以在 LangChain 中使用 Claude 或 Codex 吗?
是的,LangChain 支持各种 LLM 提供商。您可以使用 ChatAnthropic 进行 Claude 模型,或使用 OpenAI 兼容接口进行 Codex。