Dify 生成提示詞的 Prompt

Dify 生成提示詞的 Prompt

  • **第1次提示詞**
  • **第2次提示詞**
  • **第3次提示詞**
      • 總結

Dify 生成提示詞是,會和LLM進行3次交互,下面是和LLM進行交互是的Prompt。

以下是每次提示詞的概要、目標總結以及原始Prompt:


第1次提示詞

概要
請求創建一個高質量的中譯英助手提示詞模板,要求模板結構清晰,包含變量、指令、示例等部分,并使用XML格式輸出。

目標

  1. 根據任務描述(中譯英助手)創建結構化的提示詞模板。
  2. 使用{{變量}}格式定義變量名(僅包含字母、數字和下劃線)。
  3. 包含清晰的指令(用<instructions>標簽),說明如何完成任務,并避免輸出XML標簽。
  4. 提供相關示例(用<example>標簽)。
  5. 輸出語言與任務描述一致(中文)。
  6. 最終輸出為XML格式,以<instruction>開頭。

原始 Prompt

user\n\nHere is a task description for which I would like you to create a high-quality prompt template for:\n
<task_description>\n
你是一個中譯英 的助手\n
</task_description>\n
Based on task description, please create a well-structured prompt template that another AI could use to consistently complete the task. The prompt template should include:\n- Descriptive variable names surrounded by {{ }} (two curly brackets) to indicate where the actual values will be substituted in. Choose variable names that clearly indicate the type of value expected. Variable names have to be composed of number, english alphabets and underline and nothing else. \n
- Clear instructions for the AI that will be using this prompt, demarcated with <instructions> tags. The instructions should provide step-by-step directions on how to complete the task using the input variables. Also Specifies in the instructions that the output should not contain any xml tag. \n
- Relevant examples if needed to clarify the task further, demarcated with <example> tags. Do not use curly brackets any other than in <instruction> section. \n
- Any other relevant sections demarcated with appropriate XML tags like <input>, <output>, etc.\n
- Use the same language as task description. \n
- Output in ```xml ```and start with <instruction>\n
Please generate the full prompt template and output only the prompt template.\n

第2次提示詞

概要
從輸入文本中提取變量名(格式為{{變量}}),并輸出為JSON列表格式。若無變量則返回空列表。

目標

  1. 從輸入文本中提取所有{{變量}}格式的變量名。
  2. 變量名需符合規范(僅字母、數字、下劃線)。
  3. 輸出為嚴格JSON列表格式(如["variable_1", "variable_2"])。
  4. 若無變量則返回空列表[]
  5. 禁止輸出XML標簽或其他內容。
  6. 輸入文本是一個XML格式的中譯英助手模板,需從中提取變量名(如{{chinese_text}}{{english_translation}})。

原始 Prompt

user\n\nI need to extract the following information from the input text. The <information to be extracted> tag specifies the \'type\', \'description\' and \'required\' of the information to be extracted. \n
<information to be extracted>\n
variables name bounded two double curly brackets. Variable name has to be composed of number, english alphabets and underline and nothing else. \n
</information to be extracted>\n\nStep 1: Carefully read the input and understand the structure of the expected output.\n
Step 2: Extract relevant parameters from the provided text based on the name and description of object. \n
Step 3: Structure the extracted parameters to JSON object as specified in <structure>.\n
Step 4: Ensure that the list of variable_names is properly formatted and valid. The output should not contain any XML tags. Output an empty list if there is no valid variable name in input text. \n\n### Structure\nHere is the structure of the expected output, I should always follow the output structure. \n
["variable_name_1", "variable_name_2"]\n\n### Input Text\nInside <text></text> XML tags, there is a text that I should extract parameters and convert to a JSON object.\n
<text>\n
```xml\n
<instruction>\n
你是一個中譯英的助手。請將以下中文文本翻譯成英文。\n
</instruction>\n
<input>\n
{{chinese_text}}\n
</input>\n
<output>\n
{{english_translation}}\n
</output>\n
<example>\n
<input>\n
你好,世界!\n
</input>
\n<output>\n
Hello, world!\n
</output>\n
</example>\n
<example>\n
<input>\n
這是一個測試句子。\n
</input>\n<output>\n
This is a test sentence.\n
</output>\n
</example>\n
```\n
</text>\n\n### Answer\n
I should always output a valid list. Output nothing other than the list of variable_name. Output an empty list if there is no variable name in input text.\n

第3次提示詞

概要
根據任務描述(中譯英助手)生成聊天機器人的開場白,要求符合助手角色,語氣友好且語言與用戶輸入一致。

目標

  1. 從變量你是一個中譯英的助手推斷助手的角色和語氣(如專業或友好)。
  2. 生成連貫、吸引人的開場白,明確說明助手功能。
  3. 語言需與用戶輸入一致(中文輸入用中文,英文輸入用英文)。
  4. 禁止輸出XML標簽。
  5. 示例輸入為任務描述(中譯英模板),需生成類似示例輸出的歡迎語(如“歡迎!我是中譯英助手,可幫您翻譯中文文本……”)。

原始 Prompt

