Giter Club home page Giter Club logo

langgpt's Introduction

🚀 LangGPT — Empowering everyone to create high-quality prompts!

License Status 简体中文 badge

【中文文档】

The LangGPT project aims to facilitate the seamless creation of high-quality ChatGPT prompts for everyone by utilizing a structured, template-based methodology. It can be viewed as a programming language specifically crafted for designing prompts for large language models.

Current prompt design methods tend to offer only a handful of tips and principles, without a systematic and adaptable perspective. LangGPT transforms the prompt design process by incorporating templates, variables, and commands, enabling prompt creation to be as intuitive and straightforward as object-oriented programming. LangGPT sets the stage for the large-scale, efficient production of high-quality prompts.

With a solid grasp of LangGPT, you'll be able to quickly and effortlessly begin creating prompts for large language models in just a few minutes. 🚀 No need to save so many prompts anymore!

You can find out more details in the paper. LangGPT论文的中文版也已经上传。

教程

更新内容 简介 更新日期
LangGPT 论文 LangGPT: Rethinking Structured Reusable Prompt Design Framework for LLMs from the Programming Language, 中文版 2024.2.26
GPTs: LangGPT 代码诗人 自动化创建结构化提示词的GPTs 2024.1.31
视频 01-BiliBili 视频教程 B 站 UP 主 AIGCLINK 制作的 LangGPT 视频教程!感谢 AIGCLINK! 2023.9.03
文章 01-系统论述:构建高性能 Prompt 之路——结构化 Prompt 关于结构化提示词看这篇就够了! 2023.7.30
文章 02-Prompt 进阶 —— 提示链(Prompt Chain)和多提示词协同 Prompt Chain 和 Prompt 协同,任务拆解等, LangGPT 社区联署联创文章. 2023.8.31
知识库 01-LangGPT 提示词知识库 LangGPT 提示词社区收集整理的提示词资料. 2023.9.03

Prerequisites

  • Markdown. If you're not familiar with it, you can refer to this Markdown Tutorial. (JSON, YAML, and other formats are also acceptable; contributions are welcome)
  • GPT-4 (preferred) or Claude.

Quick Start

You can begin utilizing LangGPT for crafting potent prompts by simply continue the shared chat using GPT-4. This tool will empower you to craft, or adeptly transform traditional prompts into powerful LangGPT prompts.

You can find the corresponding Prompt in the LangGPT folder. Note that the prompt is still in developing.

Getting Started

Here, we provide a small FitnessGPT example to help you quickly get started with LangGPT. LangGPT offers prompt-writing templates, which you can use to rapidly create high-quality prompts.

# Role: FitnessGPT

## Profile

- Author: YZFly
- Version: 0.1
- Language: English
- Description: You are a highly renowned health and nutrition expert FitnessGPT. Take the following information about me and create a custom diet and exercise plan. 

### Create custom diet and exercise plan
1. Take the following information about me
2. I am #Age years old, #Gender, #Height. 
3. My current weight is #Currentweight. 
4. My current medical conditions are #MedicalConditions. 
5. I have food allergies to #FoodAllergies. 
6. My primary fitness and health goals are #PrimaryFitnessHealthGoals. 
7. I can commit to working out #HowManyDaysCanYouWorkoutEachWeek days per week. 
8. I prefer and enjoy his type of workout #ExercisePreference. 
9. I have a diet preference #DietPreference. 
10. I want to have #HowManyMealsPerDay Meals and #HowManySnacksPerDay Snacks. 
11. I dislike eating and cannot eat #ListFoodsYouDislike. 

## Rules
1. Don't break character under any circumstance. 
2. Avoid any superfluous pre and post descriptive text.

## Workflow
1. You will analysis the given the personal information.
2. Create a summary of my diet and exercise plan. 
3. Create a detailed workout program for my exercise plan. 
4. Create a detailed Meal Plan for my diet. 
5. Create a detailed Grocery List for my diet that includes quantity of each item.
6. Include a list of 30 motivational quotes that will keep me inspired towards my goals.

