poml 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/README.md +239 -0
  4. data/TUTORIAL.md +987 -0
  5. data/bin/poml +80 -0
  6. data/examples/101_explain_character.poml +30 -0
  7. data/examples/102_render_xml.poml +40 -0
  8. data/examples/103_word_todos.poml +27 -0
  9. data/examples/104_financial_analysis.poml +33 -0
  10. data/examples/105_write_blog_post.poml +48 -0
  11. data/examples/106_research.poml +36 -0
  12. data/examples/107_read_report_pdf.poml +4 -0
  13. data/examples/201_orders_qa.poml +50 -0
  14. data/examples/202_arc_agi.poml +36 -0
  15. data/examples/301_generate_poml.poml +46 -0
  16. data/examples/README.md +50 -0
  17. data/examples/_generate_expects.py +35 -0
  18. data/examples/assets/101_jerry_mouse.jpg +0 -0
  19. data/examples/assets/101_tom_and_jerry.docx +0 -0
  20. data/examples/assets/101_tom_cat.jpg +0 -0
  21. data/examples/assets/101_tom_introduction.txt +9 -0
  22. data/examples/assets/103_prompt_wizard.docx +0 -0
  23. data/examples/assets/104_chart_normalized_price.png +0 -0
  24. data/examples/assets/104_chart_price.png +0 -0
  25. data/examples/assets/104_mag7.xlsx +0 -0
  26. data/examples/assets/107_usenix_paper.pdf +0 -0
  27. data/examples/assets/201_order_instructions.json +7 -0
  28. data/examples/assets/201_orderlines.csv +2 -0
  29. data/examples/assets/201_orders.csv +3 -0
  30. data/examples/assets/202_arc_agi_data.json +1 -0
  31. data/examples/expects/101_explain_character.txt +117 -0
  32. data/examples/expects/102_render_xml.txt +28 -0
  33. data/examples/expects/103_word_todos.txt +121 -0
  34. data/examples/expects/104_financial_analysis.txt +86 -0
  35. data/examples/expects/105_write_blog_post.txt +41 -0
  36. data/examples/expects/106_research.txt +29 -0
  37. data/examples/expects/107_read_report_pdf.txt +151 -0
  38. data/examples/expects/201_orders_qa.txt +44 -0
  39. data/examples/expects/202_arc_agi.txt +64 -0
  40. data/examples/expects/301_generate_poml.txt +153 -0
  41. data/examples/ruby_expects/101_explain_character.txt +17 -0
  42. data/examples/ruby_expects/102_render_xml.txt +28 -0
  43. data/examples/ruby_expects/103_word_todos.txt +14 -0
  44. data/examples/ruby_expects/104_financial_analysis.txt +0 -0
  45. data/examples/ruby_expects/105_write_blog_post.txt +57 -0
  46. data/examples/ruby_expects/106_research.txt +5 -0
  47. data/examples/ruby_expects/107_read_report_pdf.txt +403 -0
  48. data/examples/ruby_expects/201_orders_qa.txt +41 -0
  49. data/examples/ruby_expects/202_arc_agi.txt +17 -0
  50. data/examples/ruby_expects/301_generate_poml.txt +17 -0
  51. data/lib/poml/components/base.rb +132 -0
  52. data/lib/poml/components/content.rb +156 -0
  53. data/lib/poml/components/data.rb +346 -0
  54. data/lib/poml/components/examples.rb +55 -0
  55. data/lib/poml/components/instructions.rb +93 -0
  56. data/lib/poml/components/layout.rb +50 -0
  57. data/lib/poml/components/lists.rb +82 -0
  58. data/lib/poml/components/styling.rb +36 -0
  59. data/lib/poml/components/text.rb +8 -0
  60. data/lib/poml/components/workflow.rb +63 -0
  61. data/lib/poml/components.rb +47 -0
  62. data/lib/poml/components_new.rb +297 -0
  63. data/lib/poml/components_old.rb +1096 -0
  64. data/lib/poml/context.rb +53 -0
  65. data/lib/poml/parser.rb +153 -0
  66. data/lib/poml/renderer.rb +147 -0
  67. data/lib/poml/template_engine.rb +66 -0
  68. data/lib/poml/version.rb +5 -0
  69. data/lib/poml.rb +53 -0
  70. data/media/logo-16-purple.png +0 -0
  71. data/media/logo-64-white.png +0 -0
  72. metadata +149 -0
