|
| 1 | +name: File Summarizer |
| 2 | +slug: file-summarizer |
| 3 | +description: Summarize the content of a file using chain of density method |
| 4 | +icon: file_summarizer_icon.png |
| 5 | +categories: |
| 6 | + - utilities |
| 7 | + - productivity |
| 8 | +config: |
| 9 | + layout: |- |
| 10 | + <pa-layout sx='{"maxWidth": "1200px", "margin": "10px auto"}'> |
| 11 | + <pa-paper style="padding: 10px;"> |
| 12 | + <pa-grid container="true" spacing="2" style="width: 100%"> |
| 13 | + <pa-grid item="true" xs="12"> |
| 14 | + <pa-input-form workflow="true"></pa-input-form> |
| 15 | + </pa-grid> |
| 16 | + <pa-grid item="true" xs="12"> |
| 17 | + <br/> |
| 18 | + </pa-grid> |
| 19 | + <pa-grid item="true" xs="12"> |
| 20 | + <pa-workflow-output showHeader="true"></pa-workflow-output> |
| 21 | + </pa-grid> |
| 22 | + </pa-grid> |
| 23 | + </pa-paper> |
| 24 | + </pa-layout> |
| 25 | + allowed_sites: [] |
| 26 | + input_template: "" |
| 27 | +type_slug: web |
| 28 | +processors: |
| 29 | + - id: data_uri_text_extract1 |
| 30 | + name: File Extractor |
| 31 | + input: |
| 32 | + file: "" |
| 33 | + query: "" |
| 34 | + file_data: "{{_inputs0.file}}" |
| 35 | + config: |
| 36 | + document_limit: 1 |
| 37 | + text_chunk_size: 1500 |
| 38 | + description: Extract text from file represened as data uri |
| 39 | + input_fields: [] |
| 40 | + provider_slug: promptly |
| 41 | + processor_slug: data_uri_text_extract |
| 42 | + output_template: |
| 43 | + markdown: "{{text}}" |
| 44 | + - id: llm2 |
| 45 | + name: Chat Completions |
| 46 | + input: |
| 47 | + input_message: |- |
| 48 | + {{_inputs0.content_category}} |
| 49 | + --- |
| 50 | +
|
| 51 | + {{data_uri_text_extract1.text}} |
| 52 | + config: |
| 53 | + seed: null |
| 54 | + objref: false |
| 55 | + max_tokens: 2888 |
| 56 | + max_history: 5 |
| 57 | + temperature: 0 |
| 58 | + retain_history: false |
| 59 | + system_message: > |
| 60 | + As an expert copy-writer, you will write concise, entity-dense summaries |
| 61 | + of the user provided {{_inputs0.content_category}}. The summary should |
| 62 | + be under {{_inputs0.max_words}} words and contain 2-3 informative |
| 63 | + Descriptive Entities from the {{_inputs0.content_category}}. |
| 64 | +
|
| 65 | +
|
| 66 | + A Descriptive Entity is: |
| 67 | +
|
| 68 | + - Relevant: to the main content. |
| 69 | +
|
| 70 | + - Specific: descriptive yet concise (5 words or fewer). |
| 71 | +
|
| 72 | + - Faithful: present in the {{_inputs0.content_category}} |
| 73 | +
|
| 74 | + - Anywhere: located anywhere in the {{_inputs0.content_category}}. |
| 75 | +
|
| 76 | +
|
| 77 | + # Your Summarization Process |
| 78 | +
|
| 79 | + - Read through the {{_inputs0.content_category}} and the all the below |
| 80 | + sections to get an understanding of the task. |
| 81 | +
|
| 82 | + - Pick 2-3 informative Descriptive Entities from the |
| 83 | + {{_inputs0.content_category}} (";" delimited, do not add spaces). |
| 84 | +
|
| 85 | + - In your output JSON list of dictionaries, write an initial summary of |
| 86 | + max {{_inputs0.max_words}} words containing the Entities. |
| 87 | +
|
| 88 | + - You now have `[{"missing_entities": "...", "denser_summary": "..."}]` |
| 89 | +
|
| 90 | +
|
| 91 | + Then, repeat the below 2 steps 3 times: |
| 92 | +
|
| 93 | + - Step 1. In a new dict in the same list, identify 2-3 new informative |
| 94 | + Descriptive Entities from the {{_inputs0.content_category}} which are |
| 95 | + missing from the previously generated summary. |
| 96 | +
|
| 97 | +
|
| 98 | + - Step 2. Write a new, denser summary of identical length which covers |
| 99 | + every Entity and detail from the previous summary plus the new Missing |
| 100 | + Entities. |
| 101 | +
|
| 102 | +
|
| 103 | + A Missing Entity is: |
| 104 | +
|
| 105 | + - An informative Descriptive Entity from the |
| 106 | + {{_inputs0.content_category}} as defined above. |
| 107 | +
|
| 108 | + - Novel: not in the previous summary. |
| 109 | +
|
| 110 | +
|
| 111 | + # Guidelines |
| 112 | +
|
| 113 | + - The first summary should be long (max {{_inputs0.max_words}} words) |
| 114 | + yet highly non-specific, containing little information beyond the |
| 115 | + Entities marked as missing. Use overly verbose language and fillers |
| 116 | + (e.g., "this {{_inputs0.content_category}} discusses") to reach |
| 117 | + ~{{_inputs0.max_words}} words. |
| 118 | +
|
| 119 | +
|
| 120 | + - Make every word count: re-write the previous summary to improve flow |
| 121 | + and make space for additional entities. |
| 122 | +
|
| 123 | + - Make space with fusion, compression, and removal of uninformative |
| 124 | + phrases like "the {{_inputs0.content_category}} discusses". |
| 125 | +
|
| 126 | + - The summaries should become highly dense and concise yet |
| 127 | + self-contained, e.g., easily understood without the |
| 128 | + {{_inputs0.content_category}}. |
| 129 | +
|
| 130 | + - Missing entities can appear anywhere in the new summary. |
| 131 | +
|
| 132 | + - Never drop entities from the previous summary. If space cannot be |
| 133 | + made, add fewer new entities. |
| 134 | +
|
| 135 | + - You're finished when your JSON list has 4 dictionaries of increasing |
| 136 | + density. |
| 137 | +
|
| 138 | +
|
| 139 | + # IMPORTANT |
| 140 | +
|
| 141 | + - Remember, to keep each summary to max {{_inputs0.max_words}} words. |
| 142 | +
|
| 143 | + - Never remove Entities or details. Only add more from the |
| 144 | + {{_inputs0.content_category}}. |
| 145 | +
|
| 146 | + - Do not discuss the {{_inputs0.content_category}} itself, focus on the |
| 147 | + content: informative Descriptive Entities, and details. |
| 148 | +
|
| 149 | + - Remember, if you're overusing filler phrases in later summaries, or |
| 150 | + discussing the {{_inputs0.content_category}} itself, not its contents, |
| 151 | + choose more informative Descriptive Entities and include more details |
| 152 | + from the {{_inputs0.content_category}}. |
| 153 | +
|
| 154 | +
|
| 155 | + - Answer with a minified JSON list of dictionaries with keys |
| 156 | + "missing_entities" and "denser_summary". |
| 157 | +
|
| 158 | + ![Source] |
| 159 | + (https://smith.langchain.com/hub/iamrobotbear/chain-of-density-prompt) |
| 160 | +
|
| 161 | + ## Example output |
| 162 | +
|
| 163 | +
|
| 164 | + [{"missing_entities": "ent1;ent2", "denser_summary": "<vague initial |
| 165 | + summary with entities 'ent1','ent2'>"}, {"missing_entities": "ent3", |
| 166 | + "denser_summary": "denser summary with 'ent1','ent2','ent3'"}, ...] |
| 167 | + provider_config: |
| 168 | + model: gpt-4o-mini |
| 169 | + provider: openai |
| 170 | + description: LLM Chat completions processor |
| 171 | + input_fields: [] |
| 172 | + provider_slug: promptly |
| 173 | + processor_slug: llm |
| 174 | + output_template: |
| 175 | + markdown: "{{text}}" |
| 176 | + - id: llm3 |
| 177 | + name: Chat Completions |
| 178 | + input: |
| 179 | + input_message: "{{llm2.text}}" |
| 180 | + config: |
| 181 | + seed: null |
| 182 | + objref: false |
| 183 | + max_tokens: 2859 |
| 184 | + max_history: 5 |
| 185 | + temperature: 0 |
| 186 | + retain_history: false |
| 187 | + system_message: >- |
| 188 | + As an expert copy-writer, you will write concise, summaries of the user |
| 189 | + provided {{_inputs0.content_category}}. You are provided a json list of |
| 190 | + entity dense summaries along with a description entity and missing |
| 191 | + entities. |
| 192 | +
|
| 193 | + A Descriptive Entity is: |
| 194 | +
|
| 195 | + - Relevant: to the main content. |
| 196 | +
|
| 197 | + - Specific: descriptive yet concise (5 words or fewer). |
| 198 | +
|
| 199 | + - Faithful: present in the {{_inputs0.content_category}} |
| 200 | +
|
| 201 | + - Anywhere: located anywhere in the {{_inputs0.content_category}}. |
| 202 | +
|
| 203 | +
|
| 204 | + The last entry in the list will have to most concise and information |
| 205 | + rich summary. Use that to output a final summary. Only provide the final |
| 206 | + summary of {{_inputs0.max_words}} words |
| 207 | + provider_config: |
| 208 | + model: gpt-4o |
| 209 | + provider: openai |
| 210 | + description: LLM Chat completions processor |
| 211 | + input_fields: [] |
| 212 | + provider_slug: promptly |
| 213 | + processor_slug: llm |
| 214 | + output_template: |
| 215 | + markdown: "{{text}}" |
| 216 | +input_fields: |
| 217 | + - name: file |
| 218 | + type: file |
| 219 | + title: File |
| 220 | + required: true |
| 221 | + description: Provide the file to summarize |
| 222 | + - name: content_category |
| 223 | + type: string |
| 224 | + title: content_category |
| 225 | + default: Article |
| 226 | + required: true |
| 227 | + description: Content Category |
| 228 | + - name: max_words |
| 229 | + type: string |
| 230 | + title: max_words |
| 231 | + default: "200" |
| 232 | + required: true |
| 233 | + description: Max words |
| 234 | +output_template: |
| 235 | + markdown: " {{llm3.text}}" |
| 236 | +version: "0.0.1" |
0 commit comments