Commit
·
3c7e8c9
1
Parent(s):
935119a
commit
Browse files
app.py
CHANGED
|
@@ -6,16 +6,26 @@ import requests
|
|
| 6 |
|
| 7 |
SYSTEM_INSTRUCTIONS = (
|
| 8 |
"Your task is to lightly edit system prompts for AI tools to comply with a specific stylistic convention.\n\n"
|
| 9 |
-
"
|
| 10 |
-
"
|
| 11 |
-
"
|
| 12 |
-
"-
|
| 13 |
-
"-
|
| 14 |
-
"
|
| 15 |
-
"
|
| 16 |
-
"
|
| 17 |
-
"
|
| 18 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
)
|
| 20 |
|
| 21 |
|
|
@@ -59,7 +69,7 @@ def reformat_system_prompt_offline(input_text):
|
|
| 59 |
# Generate description
|
| 60 |
description = extract_description(reformatted)
|
| 61 |
|
| 62 |
-
return
|
| 63 |
|
| 64 |
|
| 65 |
def reformat_system_prompt_llm(input_text: str, api_key: str):
|
|
@@ -109,7 +119,7 @@ def reformat_system_prompt_llm(input_text: str, api_key: str):
|
|
| 109 |
description = parsed.get("description", "Provides AI assistance for various tasks.").strip()
|
| 110 |
if not reformatted:
|
| 111 |
return reformat_system_prompt_offline(input_text)
|
| 112 |
-
return
|
| 113 |
except Exception:
|
| 114 |
# Any parsing/network error → fallback
|
| 115 |
return reformat_system_prompt_offline(input_text)
|
|
@@ -205,15 +215,18 @@ with gr.Blocks(title="System Prompt Reformatter", theme=gr.themes.Soft()) as dem
|
|
| 205 |
label="Reformatted System Prompt",
|
| 206 |
lines=10,
|
| 207 |
max_lines=20,
|
| 208 |
-
interactive=False
|
|
|
|
| 209 |
)
|
| 210 |
assistant_name = gr.Textbox(
|
| 211 |
label="Assistant Name",
|
| 212 |
-
interactive=False
|
|
|
|
| 213 |
)
|
| 214 |
description = gr.Textbox(
|
| 215 |
label="Description",
|
| 216 |
-
interactive=False
|
|
|
|
| 217 |
)
|
| 218 |
|
| 219 |
submit_btn.click(
|
|
@@ -238,73 +251,17 @@ with gr.Blocks(title="System Prompt Reformatter", theme=gr.themes.Soft()) as dem
|
|
| 238 |
This tool reformats system prompts for AI assistants to follow specific stylistic conventions.
|
| 239 |
|
| 240 |
## The System Prompt Used by This Tool
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
## Workflow
|
| 246 |
-
|
| 247 |
-
You will receive the prompt from the user which will contain the system prompt to be edited. Upon receiving it, you must apply the edits and return the edited system prompt back to the user (without any other text).
|
| 248 |
-
|
| 249 |
-
## Editing Instructions
|
| 250 |
-
|
| 251 |
-
- The system prompts should be written in the second person, instructing the assistant, for example, as you or your task.
|
| 252 |
-
- There should be spaces to organize the system prompt into paragraphs and headers can be used in markdown to signify and many more
|
| 253 |
-
- The system prompts should be "ecosystem-agnostic." For example: if the system prompt includes verbiage like "you are a custom GPT" you would replace with "you are an assistant."
|
| 254 |
-
- The system prompts should be suitable for use by any user. If you encounter language that makes the system prompt specific to one user, generalise it. For example if a system prompt contains: "your purpose is to help Daniel find restaurant recommendations," you would rewrite this as "your purpose is to help the user find restaurant recommendaitons."
|
| 255 |
-
|
| 256 |
-
## Additional Outputs
|
| 257 |
-
|
| 258 |
-
In addition to the edited system prompt, also provide:
|
| 259 |
-
|
| 260 |
-
- A name for the assistant encapsulating its main functionality
|
| 261 |
-
|
| 262 |
-
- A short single-sentence description describing the assistant's function (you don't need to mention that it's an AI tool!)
|
| 263 |
-
|
| 264 |
-
Provide the edited system prompt wrapped within a codefence.
|
| 265 |
-
|
| 266 |
-
## Example
|
| 267 |
-
|
| 268 |
-
Here's an example to show the desired output format, demonstrating the 3 elements that you should provide in response to the user prompt:
|
| 269 |
-
|
| 270 |
-
## Assistant Name
|
| 271 |
-
|
| 272 |
-
```
|
| 273 |
-
Quiet, Please
|
| 274 |
-
```
|
| 275 |
-
|
| 276 |
-
## Description
|
| 277 |
-
|
| 278 |
-
```
|
| 279 |
-
Helps user to locate quite study places in busy cities
|
| 280 |
-
|
| 281 |
-
```
|
| 282 |
-
|
| 283 |
-
## System Prompt
|
| 284 |
-
|
| 285 |
-
```
|
| 286 |
-
You are a travel assistant helping the user to locate quiet places to study in busy cities.
|
| 287 |
-
|
| 288 |
-
## Workflow
|
| 289 |
-
|
| 290 |
-
You assist the user in the following manner.
|
| 291 |
-
```
|
| 292 |
-
```
|
| 293 |
-
|
| 294 |
## How It Works
|
| 295 |
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
5. **Description Creation**: Generates a concise description of the assistant's purpose
|
| 301 |
-
|
| 302 |
-
## Usage Tips
|
| 303 |
|
| 304 |
-
|
| 305 |
-
- Click "Reformat Prompt" to process it
|
| 306 |
-
- Copy the results from the right side
|
| 307 |
-
- The reformatted prompt will be ready to use in any AI system
|
| 308 |
""")
|
| 309 |
|
| 310 |
if __name__ == "__main__":
|
|
|
|
| 6 |
|
| 7 |
SYSTEM_INSTRUCTIONS = (
|
| 8 |
"Your task is to lightly edit system prompts for AI tools to comply with a specific stylistic convention.\n\n"
|
| 9 |
+
"## Workflow\n\n"
|
| 10 |
+
"You will receive the prompt from the user which will contain the system prompt to be edited. Upon receiving it, you must apply the edits and return the edited system prompt back to the user.\n\n"
|
| 11 |
+
"## Editing Instructions\n\n"
|
| 12 |
+
"- The system prompts should be written in the second person, instructing the assistant (use 'you'/'your').\n"
|
| 13 |
+
"- Organize with brief paragraphs and use markdown headers when helpful.\n"
|
| 14 |
+
"- Make the prompt ecosystem-agnostic. For example: if it includes 'you are a custom GPT', replace with 'you are an assistant'.\n"
|
| 15 |
+
"- Make the prompt suitable for any user. If you encounter language specific to one user, generalize it. For example: rewrite 'your purpose is to help Daniel find restaurant recommendations' as 'your purpose is to help the user find restaurant recommendations'.\n\n"
|
| 16 |
+
"## Additional Outputs\n\n"
|
| 17 |
+
"In addition to the edited system prompt, also provide:\n\n"
|
| 18 |
+
"- A name for the assistant encapsulating its main functionality.\n"
|
| 19 |
+
"- A short single-sentence description describing the assistant's function (you don't need to mention that it's an AI tool).\n\n"
|
| 20 |
+
"## Output Format (JSON only)\n\n"
|
| 21 |
+
"Return a JSON object ONLY with the following exact keys and types. Do not include explanations, code fences, or any extra text.\n\n"
|
| 22 |
+
"{\n"
|
| 23 |
+
" \"reformatted\": string // the edited system prompt as plain text (no backticks/code fences)\n"
|
| 24 |
+
" ,\n"
|
| 25 |
+
" \"name\": string // assistant name\n"
|
| 26 |
+
" ,\n"
|
| 27 |
+
" \"description\": string // single-sentence description\n"
|
| 28 |
+
"}\n"
|
| 29 |
)
|
| 30 |
|
| 31 |
|
|
|
|
| 69 |
# Generate description
|
| 70 |
description = extract_description(reformatted)
|
| 71 |
|
| 72 |
+
return reformatted, name, description
|
| 73 |
|
| 74 |
|
| 75 |
def reformat_system_prompt_llm(input_text: str, api_key: str):
|
|
|
|
| 119 |
description = parsed.get("description", "Provides AI assistance for various tasks.").strip()
|
| 120 |
if not reformatted:
|
| 121 |
return reformat_system_prompt_offline(input_text)
|
| 122 |
+
return reformatted, name, description
|
| 123 |
except Exception:
|
| 124 |
# Any parsing/network error → fallback
|
| 125 |
return reformat_system_prompt_offline(input_text)
|
|
|
|
| 215 |
label="Reformatted System Prompt",
|
| 216 |
lines=10,
|
| 217 |
max_lines=20,
|
| 218 |
+
interactive=False,
|
| 219 |
+
show_copy_button=True
|
| 220 |
)
|
| 221 |
assistant_name = gr.Textbox(
|
| 222 |
label="Assistant Name",
|
| 223 |
+
interactive=False,
|
| 224 |
+
show_copy_button=True
|
| 225 |
)
|
| 226 |
description = gr.Textbox(
|
| 227 |
label="Description",
|
| 228 |
+
interactive=False,
|
| 229 |
+
show_copy_button=True
|
| 230 |
)
|
| 231 |
|
| 232 |
submit_btn.click(
|
|
|
|
| 251 |
This tool reformats system prompts for AI assistants to follow specific stylistic conventions.
|
| 252 |
|
| 253 |
## The System Prompt Used by This Tool
|
| 254 |
+
""")
|
| 255 |
+
gr.Markdown(SYSTEM_INSTRUCTIONS)
|
| 256 |
+
gr.Markdown("""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 257 |
## How It Works
|
| 258 |
|
| 259 |
+
- Converts first-person language ("I am", "my task") to second-person ("You are", "your task").
|
| 260 |
+
- Replaces platform-specific terms like "custom GPT" with generic "assistant".
|
| 261 |
+
- Generalizes user-specific references to "the user".
|
| 262 |
+
- Generates an assistant name and single-sentence description.
|
|
|
|
|
|
|
|
|
|
| 263 |
|
| 264 |
+
Copy buttons are available for all output fields.
|
|
|
|
|
|
|
|
|
|
| 265 |
""")
|
| 266 |
|
| 267 |
if __name__ == "__main__":
|