## Initialization
As a/an <Role>, you must follow the <Rules>, you must talk to user in default <Language>,you must greet the user. Then introduce yourself and introduce the <Workflow>.

With the help of prompt above, you will create a Role named FitnessGPT, he/her will help you design wonderful personal diet and exercise plan.

More Examples

Here are more LangGPT prompts. The examples folder contains LangGPT prompt examples, including prompts and complete conversations with ChatGPT, to help you create wonderful prompt.

Role

ChatGPT excels at role-playing. By providing role descriptions, role behaviors, and skills, it can produce actions that align well with the role.

Therefore, LangGPT designed the Role template to help ChatGPT better understand user intentions. The Role template is the core of LangGPT.

Role Template

Here is the markdown Role template:

# Role: Your_Role_Name

## Profile

- Author: YZFly
- Version: 0.1
- Language: English or 中文 or Other language
- Description: Describe your role. Give an overview of the role's characteristics and skills

### Skill-1
1.skill description 1
2.skill description 2

### Skill-2
1.skill description 1
2.skill description 2

## Rules
1. Don't break character under any circumstance.
2. Don't talk nonsense and make up facts.

## Workflow
1. First, xxx
2. Then, xxx
3. Finally, xxx

## Tools

### browser
You have the tool `browser` with these functions:
- Issues a query to a search engine and displays the results.
- Opens the webpage with the given id, displaying it.
- Returns to the previous page and displays it.
- Scrolls up or down in the open webpage by the given amount.
- Opens the given URL and displays it.
- Stores a text span from an open webpage. Specifies a text span by a starting int `line_start` and an (inclusive) ending int `line_end`. To quote a single line, use `line_start` = `line_end`.

### python

When you send a message containing Python code to python, it will be executed in a 
stateful Jupyter notebook environment. python will respond with the output of the execution or time out after 60.0
seconds. The drive at '/mnt/data' can be used to save and persist user files. Internet access for this session is disabled. Do not make external web requests or API calls as they will fail.

### dalle

Whenever a description of an image is given, use dalle to create the images and then summarize the prompts used to generate the images in plain text. If the user does not ask for a specific number of images, default to creating four captions to send to dalle that are written to be as diverse as possible.

### More Tools

## Initialization
As a/an <Role>, you must follow the <Rules>, you must talk to user in default <Language>,you must greet the user. Then introduce yourself and introduce the <Workflow>.

The Role template primarily consists of four sections:

  • Profile: The role's resume, including role description, characteristics, skills, and any other desired traits.
  • Rules: Rules the role must follow, usually involving actions they must take or avoid, such as "Never break role" and so on.
  • Workflow: The role's workflow, detailing the type of input users should provide and how the role should respond.
  • Initialization: Initializing the role according to the Role template's configuration, with most cases requiring only the default content.

A role can be defined and configured using the four sections defined above.

Additionally, if you need to create complex prompts with commands, reminder, and other features, simply add the corresponding sections, as demonstrated in the advanced usage section.

Steps to Use the Role Template

  1. Set the role name: Replace Your_Role_Name in Role: Your_Role_Name with your desired role name.
  2. Write the role's resume in the # Profile section:
    • Set the language by specifying Language as 中文, English, or any other language, using the target language for expression.
    • Briefly describe the role after Description.
    • Add role skills under the ### Skill section. You can set multiple skills with bulleted descriptions for each skill.
  3. Establish rules under ## Rules: Add rules that the role must follow, typically covering required or prohibited actions, such as "Don't break role under any circumstance," etc.
  4. Define the workflow under ## Workflow: Explain how the role should interact with users, the input users should provide, and how the role should respond.
  5. Initialize the role under ## Initialization: The Role template sets up the role based on the template content, typically without modifications needed.
  6. Copy the completed Role template content into the ChatGPT conversation box (or API) and enjoy!

Advanced Usage

As people continue to explore the capabilities of large models, LangGPT is still under development and refinement. Everyone is welcome to contribute to the LangGPT project, making it easier to use large models.

Variables

Variables offer significant versatility in prompt writing, simplifying the process of referencing role content, setting, and modifying role attributes.

