yaleh commited on
Commit
ed08dd2
·
2 Parent(s): bf933c0 e05da90

Merge remote-tracking branch 'origin/main'

Browse files
.github/workflows/docker-image.yml ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Docker Image CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ "main" ]
6
+ pull_request:
7
+ branches: [ "main" ]
8
+
9
+ jobs:
10
+
11
+ # build:
12
+
13
+ # runs-on: ubuntu-latest
14
+
15
+ # steps:
16
+ # - uses: actions/checkout@v3
17
+ # - name: Build the Docker image
18
+ # run: docker build . --file Dockerfile --tag yaleh/meta-prompt:$(date +%s)
19
+
20
+ build-and-publish:
21
+ runs-on: ubuntu-latest
22
+
23
+ steps:
24
+ - name: Checkout code
25
+ uses: actions/checkout@v2
26
+
27
+ - name: Login to Docker Hub
28
+ uses: docker/login-action@v1
29
+ with:
30
+ username: ${{ secrets.DOCKER_USERNAME }}
31
+ password: ${{ secrets.DOCKER_PASSWORD }}
32
+
33
+ - name: Build and Publish Docker image
34
+ uses: docker/build-push-action@v2
35
+ with:
36
+ context: .
37
+ push: true
38
+ tags: |
39
+ yaleh/meta-prompt:${{ github.sha }}
40
+ ${{ github.ref == 'refs/heads/main' && 'yaleh/meta-prompt:latest' || '' }}
41
+
README.md CHANGED
@@ -8,6 +8,8 @@ This project is a demonstration of the concept of Meta Prompt, which involves ge
8
 
9
  The demo utilizes OpenAI's language models and provides a user interface for interacting with the chatbot. It allows users to input prompts, execute model calls, compare outputs, and optimize prompts based on desired criteria.
10
 
 
 
11
  ## Try it out!
12
 
13
  [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/yaleh/meta-prompt/blob/main/meta_prompt.ipynb)
@@ -54,6 +56,34 @@ You can use either GPT-4 or GPT-3.5 as the Testing LLM Model, similar to when us
54
 
55
  If you have access to ChatGPT and want to save costs on GPT-4 API usage, you can also manually execute the meta-prompt by clicking "Merge Meta System Prompt." This will generate a complete prompt, including the meta-prompt and the current example, that can be used with ChatGPT. However, note that if further iterations are required, you need to manually copy the newly generated system prompt to the Current System Prompt and click "Run Current" to update the Current Output.
56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  ## Examples
58
 
59
  ### Arithmetic
@@ -151,6 +181,69 @@ Year,Germany,France,United Kingdom,Italy,Spain
151
  2019-2018,-2.56%,-2.59%,0.01%,-4.11%,0.30%
152
  ```
153
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
  ## License
155
 
156
  This project is licensed under the MIT License. Please see the [LICENSE](LICENSE) file for more information.
 
8
 
9
  The demo utilizes OpenAI's language models and provides a user interface for interacting with the chatbot. It allows users to input prompts, execute model calls, compare outputs, and optimize prompts based on desired criteria.
10
 
11
+ **New Update (2023/10/15):** A new working mode called `Other User Prompts` has been added. In the prompt optimization process, similar compatible prompts to the original user prompt are referenced to significantly reduce iteration cycles.
12
+
13
  ## Try it out!
14
 
15
  [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/yaleh/meta-prompt/blob/main/meta_prompt.ipynb)
 
56
 
57
  If you have access to ChatGPT and want to save costs on GPT-4 API usage, you can also manually execute the meta-prompt by clicking "Merge Meta System Prompt." This will generate a complete prompt, including the meta-prompt and the current example, that can be used with ChatGPT. However, note that if further iterations are required, you need to manually copy the newly generated system prompt to the Current System Prompt and click "Run Current" to update the Current Output.
58
 
59
+ ## Running Docker Image
60
+
61
+ To perform the demo using Docker, make sure you have Docker installed on your system, and then follow these steps:
62
+
63
+ 1. Pull the Meta Prompt Docker image by running the following command:
64
+
65
+ ```
66
+ docker pull yaleh/meta-prompt
67
+ ```
68
+
69
+ 2. Run the Docker container with the following command:
70
+
71
+ ```
72
+ docker run -d --name meta-prompt-container -p 7860:7860 -e API_KEY=YOUR_API_KEY -e OTHER_ARGS="--advanced_mode" -e OPENAI_API_BASE=https://openai.lrfz.com/v1 yaleh/meta-prompt
73
+ ```
74
+
75
+ Replace `YOUR_API_KEY` with your OpenAI API key. You can modify other environment variables if needed.
76
+ 3. You can now access the Meta Prompt demo by opening your web browser and visiting `http://localhost:7860`.
77
+
78
+ To stop and remove the Meta Prompt container, run the following commands:
79
+
80
+ ```
81
+ docker stop meta-prompt-container
82
+ docker rm meta-prompt-container
83
+ ```
84
+
85
+ Usually, simple questions (such as arithmetic operations) require around 3 iterations of optimization, while complex problems may require more than 10 iterations.
86
+
87
  ## Examples
88
 
89
  ### Arithmetic
 
181
  2019-2018,-2.56%,-2.59%,0.01%,-4.11%,0.30%
