Spaces:
Running
Running
Commit
•
b2bd87c
1
Parent(s):
67edd25
Update app.py
Browse files
app.py
CHANGED
@@ -17,6 +17,7 @@ builtin_pairs = [
|
|
17 |
("NSFW", "nsfw"),
|
18 |
("Main Prompt", "main"),
|
19 |
]
|
|
|
20 |
builtin_prompts = [{
|
21 |
"name": x[0],
|
22 |
"identifier": x[1],
|
@@ -117,7 +118,7 @@ class Validator:
|
|
117 |
"repetition_penalty",
|
118 |
], Real)
|
119 |
self.validate_key_if_present("names_behavior", int)
|
120 |
-
known_prompt_ids = set(
|
121 |
if self.validate_key("prompts", list):
|
122 |
for prompt in self.obj["prompts"]:
|
123 |
if not Validator.is_valid_prompt(prompt):
|
@@ -212,7 +213,10 @@ def render_prompt(prompt, enabled=True):
|
|
212 |
gr.Markdown(f"Role: {prompt['role'] or 'system'}")
|
213 |
if "injection_position" in prompt and prompt["injection_position"] == 1 and "injection_depth" in prompt:
|
214 |
gr.Markdown(f"Injection depth: {prompt['injection_depth']} (absolute)")
|
215 |
-
|
|
|
|
|
|
|
216 |
|
217 |
with gr.Blocks() as demo:
|
218 |
preset = gr.State(None)
|
|
|
17 |
("NSFW", "nsfw"),
|
18 |
("Main Prompt", "main"),
|
19 |
]
|
20 |
+
builtin_prompt_ids = [x[1] for x in builtin_pairs]
|
21 |
builtin_prompts = [{
|
22 |
"name": x[0],
|
23 |
"identifier": x[1],
|
|
|
118 |
"repetition_penalty",
|
119 |
], Real)
|
120 |
self.validate_key_if_present("names_behavior", int)
|
121 |
+
known_prompt_ids = set(builtin_prompt_ids)
|
122 |
if self.validate_key("prompts", list):
|
123 |
for prompt in self.obj["prompts"]:
|
124 |
if not Validator.is_valid_prompt(prompt):
|
|
|
213 |
gr.Markdown(f"Role: {prompt['role'] or 'system'}")
|
214 |
if "injection_position" in prompt and prompt["injection_position"] == 1 and "injection_depth" in prompt:
|
215 |
gr.Markdown(f"Injection depth: {prompt['injection_depth']} (absolute)")
|
216 |
+
if prompt["identifier"] in builtin_prompt_ids:
|
217 |
+
gr.Markdown(f"This is a system prompt ({prompt['identifier'})")
|
218 |
+
if prompt["content"].strip():
|
219 |
+
gr.Code(prompt["content"], container=False, interactive=False)
|
220 |
|
221 |
with gr.Blocks() as demo:
|
222 |
preset = gr.State(None)
|