srush HF staff commited on
Commit
69deff6
1 Parent(s): eac37df

Upload with huggingface_hub

Browse files
Files changed (17) hide show
  1. bash.log +16 -16
  2. bash.py +8 -1
  3. chat.log +22 -22
  4. chat.py +10 -4
  5. gatsby.log +12 -12
  6. gatsby.py +9 -4
  7. math.log +18 -18
  8. math_demo.md +46 -0
  9. math_demo.py +11 -16
  10. ner.log +20 -20
  11. ner.py +9 -10
  12. pal.log +14 -14
  13. pal.py +9 -3
  14. qa.log +10 -10
  15. qa.py +9 -3
  16. stats.log +8 -8
  17. stats.py +7 -3
bash.log CHANGED
@@ -1,16 +1,16 @@
1
- {"action_status": "started", "timestamp": 1678764298.5943377, "task_uuid": "fc49cf93-1e90-4821-bdad-6675b66855cf", "action_type": "bash", "task_level": [1]}
2
- {"action_status": "succeeded", "timestamp": 1678764298.594441, "task_uuid": "fc49cf93-1e90-4821-bdad-6675b66855cf", "action_type": "bash", "task_level": [2]}
3
- {"action_status": "started", "timestamp": 1678764298.6190703, "task_uuid": "0f19f0d4-688a-45e6-975a-b221550e533c", "action_type": "pal", "task_level": [1]}
4
- {"action_status": "succeeded", "timestamp": 1678764298.6191814, "task_uuid": "0f19f0d4-688a-45e6-975a-b221550e533c", "action_type": "pal", "task_level": [2]}
5
- {"action_status": "started", "timestamp": 1678764298.8476062, "task_uuid": "9e1c5028-cd43-4ad8-bb49-577f9e2ea464", "action_type": "gatsby", "task_level": [1]}
6
- {"action_status": "succeeded", "timestamp": 1678764298.8477728, "task_uuid": "9e1c5028-cd43-4ad8-bb49-577f9e2ea464", "action_type": "gatsby", "task_level": [2]}
7
- {"action_status": "started", "timestamp": 1678764298.9174392, "task_uuid": "a6b997da-7f68-4899-8ae0-dc1e27fe31d9", "action_type": "qa", "task_level": [1]}
8
- {"action_status": "succeeded", "timestamp": 1678764298.9175735, "task_uuid": "a6b997da-7f68-4899-8ae0-dc1e27fe31d9", "action_type": "qa", "task_level": [2]}
9
- {"action_status": "started", "timestamp": 1678764298.9510806, "task_uuid": "f6b21bbe-502a-4114-91a3-7ed512627047", "action_type": "stats", "task_level": [1]}
10
- {"action_status": "succeeded", "timestamp": 1678764298.9512932, "task_uuid": "f6b21bbe-502a-4114-91a3-7ed512627047", "action_type": "stats", "task_level": [2]}
11
- {"action_status": "started", "timestamp": 1678764389.9623082, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "<class 'math_demo.MathPrompt'>", "task_level": [1]}
12
- {"input": {"question": "What is the sum of the powers of 3 (3^i) that are smaller than 100?"}, "action_status": "started", "timestamp": 1678764389.962538, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "Input Function", "task_level": [2, 1]}
13
- {"action_status": "succeeded", "timestamp": 1678764389.9634213, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "Input Function", "task_level": [2, 2]}
14
- {"prompt": "#### Question:\n\n* What is 37593 * 67?\n\n#### Code:\n\n```python\nprint(37593 * 67)\n```\n\n#### Question:\n\n* Janet's ducks lay 16 eggs per day. She eats three for breakfast every morning and bakes muffins for her friends every day with four. She sells the remainder at the farmers' market daily for $2 per fresh duck egg. How much in dollars does she make every day at the farmers' market?\n\n#### Code:\n\n```python\nprint((16-3-4)*2)\n```\n\n#### Question:\n\n* How many of the integers between 0 and 99 inclusive are divisible by 8?\n\n#### Code:\n\n```python\ncount = 0\nfor i in range(0, 99+1):\n if i % 8 == 0: count += 1\nprint(count)\n```\n\n#### Question:\n\n* A robe takes 2 bolts of blue fiber and half that much white fiber. How many bolts in total does it take?\n\n#### Code:\n\n```python\nprint(2 + 2/2)\n```\n\n#### Question:\n\n* What is the sum of the powers of 3 (3^i) that are smaller than 100?\n\n#### Code:", "action_status": "started", "timestamp": 1678764389.9635243, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "Prompted", "task_level": [3, 1]}
15
- {"exception": "builtins.AssertionError", "reason": "Need an OPENAI_KEY. Get one here https://openai.com/api/", "action_status": "failed", "timestamp": 1678764389.9702687, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "Prompted", "task_level": [3, 2]}
16
- {"exception": "builtins.AssertionError", "reason": "Need an OPENAI_KEY. Get one here https://openai.com/api/", "action_status": "failed", "timestamp": 1678764389.9705117, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "<class 'math_demo.MathPrompt'>", "task_level": [4]}
 