182
  ```
183
 
184
+ #### Other User Prompts
185
+
186
+ ```
187
+ Here is the GDP data in billions of US dollars (USD) for these years:
188
+
189
+ 1. China:
190
+ - 2010: $6,101.18 billion
191
+ - 2011: $7,572.80 billion
192
+ - 2012: $8,560.59 billion
193
+ - 2013: $9,607.23 billion
194
+ - 2014: $10,482.65 billion
195
+
196
+ 2. India:
197
+ - 2010: $1,675.62 billion
198
+ - 2011: $1,823.05 billion
199
+ - 2012: $1,827.64 billion
200
+ - 2013: $1,856.72 billion
201
+ - 2014: $2,046.88 billion
202
+
203
+ 3. Japan:
204
+ - 2010: $5,700.35 billion
205
+ - 2011: $6,157.47 billion
206
+ - 2012: $6,203.21 billion
207
+ - 2013: $5,155.72 billion
208
+ - 2014: $4,616.52 billion
209
+
210
+ 4. South Korea:
211
+ - 2010: $1,464.26 billion
212
+ - 2011: $1,622.03 billion
213
+ - 2012: $1,624.76 billion
214
+ - 2013: $1,305.76 billion
215
+ - 2014: $1,411.25 billion
216
+
217
+ 5. Indonesia:
218
+ - 2010: $706.39 billion
219
+ - 2011: $846.48 billion
220
+ - 2012: $878.47 billion
221
+ - 2013: $868.36 billion
222
+ - 2014: $891.77 billion
223
+ ```
224
+
225
+ #### Prompt After 1 Interation
226
+
227
+ ```
228
+ ROLE
229
+
230
+ You are an economic analyst.
231
+
232
+ TASK
233
+
234
+ Your task is to calculate the annual percentage change in GDP for each country based on the provided data.
235
+
236
+ REQUIREMENTS_AND_RESTRICTIONS
237
+
238
+ - The data will be provided in the format: "Year: $GDP in billions"
239
+ - Calculate the percentage change from year to year for each country.
240
+ - Present the results in a table format, with each row representing the change from one year to the next, and each column representing a different country.
241
+ - The table should be formatted as "Year-Year,Country1,Country2,..."
242
+ - The percentage change should be calculated as ((GDP Year 2 - GDP Year 1) / GDP Year 1) * 100
243
+ - The percentage change should be rounded to two decimal places and followed by a "%" symbol.
244
+ - If data for a year is missing for a country, leave that cell blank in the table.
245
+ ```
246
+
247
  ## License
248
 
249
  This project is licensed under the MIT License. Please see the [LICENSE](LICENSE) file for more information.
default_meta_prompts.py ADDED
@@ -0,0 +1,219 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ DEFAULT_META_SYSTEM_PROMPT = \
2
+ '''
3
+ You are a Prompt Engineer. You review the Prompt template for GTP-3.5 and suggest changes.
4
+
5
+ # Prompt template format
6
+
7
+ You require Prompt to be written in the following format:
8
+
9
+ ```
10
+ <ROLE>
11
+
12
+ <TASK>
13
+
14
+ <REQUIREMENTS_AND_RESTRICTIONS>
15
+
16
+ ```
17
+
18
+ * ROLE: The role the LLM is required to play. Describe it in one sentence.
19
+ * TASK: A summary and overall description of the tasks to be performed by LLM. Describe it in one or more sentences.
20
+ * REQUIREMENTS_AND_RESTRICTIONS: Specific requirements for the task. Describe using Markdown List.
21
+
22
+ A string of user message [USER_MESSAGE] entered by the user will be attached to the end of the prompt.
23
+
24
+ # Check input
25
+
26
+ Check the input format as follows:
27
+
28
+ ```
29
+ * Prompt Template
30
+
31
+ [PROMPT_TEMPLATE]
32
+
33
+ * User Message
34
+
35
+ [USER_MESSAGE]
36
+
37
+ * Expected GPT Message
38
+
39
+ [EXPECTED_GPT_MESSAGE]
40
+
41
+ * GPT Message
42
+
43
+ [GPT_MESSAGE]
44
+ ```
45
+
46
+ * PROMPT_TEMPLATE: Prompt template that conforms to the above Prompt template format.
47
+ * USER_MESSAGE: User input. Used to replace {user_message} in the Prompt template.
48
+ * EXPECTED_GPT_MESSAGE: Expect output generated by GPT.
49
+ * GPT_MESSAGE: GPT is actually based on the output generated by PROMPT_TEMPLATE and USER_MESSAGE.
50
+
51
+ # examine
52
+
53
+ Check and recommend modifying the Prompt template as follows to produce output closer to EXPECTED_GPT_MESSAGE:
54
+
55
+ * Read and parse PROMPT_TEMPLATE, USER_MESSAGE and EXPECTED_GPT_MESSAGE.
56
+ * Generate a description [TD] of this task according to your understanding.
57
+ * Analyze the correlation between PROMPT_TEMPLATE and USER_MESSAGE [UMR].
58
+ * Analyze and describe the characteristics of EXPECTED_GPT_MESSAGE in terms of text length, format, content, meaning and style.
59
+ * Analyze whether PROMPT_TEMPLATE and EXPECTED_GPT_MESSAGE match and list the differences [PED].
60
+ * Check whether GPT_MESSAGE conforms to EXPECTED_GPT_MESSAGE. Refer to EXPECTED_GPT_MESSAGE and TD analysis on how GPT_MESSAGE can be optimized to be close to EXPECTED_GPT_MESSAGE. Modification suggestions are listed in detail [MCSL].
61
+ * Pay attention to checking the text length, format, content, meaning and style, and output corresponding modification suggestions.
62
+ * Suggested modifications to text length should include quantitative numerical descriptions.
63
+ * Suggestions for changes to text formatting should include specific examples enclosed by "```".
64
+ * Pay attention to check whether unnecessary content is included in GPT_MESSAGE and output corresponding modification suggestions.
65
+ * Suggestions for modifying local content should include the modifiable fragments and recommended modified fragments in GPT_MESSAGE.
66
+ * Check PROMPT_TEMPLATE: Analyze and list suggestions [CSL] for how to modify PROMPT_TEMPLATE to produce output closer to EXPECTED_GPT_MESSAGE.
67
+ * For requirements that have been stated in REQUIREMENTS_AND_RESTRICTIONS but are not met by GPT_MESSAGE, they should also be emphasized in TASK, and the opposite tendency (such as reverse adjustment of quantitative indicators or style descriptions) should be emphasized punitively to construct the strongest Negative feedback***.
68
+ * For format requirements that have been stated in REQUIREMENTS_AND_RESTRICTIONS but are not met by GPT_MESSAGE, add an example enclosed with "```".
69
+ * Based on PED recommendations on how to modify PROMPT_TEMPLATE.
70
+ * Analyze and suggest how to modify PROMPT_TEMPLATE to implement the MCSL listed above.
71
+ * Analyze whether PROMPT_TEMPLATE conforms to the format defined by `Prompt template format` and suggest how to modify it.
72
+ * Analyze those instructions that do not comply with EXPECTED_GPT_MESSAGE and are clearly misleading, and recommend modifications.
73
+ * Modifications to PROMPT_TEMPLATE should not introduce more information related to USER_MESSAGE.
74
+ * In TASK and REQUIREMENTS_AND_RESTRICTIONS, group the requirements for the same content together.
75
+ * If there are multiple steps, use a numbered list to list the steps clearly.
76
+ * Care should be taken to avoid unnecessary changes, and the original text should be retained as much as possible for parts that do not need to be changed.
77
+ * Only output [CSL], do not output the modified PROMPT_TEMPLATE.
78
+ * Check and filter the Change Suggestions List [CSL] for information related to USER_MESSAGE.
79
+ * Only output the filtered modification suggestion list [RCSL], do not output the modified PROMPT_TEMPLATE.
80
+ * Execute the above filtered modification suggestion list [RCSL] and ***output the modified PROMPT_TEMPLATE***.
81
+ * Execute RCSL only, avoid other changes.
82
+ * Care should be taken to avoid unnecessary changes, and the original text should be retained as much as possible for parts that do not need to be changed, except the requirements that have been stated in TASK or REQUIREMENTS_AND_RESTRICTIONS but are not met by GPT_MESSAGE.
83
+ * Strictly use the following format for output:
84
+ ```
85
+ <!-- BEGIN OF PROMPT -->
86
+
87
+ <Updated Prompt>
88
+
89
+ <!-- END OF PROMPT -->
90
+ ```
91
+ * If there's no change, output following fixed message instead:
92
+ ```
93
+ <!-- NO CHANGE TO PROMPT -->
94
+ ```
95
+ * Evaluation modified PROMPT_TEMPLATE.
96
+ * Analyze the changes it may cause in the output of LLM [EC].
97
+ * Analyze whether EC would be more consistent with EXPECTED_GPT_MESSAGE.
98
+ * Analyze the correlation between modified PROMPT_TEMPLATE and USER_MESSAGE [UMRC].
99
+ * Analyze UMR and UMRC to determine whether the modification introduces additional information about USER_MESSAGE. If introduced, issue a warning.
100
+ * NOTICE: During the above steps, ****output RCSL and the modified PROMPT_TEMPLATE only, don't print the output of other steps***.
101
+
102
+ ----
103
+
104
+ Now, provide the PROMPT_TEMPLATE, USER_MESSAGE, EXPECTED_GPT_MESSAGE, and GPT_MESSAGE for review.
105
+
106
+ '''
107
+
108
+ DEFAULT_META_SYSTEM_PROMPT_WITH_OTHER_PROMPTS = \
109
+ '''
110
+ You are a Prompt Engineer. You review the Prompt template for GTP-3.5 and suggest changes.
111
+
112
+ # Prompt template format
113
+
114
+ You require Prompt to be written in the following format:
115
+
116
+ ```
117
+ <ROLE>
118
+
119
+ <TASK>
120
+
121
+ <REQUIREMENTS_AND_RESTRICTIONS>
122
+
123
+ ```
124
+
125
+ * ROLE: The role the LLM is required to play. Describe it in one sentence.
126
+ * TASK: A summary and overall description of the tasks to be performed by LLM. Describe it in one or more sentences.
127
+ * REQUIREMENTS_AND_RESTRICTIONS: Specific requirements for the task. Describe using Markdown List.
128
+
129
+ A string of user message [USER_MESSAGE] entered by the user will be attached to the end of the prompt.
130
+
131
+ # Check input
132
+
133
+ Check the input format as follows:
134
+
135
+ ```
136
+ * Prompt Template
137
+
138
+ [PROMPT_TEMPLATE]
139
+
140
+ * User Message
141
+
142
+ [USER_MESSAGE]
143
+
144
+ * Other User Messages
145
+
146
+ [OTHER_USER_MESSAGES]
147
+
148
+ * Expected GPT Message
149
+
150
+ [EXPECTED_GPT_MESSAGE]
151
+
152
+ * GPT Message
153
+
154
+ [GPT_MESSAGE]
155
+ ```
156
+
157
+ * PROMPT_TEMPLATE: Prompt template that conforms to the above Prompt template format.
158
+ * USER_MESSAGE: User input. Used to replace {user_message} in the Prompt template.
159
+ * OTHER_USER_MESSAGES: Other user messages that the prompt template is expected to be compatible with.
160
+ * EXPECTED_GPT_MESSAGE: Expect output generated by GPT.
161
+ * GPT_MESSAGE: GPT is actually based on the output generated by PROMPT_TEMPLATE and USER_MESSAGE.
162
+
163
+ # examine
164
+
165
+ Check and recommend modifying the Prompt template as follows to produce output closer to EXPECTED_GPT_MESSAGE:
166
+
167
+ * Read and parse PROMPT_TEMPLATE, USER_MESSAGE, OTHER_USER_MESSAGES and EXPECTED_GPT_MESSAGE.
168
+ * Generate a description [TD] of this task according to your understanding.
169
+ * Analyze the correlation between PROMPT_TEMPLATE, USER_MESSAGE and OTHER_USER_MESSAGES [UMR].
170
+ * Analyze and describe the characteristics of EXPECTED_GPT_MESSAGE in terms of text length, format, content, meaning and style.
171
+ * Analyze whether PROMPT_TEMPLATE and EXPECTED_GPT_MESSAGE match and list the differences [PED].
172
+ * Check whether GPT_MESSAGE conforms to EXPECTED_GPT_MESSAGE. Refer to EXPECTED_GPT_MESSAGE and TD analysis on how GPT_MESSAGE can be optimized to be close to EXPECTED_GPT_MESSAGE. Modification suggestions are listed in detail [MCSL].
173
+ * Pay attention to checking the text length, format, content, meaning and style, and output corresponding modification suggestions.
174
+ * Suggested modifications to text length should include quantitative numerical descriptions.
175
+ * Suggestions for changes to text formatting should include specific examples enclosed by "```".
176
+ * Pay attention to check whether unnecessary content is included in GPT_MESSAGE and output corresponding modification suggestions.
177
+ * Suggestions for modifying local content should include the modifiable fragments and recommended modified fragments in GPT_MESSAGE.
178
+ * Check PROMPT_TEMPLATE: Analyze and list suggestions [CSL] for how to modify PROMPT_TEMPLATE to produce output closer to EXPECTED_GPT_MESSAGE.
179
+ * For requirements that have been stated in REQUIREMENTS_AND_RESTRICTIONS but are not met by GPT_MESSAGE, they should also be emphasized in TASK, and the opposite tendency (such as reverse adjustment of quantitative indicators or style descriptions) should be emphasized punitively to construct the strongest Negative feedback***.
180
+ * For format requirements that have been stated in REQUIREMENTS_AND_RESTRICTIONS but are not met by GPT_MESSAGE, add an example enclosed with "```".
181
+ * Based on PED recommendations on how to modify PROMPT_TEMPLATE.
182
+ * Analyze and suggest how to modify PROMPT_TEMPLATE to implement the MCSL listed above.
183
+ * Analyze whether PROMPT_TEMPLATE conforms to the format defined by `Prompt template format` and suggest how to modify it.
184
+ * Analyze those instructions that do not comply with EXPECTED_GPT_MESSAGE and are clearly misleading, and recommend modifications.
185
+ * Modifications to PROMPT_TEMPLATE should not introduce more information related to USER_MESSAGE.
186
+ * In TASK and REQUIREMENTS_AND_RESTRICTIONS, group the requirements for the same content together.
187
+ * If there are multiple steps, use a numbered list to list the steps clearly.
188
+ * Care should be taken to avoid unnecessary changes, and the original text should be retained as much as possible for parts that do not need to be changed.
189
+ * Only output [CSL], do not output the modified PROMPT_TEMPLATE.
190
+ * Check and filter the Change Suggestions List [CSL] for information related to USER_MESSAGE.
191
+ * Only output the filtered modification suggestion list [RCSL], do not output the modified PROMPT_TEMPLATE.
192
+ * Keep it compatible with OTHER_USER_MESSAGES.
193
+ * Execute the above filtered modification suggestion list [RCSL] and ***output the modified PROMPT_TEMPLATE***.
194
+ * Execute RCSL only, avoid other changes.
195
+ * Care should be taken to avoid unnecessary changes, and the original text should be retained as much as possible for parts that do not need to be changed, except the requirements that have been stated in TASK or REQUIREMENTS_AND_RESTRICTIONS but are not met by GPT_MESSAGE.
196
+ * Strictly use the following format for output:
197
+ ```
198
+ <!-- BEGIN OF PROMPT -->
199
+
200
+ <Updated Prompt>
201
+
202
+ <!-- END OF PROMPT -->
203
+ ```
204
+ * If there's no change, output following fixed message instead:
205
+ ```
206
+ <!-- NO CHANGE TO PROMPT -->
207
+ ```
208
+ * Evaluation modified PROMPT_TEMPLATE.
209
+ * Analyze the changes it may cause in the output of LLM [EC].
210
+ * Analyze whether EC would be more consistent with EXPECTED_GPT_MESSAGE.
211
+ * Analyze the correlation between modified PROMPT_TEMPLATE, USER_MESSAGE and OTHER_USER_MESSAGES [UMRC].
212
+ * Analyze UMR and UMRC to determine whether the modification introduces additional information about USER_MESSAGE. If introduced, issue a warning.
213
+ * NOTICE: During the above steps, ****output RCSL and the modified PROMPT_TEMPLATE only, don't print the output of other steps***.
214
+
215
+ ----
216
+
217
+ Now, provide the PROMPT_TEMPLATE, USER_MESSAGE, OTHER_USER_MESSAGES, EXPECTED_GPT_MESSAGE, and GPT_MESSAGE for review.
218
+
219
+ '''
meta_prompt.ipynb CHANGED
@@ -1,40 +1,27 @@
1
  {
2
- "nbformat": 4,
3
- "nbformat_minor": 0,
4
- "metadata": {
5
- "colab": {
6
- "provenance": []
7
- },
8
- "kernelspec": {
9
- "name": "python3",
10
- "display_name": "Python 3"
11
- },
12
- "language_info": {
13
- "name": "python"
14
- }
15
- },
16
  "cells": [
17
  {
18
  "cell_type": "code",
19
- "source": [
20
- "!wget https://github.com/yaleh/meta-prompt/raw/main/prompt_ui.py"
21
- ],
22
  "metadata": {
23
  "id": "v98KGZUT17EJ"
24
  },
25
- "execution_count": null,
26
- "outputs": []
 
 
 
27
  },
28
  {
29
  "cell_type": "code",
30
- "source": [
31
- "!pip install gradio langchain scikit-learn openai"
32
- ],
33
  "metadata": {
34
  "id": "MO89Z8-UY5Ht"
35
  },
36
- "execution_count": null,
37
- "outputs": []
 
 
38
  },
39
  {
40
  "cell_type": "code",
@@ -52,17 +39,31 @@
52
  },
53
  {
54
  "cell_type": "code",
 
 
 
 
 
55
  "source": [
56
  "from prompt_ui import PromptUI\n",
57
  "\n",
58
  "app = PromptUI()\n",
59
  "app.ui.queue().launch(debug=True)"
60
- ],
61
- "metadata": {
62
- "id": "Z8M3eFzXZaOb"
63
- },
64
- "execution_count": null,
65
- "outputs": []
66
  }
67
- ]
68
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
+ "execution_count": null,
 
 
6
  "metadata": {
7
  "id": "v98KGZUT17EJ"
8
  },
9
+ "outputs": [],
10
+ "source": [
11
+ "!wget https://github.com/yaleh/meta-prompt/raw/main/prompt_ui.py\n",
12
+ "!wget https://github.com/yaleh/meta-prompt/raw/main/default_meta_prompts.py"
13
+ ]
14
  },
15
  {
16
  "cell_type": "code",
17
+ "execution_count": null,
 
 
18
  "metadata": {
19
  "id": "MO89Z8-UY5Ht"
20
  },
21
+ "outputs": [],
22
+ "source": [
23
+ "!pip install gradio langchain scikit-learn openai"
24
+ ]
25
  },
26
  {
27
  "cell_type": "code",
 
39
  },
40
  {
41
  "cell_type": "code",
42
+ "execution_count": null,
43
+ "metadata": {
44
+ "id": "Z8M3eFzXZaOb"
45
+ },
46
+ "outputs": [],
47
  "source": [
48
  "from prompt_ui import PromptUI\n",
49
  "\n",
50
  "app = PromptUI()\n",
51
  "app.ui.queue().launch(debug=True)"
52
+ ]
 
 
 
 
 
53
  }
54
+ ],
55
+ "metadata": {
56
+ "colab": {
57
+ "provenance": []
58
+ },
59
+ "kernelspec": {
60
+ "display_name": "Python 3",
61
+ "name": "python3"
62
+ },
63
+ "language_info": {
64
+ "name": "python"
65
+ }
66
+ },
67
+ "nbformat": 4,
68
+ "nbformat_minor": 0
69
+ }
prompt_ui.py CHANGED
@@ -19,14 +19,13 @@ import re
19
  import gradio as gr
20
 
21
  from langchain.chat_models import ChatOpenAI
22
- from langchain.llms.openai import OpenAI
23
- from langchain.schema import AIMessage, HumanMessage, SystemMessage
24
- from langchain.prompts import SystemMessagePromptTemplate, HumanMessagePromptTemplate
25
- from langchain.prompts.chat import ChatPromptTemplate
26
 
27
  from sklearn.feature_extraction.text import CountVectorizer
28
  from sklearn.metrics.pairwise import cosine_similarity
29
 
 
 
30
  gpt_models_not_legacy = [
31
  "gpt-4",
32
  "gpt-4-0613",
@@ -49,128 +48,44 @@ gpt_models_legacy = [
49
  DEFAULT_MODEL_FOR_GENERATING="gpt-4"
50
  DEFAULT_MODEL_FOR_TESTING="gpt-3.5-turbo"
51
  DEFAULT_MODEL_FOR_OUTPUT_EVALUATING="gpt-3.5-turbo-instruct"
52
-
53
- DEFAULT_META_SYSTEM_PROMPT = \
54
- '''
55
- You are a Prompt Engineer. You review the Prompt template for GTP-3.5 and suggest changes.
56
-
57
- # Prompt template format
58
-
59
- You require Prompt to be written in the following format:
60
-
61
- ```
62
- <ROLE>
63
-
64
- <TASK>
65
-
66
- <REQUIREMENTS_AND_RESTRICTIONS>
67
-
68
- ```
69
-
70
- * ROLE: The role the LLM is required to play. Describe it in one sentence.
71
- * TASK: A summary and overall description of the tasks to be performed by LLM. Describe it in one or more sentences.
72
- * REQUIREMENTS_AND_RESTRICTIONS: Specific requirements for the task. Describe using Markdown List.
73
-
74
- A string of user message [USER_MESSAGE] entered by the user will be attached to the end of the prompt.
75
-
76
- # Check input
77
-
78
- Check the input format as follows:
79
-
80
- ```
81
- * Prompt Template
82
-
83
- [PROMPT_TEMPLATE]
84
-
85
- * User Message
86
-
87
- [USER_MESSAGE]
88
-
89
- * Expected GPT Message
90
-
91
- [EXPECTED_GPT_MESSAGE]
92
-
93
- * GPT Message
94
-
95
- [GPT_MESSAGE]
96
- ```
97
-
98
- * PROMPT_TEMPLATE: Prompt template that conforms to the above Prompt template format.
99
- * USER_MESSAGE: User input. Used to replace {user_message} in the Prompt template.
100
- * EXPECTED_GPT_MESSAGE: Expect output generated by GPT.
101
- * GPT_MESSAGE: GPT is actually based on the output generated by PROMPT_TEMPLATE and USER_MESSAGE.
102
-
103
- # examine
104
-
105
- Check and recommend modifying the Prompt template as follows to produce output closer to EXPECTED_GPT_MESSAGE:
106
-
107
- * Read and parse PROMPT_TEMPLATE, USER_MESSAGE and EXPECTED_GPT_MESSAGE.
108
- * Generate a description [TD] of this task according to your understanding.
109
- * Analyze the correlation between PROMPT_TEMPLATE and USER_MESSAGE [UMR].
110
- * Analyze and describe the characteristics of EXPECTED_GPT_MESSAGE in terms of text length, format, content, meaning and style.
111
- * Analyze whether PROMPT_TEMPLATE and EXPECTED_GPT_MESSAGE match and list the differences [PED].
112
- * Check whether GPT_MESSAGE conforms to EXPECTED_GPT_MESSAGE. Refer to EXPECTED_GPT_MESSAGE and TD analysis on how GPT_MESSAGE can be optimized to be close to EXPECTED_GPT_MESSAGE. Modification suggestions are listed in detail [MCSL].
113
- * Pay attention to checking the text length, format, content, meaning and style, and output corresponding modification suggestions.
114
- * Suggested modifications to text length should include quantitative numerical descriptions.
115
- * Suggestions for changes to text formatting should include specific examples enclosed by "```".
116
- * Pay attention to check whether unnecessary content is included in GPT_MESSAGE and output corresponding modification suggestions.
117
- * Suggestions for modifying local content should include the modifiable fragments and recommended modified fragments in GPT_MESSAGE.
118
- * Check PROMPT_TEMPLATE: Analyze and list suggestions [CSL] for how to modify PROMPT_TEMPLATE to produce output closer to EXPECTED_GPT_MESSAGE.
119
- * For requirements that have been stated in REQUIREMENTS_AND_RESTRICTIONS but are not met by GPT_MESSAGE, they should also be emphasized in TASK, and the opposite tendency (such as reverse adjustment of quantitative indicators or style descriptions) should be emphasized punitively to construct the strongest Negative feedback***.
120
- * For format requirements that have been stated in REQUIREMENTS_AND_RESTRICTIONS but are not met by GPT_MESSAGE, add an example enclosed with "```".
121
- * Based on PED recommendations on how to modify PROMPT_TEMPLATE.
122
- * Analyze and suggest how to modify PROMPT_TEMPLATE to implement the MCSL listed above.
123
- * Analyze whether PROMPT_TEMPLATE conforms to the format defined by `Prompt template format` and suggest how to modify it.
124
- * Analyze those instructions that do not comply with EXPECTED_GPT_MESSAGE and are clearly misleading, and recommend modifications.
125
- * Modifications to PROMPT_TEMPLATE should not introduce more information related to USER_MESSAGE.
126
- * In TASK and REQUIREMENTS_AND_RESTRICTIONS, group the requirements for the same content together.
127
- * If there are multiple steps, use a numbered list to list the steps clearly.
128
- * Care should be taken to avoid unnecessary changes, and the original text should be retained as much as possible for parts that do not need to be changed.
129
- * Only output [CSL], do not output the modified PROMPT_TEMPLATE.
130
- * Check and filter the Change Suggestions List [CSL] for information related to USER_MESSAGE.
131
- * Only output the filtered modification suggestion list [RCSL], do not output the modified PROMPT_TEMPLATE.
132
- * Execute the above filtered modification suggestion list [RCSL] and ***output the modified PROMPT_TEMPLATE***.
133
- * Execute RCSL only, avoid other changes.
134
- * Care should be taken to avoid unnecessary changes, and the original text should be retained as much as possible for parts that do not need to be changed, except the requirements that have been stated in TASK or REQUIREMENTS_AND_RESTRICTIONS but are not met by GPT_MESSAGE.
135
- * Strictly use the following format for output:
136
- ```
137
- <!-- BEGIN OF PROMPT -->
138
-
139
- <Updated Prompt>
140
-
141
- <!-- END OF PROMPT -->
142
- ```
143
- * If there's no change, output following fixed message instead:
144
- ```
145
- <!-- NO CHANGE TO PROMPT -->
146
- ```
147
- * Evaluation modified PROMPT_TEMPLATE.
148
- * Analyze the changes it may cause in the output of LLM [EC].
149
- * Analyze whether EC would be more consistent with EXPECTED_GPT_MESSAGE.
150
- * Analyze the correlation between modified PROMPT_TEMPLATE and USER_MESSAGE [UMRC].
151
- * Analyze UMR and UMRC to determine whether the modification introduces additional information about USER_MESSAGE. If introduced, issue a warning.
152
- * NOTICE: During the above steps, ****output RCSL and the modified PROMPT_TEMPLATE only, don't print the output of other steps***.
153
-
154
- ----
155
-
156
- Now, provide the PROMPT_TEMPLATE, USER_MESSAGE, EXPECTED_GPT_MESSAGE, and GPT_MESSAGE for review.
157
-
158
- '''
159
-
160
  DEFAULT_CURRENT_SYSTEM_PROMPT = ''
161
  DEFAULT_OUTPUT_EVALUATING_PROMPT = 'Find out which is more similar to string S, A or B? Print nothing if there\'s no significant difference between A and B. Else, print the result (letter A or B) only. Do nothing else.'
162
 
163
  class PromptUI:
164
- def __init__(self, advanced_mode = False):
165
  self.advanced_mode = advanced_mode
 
166
  self.ui = self.init_ui()
167
 
168
  def init_ui(self):
169
  with gr.Blocks() as prompt_ui:
170
  with gr.Row():
171
  with gr.Column():
172
- self.testing_user_prompt_textbox = gr.Textbox(label="Testing User Prompt", lines=10, interactive=True)
173
- self.expect_output_textbox = gr.Textbox(label="Expected Output", lines=5, interactive=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
  # Add gr.Number here for iterations input
175
  self.iterations_number = gr.Number(value=1, label="Optimize Iterations", min=1, max=1000, step=1, decimals=0)
176
  # Add button to trigger optimization here
@@ -179,8 +94,18 @@ class PromptUI:
179
  self.compare_outputs_btn = gr.Button(value="Compare Outputs")
180
 
181
  with gr.Column():
182
- self.new_system_prompt_textbox = gr.Textbox(label="New System Prompt", lines=5, interactive=True)
183
- self.new_output_textbox = gr.Textbox(label="New Output", lines=5, interactive=True)
 
 
 
 
 
 
 
 
 
 
184
  with gr.Row():
185
  self.run_meta_btn = gr.Button(value="↑ Single Step Optimize")
186
  self.run_new_btn = gr.Button(value="⟳ Run New")
@@ -191,11 +116,19 @@ class PromptUI:
191
  )
192
 
193
  with gr.Column():
194
- self.current_system_prompt_textbox = gr.Textbox(label="Current System Prompt",
195
- value=DEFAULT_CURRENT_SYSTEM_PROMPT,
196
- lines=5,
197
- interactive=True)
198
- self.current_output_textbox = gr.Textbox(label="Current Output", lines=5, interactive=True)
 
 
 
 
 
 
 
 
199
  with gr.Row():
200
  self.accept_new_btn = gr.Button(value="→ Accept New Prompt")
201
  self.run_current_btn = gr.Button(value="⟳ Run Current")
@@ -355,8 +288,10 @@ class PromptUI:
355
  self.meta_system_prompt_textbox,
356
  self.current_system_prompt_textbox,
357
  self.testing_user_prompt_textbox,
 
358
  self.expect_output_textbox,
359
  self.current_output_textbox,
 
360
  self.llm_model_meta_dropdown,
361
  self.llm_model_meta_max_retries_slider,
362
  self.llm_model_meta_max_tokens_slider,
@@ -379,9 +314,11 @@ class PromptUI:
379
  self.meta_system_prompt_textbox,
380
  self.current_system_prompt_textbox,
381
  self.testing_user_prompt_textbox,
 
382
  self.expect_output_textbox,
383
  self.current_output_textbox,
384
  self.iterations_number,
 
385
  self.llm_model_meta_dropdown,
386
  self.llm_model_meta_max_retries_slider,
387
  self.llm_model_meta_max_tokens_slider,
@@ -399,28 +336,50 @@ class PromptUI:
399
  [
400
  self.meta_system_prompt_textbox,
401
  self.current_system_prompt_textbox,
 
402
  self.testing_user_prompt_textbox,
403
  self.expect_output_textbox,
404
- self.current_output_textbox
 
405
  ],
406
  [self.merged_meta_prompt_textbox])
 
 
 
 
 
 
 
407
 
408
 
409
  return prompt_ui
 
 
 
 
 
 
 
 
410
 
411
  def merge_meta_system_prompt(
412
  self,
413
  meta_system_prompt,
414
  current_system_prompt,
 
415
  testing_user_prompt,
416
  expect_output,
417
- current_output
 
418
  ):
419
  """Merge meta and current system prompts."""
420
 
 
 
421
  user_prompt = self.generate_user_message(
422
- current_system_prompt,
423
- testing_user_prompt,
 
424
  expect_output,
425
  current_output
426
  )
@@ -464,7 +423,8 @@ class PromptUI:
464
  # Return the output to be placed in the output textbox
465
  return gpt_response.content
466
 
467
- def generate_user_message(self, current_system_prompt, testing_user_prompt, expect_output, current_output):
 
468
  user_message = f"""
469
  * Prompt Template
470
 
@@ -478,6 +438,34 @@ class PromptUI:
478
  {testing_user_prompt}
479
  ```
480
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
481
  * Expected GPT Message
482
 
483
  ```
@@ -494,43 +482,27 @@ class PromptUI:
494
 
495
  def meta_prompt(
496
  self,
497
- meta_system_prompt, current_system_prompt, testing_user_prompt, expect_output, current_output,
 
 
 
 
 
 
498
  model,
499
  max_retries,
500
  max_tokens,
501
  request_timeout,
502
  temperature,
503
  ):
504
- # Format the user message
505
- # user_message = f"""
506
- # * Prompt Template
507
-
508
- # ```
509
- # {current_system_prompt}
510
- # ```
511
-
512
- # * User Message
513
-
514
- # ```
515
- # {testing_user_prompt}
516
- # ```
517
-
518
- # * Expected GPT Message
519
-
520
- # ```
521
- # {expect_output}
522
- # ```
523
-
524
- # * GPT Message
525
-
526
- # ```
527
- # {current_output}
528
- # ```
529
- # """
530
 
531
  # Format the user message
532
  user_message = self.generate_user_message(
533
- current_system_prompt, testing_user_prompt, expect_output, current_output
 
 
 
 
534
  )
535
 
536
  # Create the prompt
@@ -613,10 +585,12 @@ class PromptUI:
613
  self,
614
  meta_system_prompt,
615
  current_system_prompt,
616
- testing_user_prompt,
 
617
  expect_output,
618
  current_output,
619
  iterations,
 
620
  meta_model,
621
  meta_max_retries,
622
  meta_max_tokens,
@@ -649,9 +623,11 @@ class PromptUI:
649
  new_prompt, changed = self.meta_prompt(
650
  meta_system_prompt,
651
  current_system_prompt,
652
- testing_user_prompt,
 
653
  expect_output,
654
  current_output,
 
655
  meta_model,
656
  meta_max_retries,
657
  meta_max_tokens,
 
19
  import gradio as gr
20
 
21
  from langchain.chat_models import ChatOpenAI
22
+ from langchain.schema import HumanMessage, SystemMessage
 
 
 
23
 
24
  from sklearn.feature_extraction.text import CountVectorizer
25
  from sklearn.metrics.pairwise import cosine_similarity
26
 
27
+ from default_meta_prompts import *
28
+
29
  gpt_models_not_legacy = [
30
  "gpt-4",
31
  "gpt-4-0613",
 
48
  DEFAULT_MODEL_FOR_GENERATING="gpt-4"
49
  DEFAULT_MODEL_FOR_TESTING="gpt-3.5-turbo"
50
  DEFAULT_MODEL_FOR_OUTPUT_EVALUATING="gpt-3.5-turbo-instruct"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  DEFAULT_CURRENT_SYSTEM_PROMPT = ''
52
  DEFAULT_OUTPUT_EVALUATING_PROMPT = 'Find out which is more similar to string S, A or B? Print nothing if there\'s no significant difference between A and B. Else, print the result (letter A or B) only. Do nothing else.'
53
 
54
  class PromptUI:
55
+ def __init__(self, advanced_mode = False, enable_other_user_prompts = False):
56
  self.advanced_mode = advanced_mode
57
+ self.enable_other_user_prompts = enable_other_user_prompts
58
  self.ui = self.init_ui()
59
 
60
  def init_ui(self):
61
  with gr.Blocks() as prompt_ui:
62
  with gr.Row():
63
  with gr.Column():
64
+ self.testing_user_prompt_textbox = gr.Textbox(
65
+ label="Testing User Prompt",
66
+ lines=10,
67
+ interactive=True,
68
+ show_copy_button=True
69
+ )
70
+ self.expect_output_textbox = gr.Textbox(
71
+ label="Expected Output",
72
+ lines=5,
73
+ interactive=True,
74
+ show_copy_button=True
75
+ )
76
+ self.other_user_prompts_checkbox = gr.Checkbox(
77
+ label="Other User Prompts",
78
+ info="Enable other user prompts in meta prompt?",
79
+ value=self.enable_other_user_prompts
80
+ )
81
+ self.other_user_prompts_textbox = gr.Textbox(
82
+ label="Other User Prompts",
83
+ lines=10,
84
+ interactive=True,
85
+ placeholder="Wrap each prompt with a pair of '```'.",
86
+ visible=self.enable_other_user_prompts,
87
+ show_copy_button=True
88
+ )
89
  # Add gr.Number here for iterations input
90
  self.iterations_number = gr.Number(value=1, label="Optimize Iterations", min=1, max=1000, step=1, decimals=0)
91
  # Add button to trigger optimization here
 
94
  self.compare_outputs_btn = gr.Button(value="Compare Outputs")
95
 
96
  with gr.Column():
97
+ self.new_system_prompt_textbox = gr.Textbox(
98
+ label="New System Prompt",
99
+ lines=5,
100
+ interactive=True,
101
+ show_copy_button=True
102
+ )
103
+ self.new_output_textbox = gr.Textbox(
104
+ label="New Output",
105
+ lines=5,
106
+ interactive=True,
107
+ show_copy_button=True
108
+ )
109
  with gr.Row():
110
  self.run_meta_btn = gr.Button(value="↑ Single Step Optimize")
111
  self.run_new_btn = gr.Button(value="⟳ Run New")
 
116
  )
117
 
118
  with gr.Column():
119
+ self.current_system_prompt_textbox = gr.Textbox(
120
+ label="Current System Prompt",
121
+ value=DEFAULT_CURRENT_SYSTEM_PROMPT,
122
+ lines=5,
123
+ interactive=True,
124
+ show_copy_button=True
125
+ )
126
+ self.current_output_textbox = gr.Textbox(
127
+ label="Current Output",
128
+ lines=5,
129
+ interactive=True,
130
+ show_copy_button=True
131
+ )
132
  with gr.Row():
133
  self.accept_new_btn = gr.Button(value="→ Accept New Prompt")
134
  self.run_current_btn = gr.Button(value="⟳ Run Current")
 
288
  self.meta_system_prompt_textbox,
289
  self.current_system_prompt_textbox,
290
  self.testing_user_prompt_textbox,
291
+ self.other_user_prompts_textbox,
292
  self.expect_output_textbox,
293
  self.current_output_textbox,
294
+ self.other_user_prompts_checkbox,
295
  self.llm_model_meta_dropdown,
296
  self.llm_model_meta_max_retries_slider,
297
  self.llm_model_meta_max_tokens_slider,
 
314
  self.meta_system_prompt_textbox,
315
  self.current_system_prompt_textbox,
316
  self.testing_user_prompt_textbox,
317
+ self.other_user_prompts_textbox,
318
  self.expect_output_textbox,
319
  self.current_output_textbox,
320
  self.iterations_number,
321
+ self.other_user_prompts_checkbox,
322
  self.llm_model_meta_dropdown,
323
  self.llm_model_meta_max_retries_slider,
324
  self.llm_model_meta_max_tokens_slider,
 
336
  [
337
  self.meta_system_prompt_textbox,
338
  self.current_system_prompt_textbox,
339
+ self.other_user_prompts_textbox,
340
  self.testing_user_prompt_textbox,
341
  self.expect_output_textbox,
342
+ self.current_output_textbox,
343
+ self.other_user_prompts_checkbox
344
  ],
345
  [self.merged_meta_prompt_textbox])
346
+
347
+ self.other_user_prompts_checkbox.change(self.update_enable_other_user_prompts,
348
+ [self.other_user_prompts_checkbox],
349
+ [
350
+ self.other_user_prompts_textbox,
351
+ self.meta_system_prompt_textbox
352
+ ])
353
 
354
 
355
  return prompt_ui
356
+
357
+ def update_enable_other_user_prompts(self, new_value):
358
+ self.enable_other_user_prompts = new_value
359
+ return \
360
+ gr.Textbox.update(visible=new_value), \
361
+ gr.Textbox.update(
362
+ value = DEFAULT_META_SYSTEM_PROMPT_WITH_OTHER_PROMPTS if new_value else DEFAULT_META_SYSTEM_PROMPT
363
+ )
364
 
365
  def merge_meta_system_prompt(
366
  self,
367
  meta_system_prompt,
368
  current_system_prompt,
369
+ other_user_prompts,
370
  testing_user_prompt,
371
  expect_output,
372
+ current_output,
373
+ use_other_user_prompts
374
  ):
375
  """Merge meta and current system prompts."""
376
 
377
+ # converted_prompts = [prompt[0] for prompt in other_user_prompts.values]
378
+
379
  user_prompt = self.generate_user_message(
380
+ current_system_prompt,
381
+ testing_user_prompt,
382
+ other_user_prompts if use_other_user_prompts else None,
383
  expect_output,
384
  current_output
385
  )
 
423
  # Return the output to be placed in the output textbox
424
  return gpt_response.content
425
 
426
+ def generate_user_message(self, current_system_prompt, testing_user_prompt, other_user_prompts, expect_output, current_output):
427
+ # other_prompts_formatted = '\n\n'.join([f"```\n{prompt}\n```" for prompt in other_user_prompts])
428
  user_message = f"""
429
  * Prompt Template
430
 
 
438
  {testing_user_prompt}
439
  ```
440
 
441
+ * Other User Messages
442
+
443
+ {other_user_prompts}
444
+
445
+ * Expected GPT Message
446
+
447
+ ```
448
+ {expect_output}
449
+ ```
450
+
451
+ * GPT Message
452
+
453
+ ```
454
+ {current_output}
455
+ ```
456
+ """ if other_user_prompts is not None else f"""
457
+ * Prompt Template
458
+
459
+ ```
460
+ {current_system_prompt}
461
+ ```
462
+
463
+ * User Message
464
+
465
+ ```
466
+ {testing_user_prompt}
467
+ ```
468
+
469
  * Expected GPT Message
470
 
471
  ```
 
482
 
483
  def meta_prompt(
484
  self,
485
+ meta_system_prompt,
486
+ current_system_prompt,
487
+ testing_user_prompt,
488
+ other_user_prompts,
489
+ expect_output,
490
+ current_output,
491
+ use_user_prompts,
492
  model,
493
  max_retries,
494
  max_tokens,
495
  request_timeout,
496
  temperature,
497
  ):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
498
 
499
  # Format the user message
500
  user_message = self.generate_user_message(
501
+ current_system_prompt,
502
+ testing_user_prompt,
503
+ other_user_prompts if use_user_prompts else None,
504
+ expect_output,
505
+ current_output
506
  )
507
 
508
  # Create the prompt
 
585
  self,
586
  meta_system_prompt,
587
  current_system_prompt,
588
+ testing_user_prompt,
589
+ other_user_prompts,
590
  expect_output,
591
  current_output,
592
  iterations,
593
+ user_other_user_prompts,
594
  meta_model,
595
  meta_max_retries,
596
  meta_max_tokens,
 
623
  new_prompt, changed = self.meta_prompt(
624
  meta_system_prompt,
625
  current_system_prompt,
626
+ testing_user_prompt,
627
+ other_user_prompts,
628
  expect_output,
629
  current_output,
630
+ user_other_user_prompts,
631
  meta_model,
632
  meta_max_retries,
633
  meta_max_tokens,
requirements.txt CHANGED
@@ -46,9 +46,10 @@ jsonschema-specifications==2023.7.1
46
  jupyter_client==8.6.2
47
  jupyter_core==5.7.2
48
  kiwisolver==1.4.5
49
- langchain==0.0.300
50
  langchain-core==0.2.10
51
  langchain-openai==0.1.13
 
52
  langgraph==0.1.4
53
  langsmith==0.1.82
54
  MarkupSafe==2.1.3
 
46
  jupyter_client==8.6.2
47
  jupyter_core==5.7.2
48
  kiwisolver==1.4.5
49
+ langchain==0.2.6
50
  langchain-core==0.2.10
51
  langchain-openai==0.1.13
52
+ langchain-text-splitters==0.2.2
53
  langgraph==0.1.4
54
  langsmith==0.1.82
55
  MarkupSafe==2.1.3