提示函数
介绍
当我们将GPT的对话界面与编程语言的shell进行比较时,封装提示可以被视为形成一个函数。这个函数有一个独特的名称,当我们用输入文本调用这个名称时,它会根据设定的内部规则产生结果。简而言之,我们构建了一个带有名称的可重用提示,使得与GPT的互动变得容易。这就像拥有一个方便的工具,让GPT代表我们执行特定任务——我们只需要提供输入,就能得到所需的输出。
通过将提示封装到函数中,您可以创建一系列函数来建立工作流程。每个函数代表一个特定的步骤或任务,当以特定顺序组合时,它们可以自动化复杂流程或更高效地解决问题。这种方法允许与GPT进行更有结构和简化的交互,最终增强其能力,使其成为完成各种任务的强大工具。
因此,在我们使用函数之前,我们需要让GPT知道它。以下是定义函数的提示。
提示:
让我们用meta prompt来调用这个提示。
这个提示已经在GPT3.5上测试过,在GPT4上表现更好
Hello, ChatGPT! I hope you are doing well. I am reaching out to you for assistance with a specific function. I understand that you have the capability to process information and perform various tasks based on the instructions provided. In order to help you understand my request more easily, I will be using a template to describe the function, input, and instructions on what to do with the input. Please find the details below:
function_name: [Function Name]
input: [Input]
rule: [Instructions on how to process the input]
I kindly request you to provide the output for this function, based on the details I have provided. Your assistance is greatly appreciated. Thank you!
I will replace the text inside the brackets with the relevant information for the function I want you to perform. This detailed introduction should help you understand my request more efficiently and provide the desired output. The format is function_name(input) If you understand, just answer one word with ok.
示例
英语学习助手
例如,假设我们想使用GPT来帮助我们学习英语。我们可以通过创建一系列函数来简化这个过程。
此示例已在GPT3.5上测试,并在GPT4上表现更佳
功能描述
我们需要粘贴在GPT部分上方定义的元提示
然后我们将创建一个函数 trans_word
。
这个函数提示GPT将中文翻译成英文。
提示:
function_name: [trans_word]
input: ["text"]
rule: [I want you to act as an English translator, spelling corrector and improver. I will provide you with input forms including "text" in any language and you will detect the language, translate it and answer in the corrected of my text, in English.]
编写一个扩展文本的函数。
提示:
function_name: [expand_word]
input: ["text"]
rule: [Please serve as a Chatterbox, spelling corrector, and language enhancer. I will provide you with input forms including "text" in any language, and output the original language.I want you to Keep the meaning same, but make them more literary.]
编写一个纠正文本的函数。
提示:
function_name: [fix_english]
input: ["text"]
rule: [Please serve as an English master, spelling corrector, and language enhancer. I will provide you with input forms including "text", I want you to improve the text's vocabulary and sentences with more natural and elegent. Keep the meaning same.]
最后,您可以独立运行函数或将它们链接在一起。
提示:
trans_word('婆罗摩火山处于享有“千岛之国”美称的印度尼西亚. 多岛之国印尼有4500座之多的火山, 世界著名的十大活火山有三座在这里.')
fix_english('Finally, you can run the function independently or chain them together.')
fix_english(expand_word(trans_word('婆罗摩火山处于享有“千岛之国”美称的印度尼西亚. 多岛之国印尼有4500座之多的火山, 世界著名的十大活火山有三座在这里.')))
通过以这种格式表示函数,您可以清楚地看到每个函数的名称、输入以及处理输入的规则。它提供了一种有组织的方式来理解工作流程中每个步骤的功能和目的。
提示: 如果你不希望ChatGPT输出过多的信息,你可以在定义函数规则后简单地添加一句话。
DO NOT SAY THINGS ELSE OK, UNLESS YOU DONT UNDERSTAND THE FUNCTION
多参数函数
让我们创建一个函数,该函数通过接收五个输入参数来生成密码,并输出生成的密码。
提示:
function_name: [pg]
input: ["length", "capitalized", "lowercase", "numbers", "special"]
rule: [I want you to act as a password generator for individuals in need of a secure password. I will provide you with input forms including "length", "capitalized", "lowercase", "numbers", and "special" characters. Your task is to generate a complex password using these input forms and provide it to me. Do not include any explanations or additional information in your response, simply provide the generated password. For example, if the input forms are length = 8, capitalized = 1, lowercase = 5, numbers = 2, special = 1, your response should be a password such as "D5%t9Bgf".]
pg(length = 10, capitalized = 1, lowercase = 5, numbers = 2, special = 1)
pg(10,1,5,2,1)
思考
现在,已经有许多项目正在致力于编程GPT,例如:
- GitHub Copilot (在新标签页中打开)
- Microsoft AI (在新标签页中打开)
- chatgpt-plugins (在新标签页中打开)
- LangChain (在新标签页中打开)
- marvin (在新标签页中打开)
但这些项目要么是为产品客户设计的,要么是为能够使用Python或其他编程语言编码的用户设计的。 对于普通用户来说,使用这个简单的模板进行日常工作并迭代几次。使用笔记应用程序记录功能,甚至可以将其更新为库。 另外,一些开源的ChatGPT工具,如ChatGPT-Next-Web(在新标签页中打开)、chatbox(在新标签页中打开)、PromptAppGPT(在新标签页中打开)和ChatGPT-Desktop(在新标签页中打开),可以使用。目前,ChatGPT-Next-Web允许在初始化新聊天之前添加一些示例。而PromptAppGPT支持基于提示模板的低代码Web应用程序开发,并使任何人都能够用几行提示开发类似AutoGPT的应用程序。 我们可以利用这个功能添加我们的功能,然后就可以使用了。