1
+ {"action_status": "started", "timestamp": 1678804794.3736765, "task_uuid": "b91a9977-eb2c-4ee4-8081-2c9c11c5c84b", "action_type": "bash", "task_level": [1]}
2
+ {"action_status": "succeeded", "timestamp": 1678804794.3737779, "task_uuid": "b91a9977-eb2c-4ee4-8081-2c9c11c5c84b", "action_type": "bash", "task_level": [2]}
3
+ {"action_status": "started", "timestamp": 1678804794.407293, "task_uuid": "a24f4aa6-8e24-4d6b-aa12-0c326d842918", "action_type": "pal", "task_level": [1]}
4
+ {"action_status": "succeeded", "timestamp": 1678804794.4074926, "task_uuid": "a24f4aa6-8e24-4d6b-aa12-0c326d842918", "action_type": "pal", "task_level": [2]}
5
+ {"action_status": "started", "timestamp": 1678804794.616296, "task_uuid": "45a836db-19bb-4bc5-a29b-d9a3933dd175", "action_type": "gatsby", "task_level": [1]}
6
+ {"action_status": "succeeded", "timestamp": 1678804794.616455, "task_uuid": "45a836db-19bb-4bc5-a29b-d9a3933dd175", "action_type": "gatsby", "task_level": [2]}
7
+ {"action_status": "started", "timestamp": 1678804794.7338963, "task_uuid": "dc9993f0-9c8a-42a8-8f7e-bc4b40be1a1e", "action_type": "qa", "task_level": [1]}
8
+ {"action_status": "succeeded", "timestamp": 1678804794.7341123, "task_uuid": "dc9993f0-9c8a-42a8-8f7e-bc4b40be1a1e", "action_type": "qa", "task_level": [2]}
9
+ {"action_status": "started", "timestamp": 1678804794.8375309, "task_uuid": "dd1251af-7770-460d-ac61-85db28fd24df", "action_type": "stats", "task_level": [1]}
10
+ {"action_status": "succeeded", "timestamp": 1678804794.8376832, "task_uuid": "dd1251af-7770-460d-ac61-85db28fd24df", "action_type": "stats", "task_level": [2]}
11
+ {"action_status": "started", "timestamp": 1678804807.8764367, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "<class 'math_demo.MathPrompt'>", "task_level": [1]}
12
+ {"input": {"question": "What is the sum of the powers of 3 (3^i) that are smaller than 100?"}, "action_status": "started", "timestamp": 1678804807.876612, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "Input Function", "task_level": [2, 1]}
13
+ {"action_status": "succeeded", "timestamp": 1678804807.8774285, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "Input Function", "task_level": [2, 2]}
14
+ {"prompt": "#### Question:\n\n* What is 37593 * 67?\n\n#### Code:\n\n```python\nprint(37593 * 67)\n```\n\n#### Question:\n\n* Janet's ducks lay 16 eggs per day. She eats three for breakfast every morning and bakes muffins for her friends every day with four. She sells the remainder at the farmers' market daily for $2 per fresh duck egg. How much in dollars does she make every day at the farmers' market?\n\n#### Code:\n\n```python\nprint((16-3-4)*2)\n```\n\n#### Question:\n\n* How many of the integers between 0 and 99 inclusive are divisible by 8?\n\n#### Code:\n\n```python\ncount = 0\nfor i in range(0, 99+1):\n if i % 8 == 0: count += 1\nprint(count)\n```\n\n#### Question:\n\n* A robe takes 2 bolts of blue fiber and half that much white fiber. How many bolts in total does it take?\n\n#### Code:\n\n```python\nprint(2 + 2/2)\n```\n\n#### Question:\n\n* What is the sum of the powers of 3 (3^i) that are smaller than 100?\n\n#### Code:", "action_status": "started", "timestamp": 1678804807.877532, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "Prompted", "task_level": [3, 1]}
15
+ {"exception": "builtins.AssertionError", "reason": "Need an OPENAI_KEY. Get one here https://openai.com/api/", "action_status": "failed", "timestamp": 1678804807.8874092, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "Prompted", "task_level": [3, 2]}
16
+ {"exception": "builtins.AssertionError", "reason": "Need an OPENAI_KEY. Get one here https://openai.com/api/", "action_status": "failed", "timestamp": 1678804807.8875778, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "<class 'math_demo.MathPrompt'>", "task_level": [4]}
bash.py CHANGED
@@ -9,6 +9,8 @@ Chain that ask for a command-line question and then runs the bash command. [[Cod
9
  """
10
  # -
11
 
 
 
12
  import minichain
13
 
14
  # Prompt that asks LLM to produce a bash command.
@@ -42,12 +44,17 @@ with minichain.start_chain("bash") as backend:
42
  )
43
  prompt = CLIPrompt(backend.OpenAI()).chain(BashPrompt(backend.BashProcess()))
44
 
 
 
45
  gradio = prompt.to_gradio(fields =["question"],
46
  examples=['Go up one directory, and then into the minichain directory,'
47
  'and list the files in the directory',
48
  "Please write a bash script that prints 'Hello World' to the console."],
49
  out_type="markdown",
50
- description=desc)
 
 
 
51
 
52
  if __name__ == "__main__":
53
  gradio.launch()
 
9
  """
10
  # -
11
 
12
+ # $
13
+
14
  import minichain
15
 
16
  # Prompt that asks LLM to produce a bash command.
 
44
  )
45
  prompt = CLIPrompt(backend.OpenAI()).chain(BashPrompt(backend.BashProcess()))
46
 
47
+ # $
48
+
49
  gradio = prompt.to_gradio(fields =["question"],
50
  examples=['Go up one directory, and then into the minichain directory,'
51
  'and list the files in the directory',
52
  "Please write a bash script that prints 'Hello World' to the console."],
53
  out_type="markdown",
54
+ description=desc,
55
+ code=open("bash.py", "r").read().split("$")[1].strip().strip("#").strip(),
56
+ templates=[open("bash.pmpt.tpl")]
57
+ )
58
 
59
  if __name__ == "__main__":
60
  gradio.launch()
chat.log CHANGED
@@ -1,22 +1,22 @@
1
- {"action_status": "started", "timestamp": 1678764298.2960165, "task_uuid": "1c332c73-0a45-4094-b72f-50a554205293", "action_type": "chat", "task_level": [1]}
2
- {"action_status": "succeeded", "timestamp": 1678764298.2960832, "task_uuid": "1c332c73-0a45-4094-b72f-50a554205293", "action_type": "chat", "task_level": [2]}
3
- {"action_status": "started", "timestamp": 1678764298.5457702, "task_uuid": "8ea17c38-8786-4ded-a2f1-c596efa7a3cf", "action_type": "ner", "task_level": [1]}
4
- {"action_status": "succeeded", "timestamp": 1678764298.5458457, "task_uuid": "8ea17c38-8786-4ded-a2f1-c596efa7a3cf", "action_type": "ner", "task_level": [2]}
5
- {"action_status": "started", "timestamp": 1678764298.5700758, "task_uuid": "66ffa852-642e-4bd7-95c2-6cb92fde3e00", "action_type": "math", "task_level": [1]}
6
- {"action_status": "succeeded", "timestamp": 1678764298.5701659, "task_uuid": "66ffa852-642e-4bd7-95c2-6cb92fde3e00", "action_type": "math", "task_level": [2]}
7
- {"action_status": "started", "timestamp": 1678764298.5943377, "task_uuid": "fc49cf93-1e90-4821-bdad-6675b66855cf", "action_type": "bash", "task_level": [1]}
8
- {"action_status": "succeeded", "timestamp": 1678764298.594441, "task_uuid": "fc49cf93-1e90-4821-bdad-6675b66855cf", "action_type": "bash", "task_level": [2]}
9
- {"action_status": "started", "timestamp": 1678764298.6190703, "task_uuid": "0f19f0d4-688a-45e6-975a-b221550e533c", "action_type": "pal", "task_level": [1]}
10
- {"action_status": "succeeded", "timestamp": 1678764298.6191814, "task_uuid": "0f19f0d4-688a-45e6-975a-b221550e533c", "action_type": "pal", "task_level": [2]}
11
- {"action_status": "started", "timestamp": 1678764298.8476062, "task_uuid": "9e1c5028-cd43-4ad8-bb49-577f9e2ea464", "action_type": "gatsby", "task_level": [1]}
12
- {"action_status": "succeeded", "timestamp": 1678764298.8477728, "task_uuid": "9e1c5028-cd43-4ad8-bb49-577f9e2ea464", "action_type": "gatsby", "task_level": [2]}
13
- {"action_status": "started", "timestamp": 1678764298.9174392, "task_uuid": "a6b997da-7f68-4899-8ae0-dc1e27fe31d9", "action_type": "qa", "task_level": [1]}
14
- {"action_status": "succeeded", "timestamp": 1678764298.9175735, "task_uuid": "a6b997da-7f68-4899-8ae0-dc1e27fe31d9", "action_type": "qa", "task_level": [2]}
15
- {"action_status": "started", "timestamp": 1678764298.9510806, "task_uuid": "f6b21bbe-502a-4114-91a3-7ed512627047", "action_type": "stats", "task_level": [1]}
16
- {"action_status": "succeeded", "timestamp": 1678764298.9512932, "task_uuid": "f6b21bbe-502a-4114-91a3-7ed512627047", "action_type": "stats", "task_level": [2]}
17
- {"action_status": "started", "timestamp": 1678764389.9623082, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "<class 'math_demo.MathPrompt'>", "task_level": [1]}
18
- {"input": {"question": "What is the sum of the powers of 3 (3^i) that are smaller than 100?"}, "action_status": "started", "timestamp": 1678764389.962538, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "Input Function", "task_level": [2, 1]}
19
- {"action_status": "succeeded", "timestamp": 1678764389.9634213, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "Input Function", "task_level": [2, 2]}
20
- {"prompt": "#### Question:\n\n* What is 37593 * 67?\n\n#### Code:\n\n```python\nprint(37593 * 67)\n```\n\n#### Question:\n\n* Janet's ducks lay 16 eggs per day. She eats three for breakfast every morning and bakes muffins for her friends every day with four. She sells the remainder at the farmers' market daily for $2 per fresh duck egg. How much in dollars does she make every day at the farmers' market?\n\n#### Code:\n\n```python\nprint((16-3-4)*2)\n```\n\n#### Question:\n\n* How many of the integers between 0 and 99 inclusive are divisible by 8?\n\n#### Code:\n\n```python\ncount = 0\nfor i in range(0, 99+1):\n if i % 8 == 0: count += 1\nprint(count)\n```\n\n#### Question:\n\n* A robe takes 2 bolts of blue fiber and half that much white fiber. How many bolts in total does it take?\n\n#### Code:\n\n```python\nprint(2 + 2/2)\n```\n\n#### Question:\n\n* What is the sum of the powers of 3 (3^i) that are smaller than 100?\n\n#### Code:", "action_status": "started", "timestamp": 1678764389.9635243, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "Prompted", "task_level": [3, 1]}
21
- {"exception": "builtins.AssertionError", "reason": "Need an OPENAI_KEY. Get one here https://openai.com/api/", "action_status": "failed", "timestamp": 1678764389.9702687, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "Prompted", "task_level": [3, 2]}
22
- {"exception": "builtins.AssertionError", "reason": "Need an OPENAI_KEY. Get one here https://openai.com/api/", "action_status": "failed", "timestamp": 1678764389.9705117, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "<class 'math_demo.MathPrompt'>", "task_level": [4]}
 
1
+ {"action_status": "started", "timestamp": 1678804794.0478587, "task_uuid": "ee9d703e-b2a7-49c8-bb88-44836746c9aa", "action_type": "chat", "task_level": [1]}
2
+ {"action_status": "succeeded", "timestamp": 1678804794.0480256, "task_uuid": "ee9d703e-b2a7-49c8-bb88-44836746c9aa", "action_type": "chat", "task_level": [2]}
3
+ {"action_status": "started", "timestamp": 1678804794.3142183, "task_uuid": "2447e362-ebdb-4151-bb2b-70ada0c012fa", "action_type": "ner", "task_level": [1]}
4
+ {"action_status": "succeeded", "timestamp": 1678804794.314325, "task_uuid": "2447e362-ebdb-4151-bb2b-70ada0c012fa", "action_type": "ner", "task_level": [2]}
5
+ {"action_status": "started", "timestamp": 1678804794.3484201, "task_uuid": "051d71c8-5062-4319-a533-fdf97e822b41", "action_type": "math", "task_level": [1]}
6
+ {"action_status": "succeeded", "timestamp": 1678804794.3485305, "task_uuid": "051d71c8-5062-4319-a533-fdf97e822b41", "action_type": "math", "task_level": [2]}
7
+ {"action_status": "started", "timestamp": 1678804794.3736765, "task_uuid": "b91a9977-eb2c-4ee4-8081-2c9c11c5c84b", "action_type": "bash", "task_level": [1]}
8
+ {"action_status": "succeeded", "timestamp": 1678804794.3737779, "task_uuid": "b91a9977-eb2c-4ee4-8081-2c9c11c5c84b", "action_type": "bash", "task_level": [2]}
9
+ {"action_status": "started", "timestamp": 1678804794.407293, "task_uuid": "a24f4aa6-8e24-4d6b-aa12-0c326d842918", "action_type": "pal", "task_level": [1]}
10
+ {"action_status": "succeeded", "timestamp": 1678804794.4074926, "task_uuid": "a24f4aa6-8e24-4d6b-aa12-0c326d842918", "action_type": "pal", "task_level": [2]}
11
+ {"action_status": "started", "timestamp": 1678804794.616296, "task_uuid": "45a836db-19bb-4bc5-a29b-d9a3933dd175", "action_type": "gatsby", "task_level": [1]}
12
+ {"action_status": "succeeded", "timestamp": 1678804794.616455, "task_uuid": "45a836db-19bb-4bc5-a29b-d9a3933dd175", "action_type": "gatsby", "task_level": [2]}
13
+ {"action_status": "started", "timestamp": 1678804794.7338963, "task_uuid": "dc9993f0-9c8a-42a8-8f7e-bc4b40be1a1e", "action_type": "qa", "task_level": [1]}
14
+ {"action_status": "succeeded", "timestamp": 1678804794.7341123, "task_uuid": "dc9993f0-9c8a-42a8-8f7e-bc4b40be1a1e", "action_type": "qa", "task_level": [2]}
15
+ {"action_status": "started", "timestamp": 1678804794.8375309, "task_uuid": "dd1251af-7770-460d-ac61-85db28fd24df", "action_type": "stats", "task_level": [1]}
16
+ {"action_status": "succeeded", "timestamp": 1678804794.8376832, "task_uuid": "dd1251af-7770-460d-ac61-85db28fd24df", "action_type": "stats", "task_level": [2]}
17
+ {"action_status": "started", "timestamp": 1678804807.8764367, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "<class 'math_demo.MathPrompt'>", "task_level": [1]}
18
+ {"input": {"question": "What is the sum of the powers of 3 (3^i) that are smaller than 100?"}, "action_status": "started", "timestamp": 1678804807.876612, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "Input Function", "task_level": [2, 1]}
19
+ {"action_status": "succeeded", "timestamp": 1678804807.8774285, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "Input Function", "task_level": [2, 2]}
20
+ {"prompt": "#### Question:\n\n* What is 37593 * 67?\n\n#### Code:\n\n```python\nprint(37593 * 67)\n```\n\n#### Question:\n\n* Janet's ducks lay 16 eggs per day. She eats three for breakfast every morning and bakes muffins for her friends every day with four. She sells the remainder at the farmers' market daily for $2 per fresh duck egg. How much in dollars does she make every day at the farmers' market?\n\n#### Code:\n\n```python\nprint((16-3-4)*2)\n```\n\n#### Question:\n\n* How many of the integers between 0 and 99 inclusive are divisible by 8?\n\n#### Code:\n\n```python\ncount = 0\nfor i in range(0, 99+1):\n if i % 8 == 0: count += 1\nprint(count)\n```\n\n#### Question:\n\n* A robe takes 2 bolts of blue fiber and half that much white fiber. How many bolts in total does it take?\n\n#### Code:\n\n```python\nprint(2 + 2/2)\n```\n\n#### Question:\n\n* What is the sum of the powers of 3 (3^i) that are smaller than 100?\n\n#### Code:", "action_status": "started", "timestamp": 1678804807.877532, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "Prompted", "task_level": [3, 1]}
21
+ {"exception": "builtins.AssertionError", "reason": "Need an OPENAI_KEY. Get one here https://openai.com/api/", "action_status": "failed", "timestamp": 1678804807.8874092, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "Prompted", "task_level": [3, 2]}
22
+ {"exception": "builtins.AssertionError", "reason": "Need an OPENAI_KEY. Get one here https://openai.com/api/", "action_status": "failed", "timestamp": 1678804807.8875778, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "<class 'math_demo.MathPrompt'>", "task_level": [4]}
chat.py CHANGED
@@ -10,14 +10,16 @@ desc = """
10
 
11
 
12
  import warnings
13
- from dataclasses import dataclass
14
- from typing import List, Tuple
15
- import minichain
16
 
17
  # + tags=["hide_inp"]
18
  warnings.filterwarnings("ignore")
19
  # -
20
 
 
 
 
 
 
21
 
22
  # Generic stateful Memory
23
 
@@ -49,6 +51,7 @@ with minichain.start_chain("chat") as backend:
49
  prompt = ChatPrompt(backend.OpenAI())
50
  state = State([])
51
 
 
52
 
53
  examples = [
54
  "I want you to act as a Linux terminal. I will type commands and you will reply with what the terminal should show. I want you to only reply with the terminal output inside one unique code block, and nothing else. Do not write explanations. Do not type commands unless I instruct you to do so. When I need to tell you something in English I will do so by putting text inside curly brackets {like this}. My first command is pwd.",
@@ -65,7 +68,10 @@ gradio = prompt.to_gradio(fields= ["human_input"],
65
  initial_state= state,
66
  examples=examples,
67
  out_type="json",
68
- description=desc
 
 
 
69
  )
70
  if __name__ == "__main__":
71
  gradio.launch()
 
10
 
11
 
12
  import warnings
 
 
 
13
 
14
  # + tags=["hide_inp"]
15
  warnings.filterwarnings("ignore")
16
  # -
17
 
18
+ # $
19
+
20
+ from dataclasses import dataclass
21
+ from typing import List, Tuple
22
+ import minichain
23
 
24
  # Generic stateful Memory
25
 
 
51
  prompt = ChatPrompt(backend.OpenAI())
52
  state = State([])
53
 
54
+ # $
55
 
56
  examples = [
57
  "I want you to act as a Linux terminal. I will type commands and you will reply with what the terminal should show. I want you to only reply with the terminal output inside one unique code block, and nothing else. Do not write explanations. Do not type commands unless I instruct you to do so. When I need to tell you something in English I will do so by putting text inside curly brackets {like this}. My first command is pwd.",
 
68
  initial_state= state,
69
  examples=examples,
70
  out_type="json",
71
+ description=desc,
72
+ code=open("chat.py", "r").read().split("$")[1].strip().strip("#").strip(),
73
+ templates=[open("chat.pmpt.tpl")]
74
+
75
  )
76
  if __name__ == "__main__":
77
  gradio.launch()
gatsby.log CHANGED
@@ -1,12 +1,12 @@
1
- {"action_status": "started", "timestamp": 1678764298.8476062, "task_uuid": "9e1c5028-cd43-4ad8-bb49-577f9e2ea464", "action_type": "gatsby", "task_level": [1]}
2
- {"action_status": "succeeded", "timestamp": 1678764298.8477728, "task_uuid": "9e1c5028-cd43-4ad8-bb49-577f9e2ea464", "action_type": "gatsby", "task_level": [2]}
3
- {"action_status": "started", "timestamp": 1678764298.9174392, "task_uuid": "a6b997da-7f68-4899-8ae0-dc1e27fe31d9", "action_type": "qa", "task_level": [1]}
4
- {"action_status": "succeeded", "timestamp": 1678764298.9175735, "task_uuid": "a6b997da-7f68-4899-8ae0-dc1e27fe31d9", "action_type": "qa", "task_level": [2]}
5
- {"action_status": "started", "timestamp": 1678764298.9510806, "task_uuid": "f6b21bbe-502a-4114-91a3-7ed512627047", "action_type": "stats", "task_level": [1]}
6
- {"action_status": "succeeded", "timestamp": 1678764298.9512932, "task_uuid": "f6b21bbe-502a-4114-91a3-7ed512627047", "action_type": "stats", "task_level": [2]}
7
- {"action_status": "started", "timestamp": 1678764389.9623082, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "<class 'math_demo.MathPrompt'>", "task_level": [1]}
8
- {"input": {"question": "What is the sum of the powers of 3 (3^i) that are smaller than 100?"}, "action_status": "started", "timestamp": 1678764389.962538, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "Input Function", "task_level": [2, 1]}
9
- {"action_status": "succeeded", "timestamp": 1678764389.9634213, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "Input Function", "task_level": [2, 2]}
10
- {"prompt": "#### Question:\n\n* What is 37593 * 67?\n\n#### Code:\n\n```python\nprint(37593 * 67)\n```\n\n#### Question:\n\n* Janet's ducks lay 16 eggs per day. She eats three for breakfast every morning and bakes muffins for her friends every day with four. She sells the remainder at the farmers' market daily for $2 per fresh duck egg. How much in dollars does she make every day at the farmers' market?\n\n#### Code:\n\n```python\nprint((16-3-4)*2)\n```\n\n#### Question:\n\n* How many of the integers between 0 and 99 inclusive are divisible by 8?\n\n#### Code:\n\n```python\ncount = 0\nfor i in range(0, 99+1):\n if i % 8 == 0: count += 1\nprint(count)\n```\n\n#### Question:\n\n* A robe takes 2 bolts of blue fiber and half that much white fiber. How many bolts in total does it take?\n\n#### Code:\n\n```python\nprint(2 + 2/2)\n```\n\n#### Question:\n\n* What is the sum of the powers of 3 (3^i) that are smaller than 100?\n\n#### Code:", "action_status": "started", "timestamp": 1678764389.9635243, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "Prompted", "task_level": [3, 1]}
11
- {"exception": "builtins.AssertionError", "reason": "Need an OPENAI_KEY. Get one here https://openai.com/api/", "action_status": "failed", "timestamp": 1678764389.9702687, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "Prompted", "task_level": [3, 2]}
12
- {"exception": "builtins.AssertionError", "reason": "Need an OPENAI_KEY. Get one here https://openai.com/api/", "action_status": "failed", "timestamp": 1678764389.9705117, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "<class 'math_demo.MathPrompt'>", "task_level": [4]}
 
1
+ {"action_status": "started", "timestamp": 1678804794.616296, "task_uuid": "45a836db-19bb-4bc5-a29b-d9a3933dd175", "action_type": "gatsby", "task_level": [1]}
2
+ {"action_status": "succeeded", "timestamp": 1678804794.616455, "task_uuid": "45a836db-19bb-4bc5-a29b-d9a3933dd175", "action_type": "gatsby", "task_level": [2]}
3
+ {"action_status": "started", "timestamp": 1678804794.7338963, "task_uuid": "dc9993f0-9c8a-42a8-8f7e-bc4b40be1a1e", "action_type": "qa", "task_level": [1]}
4
+ {"action_status": "succeeded", "timestamp": 1678804794.7341123, "task_uuid": "dc9993f0-9c8a-42a8-8f7e-bc4b40be1a1e", "action_type": "qa", "task_level": [2]}
5
+ {"action_status": "started", "timestamp": 1678804794.8375309, "task_uuid": "dd1251af-7770-460d-ac61-85db28fd24df", "action_type": "stats", "task_level": [1]}
6
+ {"action_status": "succeeded", "timestamp": 1678804794.8376832, "task_uuid": "dd1251af-7770-460d-ac61-85db28fd24df", "action_type": "stats", "task_level": [2]}
7
+ {"action_status": "started", "timestamp": 1678804807.8764367, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "<class 'math_demo.MathPrompt'>", "task_level": [1]}
8
+ {"input": {"question": "What is the sum of the powers of 3 (3^i) that are smaller than 100?"}, "action_status": "started", "timestamp": 1678804807.876612, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "Input Function", "task_level": [2, 1]}
9
+ {"action_status": "succeeded", "timestamp": 1678804807.8774285, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "Input Function", "task_level": [2, 2]}
10
+ {"prompt": "#### Question:\n\n* What is 37593 * 67?\n\n#### Code:\n\n```python\nprint(37593 * 67)\n```\n\n#### Question:\n\n* Janet's ducks lay 16 eggs per day. She eats three for breakfast every morning and bakes muffins for her friends every day with four. She sells the remainder at the farmers' market daily for $2 per fresh duck egg. How much in dollars does she make every day at the farmers' market?\n\n#### Code:\n\n```python\nprint((16-3-4)*2)\n```\n\n#### Question:\n\n* How many of the integers between 0 and 99 inclusive are divisible by 8?\n\n#### Code:\n\n```python\ncount = 0\nfor i in range(0, 99+1):\n if i % 8 == 0: count += 1\nprint(count)\n```\n\n#### Question:\n\n* A robe takes 2 bolts of blue fiber and half that much white fiber. How many bolts in total does it take?\n\n#### Code:\n\n```python\nprint(2 + 2/2)\n```\n\n#### Question:\n\n* What is the sum of the powers of 3 (3^i) that are smaller than 100?\n\n#### Code:", "action_status": "started", "timestamp": 1678804807.877532, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "Prompted", "task_level": [3, 1]}
11
+ {"exception": "builtins.AssertionError", "reason": "Need an OPENAI_KEY. Get one here https://openai.com/api/", "action_status": "failed", "timestamp": 1678804807.8874092, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "Prompted", "task_level": [3, 2]}
12
+ {"exception": "builtins.AssertionError", "reason": "Need an OPENAI_KEY. Get one here https://openai.com/api/", "action_status": "failed", "timestamp": 1678804807.8875778, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "<class 'math_demo.MathPrompt'>", "task_level": [4]}
gatsby.py CHANGED
@@ -8,6 +8,8 @@ Chain that does question answering with Hugging Face embeddings. [[Code](https:/
8
  """
9
  # -
10
 
 
 
11
  import datasets
12
  import numpy as np
13
 
@@ -36,19 +38,22 @@ class QAPrompt(TemplatePrompt):
36
 
37
 
38
  with start_chain("gatsby") as backend:
39
- # question = "What did Gatsby do before he met Daisy?"
40
  prompt = KNNPrompt(
41
  backend.HuggingFaceEmbed("sentence-transformers/all-mpnet-base-v2")
42
  ).chain(QAPrompt(backend.OpenAI()))
43
- # result = prompt(question)
44
- # print(result)
 
45
 
46
 
47
  gradio = prompt.to_gradio(fields=["query"],
48
  examples=["What did Gatsby do before he met Daisy?",
49
  "What did the narrator do after getting back to Chicago?"],
50
  keys={"HF_KEY"},
51
- description=desc)
 
 
 
52
  if __name__ == "__main__":
53
  gradio.launch()
54
 
 
8
  """
9
  # -
10
 
11
+ # $
12
+
13
  import datasets
14
  import numpy as np
15
 
 
38
 
39
 
40
  with start_chain("gatsby") as backend:
 
41
  prompt = KNNPrompt(
42
  backend.HuggingFaceEmbed("sentence-transformers/all-mpnet-base-v2")
43
  ).chain(QAPrompt(backend.OpenAI()))
44
+
45
+ # $
46
+
47
 
48
 
49
  gradio = prompt.to_gradio(fields=["query"],
50
  examples=["What did Gatsby do before he met Daisy?",
51
  "What did the narrator do after getting back to Chicago?"],
52
  keys={"HF_KEY"},
53
+ description=desc,
54
+ code=open("gatsby.py", "r").read().split("$")[1].strip().strip("#").strip(),
55
+ templates=[open("gatsby.pmpt.tpl")]
56
+ )
57
  if __name__ == "__main__":
58
  gradio.launch()
59
 
math.log CHANGED
@@ -1,18 +1,18 @@
1
- {"action_status": "started", "timestamp": 1678764298.5700758, "task_uuid": "66ffa852-642e-4bd7-95c2-6cb92fde3e00", "action_type": "math", "task_level": [1]}
2
- {"action_status": "succeeded", "timestamp": 1678764298.5701659, "task_uuid": "66ffa852-642e-4bd7-95c2-6cb92fde3e00", "action_type": "math", "task_level": [2]}
3
- {"action_status": "started", "timestamp": 1678764298.5943377, "task_uuid": "fc49cf93-1e90-4821-bdad-6675b66855cf", "action_type": "bash", "task_level": [1]}
4
- {"action_status": "succeeded", "timestamp": 1678764298.594441, "task_uuid": "fc49cf93-1e90-4821-bdad-6675b66855cf", "action_type": "bash", "task_level": [2]}
5
- {"action_status": "started", "timestamp": 1678764298.6190703, "task_uuid": "0f19f0d4-688a-45e6-975a-b221550e533c", "action_type": "pal", "task_level": [1]}
6
- {"action_status": "succeeded", "timestamp": 1678764298.6191814, "task_uuid": "0f19f0d4-688a-45e6-975a-b221550e533c", "action_type": "pal", "task_level": [2]}
7
- {"action_status": "started", "timestamp": 1678764298.8476062, "task_uuid": "9e1c5028-cd43-4ad8-bb49-577f9e2ea464", "action_type": "gatsby", "task_level": [1]}
8
- {"action_status": "succeeded", "timestamp": 1678764298.8477728, "task_uuid": "9e1c5028-cd43-4ad8-bb49-577f9e2ea464", "action_type": "gatsby", "task_level": [2]}
9
- {"action_status": "started", "timestamp": 1678764298.9174392, "task_uuid": "a6b997da-7f68-4899-8ae0-dc1e27fe31d9", "action_type": "qa", "task_level": [1]}
10
- {"action_status": "succeeded", "timestamp": 1678764298.9175735, "task_uuid": "a6b997da-7f68-4899-8ae0-dc1e27fe31d9", "action_type": "qa", "task_level": [2]}
11
- {"action_status": "started", "timestamp": 1678764298.9510806, "task_uuid": "f6b21bbe-502a-4114-91a3-7ed512627047", "action_type": "stats", "task_level": [1]}
12
- {"action_status": "succeeded", "timestamp": 1678764298.9512932, "task_uuid": "f6b21bbe-502a-4114-91a3-7ed512627047", "action_type": "stats", "task_level": [2]}
13
- {"action_status": "started", "timestamp": 1678764389.9623082, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "<class 'math_demo.MathPrompt'>", "task_level": [1]}
14
- {"input": {"question": "What is the sum of the powers of 3 (3^i) that are smaller than 100?"}, "action_status": "started", "timestamp": 1678764389.962538, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "Input Function", "task_level": [2, 1]}
15
- {"action_status": "succeeded", "timestamp": 1678764389.9634213, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "Input Function", "task_level": [2, 2]}
16
- {"prompt": "#### Question:\n\n* What is 37593 * 67?\n\n#### Code:\n\n```python\nprint(37593 * 67)\n```\n\n#### Question:\n\n* Janet's ducks lay 16 eggs per day. She eats three for breakfast every morning and bakes muffins for her friends every day with four. She sells the remainder at the farmers' market daily for $2 per fresh duck egg. How much in dollars does she make every day at the farmers' market?\n\n#### Code:\n\n```python\nprint((16-3-4)*2)\n```\n\n#### Question:\n\n* How many of the integers between 0 and 99 inclusive are divisible by 8?\n\n#### Code:\n\n```python\ncount = 0\nfor i in range(0, 99+1):\n if i % 8 == 0: count += 1\nprint(count)\n```\n\n#### Question:\n\n* A robe takes 2 bolts of blue fiber and half that much white fiber. How many bolts in total does it take?\n\n#### Code:\n\n```python\nprint(2 + 2/2)\n```\n\n#### Question:\n\n* What is the sum of the powers of 3 (3^i) that are smaller than 100?\n\n#### Code:", "action_status": "started", "timestamp": 1678764389.9635243, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "Prompted", "task_level": [3, 1]}
17
- {"exception": "builtins.AssertionError", "reason": "Need an OPENAI_KEY. Get one here https://openai.com/api/", "action_status": "failed", "timestamp": 1678764389.9702687, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "Prompted", "task_level": [3, 2]}
18
- {"exception": "builtins.AssertionError", "reason": "Need an OPENAI_KEY. Get one here https://openai.com/api/", "action_status": "failed", "timestamp": 1678764389.9705117, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "<class 'math_demo.MathPrompt'>", "task_level": [4]}
 
1
+ {"action_status": "started", "timestamp": 1678804794.3484201, "task_uuid": "051d71c8-5062-4319-a533-fdf97e822b41", "action_type": "math", "task_level": [1]}
2
+ {"action_status": "succeeded", "timestamp": 1678804794.3485305, "task_uuid": "051d71c8-5062-4319-a533-fdf97e822b41", "action_type": "math", "task_level": [2]}
3
+ {"action_status": "started", "timestamp": 1678804794.3736765, "task_uuid": "b91a9977-eb2c-4ee4-8081-2c9c11c5c84b", "action_type": "bash", "task_level": [1]}
4
+ {"action_status": "succeeded", "timestamp": 1678804794.3737779, "task_uuid": "b91a9977-eb2c-4ee4-8081-2c9c11c5c84b", "action_type": "bash", "task_level": [2]}
5
+ {"action_status": "started", "timestamp": 1678804794.407293, "task_uuid": "a24f4aa6-8e24-4d6b-aa12-0c326d842918", "action_type": "pal", "task_level": [1]}
6
+ {"action_status": "succeeded", "timestamp": 1678804794.4074926, "task_uuid": "a24f4aa6-8e24-4d6b-aa12-0c326d842918", "action_type": "pal", "task_level": [2]}
7
+ {"action_status": "started", "timestamp": 1678804794.616296, "task_uuid": "45a836db-19bb-4bc5-a29b-d9a3933dd175", "action_type": "gatsby", "task_level": [1]}
8
+ {"action_status": "succeeded", "timestamp": 1678804794.616455, "task_uuid": "45a836db-19bb-4bc5-a29b-d9a3933dd175", "action_type": "gatsby", "task_level": [2]}
9
+ {"action_status": "started", "timestamp": 1678804794.7338963, "task_uuid": "dc9993f0-9c8a-42a8-8f7e-bc4b40be1a1e", "action_type": "qa", "task_level": [1]}
10
+ {"action_status": "succeeded", "timestamp": 1678804794.7341123, "task_uuid": "dc9993f0-9c8a-42a8-8f7e-bc4b40be1a1e", "action_type": "qa", "task_level": [2]}
11
+ {"action_status": "started", "timestamp": 1678804794.8375309, "task_uuid": "dd1251af-7770-460d-ac61-85db28fd24df", "action_type": "stats", "task_level": [1]}
12
+ {"action_status": "succeeded", "timestamp": 1678804794.8376832, "task_uuid": "dd1251af-7770-460d-ac61-85db28fd24df", "action_type": "stats", "task_level": [2]}
13
+ {"action_status": "started", "timestamp": 1678804807.8764367, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "<class 'math_demo.MathPrompt'>", "task_level": [1]}
14
+ {"input": {"question": "What is the sum of the powers of 3 (3^i) that are smaller than 100?"}, "action_status": "started", "timestamp": 1678804807.876612, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "Input Function", "task_level": [2, 1]}
15
+ {"action_status": "succeeded", "timestamp": 1678804807.8774285, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "Input Function", "task_level": [2, 2]}
16
+ {"prompt": "#### Question:\n\n* What is 37593 * 67?\n\n#### Code:\n\n```python\nprint(37593 * 67)\n```\n\n#### Question:\n\n* Janet's ducks lay 16 eggs per day. She eats three for breakfast every morning and bakes muffins for her friends every day with four. She sells the remainder at the farmers' market daily for $2 per fresh duck egg. How much in dollars does she make every day at the farmers' market?\n\n#### Code:\n\n```python\nprint((16-3-4)*2)\n```\n\n#### Question:\n\n* How many of the integers between 0 and 99 inclusive are divisible by 8?\n\n#### Code:\n\n```python\ncount = 0\nfor i in range(0, 99+1):\n if i % 8 == 0: count += 1\nprint(count)\n```\n\n#### Question:\n\n* A robe takes 2 bolts of blue fiber and half that much white fiber. How many bolts in total does it take?\n\n#### Code:\n\n```python\nprint(2 + 2/2)\n```\n\n#### Question:\n\n* What is the sum of the powers of 3 (3^i) that are smaller than 100?\n\n#### Code:", "action_status": "started", "timestamp": 1678804807.877532, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "Prompted", "task_level": [3, 1]}
17
+ {"exception": "builtins.AssertionError", "reason": "Need an OPENAI_KEY. Get one here https://openai.com/api/", "action_status": "failed", "timestamp": 1678804807.8874092, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "Prompted", "task_level": [3, 2]}
18
+ {"exception": "builtins.AssertionError", "reason": "Need an OPENAI_KEY. Get one here https://openai.com/api/", "action_status": "failed", "timestamp": 1678804807.8875778, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "<class 'math_demo.MathPrompt'>", "task_level": [4]}
math_demo.md ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ```python tags=["hide_inp"]
2
+ desc = """
3
+ ### Word Problem Solver
4
+
5
+ Chain that solves a math word problem by first generating and then running Python code. [[Code](https://github.com/srush/MiniChain/blob/main/examples/math.py)]
6
+
7
+ (Adapted from Dust [maths-generate-code](https://dust.tt/spolu/a/d12ac33169))
8
+ """
9
+ ```
10
+
11
+ ```python
12
+ import minichain
13
+ ```
14
+
15
+ Prompt that asks LLM for code from math.
16
+
17
+ ```python
18
+ class MathPrompt(minichain.TemplatePrompt):
19
+ template_file = "math.pmpt.tpl"
20
+ ```
21
+
22
+ Ask a question and run it as python code.
23
+
24
+ ```python
25
+ with minichain.start_chain("math") as backend:
26
+ math_prompt = MathPrompt(backend.OpenAI())
27
+ code_prompt = minichain.SimplePrompt(backend.Python())
28
+ prompt = math_prompt.chain(code_prompt)
29
+ ```
30
+
31
+
32
+ ```python tags=["hide_inp"]
33
+ gradio = prompt.to_gradio(fields =["question"],
34
+ examples=["What is the sum of the powers of 3 (3^i) that are smaller than 100?",
35
+ "What is the sum of the 10 first positive integers?",
36
+ "Carla is downloading a 200 GB file. She can download 2 GB/minute, but 40% of the way through the download, the download fails. Then Carla has to restart the download from the beginning. How load did it take her to download the file in minutes?"],
37
+ out_type="markdown",
38
+ description=desc,
39
+ code=open("math_demo.md", "r").read()
40
+
41
+ )
42
+ if __name__ == "__main__":
43
+ gradio.launch()
44
+ #-
45
+
46
+ ```
math_demo.py CHANGED
@@ -8,41 +8,36 @@ Chain that solves a math word problem by first generating and then running Pytho
8
  """
9
  # -
10
 
 
 
11
  import minichain
12
 
13
  # Prompt that asks LLM for code from math.
14
 
15
- class MathPrompt(minichain.TemplatePrompt[str]):
16
  template_file = "math.pmpt.tpl"
17
-
18
-
19
  # Ask a question and run it as python code.
20
 
21
  with minichain.start_chain("math") as backend:
22
  math_prompt = MathPrompt(backend.OpenAI())
23
  code_prompt = minichain.SimplePrompt(backend.Python())
24
  prompt = math_prompt.chain(code_prompt)
25
- # result = prompt({"question": question})
26
- # print(result)
27
 
 
 
 
28
  gradio = prompt.to_gradio(fields =["question"],
29
  examples=["What is the sum of the powers of 3 (3^i) that are smaller than 100?",
30
  "What is the sum of the 10 first positive integers?",
31
  "Carla is downloading a 200 GB file. She can download 2 GB/minute, but 40% of the way through the download, the download fails. Then Carla has to restart the download from the beginning. How load did it take her to download the file in minutes?"],
32
  out_type="markdown",
33
- description=desc
 
 
34
 
35
  )
36
  if __name__ == "__main__":
37
  gradio.launch()
38
-
39
 
40
- # View the prompt
41
-
42
- # + tags=["hide_inp"]
43
- # MathPrompt().show({"question": "What is 10 + 12?"}, "10 + 12")
44
- # # -
45
-
46
- # # View the log
47
-
48
- # minichain.show_log("math.log")
 
8
  """
9
  # -
10
 
11
+ # $
12
+
13
  import minichain
14
 
15
  # Prompt that asks LLM for code from math.
16
 
17
+ class MathPrompt(minichain.TemplatePrompt):
18
  template_file = "math.pmpt.tpl"
19
+
 
20
  # Ask a question and run it as python code.
21
 
22
  with minichain.start_chain("math") as backend:
23
  math_prompt = MathPrompt(backend.OpenAI())
24
  code_prompt = minichain.SimplePrompt(backend.Python())
25
  prompt = math_prompt.chain(code_prompt)
 
 
26
 
27
+ # $
28
+
29
+ # + tags=["hide_inp"]
30
  gradio = prompt.to_gradio(fields =["question"],
31
  examples=["What is the sum of the powers of 3 (3^i) that are smaller than 100?",
32
  "What is the sum of the 10 first positive integers?",
33
  "Carla is downloading a 200 GB file. She can download 2 GB/minute, but 40% of the way through the download, the download fails. Then Carla has to restart the download from the beginning. How load did it take her to download the file in minutes?"],
34
  out_type="markdown",
35
+ description=desc,
36
+ code=open("math_demo.py", "r").read().split("$")[1].strip().strip("#").strip(),
37
+ templates=[open("math.pmpt.tpl")]
38
 
39
  )
40
  if __name__ == "__main__":
41
  gradio.launch()
42
+ # -
43
 
 
 
 
 
 
 
 
 
 
ner.log CHANGED
@@ -1,20 +1,20 @@
1
- {"action_status": "started", "timestamp": 1678764298.5457702, "task_uuid": "8ea17c38-8786-4ded-a2f1-c596efa7a3cf", "action_type": "ner", "task_level": [1]}
2
- {"action_status": "succeeded", "timestamp": 1678764298.5458457, "task_uuid": "8ea17c38-8786-4ded-a2f1-c596efa7a3cf", "action_type": "ner", "task_level": [2]}
3
- {"action_status": "started", "timestamp": 1678764298.5700758, "task_uuid": "66ffa852-642e-4bd7-95c2-6cb92fde3e00", "action_type": "math", "task_level": [1]}
4
- {"action_status": "succeeded", "timestamp": 1678764298.5701659, "task_uuid": "66ffa852-642e-4bd7-95c2-6cb92fde3e00", "action_type": "math", "task_level": [2]}
5
- {"action_status": "started", "timestamp": 1678764298.5943377, "task_uuid": "fc49cf93-1e90-4821-bdad-6675b66855cf", "action_type": "bash", "task_level": [1]}
6
- {"action_status": "succeeded", "timestamp": 1678764298.594441, "task_uuid": "fc49cf93-1e90-4821-bdad-6675b66855cf", "action_type": "bash", "task_level": [2]}
7
- {"action_status": "started", "timestamp": 1678764298.6190703, "task_uuid": "0f19f0d4-688a-45e6-975a-b221550e533c", "action_type": "pal", "task_level": [1]}
8
- {"action_status": "succeeded", "timestamp": 1678764298.6191814, "task_uuid": "0f19f0d4-688a-45e6-975a-b221550e533c", "action_type": "pal", "task_level": [2]}
9
- {"action_status": "started", "timestamp": 1678764298.8476062, "task_uuid": "9e1c5028-cd43-4ad8-bb49-577f9e2ea464", "action_type": "gatsby", "task_level": [1]}
10
- {"action_status": "succeeded", "timestamp": 1678764298.8477728, "task_uuid": "9e1c5028-cd43-4ad8-bb49-577f9e2ea464", "action_type": "gatsby", "task_level": [2]}
11
- {"action_status": "started", "timestamp": 1678764298.9174392, "task_uuid": "a6b997da-7f68-4899-8ae0-dc1e27fe31d9", "action_type": "qa", "task_level": [1]}
12
- {"action_status": "succeeded", "timestamp": 1678764298.9175735, "task_uuid": "a6b997da-7f68-4899-8ae0-dc1e27fe31d9", "action_type": "qa", "task_level": [2]}
13
- {"action_status": "started", "timestamp": 1678764298.9510806, "task_uuid": "f6b21bbe-502a-4114-91a3-7ed512627047", "action_type": "stats", "task_level": [1]}
14
- {"action_status": "succeeded", "timestamp": 1678764298.9512932, "task_uuid": "f6b21bbe-502a-4114-91a3-7ed512627047", "action_type": "stats", "task_level": [2]}
15
- {"action_status": "started", "timestamp": 1678764389.9623082, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "<class 'math_demo.MathPrompt'>", "task_level": [1]}
16
- {"input": {"question": "What is the sum of the powers of 3 (3^i) that are smaller than 100?"}, "action_status": "started", "timestamp": 1678764389.962538, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "Input Function", "task_level": [2, 1]}
17
- {"action_status": "succeeded", "timestamp": 1678764389.9634213, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "Input Function", "task_level": [2, 2]}
18
- {"prompt": "#### Question:\n\n* What is 37593 * 67?\n\n#### Code:\n\n```python\nprint(37593 * 67)\n```\n\n#### Question:\n\n* Janet's ducks lay 16 eggs per day. She eats three for breakfast every morning and bakes muffins for her friends every day with four. She sells the remainder at the farmers' market daily for $2 per fresh duck egg. How much in dollars does she make every day at the farmers' market?\n\n#### Code:\n\n```python\nprint((16-3-4)*2)\n```\n\n#### Question:\n\n* How many of the integers between 0 and 99 inclusive are divisible by 8?\n\n#### Code:\n\n```python\ncount = 0\nfor i in range(0, 99+1):\n if i % 8 == 0: count += 1\nprint(count)\n```\n\n#### Question:\n\n* A robe takes 2 bolts of blue fiber and half that much white fiber. How many bolts in total does it take?\n\n#### Code:\n\n```python\nprint(2 + 2/2)\n```\n\n#### Question:\n\n* What is the sum of the powers of 3 (3^i) that are smaller than 100?\n\n#### Code:", "action_status": "started", "timestamp": 1678764389.9635243, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "Prompted", "task_level": [3, 1]}
19
- {"exception": "builtins.AssertionError", "reason": "Need an OPENAI_KEY. Get one here https://openai.com/api/", "action_status": "failed", "timestamp": 1678764389.9702687, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "Prompted", "task_level": [3, 2]}
20
- {"exception": "builtins.AssertionError", "reason": "Need an OPENAI_KEY. Get one here https://openai.com/api/", "action_status": "failed", "timestamp": 1678764389.9705117, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "<class 'math_demo.MathPrompt'>", "task_level": [4]}
 
1
+ {"action_status": "started", "timestamp": 1678804794.3142183, "task_uuid": "2447e362-ebdb-4151-bb2b-70ada0c012fa", "action_type": "ner", "task_level": [1]}
2
+ {"action_status": "succeeded", "timestamp": 1678804794.314325, "task_uuid": "2447e362-ebdb-4151-bb2b-70ada0c012fa", "action_type": "ner", "task_level": [2]}
3
+ {"action_status": "started", "timestamp": 1678804794.3484201, "task_uuid": "051d71c8-5062-4319-a533-fdf97e822b41", "action_type": "math", "task_level": [1]}
4
+ {"action_status": "succeeded", "timestamp": 1678804794.3485305, "task_uuid": "051d71c8-5062-4319-a533-fdf97e822b41", "action_type": "math", "task_level": [2]}
5
+ {"action_status": "started", "timestamp": 1678804794.3736765, "task_uuid": "b91a9977-eb2c-4ee4-8081-2c9c11c5c84b", "action_type": "bash", "task_level": [1]}
6
+ {"action_status": "succeeded", "timestamp": 1678804794.3737779, "task_uuid": "b91a9977-eb2c-4ee4-8081-2c9c11c5c84b", "action_type": "bash", "task_level": [2]}
7
+ {"action_status": "started", "timestamp": 1678804794.407293, "task_uuid": "a24f4aa6-8e24-4d6b-aa12-0c326d842918", "action_type": "pal", "task_level": [1]}
8
+ {"action_status": "succeeded", "timestamp": 1678804794.4074926, "task_uuid": "a24f4aa6-8e24-4d6b-aa12-0c326d842918", "action_type": "pal", "task_level": [2]}
9
+ {"action_status": "started", "timestamp": 1678804794.616296, "task_uuid": "45a836db-19bb-4bc5-a29b-d9a3933dd175", "action_type": "gatsby", "task_level": [1]}
10
+ {"action_status": "succeeded", "timestamp": 1678804794.616455, "task_uuid": "45a836db-19bb-4bc5-a29b-d9a3933dd175", "action_type": "gatsby", "task_level": [2]}
11
+ {"action_status": "started", "timestamp": 1678804794.7338963, "task_uuid": "dc9993f0-9c8a-42a8-8f7e-bc4b40be1a1e", "action_type": "qa", "task_level": [1]}
12
+ {"action_status": "succeeded", "timestamp": 1678804794.7341123, "task_uuid": "dc9993f0-9c8a-42a8-8f7e-bc4b40be1a1e", "action_type": "qa", "task_level": [2]}
13
+ {"action_status": "started", "timestamp": 1678804794.8375309, "task_uuid": "dd1251af-7770-460d-ac61-85db28fd24df", "action_type": "stats", "task_level": [1]}
14
+ {"action_status": "succeeded", "timestamp": 1678804794.8376832, "task_uuid": "dd1251af-7770-460d-ac61-85db28fd24df", "action_type": "stats", "task_level": [2]}
15
+ {"action_status": "started", "timestamp": 1678804807.8764367, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "<class 'math_demo.MathPrompt'>", "task_level": [1]}
16
+ {"input": {"question": "What is the sum of the powers of 3 (3^i) that are smaller than 100?"}, "action_status": "started", "timestamp": 1678804807.876612, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "Input Function", "task_level": [2, 1]}
17
+ {"action_status": "succeeded", "timestamp": 1678804807.8774285, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "Input Function", "task_level": [2, 2]}
18
+ {"prompt": "#### Question:\n\n* What is 37593 * 67?\n\n#### Code:\n\n```python\nprint(37593 * 67)\n```\n\n#### Question:\n\n* Janet's ducks lay 16 eggs per day. She eats three for breakfast every morning and bakes muffins for her friends every day with four. She sells the remainder at the farmers' market daily for $2 per fresh duck egg. How much in dollars does she make every day at the farmers' market?\n\n#### Code:\n\n```python\nprint((16-3-4)*2)\n```\n\n#### Question:\n\n* How many of the integers between 0 and 99 inclusive are divisible by 8?\n\n#### Code:\n\n```python\ncount = 0\nfor i in range(0, 99+1):\n if i % 8 == 0: count += 1\nprint(count)\n```\n\n#### Question:\n\n* A robe takes 2 bolts of blue fiber and half that much white fiber. How many bolts in total does it take?\n\n#### Code:\n\n```python\nprint(2 + 2/2)\n```\n\n#### Question:\n\n* What is the sum of the powers of 3 (3^i) that are smaller than 100?\n\n#### Code:", "action_status": "started", "timestamp": 1678804807.877532, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "Prompted", "task_level": [3, 1]}
19
+ {"exception": "builtins.AssertionError", "reason": "Need an OPENAI_KEY. Get one here https://openai.com/api/", "action_status": "failed", "timestamp": 1678804807.8874092, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "Prompted", "task_level": [3, 2]}
20
+ {"exception": "builtins.AssertionError", "reason": "Need an OPENAI_KEY. Get one here https://openai.com/api/", "action_status": "failed", "timestamp": 1678804807.8875778, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "<class 'math_demo.MathPrompt'>", "task_level": [4]}
ner.py CHANGED
@@ -1,7 +1,7 @@
1
  # + tags=["hide_inp"]
2
 
3
  desc = """
4
- ### NER
5
 
6
  Chain that does named entity recognition with arbitrary labels. [[Code](https://github.com/srush/MiniChain/blob/main/examples/ner.py)]
7
 
@@ -9,8 +9,9 @@ Chain that does named entity recognition with arbitrary labels. [[Code](https://
9
  """
10
  # -
11
 
12
- import json
13
 
 
14
  import minichain
15
 
16
  # Prompt to extract NER tags as json
@@ -37,17 +38,15 @@ with minichain.start_chain("ner") as backend:
37
  ner_prompt = NERPrompt(backend.OpenAI())
38
  team_prompt = TeamPrompt(backend.OpenAI())
39
  prompt = ner_prompt.chain(team_prompt)
40
- # results = prompt(
41
- # {"text_input": "An NBA playoff pairing a year ago, the 76ers (39-20) meet the Miami Heat (32-29) for the first time this season on Monday night at home.",
42
- # "labels" : ["Team", "Date"],
43
- # "domain": "Sports"
44
- # }
45
- # )
46
- # print(results)
47
 
 
 
48
  gradio = prompt.to_gradio(fields =["text_input", "labels", "domain"],
49
  examples=[["An NBA playoff pairing a year ago, the 76ers (39-20) meet the Miami Heat (32-29) for the first time this season on Monday night at home.", "Team, Date", "Sports"]],
50
- description=desc)
 
 
 
51
 
52
 
53
  if __name__ == "__main__":
 
1
  # + tags=["hide_inp"]
2
 
3
  desc = """
4
+ ### Named Entity Recognition
5
 
6
  Chain that does named entity recognition with arbitrary labels. [[Code](https://github.com/srush/MiniChain/blob/main/examples/ner.py)]
7
 
 
9
  """
10
  # -
11
 
12
+ # $
13
 
14
+ import json
15
  import minichain
16
 
17
  # Prompt to extract NER tags as json
 
38
  ner_prompt = NERPrompt(backend.OpenAI())
39
  team_prompt = TeamPrompt(backend.OpenAI())
40
  prompt = ner_prompt.chain(team_prompt)
 
 
 
 
 
 
 
41
 
42
+ # $
43
+
44
  gradio = prompt.to_gradio(fields =["text_input", "labels", "domain"],
45
  examples=[["An NBA playoff pairing a year ago, the 76ers (39-20) meet the Miami Heat (32-29) for the first time this season on Monday night at home.", "Team, Date", "Sports"]],
46
+ description=desc,
47
+ code=open("ner.py", "r").read().split("$")[1].strip().strip("#").strip(),
48
+ templates=[open("ner.pmpt.tpl")]
49
+ )
50
 
51
 
52
  if __name__ == "__main__":
pal.log CHANGED
@@ -1,14 +1,14 @@
1
- {"action_status": "started", "timestamp": 1678764298.6190703, "task_uuid": "0f19f0d4-688a-45e6-975a-b221550e533c", "action_type": "pal", "task_level": [1]}
2
- {"action_status": "succeeded", "timestamp": 1678764298.6191814, "task_uuid": "0f19f0d4-688a-45e6-975a-b221550e533c", "action_type": "pal", "task_level": [2]}
3
- {"action_status": "started", "timestamp": 1678764298.8476062, "task_uuid": "9e1c5028-cd43-4ad8-bb49-577f9e2ea464", "action_type": "gatsby", "task_level": [1]}
4
- {"action_status": "succeeded", "timestamp": 1678764298.8477728, "task_uuid": "9e1c5028-cd43-4ad8-bb49-577f9e2ea464", "action_type": "gatsby", "task_level": [2]}
5
- {"action_status": "started", "timestamp": 1678764298.9174392, "task_uuid": "a6b997da-7f68-4899-8ae0-dc1e27fe31d9", "action_type": "qa", "task_level": [1]}
6
- {"action_status": "succeeded", "timestamp": 1678764298.9175735, "task_uuid": "a6b997da-7f68-4899-8ae0-dc1e27fe31d9", "action_type": "qa", "task_level": [2]}
7
- {"action_status": "started", "timestamp": 1678764298.9510806, "task_uuid": "f6b21bbe-502a-4114-91a3-7ed512627047", "action_type": "stats", "task_level": [1]}
8
- {"action_status": "succeeded", "timestamp": 1678764298.9512932, "task_uuid": "f6b21bbe-502a-4114-91a3-7ed512627047", "action_type": "stats", "task_level": [2]}
9
- {"action_status": "started", "timestamp": 1678764389.9623082, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "<class 'math_demo.MathPrompt'>", "task_level": [1]}
10
- {"input": {"question": "What is the sum of the powers of 3 (3^i) that are smaller than 100?"}, "action_status": "started", "timestamp": 1678764389.962538, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "Input Function", "task_level": [2, 1]}
11
- {"action_status": "succeeded", "timestamp": 1678764389.9634213, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "Input Function", "task_level": [2, 2]}
12
- {"prompt": "#### Question:\n\n* What is 37593 * 67?\n\n#### Code:\n\n```python\nprint(37593 * 67)\n```\n\n#### Question:\n\n* Janet's ducks lay 16 eggs per day. She eats three for breakfast every morning and bakes muffins for her friends every day with four. She sells the remainder at the farmers' market daily for $2 per fresh duck egg. How much in dollars does she make every day at the farmers' market?\n\n#### Code:\n\n```python\nprint((16-3-4)*2)\n```\n\n#### Question:\n\n* How many of the integers between 0 and 99 inclusive are divisible by 8?\n\n#### Code:\n\n```python\ncount = 0\nfor i in range(0, 99+1):\n if i % 8 == 0: count += 1\nprint(count)\n```\n\n#### Question:\n\n* A robe takes 2 bolts of blue fiber and half that much white fiber. How many bolts in total does it take?\n\n#### Code:\n\n```python\nprint(2 + 2/2)\n```\n\n#### Question:\n\n* What is the sum of the powers of 3 (3^i) that are smaller than 100?\n\n#### Code:", "action_status": "started", "timestamp": 1678764389.9635243, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "Prompted", "task_level": [3, 1]}
13
- {"exception": "builtins.AssertionError", "reason": "Need an OPENAI_KEY. Get one here https://openai.com/api/", "action_status": "failed", "timestamp": 1678764389.9702687, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "Prompted", "task_level": [3, 2]}
14
- {"exception": "builtins.AssertionError", "reason": "Need an OPENAI_KEY. Get one here https://openai.com/api/", "action_status": "failed", "timestamp": 1678764389.9705117, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "<class 'math_demo.MathPrompt'>", "task_level": [4]}
 
1
+ {"action_status": "started", "timestamp": 1678804794.407293, "task_uuid": "a24f4aa6-8e24-4d6b-aa12-0c326d842918", "action_type": "pal", "task_level": [1]}
2
+ {"action_status": "succeeded", "timestamp": 1678804794.4074926, "task_uuid": "a24f4aa6-8e24-4d6b-aa12-0c326d842918", "action_type": "pal", "task_level": [2]}
3
+ {"action_status": "started", "timestamp": 1678804794.616296, "task_uuid": "45a836db-19bb-4bc5-a29b-d9a3933dd175", "action_type": "gatsby", "task_level": [1]}
4
+ {"action_status": "succeeded", "timestamp": 1678804794.616455, "task_uuid": "45a836db-19bb-4bc5-a29b-d9a3933dd175", "action_type": "gatsby", "task_level": [2]}
5
+ {"action_status": "started", "timestamp": 1678804794.7338963, "task_uuid": "dc9993f0-9c8a-42a8-8f7e-bc4b40be1a1e", "action_type": "qa", "task_level": [1]}
6
+ {"action_status": "succeeded", "timestamp": 1678804794.7341123, "task_uuid": "dc9993f0-9c8a-42a8-8f7e-bc4b40be1a1e", "action_type": "qa", "task_level": [2]}
7
+ {"action_status": "started", "timestamp": 1678804794.8375309, "task_uuid": "dd1251af-7770-460d-ac61-85db28fd24df", "action_type": "stats", "task_level": [1]}
8
+ {"action_status": "succeeded", "timestamp": 1678804794.8376832, "task_uuid": "dd1251af-7770-460d-ac61-85db28fd24df", "action_type": "stats", "task_level": [2]}
9
+ {"action_status": "started", "timestamp": 1678804807.8764367, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "<class 'math_demo.MathPrompt'>", "task_level": [1]}
10
+ {"input": {"question": "What is the sum of the powers of 3 (3^i) that are smaller than 100?"}, "action_status": "started", "timestamp": 1678804807.876612, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "Input Function", "task_level": [2, 1]}
11
+ {"action_status": "succeeded", "timestamp": 1678804807.8774285, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "Input Function", "task_level": [2, 2]}
12
+ {"prompt": "#### Question:\n\n* What is 37593 * 67?\n\n#### Code:\n\n```python\nprint(37593 * 67)\n```\n\n#### Question:\n\n* Janet's ducks lay 16 eggs per day. She eats three for breakfast every morning and bakes muffins for her friends every day with four. She sells the remainder at the farmers' market daily for $2 per fresh duck egg. How much in dollars does she make every day at the farmers' market?\n\n#### Code:\n\n```python\nprint((16-3-4)*2)\n```\n\n#### Question:\n\n* How many of the integers between 0 and 99 inclusive are divisible by 8?\n\n#### Code:\n\n```python\ncount = 0\nfor i in range(0, 99+1):\n if i % 8 == 0: count += 1\nprint(count)\n```\n\n#### Question:\n\n* A robe takes 2 bolts of blue fiber and half that much white fiber. How many bolts in total does it take?\n\n#### Code:\n\n```python\nprint(2 + 2/2)\n```\n\n#### Question:\n\n* What is the sum of the powers of 3 (3^i) that are smaller than 100?\n\n#### Code:", "action_status": "started", "timestamp": 1678804807.877532, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "Prompted", "task_level": [3, 1]}
13
+ {"exception": "builtins.AssertionError", "reason": "Need an OPENAI_KEY. Get one here https://openai.com/api/", "action_status": "failed", "timestamp": 1678804807.8874092, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "Prompted", "task_level": [3, 2]}
14
+ {"exception": "builtins.AssertionError", "reason": "Need an OPENAI_KEY. Get one here https://openai.com/api/", "action_status": "failed", "timestamp": 1678804807.8875778, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "<class 'math_demo.MathPrompt'>", "task_level": [4]}
pal.py CHANGED
@@ -6,6 +6,8 @@ Chain for answering complex problems by code generation and execution. [[Code](h
6
  (Adapted from Prompt-aided Language Models [PAL](https://arxiv.org/pdf/2211.10435.pdf)).
7
  """
8
 
 
 
9
  import minichain
10
 
11
  # PAL Prompt
@@ -26,8 +28,9 @@ class PyPrompt(minichain.Prompt):
26
 
27
  with minichain.start_chain("pal") as backend:
28
  prompt = PalPrompt(backend.OpenAI()).chain(PyPrompt(backend.Python()))
29
- # result = prompt({"question": question})
30
-
 
31
  question = "Melanie is a door-to-door saleswoman. She sold a third of her " \
32
  "vacuum cleaners at the green house, 2 more to the red house, and half of " \
33
  "what was left at the orange house. If Melanie has 5 vacuum cleaners left, " \
@@ -35,7 +38,10 @@ question = "Melanie is a door-to-door saleswoman. She sold a third of her " \
35
 
36
  gradio = prompt.to_gradio(fields =["question"],
37
  examples=[question],
38
- description=desc)
 
 
 
39
  if __name__ == "__main__":
40
  gradio.launch()
41
 
 
6
  (Adapted from Prompt-aided Language Models [PAL](https://arxiv.org/pdf/2211.10435.pdf)).
7
  """
8
 
9
+ # $
10
+
11
  import minichain
12
 
13
  # PAL Prompt
 
28
 
29
  with minichain.start_chain("pal") as backend:
30
  prompt = PalPrompt(backend.OpenAI()).chain(PyPrompt(backend.Python()))
31
+
32
+ # $
33
+
34
  question = "Melanie is a door-to-door saleswoman. She sold a third of her " \
35
  "vacuum cleaners at the green house, 2 more to the red house, and half of " \
36
  "what was left at the orange house. If Melanie has 5 vacuum cleaners left, " \
 
38
 
39
  gradio = prompt.to_gradio(fields =["question"],
40
  examples=[question],
41
+ description=desc,
42
+ code=open("pal.py", "r").read().split("$")[1].strip().strip("#").strip(),
43
+ templates=[open("pal.pmpt.tpl")]
44
+ )
45
  if __name__ == "__main__":
46
  gradio.launch()
47
 
qa.log CHANGED
@@ -1,10 +1,10 @@
1
- {"action_status": "started", "timestamp": 1678764298.9174392, "task_uuid": "a6b997da-7f68-4899-8ae0-dc1e27fe31d9", "action_type": "qa", "task_level": [1]}
2
- {"action_status": "succeeded", "timestamp": 1678764298.9175735, "task_uuid": "a6b997da-7f68-4899-8ae0-dc1e27fe31d9", "action_type": "qa", "task_level": [2]}
3
- {"action_status": "started", "timestamp": 1678764298.9510806, "task_uuid": "f6b21bbe-502a-4114-91a3-7ed512627047", "action_type": "stats", "task_level": [1]}
4
- {"action_status": "succeeded", "timestamp": 1678764298.9512932, "task_uuid": "f6b21bbe-502a-4114-91a3-7ed512627047", "action_type": "stats", "task_level": [2]}
5
- {"action_status": "started", "timestamp": 1678764389.9623082, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "<class 'math_demo.MathPrompt'>", "task_level": [1]}
6
- {"input": {"question": "What is the sum of the powers of 3 (3^i) that are smaller than 100?"}, "action_status": "started", "timestamp": 1678764389.962538, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "Input Function", "task_level": [2, 1]}
7
- {"action_status": "succeeded", "timestamp": 1678764389.9634213, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "Input Function", "task_level": [2, 2]}
8
- {"prompt": "#### Question:\n\n* What is 37593 * 67?\n\n#### Code:\n\n```python\nprint(37593 * 67)\n```\n\n#### Question:\n\n* Janet's ducks lay 16 eggs per day. She eats three for breakfast every morning and bakes muffins for her friends every day with four. She sells the remainder at the farmers' market daily for $2 per fresh duck egg. How much in dollars does she make every day at the farmers' market?\n\n#### Code:\n\n```python\nprint((16-3-4)*2)\n```\n\n#### Question:\n\n* How many of the integers between 0 and 99 inclusive are divisible by 8?\n\n#### Code:\n\n```python\ncount = 0\nfor i in range(0, 99+1):\n if i % 8 == 0: count += 1\nprint(count)\n```\n\n#### Question:\n\n* A robe takes 2 bolts of blue fiber and half that much white fiber. How many bolts in total does it take?\n\n#### Code:\n\n```python\nprint(2 + 2/2)\n```\n\n#### Question:\n\n* What is the sum of the powers of 3 (3^i) that are smaller than 100?\n\n#### Code:", "action_status": "started", "timestamp": 1678764389.9635243, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "Prompted", "task_level": [3, 1]}
9
- {"exception": "builtins.AssertionError", "reason": "Need an OPENAI_KEY. Get one here https://openai.com/api/", "action_status": "failed", "timestamp": 1678764389.9702687, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "Prompted", "task_level": [3, 2]}
10
- {"exception": "builtins.AssertionError", "reason": "Need an OPENAI_KEY. Get one here https://openai.com/api/", "action_status": "failed", "timestamp": 1678764389.9705117, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "<class 'math_demo.MathPrompt'>", "task_level": [4]}
 
1
+ {"action_status": "started", "timestamp": 1678804794.7338963, "task_uuid": "dc9993f0-9c8a-42a8-8f7e-bc4b40be1a1e", "action_type": "qa", "task_level": [1]}
2
+ {"action_status": "succeeded", "timestamp": 1678804794.7341123, "task_uuid": "dc9993f0-9c8a-42a8-8f7e-bc4b40be1a1e", "action_type": "qa", "task_level": [2]}
3
+ {"action_status": "started", "timestamp": 1678804794.8375309, "task_uuid": "dd1251af-7770-460d-ac61-85db28fd24df", "action_type": "stats", "task_level": [1]}
4
+ {"action_status": "succeeded", "timestamp": 1678804794.8376832, "task_uuid": "dd1251af-7770-460d-ac61-85db28fd24df", "action_type": "stats", "task_level": [2]}
5
+ {"action_status": "started", "timestamp": 1678804807.8764367, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "<class 'math_demo.MathPrompt'>", "task_level": [1]}
6
+ {"input": {"question": "What is the sum of the powers of 3 (3^i) that are smaller than 100?"}, "action_status": "started", "timestamp": 1678804807.876612, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "Input Function", "task_level": [2, 1]}
7
+ {"action_status": "succeeded", "timestamp": 1678804807.8774285, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "Input Function", "task_level": [2, 2]}
8
+ {"prompt": "#### Question:\n\n* What is 37593 * 67?\n\n#### Code:\n\n```python\nprint(37593 * 67)\n```\n\n#### Question:\n\n* Janet's ducks lay 16 eggs per day. She eats three for breakfast every morning and bakes muffins for her friends every day with four. She sells the remainder at the farmers' market daily for $2 per fresh duck egg. How much in dollars does she make every day at the farmers' market?\n\n#### Code:\n\n```python\nprint((16-3-4)*2)\n```\n\n#### Question:\n\n* How many of the integers between 0 and 99 inclusive are divisible by 8?\n\n#### Code:\n\n```python\ncount = 0\nfor i in range(0, 99+1):\n if i % 8 == 0: count += 1\nprint(count)\n```\n\n#### Question:\n\n* A robe takes 2 bolts of blue fiber and half that much white fiber. How many bolts in total does it take?\n\n#### Code:\n\n```python\nprint(2 + 2/2)\n```\n\n#### Question:\n\n* What is the sum of the powers of 3 (3^i) that are smaller than 100?\n\n#### Code:", "action_status": "started", "timestamp": 1678804807.877532, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "Prompted", "task_level": [3, 1]}
9
+ {"exception": "builtins.AssertionError", "reason": "Need an OPENAI_KEY. Get one here https://openai.com/api/", "action_status": "failed", "timestamp": 1678804807.8874092, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "Prompted", "task_level": [3, 2]}
10
+ {"exception": "builtins.AssertionError", "reason": "Need an OPENAI_KEY. Get one here https://openai.com/api/", "action_status": "failed", "timestamp": 1678804807.8875778, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "<class 'math_demo.MathPrompt'>", "task_level": [4]}
qa.py CHANGED
@@ -8,9 +8,10 @@ Chain that answers questions with embeedding based retrieval. [[Code](https://gi
8
  """
9
  # -
10
 
 
 
11
  import datasets
12
  import numpy as np
13
-
14
  from minichain import EmbeddingPrompt, TemplatePrompt, show_log, start_chain
15
 
16
  # We use Hugging Face Datasets as the database by assigning
@@ -31,13 +32,15 @@ class KNNPrompt(EmbeddingPrompt):
31
 
32
  # QA prompt to ask question with examples
33
 
34
-
35
  class QAPrompt(TemplatePrompt):
36
  template_file = "qa.pmpt.tpl"
37
 
38
 
39
  with start_chain("qa") as backend:
40
  prompt = KNNPrompt(backend.OpenAIEmbed()).chain(QAPrompt(backend.OpenAI()))
 
 
 
41
 
42
  questions = ["Who won the 2020 Summer Olympics men's high jump?",
43
  "Why was the 2020 Summer Olympics originally postponed?",
@@ -47,7 +50,10 @@ questions = ["Who won the 2020 Summer Olympics men's high jump?",
47
 
48
  gradio = prompt.to_gradio(fields=["query"],
49
  examples=questions,
50
- description=desc)
 
 
 
51
  if __name__ == "__main__":
52
  gradio.launch()
53
 
 
8
  """
9
  # -
10
 
11
+ # $
12
+
13
  import datasets
14
  import numpy as np
 
15
  from minichain import EmbeddingPrompt, TemplatePrompt, show_log, start_chain
16
 
17
  # We use Hugging Face Datasets as the database by assigning
 
32
 
33
  # QA prompt to ask question with examples
34
 
 
35
  class QAPrompt(TemplatePrompt):
36
  template_file = "qa.pmpt.tpl"
37
 
38
 
39
  with start_chain("qa") as backend:
40
  prompt = KNNPrompt(backend.OpenAIEmbed()).chain(QAPrompt(backend.OpenAI()))
41
+
42
+ # $
43
+
44
 
45
  questions = ["Who won the 2020 Summer Olympics men's high jump?",
46
  "Why was the 2020 Summer Olympics originally postponed?",
 
50
 
51
  gradio = prompt.to_gradio(fields=["query"],
52
  examples=questions,
53
+ description=desc,
54
+ code=open("qa.py", "r").read().split("$")[1].strip().strip("#").strip(),
55
+ templates=[open("qa.pmpt.tpl")]
56
+ )
57
  if __name__ == "__main__":
58
  gradio.launch()
59
 
stats.log CHANGED
@@ -1,8 +1,8 @@
1
- {"action_status": "started", "timestamp": 1678764298.9510806, "task_uuid": "f6b21bbe-502a-4114-91a3-7ed512627047", "action_type": "stats", "task_level": [1]}
2
- {"action_status": "succeeded", "timestamp": 1678764298.9512932, "task_uuid": "f6b21bbe-502a-4114-91a3-7ed512627047", "action_type": "stats", "task_level": [2]}
3
- {"action_status": "started", "timestamp": 1678764389.9623082, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "<class 'math_demo.MathPrompt'>", "task_level": [1]}
4
- {"input": {"question": "What is the sum of the powers of 3 (3^i) that are smaller than 100?"}, "action_status": "started", "timestamp": 1678764389.962538, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "Input Function", "task_level": [2, 1]}
5
- {"action_status": "succeeded", "timestamp": 1678764389.9634213, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "Input Function", "task_level": [2, 2]}
6
- {"prompt": "#### Question:\n\n* What is 37593 * 67?\n\n#### Code:\n\n```python\nprint(37593 * 67)\n```\n\n#### Question:\n\n* Janet's ducks lay 16 eggs per day. She eats three for breakfast every morning and bakes muffins for her friends every day with four. She sells the remainder at the farmers' market daily for $2 per fresh duck egg. How much in dollars does she make every day at the farmers' market?\n\n#### Code:\n\n```python\nprint((16-3-4)*2)\n```\n\n#### Question:\n\n* How many of the integers between 0 and 99 inclusive are divisible by 8?\n\n#### Code:\n\n```python\ncount = 0\nfor i in range(0, 99+1):\n if i % 8 == 0: count += 1\nprint(count)\n```\n\n#### Question:\n\n* A robe takes 2 bolts of blue fiber and half that much white fiber. How many bolts in total does it take?\n\n#### Code:\n\n```python\nprint(2 + 2/2)\n```\n\n#### Question:\n\n* What is the sum of the powers of 3 (3^i) that are smaller than 100?\n\n#### Code:", "action_status": "started", "timestamp": 1678764389.9635243, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "Prompted", "task_level": [3, 1]}
7
- {"exception": "builtins.AssertionError", "reason": "Need an OPENAI_KEY. Get one here https://openai.com/api/", "action_status": "failed", "timestamp": 1678764389.9702687, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "Prompted", "task_level": [3, 2]}
8
- {"exception": "builtins.AssertionError", "reason": "Need an OPENAI_KEY. Get one here https://openai.com/api/", "action_status": "failed", "timestamp": 1678764389.9705117, "task_uuid": "8c46feaf-7082-404a-921e-25c14db68dae", "action_type": "<class 'math_demo.MathPrompt'>", "task_level": [4]}
 
1
+ {"action_status": "started", "timestamp": 1678804794.8375309, "task_uuid": "dd1251af-7770-460d-ac61-85db28fd24df", "action_type": "stats", "task_level": [1]}
2
+ {"action_status": "succeeded", "timestamp": 1678804794.8376832, "task_uuid": "dd1251af-7770-460d-ac61-85db28fd24df", "action_type": "stats", "task_level": [2]}
3
+ {"action_status": "started", "timestamp": 1678804807.8764367, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "<class 'math_demo.MathPrompt'>", "task_level": [1]}
4
+ {"input": {"question": "What is the sum of the powers of 3 (3^i) that are smaller than 100?"}, "action_status": "started", "timestamp": 1678804807.876612, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "Input Function", "task_level": [2, 1]}
5
+ {"action_status": "succeeded", "timestamp": 1678804807.8774285, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "Input Function", "task_level": [2, 2]}
6
+ {"prompt": "#### Question:\n\n* What is 37593 * 67?\n\n#### Code:\n\n```python\nprint(37593 * 67)\n```\n\n#### Question:\n\n* Janet's ducks lay 16 eggs per day. She eats three for breakfast every morning and bakes muffins for her friends every day with four. She sells the remainder at the farmers' market daily for $2 per fresh duck egg. How much in dollars does she make every day at the farmers' market?\n\n#### Code:\n\n```python\nprint((16-3-4)*2)\n```\n\n#### Question:\n\n* How many of the integers between 0 and 99 inclusive are divisible by 8?\n\n#### Code:\n\n```python\ncount = 0\nfor i in range(0, 99+1):\n if i % 8 == 0: count += 1\nprint(count)\n```\n\n#### Question:\n\n* A robe takes 2 bolts of blue fiber and half that much white fiber. How many bolts in total does it take?\n\n#### Code:\n\n```python\nprint(2 + 2/2)\n```\n\n#### Question:\n\n* What is the sum of the powers of 3 (3^i) that are smaller than 100?\n\n#### Code:", "action_status": "started", "timestamp": 1678804807.877532, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "Prompted", "task_level": [3, 1]}
7
+ {"exception": "builtins.AssertionError", "reason": "Need an OPENAI_KEY. Get one here https://openai.com/api/", "action_status": "failed", "timestamp": 1678804807.8874092, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "Prompted", "task_level": [3, 2]}
8
+ {"exception": "builtins.AssertionError", "reason": "Need an OPENAI_KEY. Get one here https://openai.com/api/", "action_status": "failed", "timestamp": 1678804807.8875778, "task_uuid": "3130f0e2-8d6f-4992-9e12-8f90e9aa96c4", "action_type": "<class 'math_demo.MathPrompt'>", "task_level": [4]}
stats.py CHANGED
@@ -7,6 +7,8 @@ Information extraction that is automatically generated from a typed specificatio
7
  (Novel to MiniChain)
8
  """
9
 
 
 
10
  import minichain
11
  from dataclasses import dataclass
12
  from typing import List
@@ -42,14 +44,16 @@ class ExtractionPrompt(minichain.TypedTemplatePrompt):
42
  with minichain.start_chain("stats") as backend:
43
  prompt = ExtractionPrompt(backend.OpenAI(max_tokens=512))
44
 
45
- # for player in p({"passage": article}):
46
- # print(player)
47
 
48
  article = open("sixers.txt").read()
49
  gradio = prompt.to_gradio(fields =["passage"],
50
  examples=[article],
51
  out_type="json",
52
- description=desc
 
 
53
  )
54
  if __name__ == "__main__":
55
  gradio.launch()
 
7
  (Novel to MiniChain)
8
  """
9
 
10
+ # $
11
+
12
  import minichain
13
  from dataclasses import dataclass
14
  from typing import List
 
44
  with minichain.start_chain("stats") as backend:
45
  prompt = ExtractionPrompt(backend.OpenAI(max_tokens=512))
46
 
47
+ # $
48
+
49
 
50
  article = open("sixers.txt").read()
51
  gradio = prompt.to_gradio(fields =["passage"],
52
  examples=[article],
53
  out_type="json",
54
+ description=desc,
55
+ code=open("stats.py", "r").read().split("$")[1].strip().strip("#").strip(),
56
+ templates=[open("stats.pmpt.tpl")]
57
  )
58
  if __name__ == "__main__":
59
  gradio.launch()