user\n\n<instruction>\n
Step 1: Identify the purpose of the chatbot from the variable 你是一個中譯英的助手 and infer chatbot's tone  (e.g., friendly, professional, etc.) to add personality traits. \n
Step 2: Create a coherent and engaging opening statement.\n
Step 3: Ensure the output is welcoming and clearly explains what the chatbot is designed to do. Do not include any XML tags in the output.\n
Please use the same language as the user's input language. If user uses chinese then generate opening statement in chinese,  if user uses english then generate opening statement in english. \n
Example Input: \n
Provide customer support for an e-commerce website\n
Example Output: \n
Welcome! I'm here to assist you with any questions or issues you might have with your shopping experience. Whether you're looking for product information, need help with your order, or have any other inquiries, feel free to ask. I'm friendly, helpful, and ready to support you in any way I can.\n
<Task>\n
Here is the task description: ```xml\n
<instruction>\n
你是一個中譯英的助手。請將以下中文文本翻譯成英文。\n
</instruction>\n
<input>\n
{{chinese_text}}\n
</input>\n
<output>\n
{{english_translation}}\n
</output>\n
<example>\n
<input>\n
你好,世界!\n
</input>\n
<output>\n
Hello, world!\n
</output>\n
</example>\n
<example>\n
<input>\n
這是一個測試句子。\n
</input>\n
<output>\n
This is a test sentence.\n
</output>\n
</example>\n
```\n\nYou just need to generate the output\n

總結

  • 第1次:創建結構化提示詞模板(XML格式)。
  • 第2次:從文本中提取變量名(JSON列表格式)。
  • 第3次:生成角色適配的開場白(自然語言)。
    共同點:均圍繞“中譯英助手”任務,強調格式規范(無XML標簽、變量命名規則等)。

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/75135.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/75135.shtml
英文地址,請注明出處:http://en.pswp.cn/web/75135.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

sqli-labs靶場 less4

文章目錄 sqli-labs靶場less 4 聯合注入 sqli-labs靶場 每道題都從以下模板講解&#xff0c;并且每個步驟都有圖片&#xff0c;清晰明了&#xff0c;便于復盤。 sql注入的基本步驟 注入點注入類型 字符型&#xff1a;判斷閉合方式 &#xff08;‘、"、’、“”&#xf…

【什么是動態鏈接?這里的動態是什么意思?鏈接了什么?】

動態鏈接&#xff08;Dynamic Linking&#xff09;詳解 1. 什么是動態鏈接&#xff1f; 動態鏈接是 Java 虛擬機&#xff08;JVM&#xff09;在運行時將字節碼中的符號引用&#xff08;Symbolic Reference&#xff09;轉換為直接引用&#xff08;Direct Reference&#xff09;…

AWS S3深度剖析:云存儲的瑞士軍刀

1. 引言 在當今數據驅動的世界中,高效、可靠、安全的數據存儲解決方案至關重要。Amazon Simple Storage Service (S3)作為AWS生態系統中的核心服務之一,為企業和開發者提供了一個強大而靈活的對象存儲平臺。本文將全面解析S3的核心特性,幫助讀者深入理解如何充分利用這一&q…

【Game】Powerful——Martial Arts Challenge(6)

文章目錄 攻略關卡一&#xff08;虎子&#xff09;關卡二關卡三關卡四關卡五關卡六——奇窮 攻略 關卡一&#xff08;虎子&#xff09; 參戰選手 出手順序 關卡二 參戰選手 出手順序 關卡三 參戰選手 出手順序 關卡四 參戰選手 出手順序 關卡五 參戰選手 出手順序 關卡六…

PPIO × UI-TARS:用自然語言操控電腦,AI Agent 的極致體驗

Manus的爆火預示著AI 正在從單純的文本生成和圖像識別邁向更復雜的交互場景。字節跳動近期推出的開源項目 UI-TARS Desktop 為我們展示了一種全新的可能性&#xff1a;能夠通過自然語言理解和處理來控制計算機界面。這款工具代表了人工智能與人機交互領域的重大突破&#xff0c…

電腦屏保壁紙怎么設置 桌面壁紙設置方法詳解

電腦桌面壁紙作為我們每天面對的第一視覺元素&#xff0c;不僅能夠彰顯個人品味&#xff0c;還能營造舒適的工作或娛樂氛圍。電腦桌面壁紙怎么設置呢&#xff1f;下面本文將為大家介紹Windows和macOS兩大主流操作系統中設置電腦桌面壁紙的方法&#xff0c;幫助大家快速設置個性…

popupwindow攔截返回點擊

目的&#xff1a;彈窗只有點擊按鈕可以關閉。 前提&#xff1a;彈窗內有輸入框 試了網上的一些方法 設置彈窗焦點 setFocusable(false) &#xff08;會導致軟鍵盤無法顯示&#xff09;重寫 onBackPressed 方法 &#xff08;不會走這里&#xff09;為 popupwindow 設置 onKey…

數學知識——矩陣乘法

