<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>CrewAI 核心概念 on On My Way</title>
    <link>https://tuanzi-wow.cn/frameworks/crewai/%E6%A0%B8%E5%BF%83%E6%A6%82%E5%BF%B5/</link>
    <description>Recent content in CrewAI 核心概念 on On My Way</description>
    <generator>Hugo</generator>
    <language>zh-CN</language>
    <atom:link href="https://tuanzi-wow.cn/frameworks/crewai/%E6%A0%B8%E5%BF%83%E6%A6%82%E5%BF%B5/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Agent</title>
      <link>https://tuanzi-wow.cn/frameworks/crewai/%E6%A0%B8%E5%BF%83%E6%A6%82%E5%BF%B5/agent/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://tuanzi-wow.cn/frameworks/crewai/%E6%A0%B8%E5%BF%83%E6%A6%82%E5%BF%B5/agent/</guid>
      <description>Agent相关学习笔记与实践要点。</description>
      <content:encoded><![CDATA[<h1 id="agent">Agent</h1>
<h2 id="概述">概述:</h2>
<p>带有特定技能,专业知识和职责的专业团队成员</p>
<h2 id="智能体的属性">智能体的属性:</h2>
<p>最基本的三个
Role,Goal,Backstory
后续全为可选,请自行查阅官网</p>
<h2 id="创建智能体">创建智能体</h2>
<p>两种方法:
YAML配置(推荐)和直接在代码中定义</p>
<h3 id="yaml配置推荐">YAML配置(推荐)</h3>
<p>在代码中使用YAML配置,需要创建一个继承自CrewBase的工作组类</p>
<h3 id="直接代码定义">直接代码定义</h3>
<p>实例化Agent类直接在代码中创建智能体</p>
<h2 id="参数详情">参数详情:</h2>
<h4 id="关键参数">关键参数</h4>
<ul>
<li><code>role</code>, <code>goal</code> 和 <code>backstory</code> 是必填项，决定了智能体的行为。</li>
<li><code>llm</code> 确定使用的语言模型（默认：OpenAI 的 GPT-4）。</li>
</ul>
<h4 id="记忆与上下文">记忆与上下文</h4>
<ul>
<li><code>memory</code>: 启用以保持对话历史。</li>
<li><code>respect_context_window</code>: 防止 Token 限制问题。</li>
<li><code>knowledge_sources</code>: 添加特定领域的知识库。</li>
</ul>
<h4 id="执行控制">执行控制</h4>
<ul>
<li><code>max_iter</code>: 给定最佳答案前的最大尝试次数。</li>
<li><code>max_execution_time</code>: 超时时间（秒）。</li>
<li><code>max_rpm</code>: API 调用速率限制。</li>
<li><code>max_retry_limit</code>: 错误重试次数。</li>
</ul>
<h4 id="代码执行">代码执行</h4>
<p><code>allow_code_execution</code> 和 <code>code_execution_mode</code> 已弃用。<code>CodeInterpreterTool</code> 已从 <code>crewai-tools</code> 中移除。请使用如 <a href="https://e2b.org.cn/">E2B</a> 或 <a href="https://modal.com/">Modal</a> 等专用沙箱服务进行安全的代码执行。</p>
<ul>
<li><code>allow_code_execution</code> <em>(已弃用)</em>: 此前通过 <code>CodeInterpreterTool</code> 启用内置代码执行。</li>
<li><code>code_execution_mode</code> <em>(已弃用)</em>: 此前控制执行模式（<code>&quot;safe&quot;</code> 用于 Docker，<code>&quot;unsafe&quot;</code> 用于直接执行）。</li>
</ul>
<h4 id="高级功能">高级功能</h4>
<ul>
<li><code>multimodal</code>: 启用多模态能力以处理文本和视觉内容。</li>
<li><code>reasoning</code>: 启用智能体在执行任务前反思并制定计划。</li>
<li><code>inject_date</code>: 自动将当前日期注入任务描述中。</li>
</ul>
<h4 id="模板">模板</h4>
<ul>
<li><code>system_template</code>: 定义智能体的核心行为。</li>
<li><code>prompt_template</code>: 构建输入格式。</li>
<li><code>response_template</code>: 格式化智能体响应。</li>
</ul>
<h2 id="智能体工具">智能体工具</h2>
<p>可以使用CrewAI和LangChain工具包</p>
<h2 id="智能体记忆和上下文">智能体记忆和上下文</h2>
<h2 id="上下文窗口管理">上下文窗口管理</h2>
<h3 id="上下文窗口管理的工作原理">上下文窗口管理的工作原理</h3>
<p>由respect_context_window控制</p>
<p>when context window is too large,
1.自动摘要内容(参数为true)
2.停止执行并且报错(参数为false)</p>
<h3 id="大数据量的替代方案">大数据量的替代方案</h3>
<h4 id="1rag工具">1.RAG工具</h4>
<h4 id="2使用知识源">2.使用知识源</h4>
<h3 id="上下文窗口最佳实践">上下文窗口最佳实践</h3>
<ol>
<li><strong>监控上下文使用</strong>: 启用 <code>verbose=True</code> 以查看正在运行的上下文管理。</li>
<li><strong>高效设计</strong>: 构建任务以最小化上下文积累。</li>
<li><strong>使用合适的模型</strong>: 选择上下文窗口适合任务的 LLM。</li>
<li><strong>测试两种设置</strong>: 尝试 <code>True</code> 和 <code>False</code>，看看哪种更适合你的用例。</li>
<li><strong>结合 RAG 使用</strong>: 对于超大数据集，使用 RAG 工具而不是完全依赖上下文窗口。</li>
</ol>
<h3 id="使用kickoff进行直接智能体交互">使用Kickoff()进行直接智能体交互</h3>
<h4 id="工作原理">工作原理:</h4>
<p>kickoff()允许你直接向智能体发送消息获取回复</p>
<h4 id="参数和返回值">参数和返回值</h4>
<p>message;response_format</p>
]]></content:encoded>
    </item>
    <item>
      <title>智能体能力</title>
      <link>https://tuanzi-wow.cn/frameworks/crewai/%E6%A0%B8%E5%BF%83%E6%A6%82%E5%BF%B5/agent-capabilities/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://tuanzi-wow.cn/frameworks/crewai/%E6%A0%B8%E5%BF%83%E6%A6%82%E5%BF%B5/agent-capabilities/</guid>
      <description>智能体能力相关学习笔记与实践要点。</description>
      <content:encoded><![CDATA[<h1 id="智能体能力">智能体能力</h1>
<p>工具:可调用函数
MCP服务器
应用:平台集合
技能:skills
知识:检索事实</p>
<h2 id="分类">分类</h2>
<h3 id="行动能力toolsmcpsapps">行动能力(Tools,MCPs,Apps)</h3>
<p>赋予了代理做事的能力</p>
<h3 id="背景能力skillsknowledge">背景能力(Skills,Knowledge)</h3>
<p>会修改代理的提示词</p>
<h2 id="对比表">对比表</h2>
<table>
	<thead>
			<tr>
					<th style="text-align: left">特性</th>
					<th style="text-align: center">工具</th>
					<th style="text-align: center">MCPs</th>
					<th style="text-align: center">应用</th>
					<th style="text-align: center">技能 (Skills)</th>
					<th style="text-align: center">知识</th>
			</tr>
	</thead>
	<tbody>
			<tr>
					<td style="text-align: left"><strong>赋予代理行动能力</strong></td>
					<td style="text-align: center">✅</td>
					<td style="text-align: center">✅</td>
					<td style="text-align: center">✅</td>
					<td style="text-align: center">❌</td>
					<td style="text-align: center">❌</td>
			</tr>
			<tr>
					<td style="text-align: left"><strong>修改提示词</strong></td>
					<td style="text-align: center">❌</td>
					<td style="text-align: center">❌</td>
					<td style="text-align: center">❌</td>
					<td style="text-align: center">✅</td>
					<td style="text-align: center">✅</td>
			</tr>
			<tr>
					<td style="text-align: left"><strong>需要代码</strong></td>
					<td style="text-align: center">是</td>
					<td style="text-align: center">仅配置</td>
					<td style="text-align: center">仅配置</td>
					<td style="text-align: center">仅 Markdown</td>
					<td style="text-align: center">仅配置</td>
			</tr>
			<tr>
					<td style="text-align: left"><strong>本地运行</strong></td>
					<td style="text-align: center">是</td>
					<td style="text-align: center">视情况而定</td>
					<td style="text-align: center">是（带环境变量）</td>
					<td style="text-align: center">不适用</td>
					<td style="text-align: center">是</td>
			</tr>
			<tr>
					<td style="text-align: left"><strong>需要 API 密钥</strong></td>
					<td style="text-align: center">按工具</td>
					<td style="text-align: center">按服务器</td>
					<td style="text-align: center">集成令牌</td>
					<td style="text-align: center">否</td>
					<td style="text-align: center">仅嵌入器 (Embedder)</td>
			</tr>
			<tr>
					<td style="text-align: left"><strong>在 Agent 上设置</strong></td>
					<td style="text-align: center"><code>tools=[]</code></td>
					<td style="text-align: center"><code>mcps=[]</code></td>
					<td style="text-align: center"><code>apps=[]</code></td>
					<td style="text-align: center"><code>skills=[]</code></td>
					<td style="text-align: center"><code>knowledge_sources=[]</code></td>
			</tr>
			<tr>
					<td style="text-align: left"><strong>在 Crew 上设置</strong></td>
					<td style="text-align: center">❌</td>
					<td style="text-align: center">❌</td>
					<td style="text-align: center">❌</td>
					<td style="text-align: center"><code>skills=[]</code></td>
					<td style="text-align: center"><code>knowledge_sources=[]</code></td>
			</tr>
	</tbody>
</table>
]]></content:encoded>
    </item>
  </channel>
</rss>
