<?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%8C%87%E5%8D%97/</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%8C%87%E5%8D%97/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>发布自定义工具</title>
      <link>https://tuanzi-wow.cn/frameworks/crewai/%E6%8C%87%E5%8D%97/publish-custom-tools/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://tuanzi-wow.cn/frameworks/crewai/%E6%8C%87%E5%8D%97/publish-custom-tools/</guid>
      <description>发布自定义工具相关学习笔记与实践要点。</description>
      <content:encoded><![CDATA[<h1 id="发布自定义工具">发布自定义工具</h1>
<p>必须满足下面两种接口之一:
1.继承BaseTool
2.使用@tool装饰器</p>
<p>参数要求:</p>
<ul>
<li>拥有一个 <strong><code>name</code></strong> —— 一个简短的描述性标识符。</li>
<li>拥有一个 <strong><code>description</code></strong> —— 告诉代理何时以及如何使用该工具。这直接影响代理使用工具的效果，因此请务必清晰具体。</li>
<li>实现 <strong><code>_run</code></strong> (BaseTool) 或提供 <strong>函数体</strong> (@tool) —— 这是同步执行逻辑。</li>
<li>对所有参数和返回值使用 <strong>类型注解</strong>。</li>
<li>返回一个 <strong>字符串</strong> 结果（或可以有意义地转换为字符串的内容）。</li>
</ul>
]]></content:encoded>
    </item>
    <item>
      <title>基础概念</title>
      <link>https://tuanzi-wow.cn/frameworks/crewai/%E6%8C%87%E5%8D%97/crewai-fundamentals/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://tuanzi-wow.cn/frameworks/crewai/%E6%8C%87%E5%8D%97/crewai-fundamentals/</guid>
      <description>基础概念相关学习笔记与实践要点。</description>
      <content:encoded><![CDATA[<h1 id="1crew和flow的定义以及选择">1.crew和flow的定义以及选择</h1>
<p>crew:团队,更适合复杂和创造性更强的用例,强调自主性和协作智能优化
flow:流程,通过事件进行触发,有严格的执行决策路径,适合路径确定,有更高的安全需求的用例,强调细粒度,事件驱动的控制</p>
<h3 id="一些核心概念">一些核心概念</h3>
<p>对于团队
crew,agent,process,task</p>
<p>对于流程</p>
<p>flow,事件,state(context),crew support</p>
<h3 id="如何决策框架crew-or-flow-or-both">如何决策框架(Crew or Flow or Both)</h3>
<p>在于理解应用的精确性和复杂性</p>
<h3 id="复杂性-精确度矩阵详解">复杂性-精确度矩阵详解</h3>
<h3 id="什么是复杂性">什么是复杂性？</h3>
<p>在CrewAI应用的上下文中，<strong>复杂性</strong>指的是：</p>
<ul>
<li>所需的不同步骤或操作数量</li>
<li>需要执行任务的多样性</li>
<li>不同组件之间的相互依赖关系</li>
<li>对条件逻辑和分支的需求</li>
<li>整体工作流程的复杂程度</li>
</ul>
<h3 id="什么是精确率"><a href="https://www.aidoczh.com/crewai/en/guides/concepts/evaluating-use-cases.html#what-is-precision"></a>什么是精确率？</h3>
<p><strong>精确度</strong>在此上下文中指的是：</p>
<ul>
<li>最终输出所需的准确度</li>
<li>对结构化、可预测结果的需求</li>
<li>可重现性的重要性</li>
<li>每个步骤所需的控制级别</li>
<li>输出结果的容差范围</li>
</ul>
<h3 id="四个象限"><a href="https://www.aidoczh.com/crewai/en/guides/concepts/evaluating-use-cases.html#the-four-quadrants"></a>四个象限</h3>
<h4 id="1-低复杂度低精度"><a href="https://www.aidoczh.com/crewai/en/guides/concepts/evaluating-use-cases.html#1-low-complexity,-low-precision"></a>1. 低复杂度，低精度</h4>
<p><strong>特性：</strong></p>
<ul>
<li>简单、直接的任务</li>
<li>对输出结果存在一定变化的容忍度</li>
<li>步骤数量有限</li>
<li>创意或探索性应用</li>
</ul>
<p><strong>推荐方法：<strong>使用最少智能体的简单Crews</strong>示例用例：</strong></p>
<ul>
<li>基础内容生成</li>
<li>创意头脑风暴</li>
<li>简单的摘要任务</li>
<li>创意写作辅助</li>
</ul>
<h4 id="2-低复杂度高精度"><a href="https://www.aidoczh.com/crewai/en/guides/concepts/evaluating-use-cases.html#2-low-complexity,-high-precision"></a>2. 低复杂度，高精度</h4>
<p><strong>特性：</strong></p>
<ul>
<li>需要精确、结构化输出的简单工作流</li>
<li>需要可重现的结果</li>
<li>步骤有限但精度要求高</li>
<li>通常涉及数据处理或转换</li>
</ul>
<p><strong>推荐方法：</strong> 使用直接LLM调用的流程或具有结构化输出的简单Crews<strong>示例用例：</strong></p>
<ul>
<li>数据提取与转换</li>
<li>表单填写与验证</li>
<li>结构化内容生成（JSON、XML）</li>
<li>简单的分类任务</li>
</ul>
<h4 id="3-高复杂度低精度"><a href="https://www.aidoczh.com/crewai/en/guides/concepts/evaluating-use-cases.html#3-high-complexity,-low-precision"></a>3. 高复杂度，低精度</h4>
<p><strong>特性：</strong></p>
<ul>
<li>包含多个步骤的多阶段流程</li>
<li>创意或探索性输出</li>
<li>组件间的复杂交互</li>
<li>对最终结果的差异容忍度</li>
</ul>
<p><strong>推荐方法：<strong>使用包含多个专业智能体的复杂Crew</strong>示例用例：</strong></p>
<ul>
<li>研究与分析</li>
<li>内容创作流水线</li>
<li>探索性数据分析</li>
<li>创造性问题解决</li>
</ul>
<h4 id="4-高复杂度高精度"><a href="https://www.aidoczh.com/crewai/en/guides/concepts/evaluating-use-cases.html#4-high-complexity,-high-precision"></a>4. 高复杂度，高精度</h4>
<p><strong>特性：</strong></p>
<ul>
<li>需要结构化输出的复杂工作流</li>
<li>具有严格准确性要求的多重相互依赖步骤</li>
<li>需要复杂的处理和精确的结果</li>
<li>通常是关键任务应用</li>
</ul>
<p><strong>推荐方法：</strong> 通过验证步骤编排多个Crew的流程<strong>示例用例：</strong></p>
<ul>
<li>企业决策支持系统</li>
<li>复杂数据处理流水线</li>
<li>多阶段文档处理</li>
<li>受监管行业应用</li>
</ul>
<h3 id="决策">决策</h3>
<p>when crew:
协作智能;问题需要思考;任务为创意性或者分析性;重视适应性而非严格结构;输出格式具有灵活性</p>
<p>when flow:
执行过程需要精确控制;应用具有复杂的状态需求;需要结构化可预测的输出;工作流程设计逻辑条件;需要将人工智能和过程化代码相结合</p>
<p>when both:
复杂地多阶段流程;需要兼顾创意和结构的应用场景;企业级人工智能应用</p>
<h1 id="2打造高效的智能体">2.打造高效的智能体</h1>
<h2 id="8020法则专注于任务而非智能体">80/20法则:专注于任务而非智能体</h2>
<p>80%的精力放在设计任务上,20%放在定义智能体上</p>
<h2 id="设计的核心原则">设计的核心原则</h2>
<h3 id="1角色-目标-背景故事框架">1.角色-目标-背景故事框架</h3>
<p>角色:智能体的专业职能:
具体专业;符合现实;包含领域专长</p>
<p>目标:智能体的目标和动机:
明确且以结果为导向;强调质量标准;纳入成功标准</p>
<p>背景故事:智能体的经验和视角
尽力专长和经验;定义工作风格和价值观;创造连贯的人格</p>
<h3 id="2专家优于通才">2.专家优于通才</h3>
<p>高度专注的智能体提供更加精确和更强相关性的输出</p>
<h3 id="3平衡专业化与多功能性">3.平衡专业化与多功能性</h3>
<p>角色专业化,应用多功能化;避免过于狭隘的定义;考虑协作环境</p>
<h3 id="4设置适当的专家水平">4.设置适当的专家水平:</h3>
<p>新手;中级;专家;世界级;</p>
<h2 id="为你的智能体打造高效任务">为你的智能体打造高效任务</h2>
<h3 id="高效任务的解剖结构">高效任务的解剖结构</h3>
<h4 id="任务描述过程">任务描述:过程</h4>
<p>详细的执行说明;上下文和背景信息;范围和限制;需要遵循的流程步骤</p>
<h4 id="预期输出交付物">预期输出:交付物</h4>
<p>格式规范(js,md);结构要求;质量标准;优质输出的示例</p>
<p>1.单一目的,单一输出 2.明确输入和输出 3.包含目的和上下文 4.使用结构化输出工具</p>
<h3 id="应该避免的常见错误">应该避免的常见错误:</h3>
<p>1.任务说明不明确 2.试图做太多全能任务 3.描述与预期输出不匹配 4.你自己都不了解流程 5.过早使用层级结构 6.模糊胡总和通用的智能体定义</p>
<h2 id="设计策略">设计策略:</h2>
<h3 id="协作设计">协作设计:</h3>
<p>在一个crew中的agent:
互补技能;交接点;建设性的张力</p>
<h3 id="创建专业的工具使用者">创建专业的工具使用者</h3>
<h3 id="使agent适应llm能力">使agent适应LLM能力</h3>
<h3 id="测试和迭代智能体设计">测试和迭代智能体设计</h3>
<p>1.从原型开始 2.使用样本任务测试 3.分析输出 4.优化定义 5.在协作中测试</p>
]]></content:encoded>
    </item>
    <item>
      <title>指纹识别</title>
      <link>https://tuanzi-wow.cn/frameworks/crewai/%E6%8C%87%E5%8D%97/crewai-fingerprints/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://tuanzi-wow.cn/frameworks/crewai/%E6%8C%87%E5%8D%97/crewai-fingerprints/</guid>
      <description>指纹识别相关学习笔记与实践要点。</description>
      <content:encoded><![CDATA[<h1 id="指纹识别">指纹识别</h1>
<p>提供了一种在整个生命周期内唯一表示和追踪组件的方法,每个agent,crew,task在创建时都会获得一个唯一的,无法手动覆盖的指纹</p>
<h2 id="工作原理">工作原理</h2>
<p>指纹时crewai.security模块中的Fingerprint类的实例,包含:
UUID字符串:唯一标识符,自动生成且无法手动覆盖
创建时间戳:自动设置无法手动覆盖
元数据:可自定义的附加信息字典</p>
<h2 id="基本用法">基本用法</h2>
<h3 id="访问指纹">访问指纹:</h3>
<h3 id="处理指纹元数据">处理指纹元数据:</h3>
<p>向指纹添加元数据以获得更多的上下文信息:</p>
<h3 id="指纹持久性">指纹持久性</h3>
<p>在整个生命周期内保持不变</p>
<h3 id="确定性指纹">确定性指纹</h3>
<p>虽然不能设置UUID和创建时间戳,但是可以使用带有种子的generate方法来创建确定性指纹</p>
<h2 id="高级用法">高级用法</h2>
<h3 id="指纹结构">指纹结构</h3>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt"> 1
</span><span class="lnt"> 2
</span><span class="lnt"> 3
</span><span class="lnt"> 4
</span><span class="lnt"> 5
</span><span class="lnt"> 6
</span><span class="lnt"> 7
</span><span class="lnt"> 8
</span><span class="lnt"> 9
</span><span class="lnt">10
</span><span class="lnt">11
</span><span class="lnt">12
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">from crewai.security import Fingerprint
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">fingerprint = agent.fingerprint
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"># UUID string - the unique identifier (auto-generated)
</span></span><span class="line"><span class="cl">uuid_str = fingerprint.uuid_str  # e.g., &#34;123e4567-e89b-12d3-a456-426614174000&#34;
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"># Creation timestamp (auto-generated)
</span></span><span class="line"><span class="cl">created_at = fingerprint.created_at  # A datetime object
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"># Metadata - for additional information (can be customized)
</span></span><span class="line"><span class="cl">metadata = fingerprint.metadata  # A dictionary, defaults to {}
</span></span></code></pre></td></tr></table>
</div>
</div>]]></content:encoded>
    </item>
    <item>
      <title>掌握flow的状态(statement)管理</title>
      <link>https://tuanzi-wow.cn/frameworks/crewai/%E6%8C%87%E5%8D%97/crewai-flow-state-management/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://tuanzi-wow.cn/frameworks/crewai/%E6%8C%87%E5%8D%97/crewai-flow-state-management/</guid>
      <description>掌握flow的状态(statement)管理相关学习笔记与实践要点。</description>
      <content:encoded><![CDATA[<h1 id="掌握流程的状态管理">掌握流程的状态管理</h1>
<h2 id="理解流程中状态的作用">理解流程中状态的作用:</h2>
<p>状态系统允许你维护上下文,在步骤之间共享数据,并构建复杂的应用逻辑</p>
<h3 id="为什么状态管理很重要">为什么状态管理很重要:</h3>
<p>1.维持上下文
2.构建复杂的条件逻辑
3.创建持久化应用
4.优雅地处理错误
5.拓展你的应用
6.实现对话式的应用</p>
<h2 id="状态管理基础">状态管理基础</h2>
<h3 id="流程状态生命周期">流程状态生命周期:</h3>
<p>1.初始化
2.修改
3.传输
4.持久化(可选):保存到存储中
5.完成</p>
<h3 id="状态管理的两种方法">状态管理的两种方法:</h3>
<p>1.非结构化状态:灵活性
2.结构化状态:使用Pydantic模型:类型安全性和验证</p>
<h2 id="非结构化状态管理">非结构化状态管理:</h2>
<h3 id="工作原理">工作原理:</h3>
<p>使用self.state访问状态,<strong>行为类似于字典</strong>;可以随时增删改查键;所有状态自动对所有流程方法可用</p>
<h3 id="when">when</h3>
<p>快速原型开发和简单流程;动态演变的状态需求;预先无法确定的结构情况;状态要求简单的流程</p>
<h2 id="结构化状态管理">结构化状态管理</h2>
<h3 id="工作原理-1">工作原理:</h3>
<p>定义一个表述状态结构的Pydantic模型
模型类型作为类型参数传给flow类
通过self.state访问状态,行为类似于Pydantic模型实例
所有字段根据定义的类型进行验证</p>
<h4 id="优势">优势:</h4>
<ol>
<li>类型安全</li>
<li>自我文档化</li>
<li>验证</li>
<li>IDE支持</li>
<li>默认值</li>
</ol>
<h3 id="when-1">when</h3>
<ul>
<li>明确数据模式的复杂流程</li>
<li>多名开发者共同参与的团队项目</li>
<li>需要验证数据验证的应用城西</li>
<li>需要强制执行特定数据类型和约束的流程</li>
</ul>
<h2 id="自动状态id">自动状态ID</h2>
<p>唯一标识符,对于非结构化,通过self.state[&ldquo;id&rdquo;]访问,对于结构化,则通过self.state.id访问
在流程中自动生成,整个生命周期不变,用于记录,跟踪和检索已经持久化的状态</p>
<h2 id="动态状态更新">动态状态更新</h2>
<h3 id="在步骤之间传递数据">在步骤之间传递数据</h3>
<p>流程方法可以返回值,这些值随后作为参数传递给监听方法</p>
<h2 id="持久化流程状态">持久化流程状态</h2>
<h3 id="persist装饰器可以自动执行状态持久化在执行的关键点保存你的流程状态">@persist()装饰器:可以自动执行状态持久化,在执行的关键点保存你的流程状态</h3>
<h4 id="类级别持久化在每次方法执行后保存状态">类级别持久化:在每次方法执行后保存状态</h4>
<h4 id="方法级别持久化更加细粒度的控制将其用于特定方法">方法级别持久化:更加细粒度的控制,将其用于特定方法</h4>
<h4 id="派生forking持久化状态">派生(Forking)持久化状态</h4>
<p><code>@persist</code> 在 <code>kickoff</code> / <code>kickoff_async</code> 上支持两种不同的水合模式。使用 <strong>resume</strong> (<code>inputs[&quot;id&quot;]</code>) 继续同一血缘；使用 <strong>fork</strong> (<code>restore_from_state_id</code>) 从快照启动一个新的血缘</p>
<table>
	<thead>
			<tr>
					<th style="text-align: left"></th>
					<th style="text-align: left">kickoff 后的 <code>state.id</code></th>
					<th style="text-align: left"><code>@persist</code> 的写入位置</th>
			</tr>
	</thead>
	<tbody>
			<tr>
					<td style="text-align: left"><code>inputs[&quot;id&quot;]</code> (恢复)</td>
					<td style="text-align: left">提供的 id</td>
					<td style="text-align: left">提供的 id (扩展历史记录)</td>
			</tr>
			<tr>
					<td style="text-align: left"><code>restore_from_state_id</code> (派生)</td>
					<td style="text-align: left">新的 id，或者如果已固定则为 <code>inputs[&quot;id&quot;]</code></td>
					<td style="text-align: left">新的 id (源已保留)</td>
			</tr>
	</tbody>
</table>
<h2 id="高级状态模式">高级状态模式</h2>
<h3 id="条件启动和可恢复执行">条件启动和可恢复执行</h3>
<p>flow支持条件@start()和用于HILT/循环场景的可恢复执行</p>
<h3 id="基于状态的条件逻辑">基于状态的条件逻辑</h3>
<p>使用状态在流程中实现复杂的条件逻辑</p>
<h3 id="处理复杂的状态转换">处理复杂的状态转换</h3>
<p>对于复杂的状态转换,可以创建专用方法</p>
<h2 id="与crew一起的状态管理">与Crew一起的状态管理</h2>
<h3 id="将状态传给crew">将状态传给crew</h3>
<p>将参数传给agent的创建方法中</p>
<h3 id="在状态中处理crew输出">在状态中处理crew输出</h3>
<h2 id="状态管理最佳实践">状态管理最佳实践</h2>
<ol>
<li>保持状态聚焦:设计时仅包含必要内容</li>
<li>复杂流程使用结构化状态</li>
<li>记录状态转化</li>
<li>优雅地处理状态错误</li>
<li>使用状态进行进度跟踪</li>
<li>尽可能使用不可变操作</li>
</ol>
]]></content:encoded>
    </item>
    <item>
      <title>构建第一个 CrewAI 项目</title>
      <link>https://tuanzi-wow.cn/frameworks/crewai/%E6%8C%87%E5%8D%97/build-first-crew/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://tuanzi-wow.cn/frameworks/crewai/%E6%8C%87%E5%8D%97/build-first-crew/</guid>
      <description>构建第一个 CrewAI 项目相关学习笔记与实践要点。</description>
      <content:encoded><![CDATA[<h2 id="第一步创建新的crewai项目">第一步:创建新的CrewAI项目</h2>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">crewai create crew research_crew
</span></span></code></pre></td></tr></table>
</div>
</div><h2 id="第二步探索项目结构">第二步:探索项目结构</h2>
<p>遵循py项目的最佳实践,通过分离配置文件和实现代码,在不修改源代码的情况下修改团队的行为</p>
<h2 id="第三步配置你的智能体">第三步:配置你的智能体</h2>
<p>通过修改agent.yaml来定义智能体
role;goal;backstory;llm</p>
<h2 id="第四步定义你的任务">第四步:定义你的任务</h2>
<p>任务代表可智能体将要执行的具体工作,包括详细的说明和预期输出
通过修改task.yaml文件
包含description和expected_output,context</p>
<h2 id="第五步配置你的团队">第五步:配置你的团队</h2>
<p>通过crew.py文件来配置</p>
<h2 id="第六步设置你的主脚本">第六步:设置你的主脚本</h2>
<h2 id="第七步设置你的环境变量">第七步:设置你的环境变量</h2>
<p>.env文件</p>
<h2 id="第八步安装依赖项">第八步:安装依赖项</h2>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">crewai install
</span></span></code></pre></td></tr></table>
</div>
</div><h2 id="第九步运行你的团队">第九步:运行你的团队</h2>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">crewai run
</span></span></code></pre></td></tr></table>
</div>
</div><h2 id="第十步查看你的输出">第十步:查看你的输出</h2>
]]></content:encoded>
    </item>
    <item>
      <title>自定义提示词</title>
      <link>https://tuanzi-wow.cn/frameworks/crewai/%E6%8C%87%E5%8D%97/custom-prompts/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://tuanzi-wow.cn/frameworks/crewai/%E6%8C%87%E5%8D%97/custom-prompts/</guid>
      <description>自定义提示词相关学习笔记与实践要点。</description>
      <content:encoded><![CDATA[<h1 id="自定义提示词">自定义提示词</h1>
<h2 id="why">why</h2>
<p>1.针对LLM进行优化
2.更改语言
3.针对复杂领域进行专业化
4.调整语气和风格
5.支持超个性化用例</p>
<h2 id="了解crewai的提示词系统">了解CrewAI的提示词系统</h2>
<ul>
<li><strong>智能体模板 (Agent templates)</strong> – 控制每个智能体对其指定角色的处理方式。</li>
<li><strong>提示词片段 (Prompt slices)</strong> – 控制任务、工具使用和输出结构等专门行为。</li>
<li><strong>错误处理 (Error handling)</strong> – 指导智能体如何应对失败、异常或超时。</li>
<li><strong>工具专用提示词 (Tool-specific prompts)</strong> – 定义如何调用或使用工具的详细说明。</li>
</ul>
<h2 id="了解默认系统指令">了解默认系统指令</h2>
<p>当通过role,goal,backstory定义agent时,自动注入的一些指令</p>
<h3 id="crewai自动注入的内容">CrewAI自动注入的内容</h3>
<h4 id="针对无工具的智能体">针对无工具的智能体</h4>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">&#34;I MUST use these formats, my job depends on it!&#34;
</span></span></code></pre></td></tr></table>
</div>
</div><h4 id="针对有工具的智能体">针对有工具的智能体</h4>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span><span class="lnt">5
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-gdscript3" data-lang="gdscript3"><span class="line"><span class="cl"><span class="s2">&#34;IMPORTANT: Use the following format in your response:</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">Thought</span><span class="p">:</span> <span class="n">you</span> <span class="n">should</span> <span class="n">always</span> <span class="n">think</span> <span class="n">about</span> <span class="n">what</span> <span class="n">to</span> <span class="k">do</span>
</span></span><span class="line"><span class="cl"><span class="n">Action</span><span class="p">:</span> <span class="n">the</span> <span class="n">action</span> <span class="n">to</span> <span class="n">take</span><span class="p">,</span> <span class="n">only</span> <span class="n">one</span> <span class="n">name</span> <span class="n">of</span> <span class="p">[</span><span class="n">tool_names</span><span class="p">]</span>
</span></span><span class="line"><span class="cl"><span class="n">Action</span> <span class="ne">Input</span><span class="p">:</span> <span class="n">the</span> <span class="n">input</span> <span class="n">to</span> <span class="n">the</span> <span class="n">action</span><span class="p">,</span> <span class="n">just</span> <span class="n">a</span> <span class="n">simple</span> <span class="n">JSON</span> <span class="n">object</span><span class="o">...</span>
</span></span></code></pre></td></tr></table>
</div>
</div><h4 id="针对结构化输出jsonpydantic">针对结构化输出（JSON/Pydantic）</h4>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">&#34;Ensure your final answer contains only the content in the following format: {output_format}
</span></span><span class="line"><span class="cl">Ensure the final output does not include any code block markers like ```json or ```python.&#34;
</span></span></code></pre></td></tr></table>
</div>
</div><h3 id="查看完整提示词">查看完整提示词</h3>
<h3 id="覆盖默认指令">覆盖默认指令</h3>
<p>选项一(推荐):自定义模板
选项二:自定义提示词文件
创建一个custom_prompt.json文件
选项三:为o1模型禁用系统提示词</p>
<h3 id="使用观测性工具进行调试">使用观测性工具进行调试</h3>
<h3 id="生产环境最佳实践">生产环境最佳实践</h3>
<ol>
<li><strong>始终检查生成的提示词</strong>，然后再部署到生产环境。</li>
<li><strong>使用自定义模板</strong>，当您需要全面控制提示词内容时。</li>
<li><strong>集成可观测性工具</strong>以进行持续的提示词监控（参阅 <a href="https://docs.crewai.com.cn/en/observability/overview">可观测性文档</a>）。</li>
<li><strong>使用不同的 LLM 进行测试</strong>，因为默认指令在不同模型间的表现可能不同。</li>
<li><strong>记录您的提示词自定义内容</strong>，以保持团队透明度。</li>
</ol>
<h2 id="管理提示词文件的最佳实践">管理提示词文件的最佳实践</h2>
<ol>
<li><strong>保持文件独立</strong> – 将自定义提示词存储在主代码库之外的专用 JSON 文件中。</li>
<li><strong>版本控制</strong> – 在代码仓库中跟踪更改，确保提示词的调整有清晰的文档记录。</li>
<li><strong>按模型或语言组织</strong> – 使用如 <code>prompts_llama.json</code> 或 <code>prompts_es.json</code> 的命名方案，以便快速识别专用配置。</li>
<li><strong>记录更改</strong> – 提供注释或维护一个 README 文件，详细说明自定义的目的和范围。</li>
<li><strong>最小化改动</strong> – 仅覆盖确实需要调整的特定片段，保持其他部分的默认功能完好无损。</li>
</ol>
]]></content:encoded>
    </item>
  </channel>
</rss>
