srush commited on
Commit
2a6dd81
·
1 Parent(s): 98d935d

Upload with huggingface_hub

Browse files
Files changed (2) hide show
  1. app.py +19 -9
  2. math.pmpt.tpl +44 -21
app.py CHANGED
@@ -8,20 +8,30 @@ import minichain
8
  class MathPrompt(minichain.TemplatePrompt[str]):
9
  template_file = "math.pmpt.tpl"
10
 
 
11
  # Ask a question and run it as python code.
12
 
13
  with minichain.start_chain("math") as backend:
14
- question = "What is the sum of the powers of 3 (3^i) that are smaller than 100?"
15
- prompt = MathPrompt(backend.OpenAI()).chain(minichain.SimplePrompt(backend.Python()))
16
- result = prompt({"question": question})
17
- print(result)
18
-
 
 
 
 
 
 
 
 
 
19
  # View the prompt
20
 
21
  # + tags=["hide_inp"]
22
- MathPrompt().show({"question": "What is 10 + 12?"}, "10 + 12")
23
- # -
24
 
25
- # View the log
26
 
27
- minichain.show_log("math.log")
 
8
  class MathPrompt(minichain.TemplatePrompt[str]):
9
  template_file = "math.pmpt.tpl"
10
 
11
+
12
  # Ask a question and run it as python code.
13
 
14
  with minichain.start_chain("math") as backend:
15
+ math_prompt = MathPrompt(backend.OpenAI())
16
+ code_prompt = minichain.SimplePrompt(backend.Python())
17
+ prompt = math_prompt.chain(code_prompt)
18
+ # result = prompt({"question": question})
19
+ # print(result)
20
+
21
+ math_prompt.set_display_options(markdown=True)
22
+ code_prompt.set_display_options(markdown=True)
23
+ prompt.to_gradio(fields =["question"],
24
+ examples=["What is the sum of the powers of 3 (3^i) that are smaller than 100?"],
25
+ out_type="markdown"
26
+
27
+ ).launch()
28
+
29
  # View the prompt
30
 
31
  # + tags=["hide_inp"]
32
+ # MathPrompt().show({"question": "What is 10 + 12?"}, "10 + 12")
33
+ # # -
34
 
35
+ # # View the log
36
 
37
+ # minichain.show_log("math.log")
math.pmpt.tpl CHANGED
@@ -1,25 +1,48 @@
1
- Question:
2
- What is 37593 * 67?
3
- Code:
4
- 37593 * 67
5
-
6
- Question:
7
- 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?
8
- Code:
9
- (16-3-4)*2
10
-
11
- Question:
12
- How many of the integers between 0 and 99 inclusive are divisible by 8?
13
- Code:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  count = 0
15
  for i in range(0, 99+1):
16
- if i % 8 == 0: count += 1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
- Question:
19
- A robe takes 2 bolts of blue fiber and half that much white fiber. How many bolts in total does it take?
20
- Code:
21
- 2 + 2/2
22
 
23
- Question:
24
- {{question}}
25
- Code:
 
1
+ #### Question:
2
+
3
+ * What is 37593 * 67?
4
+
5
+ #### Code:
6
+
7
+ ```python
8
+ print(37593 * 67)
9
+ ```
10
+
11
+ #### Question:
12
+
13
+ * 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?
14
+
15
+ #### Code:
16
+
17
+ ```python
18
+ print((16-3-4)*2)
19
+ ```
20
+
21
+ #### Question:
22
+
23
+ * How many of the integers between 0 and 99 inclusive are divisible by 8?
24
+
25
+ #### Code:
26
+
27
+ ```python
28
  count = 0
29
  for i in range(0, 99+1):
30
+ if i % 8 == 0: count += 1
31
+ print(count)
32
+ ```
33
+
34
+ #### Question:
35
+
36
+ * A robe takes 2 bolts of blue fiber and half that much white fiber. How many bolts in total does it take?
37
+
38
+ #### Code:
39
+
40
+ ```python
41
+ print(2 + 2/2)
42
+ ```
43
+
44
+ #### Question:
45
 
46
+ * {{question}}
 
 
 
47
 
48
+ #### Code: