Spaces:
Sleeping
Sleeping
Fix JSON templates - use instructional format instead of literal examples
Browse files- gradio_app.py +5 -31
gradio_app.py
CHANGED
|
@@ -87,31 +87,12 @@ def create_json_prompt(message, template_type):
|
|
| 87 |
|
| 88 |
json_templates = {
|
| 89 |
"general": {
|
| 90 |
-
"instruction": "Extract key points and
|
| 91 |
-
"schema": """[
|
| 92 |
-
"Key point 1",
|
| 93 |
-
"Key point 2",
|
| 94 |
-
"Key point 3",
|
| 95 |
-
"Key point 4",
|
| 96 |
-
"Key point 5"
|
| 97 |
-
]"""
|
| 98 |
},
|
| 99 |
"questions": {
|
| 100 |
-
"instruction": "Generate 3 user and assistant prompt pairs
|
| 101 |
-
"schema": """[
|
| 102 |
-
{
|
| 103 |
-
"user": "User question 1",
|
| 104 |
-
"assistant": "Assistant response 1"
|
| 105 |
-
},
|
| 106 |
-
{
|
| 107 |
-
"user": "User question 2",
|
| 108 |
-
"assistant": "Assistant response 2"
|
| 109 |
-
},
|
| 110 |
-
{
|
| 111 |
-
"user": "User question 3",
|
| 112 |
-
"assistant": "Assistant response 3"
|
| 113 |
-
}
|
| 114 |
-
]"""
|
| 115 |
},
|
| 116 |
"analysis": {
|
| 117 |
"instruction": "Analyze the following content and respond in JSON format:",
|
|
@@ -152,16 +133,9 @@ def create_json_prompt(message, template_type):
|
|
| 152 |
|
| 153 |
{template["instruction"]}
|
| 154 |
|
| 155 |
-
IMPORTANT: You must respond with EXACTLY this format:
|
| 156 |
-
|
| 157 |
{template["schema"]}
|
| 158 |
|
| 159 |
-
|
| 160 |
-
- Start with [ and end with ]
|
| 161 |
-
- Include multiple items in the array
|
| 162 |
-
- Use valid JSON syntax
|
| 163 |
-
- Do not include any text before or after the JSON
|
| 164 |
-
- Complete the entire JSON structure
|
| 165 |
|
| 166 |
<|eot_id|><|start_header_id|>assistant<|end_header_id|>
|
| 167 |
|
|
|
|
| 87 |
|
| 88 |
json_templates = {
|
| 89 |
"general": {
|
| 90 |
+
"instruction": "Extract the key points from the content and return them as a JSON array of strings. Each string should be a concise summary of an important point from the content.",
|
| 91 |
+
"schema": """Format: ["actual key point from content", "another key point from content", "etc..."]"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
},
|
| 93 |
"questions": {
|
| 94 |
+
"instruction": "Generate 3 diverse user and assistant prompt pairs based on the specific topic provided. Create realistic questions a user might ask and helpful assistant responses.",
|
| 95 |
+
"schema": """Format: [{"user": "realistic question about the topic", "assistant": "helpful response"}, {"user": "different question", "assistant": "different response"}, {"user": "third question", "assistant": "third response"}]"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
},
|
| 97 |
"analysis": {
|
| 98 |
"instruction": "Analyze the following content and respond in JSON format:",
|
|
|
|
| 133 |
|
| 134 |
{template["instruction"]}
|
| 135 |
|
|
|
|
|
|
|
| 136 |
{template["schema"]}
|
| 137 |
|
| 138 |
+
Important: Respond with valid JSON only. No additional text. Base your response on the actual content provided, not the format examples.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
|
| 140 |
<|eot_id|><|start_header_id|>assistant<|end_header_id|>
|
| 141 |
|