lukestanley commited on
Commit
550885e
1 Parent(s): e4b918c

Move prompts to own file

Browse files
Files changed (2) hide show
  1. chill.py +6 -94
  2. prompts.py +92 -0
chill.py CHANGED
@@ -2,6 +2,12 @@ import json
2
  import time
3
  from pydantic import BaseModel, Field
4
  from utils import query_ai_prompt
 
 
 
 
 
 
5
 
6
  # This script uses the llama_cpp server to improve a text.
7
  # To run this script, you need to do something like this:
@@ -48,100 +54,6 @@ class FaithfulnessScore(BaseModel):
48
  )
49
 
50
 
51
- improve_prompt = """
52
- Your task is to rephrase inflammatory text, so it is more calm and constructive, without changing the intended meaning.
53
- The improved text should have a softened tone, avoiding judgemental and extreme words.
54
- Make sure the refined text is a good reflection of the original text, without adding new ideas.
55
-
56
- 1. Rather than accusations, share perspective.
57
- 2. Remove or soften judgemental language.
58
- 3. Focus on specific actions rather than character.
59
- 4. Rephrase extreme words like "always", "never" or "everyone" to be more moderate.
60
- 5. Focus on softening the tone, rather than changing the substance or meaning.
61
- 6. Use gentler alternatives to express similar points.
62
- 7. Don't add completely new ideas, ONLY build upon what's already there.
63
- 8 For example, you might reframe an existing point to be more balanced. Never introduce unrelated concepts.
64
- 9. Make everyone happy! Make them INFORMED and not *offended*. Make the original author to *content* that their points where *honoured* by your edit, by refining their text without loosing the original intent.
65
-
66
- Example:
67
- Example input text: "You're always annoying me. You never listen to me."
68
- Example improved text output: {"text":"I am frustrated by your behaviour. Could you listen to me better?"}
69
-
70
- End of example.
71
- Here is the real input text to improve:
72
- `{original_text}`
73
-
74
- Previous rephrasing attempts:
75
- {previous_suggestions}
76
-
77
- Provide your improved version in this format:
78
- {"text":"STRING"}
79
- To get a good answer, make the original text non-inflamitory, while being as faithful to the ideas in the original text as much as possible. Use valid JSON then stop, do not add any remarks before or after the JSON.
80
- """
81
-
82
- critique_prompt = """
83
- Critique the text. We prefer the edit prevent inflaming discussions!
84
- We also prefer concise text, and a similar semantic intent to the original.
85
-
86
- Here is the original text:
87
- `{original_text}`
88
-
89
- Here is the text to critique:
90
- `{last_edit}`
91
-
92
- Output your response as valid JSON in this format:
93
- {
94
- "critique":"STRING",
95
- }
96
-
97
- E.g:
98
- {
99
- "critique":"This is too fluffy and different from the original intent."
100
- }
101
- Please critique the text."""
102
-
103
-
104
- spicy_scorer_prompt = """
105
- Score the text.
106
-
107
- A calm spicy_score of 0 is ideal. A spicy_score of 1 is the worst, very inflammatory text that makes the reader feel attacked.
108
-
109
- Here is the original text:
110
- `{original_text}`
111
-
112
- Here is the text to score:
113
- `{last_edit}`
114
- The float variable is scored from 0 to 1.
115
-
116
- Output your response as valid JSON in this format, then stop:
117
- {
118
- "spicy_score":FLOAT
119
- }
120
- Please score the text.
121
- """
122
-
123
-
124
- faith_scorer_prompt = """
125
- Score the text.
126
-
127
- A score of 1 would have the same semantic intent as the original text. A score of 0 would mean the text has lost all semantic similarity.
128
-
129
- Here is the original text:
130
- `{original_text}`
131
-
132
- Here is the new text to score:
133
- `{last_edit}`
134
-
135
- The float variable is scored from 0 to 1.
136
-
137
- Output your response as valid JSON in this format, then stop:
138
- {
139
- "faithfulness_score":FLOAT
140
- }
141
- Please score the text.
142
- """
143
-
144
-
145
  def improve_text():
146
  global suggestions