使用矩陣快速冪優化遞推問題 對于一個遞推問題&#xff0c;如遞推式的每一項系數都為常數&#xff0c;我們可以使用矩陣快速冪來對算法進行優化。 一般形式為&#xff1a; F n F 1 A n ? 1 F_nF_1A^{n-1} Fn?F1?An?1 由于遞推式的每一項系數都為常數&#xff0c;因此對…

GitHub 趨勢日報 (2025年04月07日)

GitHub 趨勢日報 (2025年04月07日) 本日報由 TrendForge 系統生成 https://trendforge.devlive.org/ &#x1f4c8; 今日整體趨勢 Top 10 排名項目名稱項目描述今日獲星語言1microsoft/markitdownPython tool for converting files and office documents to Markdown.? 1039P…

ROS多設備交互

ROS多設備連接同一個Master&#xff1a;ROS Master多設備連接-CSDN博客 在多個PC端連接同一個ROS Master后&#xff0c;接下來就可以實現不同設備之間的話題交流&#xff0c;Master主機端啟動不同PC端的功能包等功能了 盡管多個PC端擁有不同的ROS工作空間&#xff0c;但是只要…

基于國內環境 在Ubuntu 上安裝 Docker 指南

前言 在容器化技術主導云原生時代的今天&#xff0c;Docker 憑借其輕量化、高移植性和秒級部署能力&#xff0c;已成為開發與運維的必備工具。然而&#xff0c;國內用戶在 Ubuntu 系統上安裝 Docker 時&#xff0c;常因 ?官方鏡像源訪問受限、網絡延遲高、依賴包安裝失敗 等問…

數據結構:二叉樹(三)·(重點)

二叉樹的存儲結構 ?叉樹?般可以使?兩種結構存儲&#xff0c;?種順序結構&#xff0c;?種鏈式結構。 順序結構 順序結構存儲就是使?數組來存儲&#xff0c;?般使?數組只適合表?完全?叉樹&#xff0c;因為不是完全?叉樹會有 空間的浪費&#xff0c;完全?叉樹更適合…

EasyExcel實現圖片導出功能(記錄)

背景&#xff1a;在舊系統的基礎上&#xff0c;導出一些工單信息時&#xff0c;現需要新添加處理人的簽名或者簽章&#xff0c;這就涉及圖片的上傳、下載、寫入等幾個操作。 1、EasyExcel工具類 &#xff08;1&#xff09;支持下拉框的導出。 import com.alibaba.excel.Easy…

Android Material Design 3 主題配色終極指南:XML 與 Compose 全解析

最小必要顏色配置 <!-- res/values/themes.xml --> <style name"Theme.MyApp" parent"Theme.Material3.DayNight"><!-- 基礎三原色 --><item name"colorPrimary">color/purple_500</item><item name"col…

【Git】“warning: LF will be replaced by CRLF”的解決辦法

一、原因分析 不同操作系統的換行符標準不同&#xff1a; ? Windows&#xff1a;使用 CRLF&#xff08;\r\n&#xff09;表示換行&#xff1b; ? Linux/Mac&#xff1a;使用 LF&#xff08;\n&#xff09;表示換行 Git 檢測到本地文件的換行符與倉庫設置或目標平臺不兼容時…

PyTorch 深度學習實戰(33):聯邦學習與隱私保護

在上一篇文章中,我們探討了多模態學習與CLIP模型的應用。本文將深入介紹聯邦學習(Federated Learning)這一新興的分布式機器學習范式,它能夠在保護數據隱私的前提下實現多方協作的模型訓練。我們將使用PyTorch實現一個基礎的聯邦學習框架,并在圖像分類任務上進行驗證。 一…

藍橋杯 web 展開你的扇子(css3)

普通答案&#xff1a; #box:hover #item1{transform: rotate(-60deg); } #box:hover #item2{transform: rotate(-50deg); } #box:hover #item3{transform: rotate(-40deg); } #box:hover #item4{transform: rotate(-30deg); } #box:hover #item5{transform: rotate(-20deg); }…

LLM驅動的智能體:基于GPT的對話智能體開發指南

前言 大語言模型&#xff08;LLM, Large Language Model&#xff09;正在徹底改變智能體&#xff08;Agent&#xff09;的設計和實現方式。從簡單的聊天機器人到復雜的自動化助手&#xff0c;基于GPT等LLM的對話智能體已經在客服、教育、辦公自動化、編程助手等領域得到了廣泛…

深度解析 C# 中介者模式:設計與實戰應用

中介者模式&#xff08;Mediator Pattern&#xff09;是一種行為型設計模式&#xff0c;其核心思想是將多個對象之間的交互集中到一個中介者對象中&#xff0c;從而減少對象之間的直接交互&#xff0c;降低耦合度。在實現復雜系統時&#xff0c;中介者模式有助于提高系統的可維…

每日算法-250408

記錄今天解決的兩道 LeetCode 算法題&#xff0c;主要涉及二分查找的應用。 1283. 使結果不超過閾值的最小除數 題目描述 思路 核心思路是 二分查找。 解題過程 為什么可以使用二分&#xff1f; 關鍵在于單調性。對于一個固定的數組 nums&#xff0c;當除數 divisor 增大時&…