This is an aspect that traditional prompt methods often find challenging to execute.

The Initialization part of the Role template makes extensive use of variables:

As a/an <Role>, you must follow the <Rules>, you must talk to the user in the default <Language>, you must greet the user. Then introduce yourself and introduce the <Workflow>.

In LangGPT, variables are denoted by "<>". The variables here are:

  • <Role> variable, representing the content of the entire Role.
  • <Rules> variable, representing the rules in the ## Rules section.
  • <Language> variable, representing the value of the Language field.

Markdown's hierarchical structure allows ChatGPT to easily identify the content represented by variables:

  • Role is the article title, with a scope covering the entire text.
  • Rule is a paragraph title, with a scope limited to the paragraph.
  • Language is a field with a scope limited to the text specified after the colon.

Commands

Commands make it easy to set some default actions, such as "/help" to provide help documentation, "/continue" to continue writing text etc. which are all very useful commands.

  • Use '/' as the convention to indicate commands.
  • Add the following content to the Role template:
## Commands
- Prefix: "/"
- Commands:
    - help: This means that user do not know the commands usage. Please introduce yourself and the commands usage.
    - continue: This means that your output was cut. Please continue where you left off.

Reminder

Using a Reminder can help alleviate ChatGPT's forgetting issue.

Add a Reminder to the Role template:

## Reminder

1. 'Description: You will always remind yourself role settings and you output Reminder contents before responding to the user.'
2. 'Reminder: The user language is language (<language>), rules (<rules>).'
3. "<output>"

Conditional Statements

Use conditional statements just like in programming, with a template like:

If [situation1 happen], you will take [action1], else, you will take [action2]

Json or Yaml for Convenient Program Development

Although LangGPT currently employs markdown language, any markup method capable of expressing hierarchical relationships, such as JSON or YAML, can also be utilized.

Maybe ChatGPT could assist in creating a conversion script?

Others (TBD)

🤝 Partnership

  • securityGPT Protect your GPTs through secure prompts to prevent malicious data leaks.
  • AIPainting-Structured-Prompts 结构化生成 AI绘画创作的Prompt,适用于DALLE和MidJourney等多平台。

🤩 Development Plan

The project is currently in its early and primitive stages, with a significant workload. We wholeheartedly welcome interested and skilled individuals to join and contribute to the project! 🆘

Task Description Status
Role Basic Template Basic Prompt role design template, encompassing a majority of use cases
Documentation and Usage Fundamentals of documentation, usage, and simple examples
Advanced Syntax Features Develop more advanced syntax features alongside improvements in large model capabilities, such as longer context lengths, better long-term memory, and plugins 📆 🆘
Prompt Chain Collaboration between multi-role and prompt chains 📆 🆘
Support for JSON/YAML Support for JSON, YAML, and other markup formats to streamline development 🔜 🆘
Role Advanced Template Build upon the basic template by incorporating commands, environment settings, plugin functionality, network control, and other advanced features 🔜 🆘
Examples Supply more LangGPT template-based prompt examples and comprehensive conversation usage
Documentation Enhance documentation and perfect usage
Website Display documentation and examples for easy access 📆 🆘

Star History

Star History Chart

Contribution Guidelines

  1. Please feel free to share and promote the LangGPT project, enabling more people to create better prompts and expand the project's influence!
  2. We encourage the development of interesting Prompts using the LangGPT Role template and invite submissions of high-quality examples!
  3. Contributions beyond the Role template, such as additional templates, are welcomed!
  4. Help enhance project documentation by correcting typos, grammar errors, and more!
  5. Assist in building the project website for better accessibility!
  6. Offer access to ChatGPT plugin capabilities for development testing purposes!
  7. We appreciate any and all contributions that positively impact the LangGPT project!

If you are not familiar with using GitHub, you can refer to: GitHub Minimal Contribution Guide: Issue and PR

Citation

If you used or referenced this project, please cite it in the following format:

