Upload with huggingface_hub
Browse files
#qa.py#
CHANGED
@@ -1,8 +1,10 @@
|
|
1 |
# + tags=["hide_inp"]
|
2 |
desc = """
|
3 |
-
|
4 |
|
5 |
-
|
|
|
|
|
6 |
"""
|
7 |
# -
|
8 |
|
@@ -37,10 +39,14 @@ class QAPrompt(TemplatePrompt):
|
|
37 |
with start_chain("qa") as backend:
|
38 |
prompt = KNNPrompt(backend.OpenAIEmbed()).chain(QAPrompt(backend.OpenAI()))
|
39 |
|
40 |
-
|
|
|
|
|
|
|
|
|
41 |
|
42 |
gradio = prompt.to_gradio(fields=["query"],
|
43 |
-
examples=
|
44 |
description=desc)
|
45 |
if __name__ == "__main__":
|
46 |
gradio.launch()
|
|
|
1 |
# + tags=["hide_inp"]
|
2 |
desc = """
|
3 |
+
### Question Answering with Retrieval
|
4 |
|
5 |
+
Chain that answers questions with embeedding based retrieval. [[Code](https://github.com/srush/MiniChain/blob/main/examples/qa.py)]
|
6 |
+
|
7 |
+
(Adapted from [OpenAI Notebook](https://github.com/openai/openai-cookbook/blob/main/examples/Question_answering_using_embeddings.ipynb).)
|
8 |
"""
|
9 |
# -
|
10 |
|
|
|
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?",
|
44 |
+
"In the 2020 Summer Olympics, how many gold medals did the country which won the most medals win?",
|
45 |
+
"What is the total number of medals won by France?",
|
46 |
+
"What is the tallest mountain in the world?"]
|
47 |
|
48 |
gradio = prompt.to_gradio(fields=["query"],
|
49 |
+
examples=questions,
|
50 |
description=desc)
|
51 |
if __name__ == "__main__":
|
52 |
gradio.launch()
|
bash.log
CHANGED
@@ -1,10 +1,16 @@
|
|
1 |
-
{"action_status": "started", "timestamp":
|
2 |
-
{"action_status": "succeeded", "timestamp":
|
3 |
-
{"action_status": "started", "timestamp":
|
4 |
-
{"action_status": "succeeded", "timestamp":
|
5 |
-
{"action_status": "started", "timestamp":
|
6 |
-
{"action_status": "succeeded", "timestamp":
|
7 |
-
{"action_status": "started", "timestamp":
|
8 |
-
{"action_status": "succeeded", "timestamp":
|
9 |
-
{"action_status": "started", "timestamp":
|
10 |
-
{"action_status": "succeeded", "timestamp":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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]}
|
bash.py
CHANGED
@@ -1,10 +1,11 @@
|
|
1 |
# + tags=["hide_inp"]
|
2 |
|
3 |
desc = """
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
|
|
8 |
"""
|
9 |
# -
|
10 |
|
@@ -43,7 +44,8 @@ with minichain.start_chain("bash") as backend:
|
|
43 |
|
44 |
gradio = prompt.to_gradio(fields =["question"],
|
45 |
examples=['Go up one directory, and then into the minichain directory,'
|
46 |
-
'and list the files in the directory'
|
|
|
47 |
out_type="markdown",
|
48 |
description=desc)
|
49 |
|
|
|
1 |
# + tags=["hide_inp"]
|
2 |
|
3 |
desc = """
|
4 |
+
### Bash Command Suggestion
|
5 |
|
6 |
+
Chain that ask for a command-line question and then runs the bash command. [[Code](https://github.com/srush/MiniChain/blob/main/examples/bash.py)]
|
7 |
+
|
8 |
+
(Adapted from LangChain [BashChain](https://langchain.readthedocs.io/en/latest/modules/chains/examples/llm_bash.html))
|
9 |
"""
|
10 |
# -
|
11 |
|
|
|
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 |
|
chat.log
CHANGED
@@ -1,16 +1,22 @@
|
|
1 |
-
{"action_status": "started", "timestamp":
|
2 |
-
{"action_status": "succeeded", "timestamp":
|
3 |
-
{"action_status": "started", "timestamp":
|
4 |
-
{"action_status": "succeeded", "timestamp":
|
5 |
-
{"action_status": "started", "timestamp":
|
6 |
-
{"action_status": "succeeded", "timestamp":
|
7 |
-
{"action_status": "started", "timestamp":
|
8 |
-
{"action_status": "succeeded", "timestamp":
|
9 |
-
{"action_status": "started", "timestamp":
|
10 |
-
{"action_status": "succeeded", "timestamp":
|
11 |
-
{"action_status": "started", "timestamp":
|
12 |
-
{"action_status": "succeeded", "timestamp":
|
13 |
-
{"action_status": "started", "timestamp":
|
14 |
-
{"action_status": "succeeded", "timestamp":
|
15 |
-
{"action_status": "started", "timestamp":
|
16 |
-
{"action_status": "succeeded", "timestamp":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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]}
|
chat.py
CHANGED
@@ -1,11 +1,10 @@
|
|
1 |
# + tags=["hide_inp"]
|
2 |
-
|
3 |
desc = """
|
4 |
-
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
[LangChain](https://langchain.readthedocs.io/en/latest/modules/memory/examples/chatgpt_clone.html)'s
|
8 |
-
version of this [blog post](https://www.engraved.blog/building-a-virtual-machine-inside/).
|
9 |
"""
|
10 |
# -
|
11 |
|
|
|
1 |
# + tags=["hide_inp"]
|
|
|
2 |
desc = """
|
3 |
+
### Chat
|
4 |
+
|
5 |
+
"ChatGPT" like example for multi-turn chat with state. [[Code](https://github.com/srush/MiniChain/blob/main/examples/chat.py)]
|
6 |
|
7 |
+
(Adapted from [LangChain](https://langchain.readthedocs.io/en/latest/modules/memory/examples/chatgpt_clone.html)'s version of this [blog post](https://www.engraved.blog/building-a-virtual-machine-inside/).)
|
|
|
|
|
8 |
"""
|
9 |
# -
|
10 |
|
gatsby.log
CHANGED
@@ -1,6 +1,12 @@
|
|
1 |
-
{"action_status": "started", "timestamp":
|
2 |
-
{"action_status": "succeeded", "timestamp":
|
3 |
-
{"action_status": "started", "timestamp":
|
4 |
-
{"action_status": "succeeded", "timestamp":
|
5 |
-
{"action_status": "started", "timestamp":
|
6 |
-
{"action_status": "succeeded", "timestamp":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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]}
|
gatsby.py
CHANGED
@@ -1,9 +1,10 @@
|
|
1 |
# + tags=["hide_inp"]
|
2 |
desc = """
|
3 |
-
|
4 |
|
5 |
-
|
6 |
-
|
|
|
7 |
"""
|
8 |
# -
|
9 |
|
@@ -44,7 +45,8 @@ with start_chain("gatsby") as backend:
|
|
44 |
|
45 |
|
46 |
gradio = prompt.to_gradio(fields=["query"],
|
47 |
-
examples=["What did Gatsby do before he met Daisy?"
|
|
|
48 |
keys={"HF_KEY"},
|
49 |
description=desc)
|
50 |
if __name__ == "__main__":
|
|
|
1 |
# + tags=["hide_inp"]
|
2 |
desc = """
|
3 |
+
### Book QA
|
4 |
|
5 |
+
Chain that does question answering with Hugging Face embeddings. [[Code](https://github.com/srush/MiniChain/blob/main/examples/gatsby.py)]
|
6 |
+
|
7 |
+
(Adapted from the [LlamaIndex example](https://github.com/jerryjliu/gpt_index/blob/main/examples/gatsby/TestGatsby.ipynb).)
|
8 |
"""
|
9 |
# -
|
10 |
|
|
|
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__":
|
math.log
CHANGED
@@ -1,12 +1,18 @@
|
|
1 |
-
{"action_status": "started", "timestamp":
|
2 |
-
{"action_status": "succeeded", "timestamp":
|
3 |
-
{"action_status": "started", "timestamp":
|
4 |
-
{"action_status": "succeeded", "timestamp":
|
5 |
-
{"action_status": "started", "timestamp":
|
6 |
-
{"action_status": "succeeded", "timestamp":
|
7 |
-
{"action_status": "started", "timestamp":
|
8 |
-
{"action_status": "succeeded", "timestamp":
|
9 |
-
{"action_status": "started", "timestamp":
|
10 |
-
{"action_status": "succeeded", "timestamp":
|
11 |
-
{"action_status": "started", "timestamp":
|
12 |
-
{"action_status": "succeeded", "timestamp":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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]}
|
math_demo.py
CHANGED
@@ -1,9 +1,10 @@
|
|
1 |
# + tags=["hide_inp"]
|
2 |
desc = """
|
3 |
-
|
4 |
|
5 |
-
|
6 |
-
|
|
|
7 |
"""
|
8 |
# -
|
9 |
|
@@ -25,7 +26,9 @@ with minichain.start_chain("math") as backend:
|
|
25 |
# print(result)
|
26 |
|
27 |
gradio = prompt.to_gradio(fields =["question"],
|
28 |
-
examples=["What is the sum of the powers of 3 (3^i) that are smaller than 100?"
|
|
|
|
|
29 |
out_type="markdown",
|
30 |
description=desc
|
31 |
|
|
|
1 |
# + 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 |
|
|
|
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 |
|
ner.log
CHANGED
@@ -1,14 +1,20 @@
|
|
1 |
-
{"action_status": "started", "timestamp":
|
2 |
-
{"action_status": "succeeded", "timestamp":
|
3 |
-
{"action_status": "started", "timestamp":
|
4 |
-
{"action_status": "succeeded", "timestamp":
|
5 |
-
{"action_status": "started", "timestamp":
|
6 |
-
{"action_status": "succeeded", "timestamp":
|
7 |
-
{"action_status": "started", "timestamp":
|
8 |
-
{"action_status": "succeeded", "timestamp":
|
9 |
-
{"action_status": "started", "timestamp":
|
10 |
-
{"action_status": "succeeded", "timestamp":
|
11 |
-
{"action_status": "started", "timestamp":
|
12 |
-
{"action_status": "succeeded", "timestamp":
|
13 |
-
{"action_status": "started", "timestamp":
|
14 |
-
{"action_status": "succeeded", "timestamp":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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]}
|
ner.py
CHANGED
@@ -1,10 +1,11 @@
|
|
1 |
# + tags=["hide_inp"]
|
2 |
|
3 |
desc = """
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
|
|
8 |
"""
|
9 |
# -
|
10 |
|
|
|
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 |
+
|
8 |
+
(Adapted from [promptify](https://github.com/promptslab/Promptify/blob/main/promptify/prompts/nlp/templates/ner.jinja)).
|
9 |
"""
|
10 |
# -
|
11 |
|
pal.log
CHANGED
@@ -1,8 +1,14 @@
|
|
1 |
-
{"action_status": "started", "timestamp":
|
2 |
-
{"action_status": "succeeded", "timestamp":
|
3 |
-
{"action_status": "started", "timestamp":
|
4 |
-
{"action_status": "succeeded", "timestamp":
|
5 |
-
{"action_status": "started", "timestamp":
|
6 |
-
{"action_status": "succeeded", "timestamp":
|
7 |
-
{"action_status": "started", "timestamp":
|
8 |
-
{"action_status": "succeeded", "timestamp":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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]}
|
pal.py
CHANGED
@@ -1,7 +1,9 @@
|
|
1 |
desc = """
|
2 |
-
|
3 |
|
4 |
-
|
|
|
|
|
5 |
"""
|
6 |
|
7 |
import minichain
|
|
|
1 |
desc = """
|
2 |
+
### Prompt-aided Language Models
|
3 |
|
4 |
+
Chain for answering complex problems by code generation and execution. [[Code](https://github.com/srush/MiniChain/blob/main/examples/pal.py)]
|
5 |
+
|
6 |
+
(Adapted from Prompt-aided Language Models [PAL](https://arxiv.org/pdf/2211.10435.pdf)).
|
7 |
"""
|
8 |
|
9 |
import minichain
|
qa.log
CHANGED
@@ -1,4 +1,10 @@
|
|
1 |
-
{"action_status": "started", "timestamp":
|
2 |
-
{"action_status": "succeeded", "timestamp":
|
3 |
-
{"action_status": "started", "timestamp":
|
4 |
-
{"action_status": "succeeded", "timestamp":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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]}
|
qa.py
CHANGED
@@ -1,8 +1,10 @@
|
|
1 |
# + tags=["hide_inp"]
|
2 |
desc = """
|
3 |
-
|
4 |
|
5 |
-
|
|
|
|
|
6 |
"""
|
7 |
# -
|
8 |
|
@@ -37,10 +39,14 @@ class QAPrompt(TemplatePrompt):
|
|
37 |
with start_chain("qa") as backend:
|
38 |
prompt = KNNPrompt(backend.OpenAIEmbed()).chain(QAPrompt(backend.OpenAI()))
|
39 |
|
40 |
-
|
|
|
|
|
|
|
|
|
41 |
|
42 |
gradio = prompt.to_gradio(fields=["query"],
|
43 |
-
examples=
|
44 |
description=desc)
|
45 |
if __name__ == "__main__":
|
46 |
gradio.launch()
|
|
|
1 |
# + tags=["hide_inp"]
|
2 |
desc = """
|
3 |
+
### Question Answering with Retrieval
|
4 |
|
5 |
+
Chain that answers questions with embeedding based retrieval. [[Code](https://github.com/srush/MiniChain/blob/main/examples/qa.py)]
|
6 |
+
|
7 |
+
(Adapted from [OpenAI Notebook](https://github.com/openai/openai-cookbook/blob/main/examples/Question_answering_using_embeddings.ipynb).)
|
8 |
"""
|
9 |
# -
|
10 |
|
|
|
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?",
|
44 |
+
"In the 2020 Summer Olympics, how many gold medals did the country which won the most medals win?",
|
45 |
+
"What is the total number of medals won by France?",
|
46 |
+
"What is the tallest mountain in the world?"]
|
47 |
|
48 |
gradio = prompt.to_gradio(fields=["query"],
|
49 |
+
examples=questions,
|
50 |
description=desc)
|
51 |
if __name__ == "__main__":
|
52 |
gradio.launch()
|
stats.log
CHANGED
@@ -1,2 +1,8 @@
|
|
1 |
-
{"action_status": "started", "timestamp":
|
2 |
-
{"action_status": "succeeded", "timestamp":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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]}
|
stats.py
CHANGED
@@ -1,8 +1,10 @@
|
|
1 |
|
2 |
desc = """
|
3 |
-
|
4 |
|
5 |
-
Information extraction from a typed
|
|
|
|
|
6 |
"""
|
7 |
|
8 |
import minichain
|
@@ -47,7 +49,7 @@ article = open("sixers.txt").read()
|
|
47 |
gradio = prompt.to_gradio(fields =["passage"],
|
48 |
examples=[article],
|
49 |
out_type="json",
|
50 |
-
desc
|
51 |
)
|
52 |
if __name__ == "__main__":
|
53 |
gradio.launch()
|
|
|
1 |
|
2 |
desc = """
|
3 |
+
### Typed Extraction
|
4 |
|
5 |
+
Information extraction that is automatically generated from a typed specification. [[Code](https://github.com/srush/MiniChain/blob/main/examples/stats.py)]
|
6 |
+
|
7 |
+
(Novel to MiniChain)
|
8 |
"""
|
9 |
|
10 |
import minichain
|
|
|
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()
|