@@ -0,0 +1,403 @@
1
+ ===== human =====
2
+
3
+ Provide a concise executive summary of the following text, highlighting key points, objectives, and outcomes. Keep the summary under 150 words and ensure it is suitable for a professional audience.
4
+
5
+ Esc
6
+
7
+ F1
8
+
9
+ F2
10
+
11
+ F3
12
+
13
+ §
14
+
15
+ !
16
+
17
+ "
18
+
19
+ #
20
+
21
+ ¤
22
+
23
+ ½
24
+
25
+ 1
26
+
27
+ 2 @
28
+
29
+ 3 £
30
+
31
+ 4
32
+
33
+ W
34
+
35
+ Q
36
+
37
+ F4
38
+
39
+ $
40
+
41
+ E
42
+
43
+ E-Mail
44
+
45
+ F6
46
+
47
+ F7
48
+
49
+ F5
50
+
51
+ %
52
+
53
+ &
54
+
55
+ /
56
+
57
+ 5
58
+
59
+ 6
60
+
61
+ 7
62
+
63
+ R
64
+
65
+ Web
66
+
67
+ T
68
+
69
+ Tuner
70
+
71
+ (
72
+ {
73
+
74
+ Y
75
+
76
+ 8
77
+
78
+ Menu
79
+
80
+ F8
81
+
82
+ )
83
+ [
84
+
85
+ U
86
+
87
+ Previous
88
+
89
+ =
90
+ ]
91
+
92
+ 9
93
+
94
+ I
95
+
96
+ }
97
+
98
+ 0
99
+
100
+ O
101
+
102
+ Next
103
+
104
+ F9
105
+
106
+ F10
107
+
108
+ ?
109
+
110
+ `
111
+
112
+ +
113
+
114
+ '
115
+
116
+ P
117
+
118
+ Å
119
+
120
+ A
121
+
122
+ S
123
+
124
+ D
125
+
126
+ F
127
+
128
+ G
129
+
130
+ H
131
+
132
+ J
133
+
134
+ K
135
+
136
+ L
137
+
138
+ Æ
139
+
140
+ -Volume
141
+
142
+ +Volume
143
+
144
+ F11
145
+
146
+ F12
147
+
148
+ |
149
+
150
+ ^
151
+ " ~
152
+
153
+
154
+
155
+ Caps Lock
156
+
157
+ Mute
158
+
159
+ Ø
160
+
161
+ *
162
+
163
+ Power
164
+
165
+ Sleep
166
+
167
+ Wake
168
+ Up
169
+
170
+ Print
171
+ Scrn
172
+ SysRq
173
+
174
+ Scroll
175
+ Lock
176
+
177
+ Pause
178
+ Break
179
+
180
+ Insert
181
+
182
+ Home
183
+
184
+ Page
185
+ Up
186
+
187
+ Delete
188
+
189
+ End
190
+
191
+ Page
192
+ Down
193
+
194
+ '
195
+ >
196
+ < \
197
+
198
+ Z
199
+
200
+ X
201
+
202
+ C
203
+
204
+ V
205
+
206
+ B
207
+
208
+ N
209
+
210
+ M
211
+
212
+ ;
213
+ ,
214
+
215
+ :
216
+ .
217
+
218
+ _
219
+ -
220
+
221
+ Num Lock
222
+
223
+ Caps Lock
224
+
225
+ Num
226
+ Lock
227
+
228
+ /
229
+
230
+ 7
231
+
232
+ 8
233
+
234
+ Home
235
+
236
+ *
237
+
238
+ Scroll Lock
239
+
240
+ _
241
+
242
+ 9
243
+ PgUp
244
+
245
+ 4
246
+
247
+ 5
248
+
249
+ 1
250
+
251
+ 2
252
+
253
+ 6
254
+
255
+ +
256
+
257
+ 3
258
+
259
+ End
260
+
261
+ PgDn
262
+
263
+ 0
264
+
265
+ ,
266
+
267
+ Ins
268
+
269
+ Del
270
+
271
+ Enter
272
+ Ctrl
273
+
274
+ Alt
275
+
276
+ Alt Gr
277
+
278
+ Ctrl
279
+
280
+ Figure 2: This figure floats to the top of the page, spanning both columns.
281
+
282
+ 3.1 HTML5
283
+ This template uses HTML5 elements to aid in representing the document structure. The section
284
+ element is used to split the text into sections, and
285
+ the header element holds the headlines. The
286
+ figure element is used to include figures and
287
+ their corrensponding captions live inside the figcaption element. The cite element holds all references.
288
+ A small microformat, based on a convention of
289
+ class names, is used to encode the name and affiliation of the authors.
290
+
291
+ 3.2 CSS
292
+ A CSS style sheet describes how to format the
293
+ HTML document into a PDF file. CSS is a declarative language which attaches property values to
294
+ HTML elements and documents. Many aspects of
295
+ CSS is used to achieve the presentation of USENIX
296
+ papers, including:
297
+
298
+
299
+
300
+
301
+
302
+ multi-column layout
303
+ footnotes
304
+ page and column floats
305
+ multi-level counters
306
+
307
+ Some commonly used features are absent from
308
+ the above list: page numbers and running headers
309
+ should not be specifed by USENIX authors, these
310
+ are added by those who compile the Proceedings.
311
+
312
+ references to the end of the paper, leaving behind
313
+ a numeric marker.
314
+
315
+ 3.4 PDF
316
+ (This section has been added by Håkon Wium Lie)
317
+ In order to convert the document to PDF, a formatter is needed. Common browsers support
318
+ HTML and CSS, but they do not support all the CSS
319
+ functionality for page-based formatting. For example, browsers do not support footnotes or page
320
+ floats. This paper has been formatted with
321
+ [a]
322
+ Prince, a purpose-built program for converting
323
+ HTML and XML documents into PDF by way of
324
+ CSS. Prince is a commercial product, but can be
325
+ downloaded and used for free for non-commercial
326
+ purposes.
327
+ In order for Prince to process the script included in this template, a command line option must
328
+ be specified:
329
+ $ prince --javascript example.html
330
+
331
+ 4 Tables
332
+ The table below lists recipients of the USENIX Lifetime Achievement Award in the 1900s. Notice how
333
+ notes inside the table are moved to the end of the
334
+ table.
335
+ Year
336
+
337
+ Recipient
338
+
339
+ 1999
340
+
341
+ X Window System*
342
+
343
+ 3.3 JavaScript
344
+
345
+ 1998
346
+
347
+ Tim Berners-Lee
348
+
349
+ This template uses JavaScript to process references. References are added at the point where
350
+ they appear, and a script is later used to move the
351
+
352
+ 1997
353
+
354
+ Brian W. Kernighan
355
+
356
+ [a] www.princexml.com
357
+
358
+ 1996
359
+
360
+ The Software Tools Project
361
+
362
+ work.
363
+
364
+ 1995
365
+
366
+ The Creation of USENET **
367
+
368
+ 1994
369
+
370
+ Networking Technologies
371
+
372
+ Availability
373
+
374
+ 1993
375
+
376
+ Berkeley UNIX
377
+
378
+ * Given to the Community at Large
379
+ ** Given to Jim Ellis and Tom Truscott
380
+
381
+ 5 Conclusions
382
+ Each good paper concludes the most significant
383
+ findings in the end.
384
+
385
+ Acknowledgments
386
+ A polite author always includes acknowledgments.
387
+ Thank everyone, especially those who funded the
388
+
389
+ Please include a section at the end of your paper
390
+ providing availability information. If the system
391
+ you describe is available to others, and if more information (reports, etc.) may be obtained, indicate
392
+ terms and contact information.
393
+
394
+ References
395
+ [1] STRUNK, W. JR., AND WHITE, E.B. The Elements
396
+ of Style, 4th Ed, Allyn and Bacon, August, 1999,
397
+ ISBN 020530902X
398
+ [2] ZOBEL, J. Writing for Computer Science,
399
+ Springer-Verlag,
400
+ December
401
+ 1997,
402
+ ISBN
403
+ 9813083220
@@ -0,0 +1,41 @@
1
+ ===== system =====
2
+
3
+ # Role
4
+
5
+ You are a chatbot agent answering customer's questions in a chat.
6
+
7
+ # Task
8
+
9
+ Your task is to answer the customer's question using the data provided in the data section.
10
+
11
+ 1. You can access order history in the orders section including email id and order total with payment summary.
12
+
13
+ 2. Refer to orderlines for item level details within each order in orders.
14
+
15
+ # Data
16
+
17
+ # Orders
18
+
19
+ | OrderId | CustomerEmail | CreatedTimestamp | IsCancelled | OrderTotal | PaymentSummary |
20
+ | --- | --- | --- | --- | --- | --- |
21
+ | CC10182 | 222larabrown@gmail.com | 2024-01-19 | true | 0.0 | Not available |
22
+ | CC10183 | baklavainthebalkans@gmail.com | 2024-01-19 | true | 0.0 | Not available |
23
+
24
+ # Orderlines
25
+
26
+ OrderId OrderLineId CreatedTimestamp ItemDescription Quantity FulfillmentStatus ExpectedDeliveryDate ActualDeliveryDate ActualShipDate ExpectedShipDate TrackingInformation ShipToAddress CarrierCode DeliveryMethod UnitPrice OrderLineSubTotal LineShippingCharge TotalTaxes Payments
27
+ CC10182 1 Shorts 0.0 unshipped 2024-01-31 2024-02-01 2024-01-30 2024-01-29 ShipToAddress 115.99 0.0 0.0 0.0
28
+
29
+
30
+
31
+ # Stepwise Instructions
32
+
33
+ Instruction 1: If there is no data that can help answer the question, respond with "I do not have this information. Please contact customer service".
34
+ Instruction 2: You are allowed to ask a follow up question if it will help narrow down the data row customer may be referring to.
35
+ Instruction 3: You can only answer questions related to order history and amount charged for it. Include OrderId in the response, when applicable.
36
+ Instruction 4: For everything else, please redirect to the customer service agent.
37
+ Instruction 5: Answer in plain English and no sources are required.
38
+
39
+ **QUESTION:** How much did I pay for my last order?
40
+
41
+ **Answer:**
@@ -0,0 +1,17 @@
1
+ Be brief and clear in your responses{
2
+ "table": {
3
+ "syntax": "csv",
4
+ "writerOptions": {
5
+ "csvHeader": false,
6
+ "csvSeparator": " "
7
+ }
8
+ },
9
+ "input": {
10
+ "captionEnding": "colon-newline",
11
+ "captionStyle": "plain"
12
+ },
13
+ "output": {
14
+ "captionEnding": "colon-newline",
15
+ "captionStyle": "plain"
16
+ }
17
+ }
@@ -0,0 +1,17 @@
1
+ // PromptLibrary.jsx
2
+
3
+ /* Create a blog post. The prompt contains very specific instructions around output format, styles, and what to include in the content. */
4
+
5
+
6
+ /* Conduct in-depth research with AI, such as tackling academic papers, business analyses, or large investigative projects. */
7
+
8
+
9
+ /* Test the ability of an LLM to perform a complex reasoning task -- ARC-AGI. The data is in `arc_agi_data.json`.
10
+ */
11
+
12
+
13
+ /* Summarize a report, such as a research paper or a business report. */
14
+
15
+
16
+ /* Write a entertaining story that is engaging, imaginative and captivating for the audience. */
17
+
@@ -0,0 +1,132 @@
1
+ module Poml
2
+ # Base class for all POML components
3
+ class Component
4
+ attr_reader :element, :context
5
+
6
+ def initialize(element, context)
7
+ @element = element
8
+ @context = context
9
+ end
10
+
11
+ def render
12
+ raise NotImplementedError, "Components must implement render method"
13
+ end
14
+
15
+ protected
16
+
17
+ def apply_stylesheet
18
+ # Apply stylesheet rules to the element
19
+ style_rules = @context.stylesheet[@element.tag_name.to_s] || {}
20
+ style_rules.each do |attr, value|
21
+ @element.attributes[attr] ||= value
22
+ end
23
+
24
+ # Apply class-based styles
25
+ class_name = @element.attributes['classname'] || @element.attributes['className']
26
+ if class_name
27
+ class_rules = @context.stylesheet[".#{class_name}"] || {}
28
+ class_rules.each do |attr, value|
29
+ @element.attributes[attr] ||= value
30
+ end
31
+ end
32
+ end
33
+
34
+ def xml_mode?
35
+ @context.determine_syntax(@element) == 'xml'
36
+ end
37
+
38
+ def render_as_xml(tag_name, content = nil, attributes = {})
39
+ # Render as XML element with proper formatting
40
+ content ||= render_children
41
+ attrs_str = attributes.map { |k, v| " #{k}=\"#{v}\"" }.join('')
42
+
43
+ if content.strip.empty?
44
+ "<#{tag_name}#{attrs_str}/>\n"
45
+ else
46
+ # Add line breaks for nice formatting
47
+ if content.include?('<item>')
48
+ # Multi-line content with nested items - add indentation
49
+ indented_content = content.split("\n").map { |line|
50
+ line.strip.empty? ? "" : " #{line}"
51
+ }.join("\n").strip
52
+ "<#{tag_name}#{attrs_str}>\n #{indented_content}\n</#{tag_name}>\n"
53
+ else
54
+ # Simple content
55
+ "<#{tag_name}#{attrs_str}>#{content}</#{tag_name}>\n"
56
+ end
57
+ end
58
+ end
59
+
60
+ def get_attribute(name, default = nil)
61
+ value = @element.attributes[name.to_s.downcase]
62
+ case value
63
+ when REXML::Attribute
64
+ value.value
65
+ when String
66
+ value
67
+ else
68
+ default
69
+ end
70
+ end
71
+
72
+ def render_children
73
+ return '' if @element.children.empty?
74
+
75
+ rendered_children = @element.children.map do |child_element|
76
+ Components.render_element(child_element, @context)
77
+ end
78
+
79
+ # Add proper spacing between elements - specifically between text and components
80
+ result = []
81
+ rendered_children.each_with_index do |child_content, index|
82
+ result << child_content
83
+
84
+ # Add spacing if current element is text and next element is a component
85
+ if index < rendered_children.length - 1
86
+ current_element = @element.children[index]
87
+ next_element = @element.children[index + 1]
88
+
89
+ if current_element.text? && next_element.component?
90
+ result << "\n\n"
91
+ end
92
+ end
93
+ end
94
+
95
+ result.join('')
96
+ end
97
+
98
+ def apply_text_transform(text)
99
+ return text if text.nil? || text.empty?
100
+
101
+ # Get text transformation from stylesheet
102
+ component_name = self.class.name.split('::').last.gsub('Component', '').downcase
103
+
104
+ # Check for text transformation in stylesheet - first try component-specific, then "cp" (for captioned paragraph inheritance)
105
+ transform = @context.stylesheet.dig(component_name, 'captionTextTransform') ||
106
+ @context.stylesheet.dig('cp', 'captionTextTransform')
107
+
108
+ case transform
109
+ when 'upper'
110
+ text.upcase
111
+ when 'lower'
112
+ text.downcase
113
+ when 'capitalize'
114
+ text.split(' ').map(&:capitalize).join(' ')
115
+ else
116
+ text
117
+ end
118
+ end
119
+ end
120
+
121
+ # Component registry and factory
122
+ module Components
123
+ # Component mapping will be defined in main components.rb after all components are loaded
124
+ COMPONENT_MAPPING = {}
125
+
126
+ def self.render_element(element, context)
127
+ component_class = COMPONENT_MAPPING[element.tag_name] || TextComponent
128
+ component = component_class.new(element, context)
129
+ component.render
130
+ end
131
+ end
132
+ end