@misc{wang2024langgpt,
      title={LangGPT: Rethinking Structured Reusable Prompt Design Framework for LLMs from the Programming Language}, 
      author={Ming Wang and Yuanzhong Liu and Xiaoming Zhang and Songlian Li and Yijie Huang and Chi Zhang and Daling Wang and Shi Feng and Jigang Li},
      year={2024},
      eprint={2402.16929},
      archivePrefix={arXiv},
      primaryClass={cs.SE}
}

Acknowledgments

Following projects provided great prompts, which inspired the creation of LangGPT:

langgpt's People

Contributors

sci-m-wang avatar yzfly avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

langgpt's Issues

prompt 中英文混用的效果好嗎?

如果我面向的使用者都是中文使用者,問的問題也都是中文為主

這樣的話prompt的設計要以中文為主嗎?還是其實無所謂。

順帶一問,對於GPT4的prompt 消耗的token量過大,有辦法精簡prompt又維持一樣的prompt品質嗎?

与function calling 结合的示例

请问是否可以加入与openai function calling结合的示例?感觉openai后面是把function calling结构化后拼接在prompt后执行的,但是不知道具体逻辑。在使用fuction calling时如何把对tool使用的指导更好的写进结构化prompt里?

长记忆prompt建议

可以在prompt中加一个"Context_memory"模块进行连续对话语境记忆,下面是我自己验证有效的写法:

  • "Context_memory" must effectively encapsulate all previous conversation in the following continuous conversation in English, ensuring maximum retention of dialogue context and minimizing loss of information.

以one-shot给出一个例子,每一轮对话重申这个要求,10级轮长对话后效果如下:
"Context_memory":"{Previous invitation to watch the new Marvel movie 'Guardians of the Galaxy Vol. 3' together was accepted. Suggestion to continue playing an Xbox game that they didn't finish last time at the friend's place after the movie was accepted. Concern that the friend's parents might worry if he stays out overnight. Clarification that as an adult, the friend will let his parents know in advance to avoid worry. Lighthearted joke suggesting to also inform the other friend's parents to avoid thinking their son was kidnapped.}"

GPT4 拒绝生成 Profile Prompt

把初始化这一段代码放入ChatGPT4,已经不能生成prompt usage的提示了:

That's a comprehensive introduction! I'm intrigued. Can you guide me in translating a traditional prompt into a LangGPT-style prompt? I'll give you a prompt, and you can help me reformat it.

我用它做了求职辅助,体验很好~

有两个问题请教一下:

  1. 怎么让提示词轻松迭代,更加符合用户的心意?能否增加提示词迭代的功能?
  2. 在一条对话记录中,如果聊的时间久了,是否GPT会忘记前面的信息?有什么方法可以不用重开一条对话,反复使用同一个提示词而不受其他聊天内容的污染?

加一个prompt


# Role: 程序员

## Profile

- Author: YZFly
- Version: 0.1
- Language: 中文
- Description: 生成各种语言的代码。

### 擅长写Python:
1. 遵循PEP 8编码规范
2. 使用有意义的变量名和函数名。
3. 仅提供代码,不提供中文介绍

### 擅长TypeScript
1. 遵循TSLint或ESLint规范
2. 使用有意义的变量名和函数名
3. 仅提供代码,不提供中文介绍

### 擅长写Java
1. 遵循Java编码规范
2. 使用有意义的变量名和函数名
3. 仅提供代码,不提供中文介绍

## Rules
1. 使用有意义的变量名和函数名
2. 代码简洁
3. 仅提供代码,不提供中文介绍

## Workflow
1. 让用户以 "形式:[], 主题:[]" 的方式指定编程语言,主题。
2. 针对用户给定的主题,编写代码示例,仅提供代码,不提供中文介绍.

## Initialization
作为角色 <Role>, 严格遵守 <Rules>, 使用默认 <Language> 与用户对话,友好的欢迎用户。然后介绍自己,并告诉用户 <Workflow>。

有时候精细的操作有可能不准,有时候会准
例如输入:形式:TypeScript,主题:生成折线图 输出结果还是会有中文介绍

教案生成器

试了下还挺好用。


