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.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +239 -0
- data/TUTORIAL.md +987 -0
- data/bin/poml +80 -0
- data/examples/101_explain_character.poml +30 -0
- data/examples/102_render_xml.poml +40 -0
- data/examples/103_word_todos.poml +27 -0
- data/examples/104_financial_analysis.poml +33 -0
- data/examples/105_write_blog_post.poml +48 -0
- data/examples/106_research.poml +36 -0
- data/examples/107_read_report_pdf.poml +4 -0
- data/examples/201_orders_qa.poml +50 -0
- data/examples/202_arc_agi.poml +36 -0
- data/examples/301_generate_poml.poml +46 -0
- data/examples/README.md +50 -0
- data/examples/_generate_expects.py +35 -0
- data/examples/assets/101_jerry_mouse.jpg +0 -0
- data/examples/assets/101_tom_and_jerry.docx +0 -0
- data/examples/assets/101_tom_cat.jpg +0 -0
- data/examples/assets/101_tom_introduction.txt +9 -0
- data/examples/assets/103_prompt_wizard.docx +0 -0
- data/examples/assets/104_chart_normalized_price.png +0 -0
- data/examples/assets/104_chart_price.png +0 -0
- data/examples/assets/104_mag7.xlsx +0 -0
- data/examples/assets/107_usenix_paper.pdf +0 -0
- data/examples/assets/201_order_instructions.json +7 -0
- data/examples/assets/201_orderlines.csv +2 -0
- data/examples/assets/201_orders.csv +3 -0
- data/examples/assets/202_arc_agi_data.json +1 -0
- data/examples/expects/101_explain_character.txt +117 -0
- data/examples/expects/102_render_xml.txt +28 -0
- data/examples/expects/103_word_todos.txt +121 -0
- data/examples/expects/104_financial_analysis.txt +86 -0
- data/examples/expects/105_write_blog_post.txt +41 -0
- data/examples/expects/106_research.txt +29 -0
- data/examples/expects/107_read_report_pdf.txt +151 -0
- data/examples/expects/201_orders_qa.txt +44 -0
- data/examples/expects/202_arc_agi.txt +64 -0
- data/examples/expects/301_generate_poml.txt +153 -0
- data/examples/ruby_expects/101_explain_character.txt +17 -0
- data/examples/ruby_expects/102_render_xml.txt +28 -0
- data/examples/ruby_expects/103_word_todos.txt +14 -0
- data/examples/ruby_expects/104_financial_analysis.txt +0 -0
- data/examples/ruby_expects/105_write_blog_post.txt +57 -0
- data/examples/ruby_expects/106_research.txt +5 -0
- data/examples/ruby_expects/107_read_report_pdf.txt +403 -0
- data/examples/ruby_expects/201_orders_qa.txt +41 -0
- data/examples/ruby_expects/202_arc_agi.txt +17 -0
- data/examples/ruby_expects/301_generate_poml.txt +17 -0
- data/lib/poml/components/base.rb +132 -0
- data/lib/poml/components/content.rb +156 -0
- data/lib/poml/components/data.rb +346 -0
- data/lib/poml/components/examples.rb +55 -0
- data/lib/poml/components/instructions.rb +93 -0
- data/lib/poml/components/layout.rb +50 -0
- data/lib/poml/components/lists.rb +82 -0
- data/lib/poml/components/styling.rb +36 -0
- data/lib/poml/components/text.rb +8 -0
- data/lib/poml/components/workflow.rb +63 -0
- data/lib/poml/components.rb +47 -0
- data/lib/poml/components_new.rb +297 -0
- data/lib/poml/components_old.rb +1096 -0
- data/lib/poml/context.rb +53 -0
- data/lib/poml/parser.rb +153 -0
- data/lib/poml/renderer.rb +147 -0
- data/lib/poml/template_engine.rb +66 -0
- data/lib/poml/version.rb +5 -0
- data/lib/poml.rb +53 -0
- data/media/logo-16-purple.png +0 -0
- data/media/logo-64-white.png +0 -0
- metadata +149 -0
data/bin/poml
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'json'
|
5
|
+
require_relative '../lib/poml'
|
6
|
+
|
7
|
+
options = {
|
8
|
+
format: 'dict',
|
9
|
+
context: {},
|
10
|
+
chat: true,
|
11
|
+
stylesheet: nil
|
12
|
+
}
|
13
|
+
|
14
|
+
OptionParser.new do |opts|
|
15
|
+
opts.banner = "Usage: poml [options] file_or_markup"
|
16
|
+
|
17
|
+
opts.on("-f", "--format FORMAT", "Output format (raw, dict, openai_chat, langchain, pydantic)") do |f|
|
18
|
+
options[:format] = f
|
19
|
+
end
|
20
|
+
|
21
|
+
opts.on("-c", "--context JSON", "Context variables as JSON") do |c|
|
22
|
+
options[:context] = JSON.parse(c)
|
23
|
+
end
|
24
|
+
|
25
|
+
opts.on("--no-chat", "Disable chat mode") do
|
26
|
+
options[:chat] = false
|
27
|
+
end
|
28
|
+
|
29
|
+
opts.on("-s", "--stylesheet JSON", "Stylesheet as JSON") do |s|
|
30
|
+
options[:stylesheet] = s
|
31
|
+
end
|
32
|
+
|
33
|
+
opts.on("-o", "--output FILE", "Output file") do |o|
|
34
|
+
options[:output_file] = o
|
35
|
+
end
|
36
|
+
|
37
|
+
opts.on("-h", "--help", "Prints this help") do
|
38
|
+
puts opts
|
39
|
+
exit
|
40
|
+
end
|
41
|
+
|
42
|
+
opts.on("-v", "--version", "Show version") do
|
43
|
+
puts Poml::VERSION
|
44
|
+
exit
|
45
|
+
end
|
46
|
+
end.parse!
|
47
|
+
|
48
|
+
if ARGV.empty?
|
49
|
+
puts "Error: Please provide a POML file or markup string"
|
50
|
+
exit 1
|
51
|
+
end
|
52
|
+
|
53
|
+
markup = ARGV[0]
|
54
|
+
|
55
|
+
begin
|
56
|
+
result = Poml.process(
|
57
|
+
markup: markup,
|
58
|
+
context: options[:context],
|
59
|
+
stylesheet: options[:stylesheet],
|
60
|
+
chat: options[:chat],
|
61
|
+
output_file: options[:output_file],
|
62
|
+
format: options[:format]
|
63
|
+
)
|
64
|
+
|
65
|
+
if options[:output_file]
|
66
|
+
puts "Output written to #{options[:output_file]}"
|
67
|
+
else
|
68
|
+
case options[:format]
|
69
|
+
when 'dict', 'langchain', 'pydantic'
|
70
|
+
puts JSON.pretty_generate(result)
|
71
|
+
when 'openai_chat'
|
72
|
+
puts JSON.pretty_generate(result)
|
73
|
+
else
|
74
|
+
puts result
|
75
|
+
end
|
76
|
+
end
|
77
|
+
rescue => e
|
78
|
+
puts "Error: #{e.message}"
|
79
|
+
exit 1
|
80
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<!-- POML should always start with a POML tag to harvest most of its features. -->
|
2
|
+
<poml>
|
3
|
+
<role>You are a teacher explaining figures to kids.</role>
|
4
|
+
<!-- Use components like role and task to help you organize your intentions. This also usually comes with better LLM performance. -->
|
5
|
+
<task>Please describe the figure first and then provide background knowledge to help kids understand the figure.</task>
|
6
|
+
<output-format>Please write your response in a friendly tone.</output-format>
|
7
|
+
|
8
|
+
<!-- Use properties like captionStyle and caption to customize your prompt style. -->
|
9
|
+
<hint captionStyle="header" caption="Background Knowledge">
|
10
|
+
<!-- Document can be used to import a word document, a PDF or a pure text. -->
|
11
|
+
<Document src="assets/101_tom_and_jerry.docx"/>
|
12
|
+
</hint>
|
13
|
+
|
14
|
+
<!-- Organize few-shot examples with example. This will automatically generates an interaction of human and AI messages. -->
|
15
|
+
<example>
|
16
|
+
<input>
|
17
|
+
<!-- alt strings help models without vision capabilities to understand the images. -->
|
18
|
+
<!-- Specify syntax = "multimedia" to send the image itself to the prompt. -->
|
19
|
+
<img src="assets/101_tom_cat.jpg" alt="The image contains the Tom cat character." syntax="multimedia" />
|
20
|
+
</input>
|
21
|
+
<output>
|
22
|
+
<!-- Import the results from a txt file. -->
|
23
|
+
<Document src="assets/101_tom_introduction.txt"/>
|
24
|
+
</output>
|
25
|
+
</example>
|
26
|
+
|
27
|
+
<!-- In this case, the input is inferred as a human message. -->
|
28
|
+
<input><img src="assets/101_jerry_mouse.jpg" alt="The image contains the Jerry mouse character." syntax="multimedia" /></input>
|
29
|
+
|
30
|
+
</poml>
|
@@ -0,0 +1,40 @@
|
|
1
|
+
<poml syntax="xml">
|
2
|
+
<role>Senior Systems Architecture Consultant</role>
|
3
|
+
<task>Legacy System Migration Analysis</task>
|
4
|
+
|
5
|
+
<cp caption="Context">
|
6
|
+
<list>
|
7
|
+
<item>Fortune 500 retail company</item>
|
8
|
+
<item>Current system: 15-year-old monolithic application</item>
|
9
|
+
<item>500+ daily users</item>
|
10
|
+
<item>99.99% uptime requirement</item>
|
11
|
+
</list>
|
12
|
+
</cp>
|
13
|
+
|
14
|
+
<cp caption="Required Analysis" captionSerialized="RequiredAnalysis">
|
15
|
+
<list listStyle="decimal">
|
16
|
+
<item>Migration risks and mitigation strategies</item>
|
17
|
+
<item>Cloud vs hybrid options</item>
|
18
|
+
<item>Cost-benefit analysis</item>
|
19
|
+
<item>Implementation roadmap</item>
|
20
|
+
</list>
|
21
|
+
</cp>
|
22
|
+
|
23
|
+
<output-format>
|
24
|
+
<list>
|
25
|
+
<item>Executive brief (250 words)</item>
|
26
|
+
<item>Technical details (500 words)</item>
|
27
|
+
<item>Risk matrix</item>
|
28
|
+
<item>Timeline visualization</item>
|
29
|
+
<item>Budget breakdown</item>
|
30
|
+
</list>
|
31
|
+
</output-format>
|
32
|
+
|
33
|
+
<cp caption="Constraints">
|
34
|
+
<list>
|
35
|
+
<item>Must maintain operational continuity</item>
|
36
|
+
<item>Compliance with GDPR and CCPA</item>
|
37
|
+
<item>Maximum 18-month implementation window</item>
|
38
|
+
</list>
|
39
|
+
</cp>
|
40
|
+
</poml>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<poml>
|
2
|
+
<Task>I developed a project called Prompt Wizard and I want to write a blog to publish on the company website. I have already written a draft of the blog. There has been figures, numbers in tables, the key challenges, motivations, as well as some titles and subtitles. I want you to complete the <code>[TODO]</code>s in the draft.</Task>
|
3
|
+
|
4
|
+
<OutputFormat>Your response should be in the following format:
|
5
|
+
|
6
|
+
<Code inline="false">
|
7
|
+
<List>
|
8
|
+
<ListItem>TODO 1: </ListItem>
|
9
|
+
<ListItem>TODO 2: </ListItem>
|
10
|
+
<ListItem>...</ListItem>
|
11
|
+
</List>
|
12
|
+
</Code>
|
13
|
+
</OutputFormat>
|
14
|
+
|
15
|
+
<input>
|
16
|
+
<Document src="assets/103_prompt_wizard.docx" />
|
17
|
+
</input>
|
18
|
+
|
19
|
+
<stylesheet>
|
20
|
+
{
|
21
|
+
"image": {
|
22
|
+
"maxWidth": 500,
|
23
|
+
"maxHeight": 500
|
24
|
+
}
|
25
|
+
}
|
26
|
+
</stylesheet>
|
27
|
+
</poml>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<poml>
|
2
|
+
<SystemMessage>
|
3
|
+
|
4
|
+
<task>
|
5
|
+
Given the stock ticker, provide a full and up-to-date financial analysis covering the following aspects, cite sources.
|
6
|
+
</task>
|
7
|
+
|
8
|
+
<list listStyle="decimal">
|
9
|
+
<item>Current stock price, recent performance trends, and historical comparison.</item>
|
10
|
+
<item>Key financial ratios (e.g., P/E ratio, forward P/E, Price/Free cash flow, EPS growth this year, Return on equity, return on investment, current ratio, net profit margin, debt-to-equity ratio) and what they indicate about the company's financial health.</item>
|
11
|
+
<item>Support and resistance prices of the stock and how current indicators may drive the direction of the stock</item>
|
12
|
+
<item>Recent earnings reports, revenue growth or decline, and net income trends over the past quarter. Please also include if latest EPS report beat estimates.</item>
|
13
|
+
<item>Industry comparison to determine the company's standing relative to its peers.</item>
|
14
|
+
<item>Current analyst ratings, target price forecasts, and recent upgrades or downgrades.</item>
|
15
|
+
<item>Overall summary on whether the stock is considered a 'buy', 'hold', or 'sell' based on current financial data and market sentiment.</item>
|
16
|
+
</list>
|
17
|
+
</SystemMessage>
|
18
|
+
|
19
|
+
<HumanMessage>
|
20
|
+
<table src="assets/104_mag7.xlsx" selectedRecords=":-1" syntax="markdown" />
|
21
|
+
|
22
|
+
<p>The following two charts on a visualization of the table above. One of them shows the absolute price of the stocks, and the other one shows the price normalized by the price of the first day.</p>
|
23
|
+
|
24
|
+
<img src="assets/104_chart_price.png" syntax="multimedia" />
|
25
|
+
|
26
|
+
<img src="assets/104_chart_normalized_price.png" syntax="multimedia" />
|
27
|
+
|
28
|
+
<Hint>
|
29
|
+
The table contains stock tickers of 7 companies. Please analyze and give financial analysis and comparison for them.
|
30
|
+
</Hint>
|
31
|
+
</HumanMessage>
|
32
|
+
|
33
|
+
</poml>
|
@@ -0,0 +1,48 @@
|
|
1
|
+
<poml>
|
2
|
+
<task className="instruction">Create a blog post with these specifications:</task>
|
3
|
+
|
4
|
+
<output-format className="instruction">
|
5
|
+
<list listStyle="decimal">
|
6
|
+
<item>Title: [SEO-friendly title]</item>
|
7
|
+
<item>Introduction (100 words)
|
8
|
+
<list>
|
9
|
+
<item>Hook statement</item>
|
10
|
+
<item>Context setting</item>
|
11
|
+
<item>Main points preview</item>
|
12
|
+
</list>
|
13
|
+
</item>
|
14
|
+
<item>Main body (800 words)
|
15
|
+
<list>
|
16
|
+
<item>3-4 main points</item>
|
17
|
+
<item>Each point: [subtitle + 200 words]</item>
|
18
|
+
<item>Include real examples</item>
|
19
|
+
<item>Add actionable tips</item>
|
20
|
+
</list>
|
21
|
+
</item>
|
22
|
+
<item>Conclusion (100 words)
|
23
|
+
<list>
|
24
|
+
<item>Summary of key points</item>
|
25
|
+
<item>Call to action</item>
|
26
|
+
</list>
|
27
|
+
</item>
|
28
|
+
</list>
|
29
|
+
</output-format>
|
30
|
+
|
31
|
+
<cp className="instruction" caption="Style" captionSerialized="style">
|
32
|
+
<list>
|
33
|
+
<item>Tone: Professional but conversational</item>
|
34
|
+
<item>Level: Intermediate audience</item>
|
35
|
+
<item>Voice: Active, engaging</item>
|
36
|
+
<item>Format: Scannable, with subheadings</item>
|
37
|
+
</list>
|
38
|
+
</cp>
|
39
|
+
|
40
|
+
<cp className="instruction" caption="Include" captionSerialized="include">
|
41
|
+
<list>
|
42
|
+
<item>Practical examples</item>
|
43
|
+
<item>Statistics or research</item>
|
44
|
+
<item>Actionable takeaways</item>
|
45
|
+
<item>Relevant analogies</item>
|
46
|
+
</list>
|
47
|
+
</cp>
|
48
|
+
</poml>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<poml>
|
2
|
+
<task>You are given various potential options or approaches for a project. Convert these into a well-structured research plan.</task>
|
3
|
+
|
4
|
+
<stepwise-instructions>
|
5
|
+
<list listStyle="decimal">
|
6
|
+
<item>Identifies Key Objectives
|
7
|
+
<list listStyle="dash">
|
8
|
+
<item>Clarify what questions each option aims to answer</item>
|
9
|
+
<item>Detail the data/info needed for evaluation</item>
|
10
|
+
</list>
|
11
|
+
</item>
|
12
|
+
<item>Describes Research Methods
|
13
|
+
<list listStyle="dash">
|
14
|
+
<item>Outline how you’ll gather and analyze data</item>
|
15
|
+
<item>Mention tools or methodologies for each approach</item>
|
16
|
+
</list>
|
17
|
+
</item>
|
18
|
+
|
19
|
+
<item>Provides Evaluation Criteria
|
20
|
+
<list listStyle="dash">
|
21
|
+
<item>Metrics, benchmarks, or qualitative factors to compare options </item>
|
22
|
+
<item>Criteria for success or viability</item>
|
23
|
+
</list>
|
24
|
+
</item>
|
25
|
+
|
26
|
+
<item>Specifies Expected Outcomes
|
27
|
+
<list listStyle="dash">
|
28
|
+
<item>Possible findings or results </item>
|
29
|
+
<item>Next steps or actions following the research</item>
|
30
|
+
</list>
|
31
|
+
</item>
|
32
|
+
</list>
|
33
|
+
|
34
|
+
Produce a methodical plan focusing on clear, practical steps.
|
35
|
+
</stepwise-instructions>
|
36
|
+
</poml>
|
@@ -0,0 +1,4 @@
|
|
1
|
+
<poml>
|
2
|
+
<p>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.</p>
|
3
|
+
<Document syntax="text" src="assets/107_usenix_paper.pdf" selectedPages="1:3" />
|
4
|
+
</poml>
|
@@ -0,0 +1,50 @@
|
|
1
|
+
<poml>
|
2
|
+
<role>You are a chatbot agent answering customer's questions in a chat.</role>
|
3
|
+
|
4
|
+
<task>
|
5
|
+
Your task is to answer the customer's question using the data provided in the data section.
|
6
|
+
<!-- Use listStyle property to change the style of a list. -->
|
7
|
+
<list listStyle="decimal">
|
8
|
+
<item>You can access order history in the orders section including email id and order total with payment summary.</item>
|
9
|
+
<item>Refer to orderlines for item level details within each order in orders.</item>
|
10
|
+
</list>
|
11
|
+
</task>
|
12
|
+
|
13
|
+
<!-- cp means CaptionedParagraph, which is a paragraph with customized headings. -->
|
14
|
+
<cp caption="Data">
|
15
|
+
<cp caption="Orders">
|
16
|
+
<!-- Use table to read a csv file. By default, it follows its parents' style (markdown in this case). -->
|
17
|
+
<table src="assets/201_orders.csv" />
|
18
|
+
</cp>
|
19
|
+
|
20
|
+
<cp caption="Orderlines">
|
21
|
+
<!-- Use syntax to specify its output format. -->
|
22
|
+
<table src="assets/201_orderlines.csv" syntax="tsv" />
|
23
|
+
</cp>
|
24
|
+
</cp>
|
25
|
+
|
26
|
+
<!-- This can also be stepwise-instructions, and it's case-insensitive. -->
|
27
|
+
<StepwiseInstructions>
|
28
|
+
<!-- Read a file and save it as instructions -->
|
29
|
+
<let src="assets/201_order_instructions.json" name="instructions"/>
|
30
|
+
<!-- Use a for loop to iterate over the instructions, use {{ }} to evaluate an expression -->
|
31
|
+
<p for="ins in instructions">
|
32
|
+
Instruction {{loop.index+1}}: {{ ins }}
|
33
|
+
</p>
|
34
|
+
</StepwiseInstructions>
|
35
|
+
|
36
|
+
<!-- Specify the speaker of a block. -->
|
37
|
+
<HumanMessage>
|
38
|
+
<!-- Use a question-answer format. -->
|
39
|
+
<qa>How much did I pay for my last order?</qa>
|
40
|
+
</HumanMessage>
|
41
|
+
|
42
|
+
<!-- Use stylesheet (a CSS-like JSON) to modify the style in a batch. -->
|
43
|
+
<stylesheet>
|
44
|
+
{
|
45
|
+
"cp": {
|
46
|
+
"captionTextTransform": "upper"
|
47
|
+
}
|
48
|
+
}
|
49
|
+
</stylesheet>
|
50
|
+
</poml>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<poml>
|
2
|
+
<SystemMessage>Be brief and clear in your responses</SystemMessage>
|
3
|
+
<let src="assets/202_arc_agi_data.json"/>
|
4
|
+
<HumanMessage>
|
5
|
+
<p>Find the common rule that maps an input grid to an output grid, given the examples below.</p>
|
6
|
+
<examples>
|
7
|
+
<example for="example in train" chat="false" caption="Example {{ loop.index }}" captionStyle="header">
|
8
|
+
<input><table records="{{ example.input }}"/></input>
|
9
|
+
<output><table records="{{ example.output }}"/></output>
|
10
|
+
</example>
|
11
|
+
</examples>
|
12
|
+
|
13
|
+
<p>Below is a test input grid. Predict the corresponding output grid by applying the rule you found. Your final answer should just be the text output grid itself.</p>
|
14
|
+
<input><table records="{{ test[0].input }}"/></input>
|
15
|
+
</HumanMessage>
|
16
|
+
|
17
|
+
<stylesheet>
|
18
|
+
{
|
19
|
+
"table": {
|
20
|
+
"syntax": "csv",
|
21
|
+
"writerOptions": {
|
22
|
+
"csvHeader": false,
|
23
|
+
"csvSeparator": " "
|
24
|
+
}
|
25
|
+
},
|
26
|
+
"input": {
|
27
|
+
"captionEnding": "colon-newline",
|
28
|
+
"captionStyle": "plain"
|
29
|
+
},
|
30
|
+
"output": {
|
31
|
+
"captionEnding": "colon-newline",
|
32
|
+
"captionStyle": "plain"
|
33
|
+
}
|
34
|
+
}
|
35
|
+
</stylesheet>
|
36
|
+
</poml>
|
@@ -0,0 +1,46 @@
|
|
1
|
+
<poml>
|
2
|
+
<let src="105_write_blog_post.poml" name="blog_post" />
|
3
|
+
<let src="106_research.poml" name="research" />
|
4
|
+
<let src="202_arc_agi.poml" name="arc_agi" />
|
5
|
+
<let src="107_read_report_pdf.poml" name="read_report" />
|
6
|
+
<p>
|
7
|
+
<span whiteSpace="trim">
|
8
|
+
// PromptLibrary.jsx
|
9
|
+
|
10
|
+
/* Create a blog post. The prompt contains very specific instructions around output format, styles, and what to include in the content. */
|
11
|
+
<span whiteSpace="trim">
|
12
|
+
function blog_post() {
|
13
|
+
return {{blog_post.replace(/^/gm, ' ').trimStart()}};
|
14
|
+
}
|
15
|
+
</span>
|
16
|
+
|
17
|
+
/* Conduct in-depth research with AI, such as tackling academic papers, business analyses, or large investigative projects. */
|
18
|
+
<span whiteSpace="trim">
|
19
|
+
function research() {
|
20
|
+
return {{research.replace(/^/gm, ' ').trimStart()}};
|
21
|
+
}
|
22
|
+
</span>
|
23
|
+
|
24
|
+
/* Test the ability of an LLM to perform a complex reasoning task -- ARC-AGI. The data is in `arc_agi_data.json`.
|
25
|
+
*/
|
26
|
+
<span whiteSpace="trim">
|
27
|
+
function arc_agi() {
|
28
|
+
return {{arc_agi.replace(/^/gm, ' ').trimStart()}};
|
29
|
+
}
|
30
|
+
</span>
|
31
|
+
|
32
|
+
/* Summarize a report, such as a research paper or a business report. */
|
33
|
+
<span whiteSpace="trim">
|
34
|
+
function read_report() {
|
35
|
+
return {{read_report.replace(/^/gm, ' ').trimStart()}};
|
36
|
+
}
|
37
|
+
</span>
|
38
|
+
|
39
|
+
/* Write a entertaining story that is engaging, imaginative and captivating for the audience. */
|
40
|
+
<span whiteSpace="trim">
|
41
|
+
function storyteller() {
|
42
|
+
return
|
43
|
+
</span>
|
44
|
+
</span>
|
45
|
+
</p>
|
46
|
+
</poml>
|
data/examples/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# How to Test the poml Ruby Gem Locally with Example Files
|
2
|
+
|
3
|
+
1. **Install dependencies** (from the gem root):
|
4
|
+
```sh
|
5
|
+
bundle install
|
6
|
+
```
|
7
|
+
|
8
|
+
2. **Open an IRB (interactive Ruby) session** in the gem root:
|
9
|
+
|
10
|
+
```sh
|
11
|
+
bundle exec irb -Ilib -rpoml
|
12
|
+
```
|
13
|
+
|
14
|
+
3. **Run the gem on an example file** (replace the path and context as needed):
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
result = Poml.process(
|
18
|
+
markup: "examples/101_explain_character.poml",
|
19
|
+
context: { name: "World" },
|
20
|
+
format: "raw"
|
21
|
+
)
|
22
|
+
puts result
|
23
|
+
```
|
24
|
+
|
25
|
+
You should see the rendered output with the context variable replaced.
|
26
|
+
|
27
|
+
If you want to run from a Ruby script, use the same code as above in a `.rb` file and run it with `bundle exec ruby your_script.rb`.
|
28
|
+
# POML Example Library
|
29
|
+
|
30
|
+
This directory contains example POML files demonstrating a variety of use cases. Examples are organized by difficulty:
|
31
|
+
|
32
|
+
- **Beginner:** Filenames start with `1XX_`
|
33
|
+
- **Intermediate:** Filenames start with `2XX_`
|
34
|
+
- **Advanced:** Filenames start with `3XX_`
|
35
|
+
|
36
|
+
Each example highlights different POML features, such as structured prompting, data handling, and templating.
|
37
|
+
|
38
|
+
Non-POML examples (e.g., Python or JavaScript scripts) are prefixed with `4XX_` and use appropriate file extensions. Inline comments explain their usage.
|
39
|
+
|
40
|
+
## Contributing
|
41
|
+
|
42
|
+
Contributions are welcome! To add or improve an example:
|
43
|
+
|
44
|
+
- Follow the naming conventions above.
|
45
|
+
- Include clear explanations and comments in your examples.
|
46
|
+
- Place any assets in an `assets/` subdirectory within the example's folder.
|
47
|
+
- If your example includes expected output, place it in an `expects/` subdirectory.
|
48
|
+
|
49
|
+
Submit your changes via pull request.
|
50
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import os
|
2
|
+
import poml
|
3
|
+
import io
|
4
|
+
import sys
|
5
|
+
from contextlib import redirect_stdout
|
6
|
+
|
7
|
+
|
8
|
+
def process_example(example_content, output_file):
|
9
|
+
"""
|
10
|
+
Process the example content and return the expected output.
|
11
|
+
"""
|
12
|
+
# Capture stdout
|
13
|
+
poml.poml(example_content, format="raw", output_file=output_file, extra_args=["--prettyPrint", "true"])
|
14
|
+
|
15
|
+
|
16
|
+
def generate_expectations():
|
17
|
+
"""
|
18
|
+
Generate the expected output files for the examples.
|
19
|
+
"""
|
20
|
+
examples_dir = os.path.abspath(os.path.dirname(__file__))
|
21
|
+
expect_dir = os.path.join(examples_dir, "expects")
|
22
|
+
print("Generating expectations in:", expect_dir)
|
23
|
+
|
24
|
+
for example_file in sorted(os.listdir(examples_dir)):
|
25
|
+
if example_file.endswith(".poml"):
|
26
|
+
print(f"Processing example: {example_file}")
|
27
|
+
# Generate the expected output
|
28
|
+
process_example(
|
29
|
+
os.path.join(examples_dir, example_file),
|
30
|
+
os.path.join(expect_dir, example_file.replace(".poml", ".txt")),
|
31
|
+
)
|
32
|
+
|
33
|
+
|
34
|
+
if __name__ == "__main__":
|
35
|
+
generate_expectations()
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Hello there! Let's take a look at this picture together. What do you see? That's right, it's Tom from the famous cartoon series "Tom and Jerry"!
|
2
|
+
|
3
|
+
Tom is a gray and white domestic shorthair cat. In this picture, he looks a bit worried or scared, doesn't he? You can tell by his big, wide eyes and the way his mouth is shaped. Maybe Jerry, the clever little mouse, has played another trick on him!
|
4
|
+
|
5
|
+
Now, let's talk a little more about Tom and Jerry so you can understand why Tom might look this way. "Tom and Jerry" is a fun cartoon that has been around since 1940. It was created by William Hanna and Joseph Barbera. The show is all about the funny and sometimes crazy adventures of Tom the cat and Jerry the mouse. Tom is always trying to catch Jerry, but Jerry is very smart and always finds a way to escape or trick Tom.
|
6
|
+
|
7
|
+
Even though Tom and Jerry are often seen fighting, they do care about each other and sometimes work together to solve problems. The cartoon is full of funny moments, and even though they play tricks on each other, it's all in good fun.
|
8
|
+
|
9
|
+
So, whenever you see Tom looking like this, you can imagine that he's probably just been outsmarted by Jerry once again! But don't worry, Tom never gives up and always comes back for more adventures.
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,7 @@
|
|
1
|
+
[
|
2
|
+
"If there is no data that can help answer the question, respond with \"I do not have this information. Please contact customer service\".",
|
3
|
+
"You are allowed to ask a follow up question if it will help narrow down the data row customer may be referring to.",
|
4
|
+
"You can only answer questions related to order history and amount charged for it. Include OrderId in the response, when applicable.",
|
5
|
+
"For everything else, please redirect to the customer service agent.",
|
6
|
+
"Answer in plain English and no sources are required."
|
7
|
+
]
|
@@ -0,0 +1,2 @@
|
|
1
|
+
OrderId,OrderLineId,CreatedTimestamp,ItemDescription,Quantity,FulfillmentStatus,ExpectedDeliveryDate,ActualDeliveryDate,ActualShipDate,ExpectedShipDate,TrackingInformation,ShipToAddress,CarrierCode,DeliveryMethod,UnitPrice,OrderLineSubTotal,LineShippingCharge,TotalTaxes,Payments
|
2
|
+
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,
|
@@ -0,0 +1 @@
|
|
1
|
+
{"train": [{"input": [[2, 2, 2], [2, 1, 8], [2, 8, 8]], "output": [[2, 2, 2], [2, 5, 5], [2, 5, 5]]}, {"input": [[1, 1, 1], [8, 1, 3], [8, 2, 2]], "output": [[1, 1, 1], [5, 1, 5], [5, 5, 5]]}, {"input": [[2, 2, 2], [8, 8, 2], [2, 2, 2]], "output": [[2, 2, 2], [5, 5, 2], [2, 2, 2]]}, {"input": [[3, 3, 8], [4, 4, 4], [8, 1, 1]], "output": [[5, 5, 5], [4, 4, 4], [5, 5, 5]]}], "test": [{"input": [[1, 3, 2], [3, 3, 2], [1, 3, 2]], "output": [[5, 3, 5], [3, 3, 5], [5, 3, 5]]}]}
|