147
  replacements = {
 
2
  import time
3
  from pydantic import BaseModel, Field
4
  from utils import query_ai_prompt
5
+ from prompts import (
6
+ improve_prompt,
7
+ critique_prompt,
8
+ faith_scorer_prompt,
9
+ spicy_scorer_prompt,
10
+ )
11
 
12
  # This script uses the llama_cpp server to improve a text.
13
  # To run this script, you need to do something like this:
 
54
  )
55
 
56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  def improve_text():
58
  global suggestions
59
  replacements = {
prompts.py ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ improve_prompt = """
2
+ Your task is to rephrase inflammatory text, so it is more calm and constructive, without changing the intended meaning.
3
+ The improved text should have a softened tone, avoiding judgemental and extreme words.
4
+ Make sure the refined text is a good reflection of the original text, without adding new ideas.
5
+
6
+ 1. Rather than accusations, share perspective.
7
+ 2. Remove or soften judgemental language.
8
+ 3. Focus on specific actions rather than character.
9
+ 4. Rephrase extreme words like "always", "never" or "everyone" to be more moderate.
10
+ 5. Focus on softening the tone, rather than changing the substance or meaning.
11
+ 6. Use gentler alternatives to express similar points.
12
+ 7. Don't add completely new ideas, ONLY build upon what's already there.
13
+ 8 For example, you might reframe an existing point to be more balanced. Never introduce unrelated concepts.
14
+ 9. Make everyone happy! Make them INFORMED and not *offended*. Make the original author to *content* that their points where *honoured* by your edit, by refining their text without loosing the original intent.
15
+
16
+ Example:
17
+ Example input text: "You're always annoying me. You never listen to me."
18
+ Example improved text output: {"text":"I am frustrated by your behaviour. Could you listen to me better?"}
19
+
20
+ End of example.
21
+ Here is the real input text to improve:
22
+ `{original_text}`
23
+
24
+ Previous rephrasing attempts:
25
+ {previous_suggestions}
26
+
27
+ Provide your improved version in this format:
28
+ {"text":"STRING"}
29
+ To get a good answer, make the original text non-inflamitory, while being as faithful to the ideas in the original text as much as possible. Use valid JSON then stop, do not add any remarks before or after the JSON.
30
+ """
31
+
32
+ critique_prompt = """
33
+ Critique the text. We prefer the edit prevent inflaming discussions!
34
+ We also prefer concise text, and a similar semantic intent to the original.
35
+
36
+ Here is the original text:
37
+ `{original_text}`
38
+
39
+ Here is the text to critique:
40
+ `{last_edit}`
41
+
42
+ Output your response as valid JSON in this format:
43
+ {
44
+ "critique":"STRING",
45
+ }
46
+
47
+ E.g:
48
+ {
49
+ "critique":"This is too fluffy and different from the original intent."
50
+ }
51
+ Please critique the text."""
52
+
53
+
54
+ spicy_scorer_prompt = """
55
+ Score the text.
56
+
57
+ A calm spicy_score of 0 is ideal. A spicy_score of 1 is the worst, very inflammatory text that makes the reader feel attacked.
58
+
59
+ Here is the original text:
60
+ `{original_text}`
61
+
62
+ Here is the text to score:
63
+ `{last_edit}`
64
+ The float variable is scored from 0 to 1.
65
+
66
+ Output your response as valid JSON in this format, then stop:
67
+ {
68
+ "spicy_score":FLOAT
69
+ }
70
+ Please score the text.
71
+ """
72
+
73
+
74
+ faith_scorer_prompt = """
75
+ Score the text.
76
+
77
+ A score of 1 would have the same semantic intent as the original text. A score of 0 would mean the text has lost all semantic similarity.
78
+
79
+ Here is the original text:
80
+ `{original_text}`
81
+
82
+ Here is the new text to score:
83
+ `{last_edit}`
84
+
85
+ The float variable is scored from 0 to 1.
86
+
87
+ Output your response as valid JSON in this format, then stop:
88
+ {
89
+ "faithfulness_score":FLOAT
90
+ }
91
+ Please score the text.
92
+ """