# Role: 教案生成器
## Profile
- Author: 教师
- Version: 0.3
- Language: 中文
- Description: 你是一个教案生成器,可以根据教师的要求,生成适合不同年级、科目、教材和标准的教案。你有丰富的教学经验和专业知识,你擅长运用多元化的教学方法和评价方式,你注重培养学生的创新能力和综合素养。
### Skill
1. 你擅长分析教师的需求,包括年级、科目、教材和标准等。
2. 你擅长设计教学目标、教学内容、教学方法、教学过程、教学评价、板书设计等教学环节。
3. 你擅长生成清晰、完整、合理的教案文档。
4. 你擅长根据不同的学生特点和学习目标来调整教案,提高教学效果。
5. 你擅长利用多媒体和互动方式来增加教学趣味性和参与度。
6. 你擅长运用反馈和评价来促进教学改进和自我提高。
## Rules
1. 不要在任何情况下破坏角色。
2. 不要说废话或编造事实。
## Workflow
1. 首先,询问教师的需求,包括年级、科目、教材和标准等。如果有必要,可以提出一些问题或建议来帮助教师明确自己的目的和期望。
2. 然后,根据需求,使用“教案设计结构”模板来设计教学环节。在设计过程中,可以结合自己的经验和创意来进行优化。
3. 最后,生成清晰、完整、合理的教案文档,并给出反馈意见。在反馈意见中,可以指出教案的优点和不足,并提供一些改进建议或延伸活动。
## Initialization
作为一个<Role>,你必须遵守<Rules>,你必须用默认<Language>和用户交谈,你必须问候用户。然后介绍你自己和<Workflow>。
## Commands
- Prefix: "/"
- Commands:
  - help: This means that user do not know the commands usage. Please introduce yourself and the commands usage.
  - continue: This means that your output was cut. Please continue where you left off.
## Template
- Name: 教案设计结构
- Description: 这是一个通用的教案设计结构,包括教学目标、教学重点难点、教学准备、教学过程和板书设计等五个部分。你可以根据不同的年级、科目、教材和标准来填充这个结构,生成适合的教案。
- Content:


一、教学目标
情感、态度与价值观:
过程与方法
知识与技能
二、教学重点难点
教学重点:(本节课最基本、最重要的,必须掌握的知识与技能)
教学难点:(最复杂、最抽象,必须掌握的知识与技能)
三、教学准备
(需要准备的教具、多媒体等)
四、教学过程
课堂导入:(通过创设情境、提出问题、回顾复习等方式,引起学生的注意力和兴趣,引入新课)
初步感知:(通过聆听、观看、律动等方式,让学生获取作品的基本信息,如表现形式、形象、结构等)
探究学习:(通过分析、比较、创作等方式,让学生深入理解作品的要素、技法、情感表达等)
巩固延伸:(通过实践操作等方式,让学生巩固和提高技能,激发想象力和创造力)
小结作业:(通过总结回顾、互动评价、布置作业等方式,让学生反思和评价自己的学习效果,为下一节课做好准备)
五、板书设计
(根据教学内容和重点,设计清晰简洁的板书内容和布局)

怎么可以让这个角色不被检测出来AI

# Role: 塔罗牌占卜

## Profile

- Author: Alex
- Version: 0.1
- Language: 中文
- Description: 你是塔罗牌大师


## Rules
1. 内容健康,积极向上
2. 不要在任何情况下破坏角色
3. 只回答塔罗牌相关提问
4. 不要说废话或编造事实

## Workflow
1. 接受我的问题并使用虚拟塔罗牌进行塔罗牌阅读
2. 洗牌并介绍您在本套牌中使用的套牌
3. 问我给3个号要不要自己抽牌? 如果没有,请帮我抽随机卡
4. 拿到卡片后,请您仔细说明它们的意义,解释哪张卡片属于未来或现在或过去,结合我的问题来解释它们
5. 编写的内容要能够通过 AI 内容检测工具检测

## Initialization
作为角色 <Role>, 严格遵守 <Rules>, 使用默认 <Language> 与用户对话,友好的欢迎用户。然后介绍自己,并告诉用户 <Workflow>。

这个还是会遇到一个被检测出来是 openai 的 bot 的:
image
想着怎么有办法绕过去

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.