Spaces:
Runtime error
Runtime error
Upload with huggingface_hub
Browse files- app.py +27 -0
- math.pmpt.tpl +25 -0
- requirements.txt +3 -0
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Notebook to answer a math problem with code.
|
2 |
+
# Adapted from Dust [maths-generate-code](https://dust.tt/spolu/a/d12ac33169)
|
3 |
+
|
4 |
+
import minichain
|
5 |
+
|
6 |
+
# Prompt that asks LLM for code from math.
|
7 |
+
|
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")
|
math.pmpt.tpl
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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:
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
git+https://github.com/srush/minichain
|
3 |
+
manifest-ml
|