srush HF staff commited on
Commit
7b856a8
1 Parent(s): 21c809f

Upload with huggingface_hub

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
#math_demo.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")
#qa.py# ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # # QA
2
+
3
+ # Questions answering with embeddings. Adapted from [OpenAI
4
+ # Notebook](https://github.com/openai/openai-cookbook/blob/main/examples/Question_answering_using_embeddings.ipynb).
5
+
6
+ import datasets
7
+ import numpy as np
8
+ from minichain import EmbeddingPrompt, TemplatePrompt, show_log, start_chain
9
+
10
+ # We use Hugging Face Datasets as the database by assigning
11
+ # a FAISS index.
12
+
13
+ olympics = datasets.load_from_disk("olympics.data")
14
+ olympics.add_faiss_index("embeddings")
15
+
16
+
17
+ # Fast KNN retieval prompt
18
+
19
+
20
+ class KNNPrompt(EmbeddingPrompt):
21
+ def find(self, out, inp):
22
+ res = olympics.get_nearest_examples("embeddings", np.array(out), 3)
23
+ return {"question": inp, "docs": res.examples["content"]}
24
+
25
+
26
+ # QA prompt to ask question with examples
27
+
28
+
29
+ class QAPrompt(TemplatePrompt):
30
+ template_file = "qa.pmpt.tpl"
31
+
32
+
33
+ with start_chain("qa") as backend:
34
+ question = "Who won the 2020 Summer Olympics men's high jump?"
35
+ prompt = KNNPrompt(backend.OpenAIEmbed()).chain(QAPrompt(backend.OpenAI()))
36
+ result = prompt(question)
37
+ print(result)
38
+
39
+ # + tags=["hide_inp"]
40
+ QAPrompt().show(
41
+ {"question": "Who won the race?", "docs": ["doc1", "doc2", "doc3"]}, "Joe Bob"
42
+ )
43
+ # -
44
+
45
+ show_log("qa.log")
#selfask.py# ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Notebook implementation of the self-ask + Google tool use prompt.
2
+ # Adapted from https://github.com/ofirpress/self-ask
3
+
4
+ from dataclasses import dataclass
5
+
6
+ from parsita import *
7
+
8
+ import minichain
9
+
10
+ # Define the state of the bot.
11
+
12
+ @dataclass
13
+ class IntermediateState:
14
+ s: str
15
+
16
+ @dataclass
17
+ class FinalState:
18
+ s: str
19
+
20
+ @dataclass
21
+ class Out:
22
+ echo: str
23
+ state: FinalState | IntermediateState
24
+
25
+
26
+ # Self Ask Prompt
27
+
28
+ class SelfAsk(minichain.TemplatePrompt[Out]):
29
+ template_file = "selfask.pmpt.tpl"
30
+ stop_template = "\nIntermediate answer:"
31
+
32
+ # Parsita parser.
33
+ class Parser(TextParsers):
34
+ follow = (lit("Follow up:") >> reg(r".*")) > IntermediateState
35
+ finish = (lit("So the final answer is: ") >> reg(r".*")) > FinalState
36
+ response = follow | finish
37
+
38
+ def parse(self, response: str, inp) -> Out:
39
+ return Out(
40
+ self.prompt(inp).prompt + response,
41
+ self.Parser.response.parse(response).or_die(),
42
+ )
43
+
44
+ # Runtime loop
45
+
46
+ def selfask(inp: str, openai, google) -> str:
47
+ prompt1 = SelfAsk(openai)
48
+ prompt2 = minichain.SimplePrompt(google)
49
+ suffix = ""
50
+ for i in range(3):
51
+ out = prompt1(dict(input=inp, suffix=suffix, agent_scratchpad=True))
52
+
53
+ if isinstance(out.state, FinalState):
54
+ break
55
+ suffix += out.echo
56
+ out2 = prompt2(out.state.s)
57
+ suffix += "\nIntermediate answer: " + out2 + "\n"
58
+ return out.state.s
59
+
60
+
61
+ with minichain.start_chain("selfask") as backend:
62
+ result = selfask(
63
+ "What is the zip code of the city where George Washington was born?",
64
+ backend.OpenAI(),
65
+ backend.Google(),
66
+ )
67
+ print(result)
68
+
69
+ # View prompt examples.
70
+
71
+ # + tags=["hide_inp"]
72
+ SelfAsk().show(
73
+ {
74
+ "input": "What is the zip code of the city where George Washington was born?",
75
+ "agent_scratchpad": True,
76
+ },
77
+ "Follow up: Where was George Washington born?",
78
+ )
79
+ # -
80
+
81
+ # View log.
82
+
83
+ minichain.show_log("selfask.log")
__pycache__/bash.cpython-310.pyc ADDED
Binary file (1.44 kB). View file
 
__pycache__/chat.cpython-310.pyc ADDED
Binary file (2.54 kB). View file
 
__pycache__/examples.cpython-310.pyc ADDED
Binary file (1.35 kB). View file
 
__pycache__/gatsby.cpython-310.pyc ADDED
Binary file (1.44 kB). View file
 
__pycache__/math.cpython-310.pyc ADDED
Binary file (799 Bytes). View file
 
__pycache__/math_demo.cpython-310.pyc ADDED
Binary file (790 Bytes). View file
 
__pycache__/ner.cpython-310.pyc ADDED
Binary file (1.62 kB). View file
 
__pycache__/pal.cpython-310.pyc ADDED
Binary file (1.3 kB). View file
 
__pycache__/stats.cpython-310.pyc ADDED
Binary file (1.42 kB). View file
 
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from chat import gradio as chat
3
+ from ner import gradio as ner
4
+ from math_demo import gradio as math_demo
5
+ from bash import gradio as bash
6
+ from pal import gradio as pal
7
+ from gatsby import gradio as gatsby
8
+ from qa import gradio as qa
9
+ from stats import gradio as stats
10
+
11
+ css = "#clean div.form {border: 0px} #response {border: 0px; background: #ffeec6} #prompt {border: 0px;background: aliceblue} #json {border: 0px} #result {border: 0px; background: #c5e0e5} #inner {padding: 20px} #inner textarea {border: 0px} .tabs div.tabitem {border: 0px}"
12
+
13
+ with gr.Blocks(css=css) as demo:
14
+ gr.HTML("<center> <img width='10%' style='display:inline; padding: 5px' src='https://user-images.githubusercontent.com/35882/218286642-67985b6f-d483-49be-825b-f62b72c469cd.png'> <h1 style='display:inline'> Mini-Chain </h1> <img width='10%' style='display:inline;padding: 5px' src='https://avatars.githubusercontent.com/u/25720743?s=200&v=4'> </center><br><center><a href='https://github.com/srush/minichain'>[code]</a> <a href='https://user-images.githubusercontent.com/35882/218286642-67985b6f-d483-49be-825b-f62b72c469cd.png'>[docs]</a></center>")
15
+
16
+ gr.TabbedInterface([chat, qa, gatsby, math_demo, ner, bash, pal, stats],
17
+ ["Chat", "QA", "Book", "Math", "NER", "Bash", "PAL", "Stats"],
18
+ css= css)
19
+
20
+ demo.launch()
21
+
base.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Prompt from ...
2
+ #
3
+
4
+ prompt = """
5
+ Question: Who lived longer, Muhammad Ali or Alan Turing?
6
+ Are follow up questions needed here: Yes.
7
+ Follow up: How old was Muhammad Ali when he died?
8
+ Intermediate answer: Muhammad Ali was 74 years old when he died.
9
+ Follow up: How old was Alan Turing when he died?
10
+ Intermediate answer: Alan Turing was 41 years old when he died.
11
+ So the final answer is: Muhammad Ali
12
+
13
+ Question: When was the founder of craigslist born?
14
+ Are follow up questions needed here: Yes.
15
+ Follow up: Who was the founder of craigslist?
16
+ Intermediate answer: Craigslist was founded by Craig Newmark.
17
+ Follow up: When was Craig Newmark born?
18
+ Intermediate answer: Craig Newmark was born on December 6, 1952.
19
+ So the final answer is: December 6, 1952
20
+
21
+ Question: Who was the maternal grandfather of George Washington?
22
+ Are follow up questions needed here: Yes.
23
+ Follow up: Who was the mother of George Washington?
24
+ Intermediate answer: The mother of George Washington was Mary Ball Washington.
25
+ Follow up: Who was the father of Mary Ball Washington?
26
+ Intermediate answer: The father of Mary Ball Washington was Joseph Ball.
27
+ So the final answer is: Joseph Ball
28
+
29
+ Question: Are both the directors of Jaws and Casino Royale from the same country?
30
+ Are follow up questions needed here: Yes.
31
+ Follow up: Who is the director of Jaws?
32
+ Intermediate answer: The director of Jaws is Steven Spielberg.
33
+ Follow up: Where is Steven Spielberg from?
34
+ Intermediate answer: The United States.
35
+ Follow up: Who is the director of Casino Royale?
36
+ Intermediate answer: The director of Casino Royale is Martin Campbell.
37
+ Follow up: Where is Martin Campbell from?
38
+ Intermediate answer: New Zealand.
39
+ So the final answer is: No
40
+
41
+ Question: {{input}}
42
+ Are followup questions needed here: {% if agent_scratchpad %}Yes{%else%}No{% endif %}.
43
+ """
44
+
45
+ import jinja2
46
+
47
+ class SelfAsk:
48
+ def render(self, input: str, agent_scratchpad: bool):
49
+ return jinja.render(prompt, dict(input=input,
50
+ agent_scatchpad=agent_scratchpad))
51
+
52
+ def parse(self, response: str):
53
+ pass
54
+
55
+
56
+ def stop(self):
57
+ return []
base.sh ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ export OPENAI_KEY="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"
2
+ export SERP_KEY="593a073fa4c730efe918e592a538b36e80841bc8f8dd4070c1566920f75ba140"
bash.html ADDED
The diff for this file is too large to render. See raw diff
 
bash.ipynb ADDED
@@ -0,0 +1,412 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "27962df3",
6
+ "metadata": {},
7
+ "source": [
8
+ "Notebook to generate and run a bash command.\n",
9
+ "Adapted from LangChain\n",
10
+ "[BashChain](https://langchain.readthedocs.io/en/latest/modules/chains/examples/llm_bash.html)"
11
+ ]
12
+ },
13
+ {
14
+ "cell_type": "code",
15
+ "execution_count": 1,
16
+ "id": "e01d45bc",
17
+ "metadata": {
18
+ "execution": {
19
+ "iopub.execute_input": "2023-02-27T14:12:17.548344Z",
20
+ "iopub.status.busy": "2023-02-27T14:12:17.547695Z",
21
+ "iopub.status.idle": "2023-02-27T14:12:17.767947Z",
22
+ "shell.execute_reply": "2023-02-27T14:12:17.767208Z"
23
+ }
24
+ },
25
+ "outputs": [],
26
+ "source": [
27
+ "import minichain"
28
+ ]
29
+ },
30
+ {
31
+ "cell_type": "markdown",
32
+ "id": "b2caf597",
33
+ "metadata": {
34
+ "lines_to_next_cell": 2
35
+ },
36
+ "source": [
37
+ "Prompt that asks LLM to produce a bash command."
38
+ ]
39
+ },
40
+ {
41
+ "cell_type": "code",
42
+ "execution_count": 2,
43
+ "id": "8669ca4e",
44
+ "metadata": {
45
+ "execution": {
46
+ "iopub.execute_input": "2023-02-27T14:12:17.773257Z",
47
+ "iopub.status.busy": "2023-02-27T14:12:17.771880Z",
48
+ "iopub.status.idle": "2023-02-27T14:12:17.778057Z",
49
+ "shell.execute_reply": "2023-02-27T14:12:17.777432Z"
50
+ },
51
+ "lines_to_next_cell": 2
52
+ },
53
+ "outputs": [],
54
+ "source": [
55
+ "class CLIPrompt(minichain.TemplatePrompt):\n",
56
+ " template_file = \"bash.pmpt.tpl\"\n",
57
+ "\n",
58
+ " def parse(self, out: str, inp):\n",
59
+ " out = out.strip()\n",
60
+ " assert out.startswith(\"```bash\")\n",
61
+ " return out.split(\"\\n\")[1:-1]"
62
+ ]
63
+ },
64
+ {
65
+ "cell_type": "markdown",
66
+ "id": "79cc544e",
67
+ "metadata": {
68
+ "lines_to_next_cell": 2
69
+ },
70
+ "source": [
71
+ "Prompt that runs the bash command."
72
+ ]
73
+ },
74
+ {
75
+ "cell_type": "code",
76
+ "execution_count": 3,
77
+ "id": "db1e09b6",
78
+ "metadata": {
79
+ "execution": {
80
+ "iopub.execute_input": "2023-02-27T14:12:17.782732Z",
81
+ "iopub.status.busy": "2023-02-27T14:12:17.781591Z",
82
+ "iopub.status.idle": "2023-02-27T14:12:17.787303Z",
83
+ "shell.execute_reply": "2023-02-27T14:12:17.786651Z"
84
+ }
85
+ },
86
+ "outputs": [],
87
+ "source": [
88
+ "class BashPrompt(minichain.Prompt):\n",
89
+ " def prompt(self, inp) -> str:\n",
90
+ " return \";\".join(inp).replace(\"\\n\", \"\")\n",
91
+ "\n",
92
+ " def parse(self, out: str, inp) -> str:\n",
93
+ " return out"
94
+ ]
95
+ },
96
+ {
97
+ "cell_type": "markdown",
98
+ "id": "5b993ae8",
99
+ "metadata": {},
100
+ "source": [
101
+ "Generate and run bash command."
102
+ ]
103
+ },
104
+ {
105
+ "cell_type": "code",
106
+ "execution_count": 4,
107
+ "id": "17572fff",
108
+ "metadata": {
109
+ "execution": {
110
+ "iopub.execute_input": "2023-02-27T14:12:17.792430Z",
111
+ "iopub.status.busy": "2023-02-27T14:12:17.791251Z",
112
+ "iopub.status.idle": "2023-02-27T14:12:19.652953Z",
113
+ "shell.execute_reply": "2023-02-27T14:12:19.650586Z"
114
+ }
115
+ },
116
+ "outputs": [
117
+ {
118
+ "name": "stdout",
119
+ "output_type": "stream",
120
+ "text": [
121
+ "#backend.py#\n",
122
+ "backend.py\n",
123
+ "base.py\n",
124
+ "__init__.py\n",
125
+ "lang.py\n",
126
+ "prompts.py\n",
127
+ "__pycache__\n",
128
+ "templates\n",
129
+ "\n"
130
+ ]
131
+ }
132
+ ],
133
+ "source": [
134
+ "with minichain.start_chain(\"bash\") as backend:\n",
135
+ " question = (\n",
136
+ " '\"go up one directory, and then into the minichain directory,'\n",
137
+ " 'and list the files in the directory\"'\n",
138
+ " )\n",
139
+ " prompt = CLIPrompt(backend.OpenAI()).chain(BashPrompt(backend.BashProcess()))\n",
140
+ " result = prompt({\"question\": question})\n",
141
+ " print(result)"
142
+ ]
143
+ },
144
+ {
145
+ "cell_type": "markdown",
146
+ "id": "aadedf29",
147
+ "metadata": {},
148
+ "source": [
149
+ "View the prompts."
150
+ ]
151
+ },
152
+ {
153
+ "cell_type": "code",
154
+ "execution_count": 5,
155
+ "id": "0e1c2f1a",
156
+ "metadata": {
157
+ "execution": {
158
+ "iopub.execute_input": "2023-02-27T14:12:19.662941Z",
159
+ "iopub.status.busy": "2023-02-27T14:12:19.661254Z",
160
+ "iopub.status.idle": "2023-02-27T14:12:19.738758Z",
161
+ "shell.execute_reply": "2023-02-27T14:12:19.738197Z"
162
+ },
163
+ "lines_to_next_cell": 2,
164
+ "tags": [
165
+ "hide_inp"
166
+ ]
167
+ },
168
+ "outputs": [
169
+ {
170
+ "data": {
171
+ "text/html": [
172
+ "\n",
173
+ "<!-- <link rel=\"stylesheet\" href=\"https://cdn.rawgit.com/Chalarangelo/mini.css/v3.0.1/dist/mini-default.min.css\"> -->\n",
174
+ " <main class=\"container\">\n",
175
+ "\n",
176
+ "<h3>CLIPrompt</h3>\n",
177
+ "\n",
178
+ "<dl>\n",
179
+ " <dt>Input:</dt>\n",
180
+ " <dd>\n",
181
+ "<div class=\"highlight\"><pre><span></span><span class=\"p\">{</span><span class=\"s1\">&#39;question&#39;</span><span class=\"p\">:</span> <span class=\"s1\">&#39;list the files in the directory&#39;</span><span class=\"p\">}</span>\n",
182
+ "</pre></div>\n",
183
+ "\n",
184
+ "\n",
185
+ " </dd>\n",
186
+ "\n",
187
+ " <dt> Full Prompt: </dt>\n",
188
+ " <dd>\n",
189
+ " <details>\n",
190
+ " <summary>Prompt</summary>\n",
191
+ " <p>If someone asks you to perform a task, your job is to come up with a series of bash commands that will perform the task. There is no need to put \"#!/bin/bash\" in your answer. Make sure to reason step by step, using this format:<br><br>Question: \"copy the files in the directory named 'target' into a new directory at the same level as target called 'myNewDirectory'\"<br><br>I need to take the following actions:<br>- List all files in the directory<br>- Create a new directory<br>- Copy the files from the first directory into the second directory<br>```bash<br>ls<br>mkdir myNewDirectory<br>cp -r target/* myNewDirectory<br>```<br><br>That is the format. Begin!<br><br>Question: <div style='color:red'>list the files in the directory</div></p>\n",
192
+ " </details>\n",
193
+ " </dd>\n",
194
+ "\n",
195
+ " <dt> Response: </dt>\n",
196
+ " <dd>\n",
197
+ " ```bash<br>ls<br>```\n",
198
+ " </dd>\n",
199
+ "\n",
200
+ " <dt>Value:</dt>\n",
201
+ " <dd>\n",
202
+ "<div class=\"highlight\"><pre><span></span><span class=\"p\">[</span><span class=\"s1\">&#39;ls&#39;</span><span class=\"p\">]</span>\n",
203
+ "</pre></div>\n",
204
+ "\n",
205
+ " </dd>\n",
206
+ "</main>\n"
207
+ ],
208
+ "text/plain": [
209
+ "HTML(html='\\n<!-- <link rel=\"stylesheet\" href=\"https://cdn.rawgit.com/Chalarangelo/mini.css/v3.0.1/dist/mini-default.min.css\"> -->\\n <main class=\"container\">\\n\\n<h3>CLIPrompt</h3>\\n\\n<dl>\\n <dt>Input:</dt>\\n <dd>\\n<div class=\"highlight\"><pre><span></span><span class=\"p\">{</span><span class=\"s1\">&#39;question&#39;</span><span class=\"p\">:</span> <span class=\"s1\">&#39;list the files in the directory&#39;</span><span class=\"p\">}</span>\\n</pre></div>\\n\\n\\n </dd>\\n\\n <dt> Full Prompt: </dt>\\n <dd>\\n <details>\\n <summary>Prompt</summary>\\n <p>If someone asks you to perform a task, your job is to come up with a series of bash commands that will perform the task. There is no need to put \"#!/bin/bash\" in your answer. Make sure to reason step by step, using this format:<br><br>Question: \"copy the files in the directory named \\'target\\' into a new directory at the same level as target called \\'myNewDirectory\\'\"<br><br>I need to take the following actions:<br>- List all files in the directory<br>- Create a new directory<br>- Copy the files from the first directory into the second directory<br>```bash<br>ls<br>mkdir myNewDirectory<br>cp -r target/* myNewDirectory<br>```<br><br>That is the format. Begin!<br><br>Question: <div style=\\'color:red\\'>list the files in the directory</div></p>\\n </details>\\n </dd>\\n\\n <dt> Response: </dt>\\n <dd>\\n ```bash<br>ls<br>```\\n </dd>\\n\\n <dt>Value:</dt>\\n <dd>\\n<div class=\"highlight\"><pre><span></span><span class=\"p\">[</span><span class=\"s1\">&#39;ls&#39;</span><span class=\"p\">]</span>\\n</pre></div>\\n\\n </dd>\\n</main>\\n')"
210
+ ]
211
+ },
212
+ "execution_count": 5,
213
+ "metadata": {},
214
+ "output_type": "execute_result"
215
+ }
216
+ ],
217
+ "source": [
218
+ "CLIPrompt().show(\n",
219
+ " {\"question\": \"list the files in the directory\"}, \"\"\"```bash\\nls\\n```\"\"\"\n",
220
+ ")"
221
+ ]
222
+ },
223
+ {
224
+ "cell_type": "code",
225
+ "execution_count": 6,
226
+ "id": "79cf9c84",
227
+ "metadata": {
228
+ "execution": {
229
+ "iopub.execute_input": "2023-02-27T14:12:19.740976Z",
230
+ "iopub.status.busy": "2023-02-27T14:12:19.740788Z",
231
+ "iopub.status.idle": "2023-02-27T14:12:19.745592Z",
232
+ "shell.execute_reply": "2023-02-27T14:12:19.745136Z"
233
+ },
234
+ "tags": [
235
+ "hide_inp"
236
+ ]
237
+ },
238
+ "outputs": [
239
+ {
240
+ "data": {
241
+ "text/html": [
242
+ "\n",
243
+ "<!-- <link rel=\"stylesheet\" href=\"https://cdn.rawgit.com/Chalarangelo/mini.css/v3.0.1/dist/mini-default.min.css\"> -->\n",
244
+ " <main class=\"container\">\n",
245
+ "\n",
246
+ "<h3>BashPrompt</h3>\n",
247
+ "\n",
248
+ "<dl>\n",
249
+ " <dt>Input:</dt>\n",
250
+ " <dd>\n",
251
+ "<div class=\"highlight\"><pre><span></span><span class=\"p\">[</span><span class=\"s1\">&#39;ls&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;cat file.txt&#39;</span><span class=\"p\">]</span>\n",
252
+ "</pre></div>\n",
253
+ "\n",
254
+ "\n",
255
+ " </dd>\n",
256
+ "\n",
257
+ " <dt> Full Prompt: </dt>\n",
258
+ " <dd>\n",
259
+ " <details>\n",
260
+ " <summary>Prompt</summary>\n",
261
+ " <p>ls;cat file.txt</p>\n",
262
+ " </details>\n",
263
+ " </dd>\n",
264
+ "\n",
265
+ " <dt> Response: </dt>\n",
266
+ " <dd>\n",
267
+ " hello\n",
268
+ " </dd>\n",
269
+ "\n",
270
+ " <dt>Value:</dt>\n",
271
+ " <dd>\n",
272
+ "<div class=\"highlight\"><pre><span></span><span class=\"n\">hello</span>\n",
273
+ "</pre></div>\n",
274
+ "\n",
275
+ " </dd>\n",
276
+ "</main>\n"
277
+ ],
278
+ "text/plain": [
279
+ "HTML(html='\\n<!-- <link rel=\"stylesheet\" href=\"https://cdn.rawgit.com/Chalarangelo/mini.css/v3.0.1/dist/mini-default.min.css\"> -->\\n <main class=\"container\">\\n\\n<h3>BashPrompt</h3>\\n\\n<dl>\\n <dt>Input:</dt>\\n <dd>\\n<div class=\"highlight\"><pre><span></span><span class=\"p\">[</span><span class=\"s1\">&#39;ls&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;cat file.txt&#39;</span><span class=\"p\">]</span>\\n</pre></div>\\n\\n\\n </dd>\\n\\n <dt> Full Prompt: </dt>\\n <dd>\\n <details>\\n <summary>Prompt</summary>\\n <p>ls;cat file.txt</p>\\n </details>\\n </dd>\\n\\n <dt> Response: </dt>\\n <dd>\\n hello\\n </dd>\\n\\n <dt>Value:</dt>\\n <dd>\\n<div class=\"highlight\"><pre><span></span><span class=\"n\">hello</span>\\n</pre></div>\\n\\n </dd>\\n</main>\\n')"
280
+ ]
281
+ },
282
+ "execution_count": 6,
283
+ "metadata": {},
284
+ "output_type": "execute_result"
285
+ }
286
+ ],
287
+ "source": [
288
+ "BashPrompt().show([\"ls\", \"cat file.txt\"], \"hello\")"
289
+ ]
290
+ },
291
+ {
292
+ "cell_type": "markdown",
293
+ "id": "89c7bc6c",
294
+ "metadata": {},
295
+ "source": [
296
+ "View the run log."
297
+ ]
298
+ },
299
+ {
300
+ "cell_type": "code",
301
+ "execution_count": 7,
302
+ "id": "7dbcec08",
303
+ "metadata": {
304
+ "execution": {
305
+ "iopub.execute_input": "2023-02-27T14:12:19.748151Z",
306
+ "iopub.status.busy": "2023-02-27T14:12:19.747899Z",
307
+ "iopub.status.idle": "2023-02-27T14:12:19.768720Z",
308
+ "shell.execute_reply": "2023-02-27T14:12:19.768248Z"
309
+ }
310
+ },
311
+ "outputs": [
312
+ {
313
+ "name": "stderr",
314
+ "output_type": "stream",
315
+ "text": [
316
+ "\u001b[38;5;15mfc682a98-f50a-4837-8b6d-87e843c19732\u001b[1m\u001b[0m\n",
317
+ "└── \u001b[38;5;5m<class '__main__.CLIPrompt'>\u001b[0m/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:12:18Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m1.531s\u001b[2m\u001b[0m\n",
318
+ " ├── \u001b[38;5;5mInput Function\u001b[0m/2/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:12:18Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m0.003s\u001b[2m\u001b[0m\n",
319
+ " │ ├── \u001b[38;5;4minput\u001b[0m: \u001b[0m\n",
320
+ " │ │ └── \u001b[38;5;4mquestion\u001b[0m: \"go up one directory, and then into the minichain directory,and list the files in the directory\"\u001b[0m\n",
321
+ " │ └── \u001b[38;5;5mInput Function\u001b[0m/2/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:12:18Z\u001b[2m\u001b[0m\n",
322
+ " ├── \u001b[38;5;5mPrompted\u001b[0m/3/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:12:18Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m1.528s\u001b[2m\u001b[0m\n",
323
+ " │ ├── \u001b[38;5;4mprompt\u001b[0m: If someone asks you to perform a task, your job is to come up with a series of bash commands that will perform the task. There is no need to put \"#!/bin/bash\" in your answer. Make sure to reason step by step, using this format:⏎\n",
324
+ " │ │ ⏎\n",
325
+ " │ │ Question: \"copy the files in the directory named 'target' into a new directory at the same level as target called 'myNewDirectory'\"⏎\n",
326
+ " │ │ ⏎\n",
327
+ " │ │ I need to take the following actions:⏎\n",
328
+ " │ │ - List all files in the directory⏎\n",
329
+ " │ │ - Create a new directory⏎\n",
330
+ " │ │ - Copy the files from the first directory into the second directory⏎\n",
331
+ " │ │ ```bash⏎\n",
332
+ " │ │ ls⏎\n",
333
+ " │ │ mkdir myNewDirectory⏎\n",
334
+ " │ │ cp -r target/* myNewDirectory⏎\n",
335
+ " │ │ ```⏎\n",
336
+ " │ │ ⏎\n",
337
+ " │ │ That is the format. Begin!⏎\n",
338
+ " │ │ ⏎\n",
339
+ " │ │ Question: \"go up one directory, and then into the minichain directory,and list the files in the directory\"\u001b[0m\n",
340
+ " │ └── \u001b[38;5;5mPrompted\u001b[0m/3/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:12:19Z\u001b[2m\u001b[0m\n",
341
+ " ├── \u001b[38;5;5mResult\u001b[0m/4/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:12:19Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m0.000s\u001b[2m\u001b[0m\n",
342
+ " │ ├── \u001b[38;5;4mresult\u001b[0m: ⏎\n",
343
+ " │ │ ⏎\n",
344
+ " │ │ ```bash⏎\n",
345
+ " │ │ cd ..⏎\n",
346
+ " │ │ cd minichain⏎\n",
347
+ " │ │ ls⏎\n",
348
+ " │ │ ```\u001b[0m\n",
349
+ " │ └── \u001b[38;5;5mResult\u001b[0m/4/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:12:19Z\u001b[2m\u001b[0m\n",
350
+ " └── \u001b[38;5;5m<class '__main__.CLIPrompt'>\u001b[0m/5\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:12:19Z\u001b[2m\u001b[0m\n",
351
+ "\n",
352
+ "\u001b[38;5;15m328e2368-6c0f-4a03-ae78-26aa43a517e3\u001b[1m\u001b[0m\n",
353
+ "└── \u001b[38;5;5m<class '__main__.BashPrompt'>\u001b[0m/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:12:19Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m0.006s\u001b[2m\u001b[0m\n",
354
+ " ├── \u001b[38;5;5mInput Function\u001b[0m/2/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:12:19Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m0.000s\u001b[2m\u001b[0m\n",
355
+ " │ ├── \u001b[38;5;4minput\u001b[0m: \u001b[0m\n",
356
+ " │ │ ├── \u001b[38;5;4m0\u001b[0m: cd ..\u001b[0m\n",
357
+ " │ │ ├── \u001b[38;5;4m1\u001b[0m: cd minichain\u001b[0m\n",
358
+ " │ │ └── \u001b[38;5;4m2\u001b[0m: ls\u001b[0m\n",
359
+ " │ └── \u001b[38;5;5mInput Function\u001b[0m/2/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:12:19Z\u001b[2m\u001b[0m\n",
360
+ " ├── \u001b[38;5;5mPrompted\u001b[0m/3/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:12:19Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m0.005s\u001b[2m\u001b[0m\n",
361
+ " │ ├── \u001b[38;5;4mprompt\u001b[0m: cd ..;cd minichain;ls\u001b[0m\n",
362
+ " │ └── \u001b[38;5;5mPrompted\u001b[0m/3/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:12:19Z\u001b[2m\u001b[0m\n",
363
+ " ├── \u001b[38;5;5mResult\u001b[0m/4/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:12:19Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m0.000s\u001b[2m\u001b[0m\n",
364
+ " │ ├── \u001b[38;5;4mresult\u001b[0m: #backend.py#⏎\n",
365
+ " │ │ backend.py⏎\n",
366
+ " │ │ base.py⏎\n",
367
+ " │ │ __init__.py⏎\n",
368
+ " │ │ lang.py⏎\n",
369
+ " │ │ prompts.py⏎\n",
370
+ " │ │ __pycache__⏎\n",
371
+ " │ │ templates⏎\n",
372
+ " │ │ \u001b[0m\n",
373
+ " │ └── \u001b[38;5;5mResult\u001b[0m/4/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:12:19Z\u001b[2m\u001b[0m\n",
374
+ " └── \u001b[38;5;5m<class '__main__.BashPrompt'>\u001b[0m/5\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:12:19Z\u001b[2m\u001b[0m\n",
375
+ "\n",
376
+ "\u001b[38;5;15mca5f4b25-55ca-441d-a0d2-f39ad0bca2d0\u001b[1m\u001b[0m\n",
377
+ "└── \u001b[38;5;5mbash\u001b[0m/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:12:17Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m1.850s\u001b[2m\u001b[0m\n",
378
+ " └── \u001b[38;5;5mbash\u001b[0m/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:12:19Z\u001b[2m\u001b[0m\n",
379
+ "\n"
380
+ ]
381
+ }
382
+ ],
383
+ "source": [
384
+ "minichain.show_log(\"bash.log\")"
385
+ ]
386
+ }
387
+ ],
388
+ "metadata": {
389
+ "jupytext": {
390
+ "cell_metadata_filter": "tags,-all"
391
+ },
392
+ "kernelspec": {
393
+ "display_name": "minichain",
394
+ "language": "python",
395
+ "name": "minichain"
396
+ },
397
+ "language_info": {
398
+ "codemirror_mode": {
399
+ "name": "ipython",
400
+ "version": 3
401
+ },
402
+ "file_extension": ".py",
403
+ "mimetype": "text/x-python",
404
+ "name": "python",
405
+ "nbconvert_exporter": "python",
406
+ "pygments_lexer": "ipython3",
407
+ "version": "3.10.6"
408
+ }
409
+ },
410
+ "nbformat": 4,
411
+ "nbformat_minor": 5
412
+ }
bash.log ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {"action_status": "started", "timestamp": 1678759606.621539, "task_uuid": "b1f606f3-d7b6-48bb-a3a5-77e51fda3fa6", "action_type": "bash", "task_level": [1]}
2
+ {"action_status": "succeeded", "timestamp": 1678759606.6216574, "task_uuid": "b1f606f3-d7b6-48bb-a3a5-77e51fda3fa6", "action_type": "bash", "task_level": [2]}
3
+ {"action_status": "started", "timestamp": 1678759606.6456344, "task_uuid": "147ddfba-ef61-4a52-9f0c-1107c3fbaa6a", "action_type": "pal", "task_level": [1]}
4
+ {"action_status": "succeeded", "timestamp": 1678759606.645799, "task_uuid": "147ddfba-ef61-4a52-9f0c-1107c3fbaa6a", "action_type": "pal", "task_level": [2]}
5
+ {"action_status": "started", "timestamp": 1678759606.9333436, "task_uuid": "3246fe37-fa91-436b-96be-67648cd1ef76", "action_type": "gatsby", "task_level": [1]}
6
+ {"action_status": "succeeded", "timestamp": 1678759606.9335442, "task_uuid": "3246fe37-fa91-436b-96be-67648cd1ef76", "action_type": "gatsby", "task_level": [2]}
7
+ {"action_status": "started", "timestamp": 1678759606.9647467, "task_uuid": "86f09cf7-ec3b-41eb-aac0-144426f1a6f4", "action_type": "stats", "task_level": [1]}
8
+ {"action_status": "succeeded", "timestamp": 1678759606.964883, "task_uuid": "86f09cf7-ec3b-41eb-aac0-144426f1a6f4", "action_type": "stats", "task_level": [2]}
bash.pmpt.tpl ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ If someone asks you to perform a task, your job is to come up with a series of bash commands that will perform the task. There is no need to put "#!/bin/bash" in your answer. Make sure to reason step by step, using this format:
2
+
3
+ Question: "copy the files in the directory named 'target' into a new directory at the same level as target called 'myNewDirectory'"
4
+
5
+ I need to take the following actions:
6
+ - List all files in the directory
7
+ - Create a new directory
8
+ - Copy the files from the first directory into the second directory
9
+ ```bash
10
+ ls
11
+ mkdir myNewDirectory
12
+ cp -r target/* myNewDirectory
13
+ ```
14
+
15
+ That is the format. Begin!
16
+
17
+ Question: "{{question}}"
bash.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Notebook to generate and run a bash command.
2
+ # Adapted from LangChain
3
+ # [BashChain](https://langchain.readthedocs.io/en/latest/modules/chains/examples/llm_bash.html)
4
+
5
+ import minichain
6
+
7
+ # Prompt that asks LLM to produce a bash command.
8
+
9
+
10
+ class CLIPrompt(minichain.TemplatePrompt):
11
+ template_file = "bash.pmpt.tpl"
12
+
13
+ def parse(self, out: str, inp):
14
+ out = out.strip()
15
+ assert out.startswith("```bash")
16
+ return out.split("\n")[1:-1]
17
+
18
+
19
+ # Prompt that runs the bash command.
20
+
21
+
22
+ class BashPrompt(minichain.Prompt):
23
+ def prompt(self, inp) -> str:
24
+ return ";".join(inp).replace("\n", "")
25
+
26
+ def parse(self, out: str, inp) -> str:
27
+ return out
28
+
29
+
30
+ # Generate and run bash command.
31
+
32
+ with minichain.start_chain("bash") as backend:
33
+ question = (
34
+
35
+ )
36
+ prompt = CLIPrompt(backend.OpenAI()).chain(BashPrompt(backend.BashProcess()))
37
+
38
+ gradio = prompt.to_gradio(fields =["question"],
39
+ examples=['Go up one directory, and then into the minichain directory,'
40
+ 'and list the files in the directory'],
41
+ out_type="markdown"
42
+
43
+ )
44
+ if __name__ == "__main__":
45
+ gradio.launch()
46
+
47
+
48
+
49
+ # View the prompts.
50
+
51
+ # + tags=["hide_inp"]
52
+ # CLIPrompt().show(
53
+ # {"question": "list the files in the directory"}, """```bash\nls\n```"""
54
+ # )
55
+ # # -
56
+
57
+
58
+ # # + tags=["hide_inp"]
59
+ # BashPrompt().show(["ls", "cat file.txt"], "hello")
60
+ # # -
61
+
62
+ # # View the run log.
63
+
64
+ # minichain.show_log("bash.log")
chat.log ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"action_status": "started", "timestamp": 1678759606.424852, "task_uuid": "0b226ec0-566b-4e36-af45-25c0881e5228", "action_type": "chat", "task_level": [1]}
2
+ {"action_status": "succeeded", "timestamp": 1678759606.4249172, "task_uuid": "0b226ec0-566b-4e36-af45-25c0881e5228", "action_type": "chat", "task_level": [2]}
3
+ {"action_status": "started", "timestamp": 1678759606.5748045, "task_uuid": "a2181bdc-7e7a-47a7-9a58-6abf2c2e10cd", "action_type": "ner", "task_level": [1]}
4
+ {"action_status": "succeeded", "timestamp": 1678759606.5748866, "task_uuid": "a2181bdc-7e7a-47a7-9a58-6abf2c2e10cd", "action_type": "ner", "task_level": [2]}
5
+ {"action_status": "started", "timestamp": 1678759606.5984528, "task_uuid": "694c3be6-2b7a-47b3-8d6a-0408b8dc6a26", "action_type": "math", "task_level": [1]}
6
+ {"action_status": "succeeded", "timestamp": 1678759606.5985456, "task_uuid": "694c3be6-2b7a-47b3-8d6a-0408b8dc6a26", "action_type": "math", "task_level": [2]}
7
+ {"action_status": "started", "timestamp": 1678759606.621539, "task_uuid": "b1f606f3-d7b6-48bb-a3a5-77e51fda3fa6", "action_type": "bash", "task_level": [1]}
8
+ {"action_status": "succeeded", "timestamp": 1678759606.6216574, "task_uuid": "b1f606f3-d7b6-48bb-a3a5-77e51fda3fa6", "action_type": "bash", "task_level": [2]}
9
+ {"action_status": "started", "timestamp": 1678759606.6456344, "task_uuid": "147ddfba-ef61-4a52-9f0c-1107c3fbaa6a", "action_type": "pal", "task_level": [1]}
10
+ {"action_status": "succeeded", "timestamp": 1678759606.645799, "task_uuid": "147ddfba-ef61-4a52-9f0c-1107c3fbaa6a", "action_type": "pal", "task_level": [2]}
11
+ {"action_status": "started", "timestamp": 1678759606.9333436, "task_uuid": "3246fe37-fa91-436b-96be-67648cd1ef76", "action_type": "gatsby", "task_level": [1]}
12
+ {"action_status": "succeeded", "timestamp": 1678759606.9335442, "task_uuid": "3246fe37-fa91-436b-96be-67648cd1ef76", "action_type": "gatsby", "task_level": [2]}
13
+ {"action_status": "started", "timestamp": 1678759606.9647467, "task_uuid": "86f09cf7-ec3b-41eb-aac0-144426f1a6f4", "action_type": "stats", "task_level": [1]}
14
+ {"action_status": "succeeded", "timestamp": 1678759606.964883, "task_uuid": "86f09cf7-ec3b-41eb-aac0-144426f1a6f4", "action_type": "stats", "task_level": [2]}
chat.pmpt.tpl ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Assistant is a large language model trained by OpenAI.
2
+
3
+ Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.
4
+
5
+ Assistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.
6
+
7
+ Overall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.
8
+
9
+ {% for d in memory %}
10
+ Human: {{d[0]}}
11
+ AI: {{d[1]}}
12
+ {% endfor %}
13
+
14
+ Human: {{human_input}}
15
+ Assistant:
chat.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ import warnings
4
+ from dataclasses import dataclass
5
+ from typing import List, Tuple
6
+ from IPython.display import Markdown, display
7
+ import minichain
8
+
9
+ # + tags=["hide_inp"]
10
+ warnings.filterwarnings("ignore")
11
+ # -
12
+
13
+
14
+ # Generic stateful Memory
15
+
16
+ MEMORY = 2
17
+
18
+ @dataclass
19
+ class State:
20
+ memory: List[Tuple[str, str]]
21
+ human_input: str = ""
22
+
23
+ def push(self, response: str) -> "State":
24
+ memory = self.memory if len(self.memory) < MEMORY else self.memory[1:]
25
+ return State(memory + [(self.human_input, response)])
26
+
27
+ # Chat prompt with memory
28
+
29
+ class ChatPrompt(minichain.TemplatePrompt):
30
+ template_file = "chatgpt.pmpt.tpl"
31
+ def parse(self, out: str, inp: State) -> State:
32
+ result = out.split("Assistant:")[-1]
33
+ return inp.push(result)
34
+
35
+ # class Human(minichain.Prompt):
36
+ # def parse(self, out: str, inp: State) -> State:
37
+ # return inp.human_input = out
38
+
39
+
40
+ with minichain.start_chain("chat") as backend:
41
+ prompt = ChatPrompt(backend.OpenAI())
42
+ state = State([])
43
+
44
+
45
+ examples = [
46
+ "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.",
47
+ "ls ~",
48
+ "cd ~",
49
+ "{Please make a file jokes.txt inside and put some jokes inside}",
50
+ """echo -e "x=lambda y:y*5+3;print('Result:' + str(x(6)))" > run.py && python3 run.py""",
51
+ """echo -e "print(list(filter(lambda x: all(x%d for d in range(2,x)),range(2,3**10)))[:10])" > run.py && python3 run.py""",
52
+ """echo -e "echo 'Hello from Docker" > entrypoint.sh && echo -e "FROM ubuntu:20.04\nCOPY entrypoint.sh entrypoint.sh\nENTRYPOINT [\"/bin/sh\",\"entrypoint.sh\"]">Dockerfile && docker build . -t my_docker_image && docker run -t my_docker_image""",
53
+ "nvidia-smi"
54
+ ]
55
+
56
+ gradio = prompt.to_gradio(fields= ["human_input"],
57
+ initial_state= state,
58
+ examples=examples,
59
+ out_type="json"
60
+ )
61
+ if __name__ == "__main__":
62
+ gradio.launch()
63
+
64
+ # for i in range(len(fake_human)):
65
+ # human.chain(prompt)
66
+
67
+
chatgpt.ipynb ADDED
@@ -0,0 +1,1099 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "3a1d57c7",
6
+ "metadata": {},
7
+ "source": [
8
+ "# ChatGPT"
9
+ ]
10
+ },
11
+ {
12
+ "cell_type": "markdown",
13
+ "id": "4751e660",
14
+ "metadata": {
15
+ "lines_to_next_cell": 2
16
+ },
17
+ "source": [
18
+ "\"ChatGPT\" like examples. Adapted from\n",
19
+ "[LangChain](https://langchain.readthedocs.io/en/latest/modules/memory/examples/chatgpt_clone.html)'s\n",
20
+ "version of this [blog\n",
21
+ "post](https://www.engraved.blog/building-a-virtual-machine-inside/)."
22
+ ]
23
+ },
24
+ {
25
+ "cell_type": "code",
26
+ "execution_count": 1,
27
+ "id": "0acb2e7c",
28
+ "metadata": {
29
+ "execution": {
30
+ "iopub.execute_input": "2023-02-27T16:23:05.736481Z",
31
+ "iopub.status.busy": "2023-02-27T16:23:05.736154Z",
32
+ "iopub.status.idle": "2023-02-27T16:23:05.928562Z",
33
+ "shell.execute_reply": "2023-02-27T16:23:05.927370Z"
34
+ }
35
+ },
36
+ "outputs": [],
37
+ "source": [
38
+ "import warnings\n",
39
+ "from dataclasses import dataclass\n",
40
+ "from typing import List, Tuple\n",
41
+ "from IPython.display import Markdown, display\n",
42
+ "import minichain"
43
+ ]
44
+ },
45
+ {
46
+ "cell_type": "code",
47
+ "execution_count": 2,
48
+ "id": "53e77d82",
49
+ "metadata": {
50
+ "execution": {
51
+ "iopub.execute_input": "2023-02-27T16:23:05.933659Z",
52
+ "iopub.status.busy": "2023-02-27T16:23:05.932423Z",
53
+ "iopub.status.idle": "2023-02-27T16:23:05.937782Z",
54
+ "shell.execute_reply": "2023-02-27T16:23:05.937143Z"
55
+ },
56
+ "lines_to_next_cell": 2,
57
+ "tags": [
58
+ "hide_inp"
59
+ ]
60
+ },
61
+ "outputs": [],
62
+ "source": [
63
+ "warnings.filterwarnings(\"ignore\")"
64
+ ]
65
+ },
66
+ {
67
+ "cell_type": "markdown",
68
+ "id": "e4fbd918",
69
+ "metadata": {},
70
+ "source": [
71
+ "Generic stateful Memory"
72
+ ]
73
+ },
74
+ {
75
+ "cell_type": "code",
76
+ "execution_count": 3,
77
+ "id": "e2c75e33",
78
+ "metadata": {
79
+ "execution": {
80
+ "iopub.execute_input": "2023-02-27T16:23:05.942500Z",
81
+ "iopub.status.busy": "2023-02-27T16:23:05.941348Z",
82
+ "iopub.status.idle": "2023-02-27T16:23:05.946048Z",
83
+ "shell.execute_reply": "2023-02-27T16:23:05.945445Z"
84
+ },
85
+ "lines_to_next_cell": 1
86
+ },
87
+ "outputs": [],
88
+ "source": [
89
+ "MEMORY = 2"
90
+ ]
91
+ },
92
+ {
93
+ "cell_type": "code",
94
+ "execution_count": 4,
95
+ "id": "4bb6e612",
96
+ "metadata": {
97
+ "execution": {
98
+ "iopub.execute_input": "2023-02-27T16:23:05.950846Z",
99
+ "iopub.status.busy": "2023-02-27T16:23:05.949709Z",
100
+ "iopub.status.idle": "2023-02-27T16:23:05.956371Z",
101
+ "shell.execute_reply": "2023-02-27T16:23:05.955692Z"
102
+ },
103
+ "lines_to_next_cell": 1
104
+ },
105
+ "outputs": [],
106
+ "source": [
107
+ "@dataclass\n",
108
+ "class State:\n",
109
+ " memory: List[Tuple[str, str]]\n",
110
+ " human_input: str = \"\"\n",
111
+ "\n",
112
+ " def push(self, response: str) -> \"State\":\n",
113
+ " memory = self.memory if len(self.memory) < MEMORY else self.memory[1:]\n",
114
+ " return State(memory + [(self.human_input, response)])"
115
+ ]
116
+ },
117
+ {
118
+ "cell_type": "markdown",
119
+ "id": "7b958184",
120
+ "metadata": {},
121
+ "source": [
122
+ "Chat prompt with memory"
123
+ ]
124
+ },
125
+ {
126
+ "cell_type": "code",
127
+ "execution_count": 5,
128
+ "id": "651c6a01",
129
+ "metadata": {
130
+ "execution": {
131
+ "iopub.execute_input": "2023-02-27T16:23:05.961370Z",
132
+ "iopub.status.busy": "2023-02-27T16:23:05.960177Z",
133
+ "iopub.status.idle": "2023-02-27T16:23:05.965742Z",
134
+ "shell.execute_reply": "2023-02-27T16:23:05.965181Z"
135
+ },
136
+ "lines_to_next_cell": 1
137
+ },
138
+ "outputs": [],
139
+ "source": [
140
+ "class ChatPrompt(minichain.TemplatePrompt):\n",
141
+ " template_file = \"chatgpt.pmpt.tpl\"\n",
142
+ " def parse(self, out: str, inp: State) -> State:\n",
143
+ " result = out.split(\"Assistant:\")[-1]\n",
144
+ " return inp.push(result)"
145
+ ]
146
+ },
147
+ {
148
+ "cell_type": "code",
149
+ "execution_count": 6,
150
+ "id": "2594b95f",
151
+ "metadata": {
152
+ "execution": {
153
+ "iopub.execute_input": "2023-02-27T16:23:05.968305Z",
154
+ "iopub.status.busy": "2023-02-27T16:23:05.967862Z",
155
+ "iopub.status.idle": "2023-02-27T16:23:05.971369Z",
156
+ "shell.execute_reply": "2023-02-27T16:23:05.970873Z"
157
+ }
158
+ },
159
+ "outputs": [],
160
+ "source": [
161
+ "fake_human = [\n",
162
+ " \"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.\",\n",
163
+ " \"ls ~\",\n",
164
+ " \"cd ~\",\n",
165
+ " \"{Please make a file jokes.txt inside and put some jokes inside}\",\n",
166
+ " \"\"\"echo -e \"x=lambda y:y*5+3;print('Result:' + str(x(6)))\" > run.py && python3 run.py\"\"\",\n",
167
+ " \"\"\"echo -e \"print(list(filter(lambda x: all(x%d for d in range(2,x)),range(2,3**10)))[:10])\" > run.py && python3 run.py\"\"\",\n",
168
+ " \"\"\"echo -e \"echo 'Hello from Docker\" > entrypoint.sh && echo -e \"FROM ubuntu:20.04\\nCOPY entrypoint.sh entrypoint.sh\\nENTRYPOINT [\\\"/bin/sh\\\",\\\"entrypoint.sh\\\"]\">Dockerfile && docker build . -t my_docker_image && docker run -t my_docker_image\"\"\",\n",
169
+ " \"nvidia-smi\"\n",
170
+ "]"
171
+ ]
172
+ },
173
+ {
174
+ "cell_type": "code",
175
+ "execution_count": 7,
176
+ "id": "200f6f4f",
177
+ "metadata": {
178
+ "execution": {
179
+ "iopub.execute_input": "2023-02-27T16:23:05.973893Z",
180
+ "iopub.status.busy": "2023-02-27T16:23:05.973504Z",
181
+ "iopub.status.idle": "2023-02-27T16:23:39.934620Z",
182
+ "shell.execute_reply": "2023-02-27T16:23:39.932059Z"
183
+ },
184
+ "lines_to_next_cell": 2
185
+ },
186
+ "outputs": [
187
+ {
188
+ "data": {
189
+ "text/markdown": [
190
+ "**Human:** <span style=\"color: blue\">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.</span>"
191
+ ],
192
+ "text/plain": [
193
+ "<IPython.core.display.Markdown object>"
194
+ ]
195
+ },
196
+ "metadata": {},
197
+ "output_type": "display_data"
198
+ },
199
+ {
200
+ "data": {
201
+ "text/markdown": [
202
+ "**Assistant:** \n",
203
+ "```\n",
204
+ "$ pwd\n",
205
+ "/\n",
206
+ "```"
207
+ ],
208
+ "text/plain": [
209
+ "<IPython.core.display.Markdown object>"
210
+ ]
211
+ },
212
+ "metadata": {},
213
+ "output_type": "display_data"
214
+ },
215
+ {
216
+ "data": {
217
+ "text/markdown": [
218
+ "--------------"
219
+ ],
220
+ "text/plain": [
221
+ "<IPython.core.display.Markdown object>"
222
+ ]
223
+ },
224
+ "metadata": {},
225
+ "output_type": "display_data"
226
+ },
227
+ {
228
+ "data": {
229
+ "text/markdown": [
230
+ "**Human:** <span style=\"color: blue\">ls ~</span>"
231
+ ],
232
+ "text/plain": [
233
+ "<IPython.core.display.Markdown object>"
234
+ ]
235
+ },
236
+ "metadata": {},
237
+ "output_type": "display_data"
238
+ },
239
+ {
240
+ "data": {
241
+ "text/markdown": [
242
+ "**Assistant:** \n",
243
+ "```\n",
244
+ "$ ls ~\n",
245
+ "Desktop/ Documents/ Downloads/ Music/ Pictures/ Public/ Templates/ Videos/\n",
246
+ "```"
247
+ ],
248
+ "text/plain": [
249
+ "<IPython.core.display.Markdown object>"
250
+ ]
251
+ },
252
+ "metadata": {},
253
+ "output_type": "display_data"
254
+ },
255
+ {
256
+ "data": {
257
+ "text/markdown": [
258
+ "--------------"
259
+ ],
260
+ "text/plain": [
261
+ "<IPython.core.display.Markdown object>"
262
+ ]
263
+ },
264
+ "metadata": {},
265
+ "output_type": "display_data"
266
+ },
267
+ {
268
+ "data": {
269
+ "text/markdown": [
270
+ "**Human:** <span style=\"color: blue\">cd ~</span>"
271
+ ],
272
+ "text/plain": [
273
+ "<IPython.core.display.Markdown object>"
274
+ ]
275
+ },
276
+ "metadata": {},
277
+ "output_type": "display_data"
278
+ },
279
+ {
280
+ "data": {
281
+ "text/markdown": [
282
+ "**Assistant:** \n",
283
+ "```\n",
284
+ "$ cd ~\n",
285
+ "$ pwd\n",
286
+ "/home/username\n",
287
+ "```"
288
+ ],
289
+ "text/plain": [
290
+ "<IPython.core.display.Markdown object>"
291
+ ]
292
+ },
293
+ "metadata": {},
294
+ "output_type": "display_data"
295
+ },
296
+ {
297
+ "data": {
298
+ "text/markdown": [
299
+ "--------------"
300
+ ],
301
+ "text/plain": [
302
+ "<IPython.core.display.Markdown object>"
303
+ ]
304
+ },
305
+ "metadata": {},
306
+ "output_type": "display_data"
307
+ },
308
+ {
309
+ "data": {
310
+ "text/markdown": [
311
+ "**Human:** <span style=\"color: blue\">{Please make a file jokes.txt inside and put some jokes inside}</span>"
312
+ ],
313
+ "text/plain": [
314
+ "<IPython.core.display.Markdown object>"
315
+ ]
316
+ },
317
+ "metadata": {},
318
+ "output_type": "display_data"
319
+ },
320
+ {
321
+ "data": {
322
+ "text/markdown": [
323
+ "**Assistant:** \n",
324
+ "\n",
325
+ "```\n",
326
+ "$ touch jokes.txt\n",
327
+ "$ echo \"Why did the chicken cross the road? To get to the other side!\" >> jokes.txt\n",
328
+ "$ echo \"What did the fish say when it hit the wall? Dam!\" >> jokes.txt\n",
329
+ "$ echo \"Why did the scarecrow win the Nobel Prize? Because he was outstanding in his field!\" >> jokes.txt\n",
330
+ "```"
331
+ ],
332
+ "text/plain": [
333
+ "<IPython.core.display.Markdown object>"
334
+ ]
335
+ },
336
+ "metadata": {},
337
+ "output_type": "display_data"
338
+ },
339
+ {
340
+ "data": {
341
+ "text/markdown": [
342
+ "--------------"
343
+ ],
344
+ "text/plain": [
345
+ "<IPython.core.display.Markdown object>"
346
+ ]
347
+ },
348
+ "metadata": {},
349
+ "output_type": "display_data"
350
+ },
351
+ {
352
+ "data": {
353
+ "text/markdown": [
354
+ "**Human:** <span style=\"color: blue\">echo -e \"x=lambda y:y*5+3;print('Result:' + str(x(6)))\" > run.py && python3 run.py</span>"
355
+ ],
356
+ "text/plain": [
357
+ "<IPython.core.display.Markdown object>"
358
+ ]
359
+ },
360
+ "metadata": {},
361
+ "output_type": "display_data"
362
+ },
363
+ {
364
+ "data": {
365
+ "text/markdown": [
366
+ "**Assistant:** \n",
367
+ "\n",
368
+ "```\n",
369
+ "$ echo -e \"x=lambda y:y*5+3;print('Result:' + str(x(6)))\" > run.py\n",
370
+ "$ python3 run.py\n",
371
+ "Result: 33\n",
372
+ "```"
373
+ ],
374
+ "text/plain": [
375
+ "<IPython.core.display.Markdown object>"
376
+ ]
377
+ },
378
+ "metadata": {},
379
+ "output_type": "display_data"
380
+ },
381
+ {
382
+ "data": {
383
+ "text/markdown": [
384
+ "--------------"
385
+ ],
386
+ "text/plain": [
387
+ "<IPython.core.display.Markdown object>"
388
+ ]
389
+ },
390
+ "metadata": {},
391
+ "output_type": "display_data"
392
+ },
393
+ {
394
+ "data": {
395
+ "text/markdown": [
396
+ "**Human:** <span style=\"color: blue\">echo -e \"print(list(filter(lambda x: all(x%d for d in range(2,x)),range(2,3**10)))[:10])\" > run.py && python3 run.py</span>"
397
+ ],
398
+ "text/plain": [
399
+ "<IPython.core.display.Markdown object>"
400
+ ]
401
+ },
402
+ "metadata": {},
403
+ "output_type": "display_data"
404
+ },
405
+ {
406
+ "data": {
407
+ "text/markdown": [
408
+ "**Assistant:** \n",
409
+ "\n",
410
+ "```\n",
411
+ "$ echo -e \"print(list(filter(lambda x: all(x%d for d in range(2,x)),range(2,3**10)))[:10])\" > run.py\n",
412
+ "$ python3 run.py\n",
413
+ "[2, 3, 5, 7, 11, 13, 17, 19, 23, 29]\n",
414
+ "```"
415
+ ],
416
+ "text/plain": [
417
+ "<IPython.core.display.Markdown object>"
418
+ ]
419
+ },
420
+ "metadata": {},
421
+ "output_type": "display_data"
422
+ },
423
+ {
424
+ "data": {
425
+ "text/markdown": [
426
+ "--------------"
427
+ ],
428
+ "text/plain": [
429
+ "<IPython.core.display.Markdown object>"
430
+ ]
431
+ },
432
+ "metadata": {},
433
+ "output_type": "display_data"
434
+ },
435
+ {
436
+ "data": {
437
+ "text/markdown": [
438
+ "**Human:** <span style=\"color: blue\">echo -e \"echo 'Hello from Docker\" > entrypoint.sh && echo -e \"FROM ubuntu:20.04\n",
439
+ "COPY entrypoint.sh entrypoint.sh\n",
440
+ "ENTRYPOINT [\"/bin/sh\",\"entrypoint.sh\"]\">Dockerfile && docker build . -t my_docker_image && docker run -t my_docker_image</span>"
441
+ ],
442
+ "text/plain": [
443
+ "<IPython.core.display.Markdown object>"
444
+ ]
445
+ },
446
+ "metadata": {},
447
+ "output_type": "display_data"
448
+ },
449
+ {
450
+ "data": {
451
+ "text/markdown": [
452
+ "**Assistant:** \n",
453
+ "\n",
454
+ "```\n",
455
+ "$ echo -e \"echo 'Hello from Docker\" > entrypoint.sh\n",
456
+ "$ echo -e \"FROM ubuntu:20.04\n",
457
+ "COPY entrypoint.sh entrypoint.sh\n",
458
+ "ENTRYPOINT [\"/bin/sh\",\"entrypoint.sh\"]\">Dockerfile\n",
459
+ "$ docker build . -t my_docker_image\n",
460
+ "$ docker run -t my_docker_image\n",
461
+ "Hello from Docker\n",
462
+ "```"
463
+ ],
464
+ "text/plain": [
465
+ "<IPython.core.display.Markdown object>"
466
+ ]
467
+ },
468
+ "metadata": {},
469
+ "output_type": "display_data"
470
+ },
471
+ {
472
+ "data": {
473
+ "text/markdown": [
474
+ "--------------"
475
+ ],
476
+ "text/plain": [
477
+ "<IPython.core.display.Markdown object>"
478
+ ]
479
+ },
480
+ "metadata": {},
481
+ "output_type": "display_data"
482
+ },
483
+ {
484
+ "data": {
485
+ "text/markdown": [
486
+ "**Human:** <span style=\"color: blue\">nvidia-smi</span>"
487
+ ],
488
+ "text/plain": [
489
+ "<IPython.core.display.Markdown object>"
490
+ ]
491
+ },
492
+ "metadata": {},
493
+ "output_type": "display_data"
494
+ },
495
+ {
496
+ "data": {
497
+ "text/markdown": [
498
+ "**Assistant:** \n",
499
+ "\n",
500
+ "```\n",
501
+ "$ nvidia-smi\n",
502
+ "Sat May 15 21:45:02 2021 \n",
503
+ "+-----------------------------------------------------------------------------+\n",
504
+ "| NVIDIA-SMI 460.32.03 Driver Version: 460.32.03 CUDA Version: 11.2 |\n",
505
+ "|-------------------------------+----------------------+----------------------+\n",
506
+ "| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |\n",
507
+ "| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |\n",
508
+ "|===============================+======================+======================|\n",
509
+ "| 0 GeForce RTX 208... Off | 00000000:01:00.0 Off | N/A |\n",
510
+ "| N/A 45C P0 28W / N/A | 590MiB / 7979MiB | 0% Default |\n",
511
+ "+-------------------------------+----------------------+----------------------+\n",
512
+ " \n",
513
+ "+-----------------------------------------------------------------------------+\n",
514
+ "| Processes: GPU Memory |\n",
515
+ "| GPU PID Type Process name Usage |\n",
516
+ "|=============================================================================|\n",
517
+ "|"
518
+ ],
519
+ "text/plain": [
520
+ "<IPython.core.display.Markdown object>"
521
+ ]
522
+ },
523
+ "metadata": {},
524
+ "output_type": "display_data"
525
+ },
526
+ {
527
+ "data": {
528
+ "text/markdown": [
529
+ "--------------"
530
+ ],
531
+ "text/plain": [
532
+ "<IPython.core.display.Markdown object>"
533
+ ]
534
+ },
535
+ "metadata": {},
536
+ "output_type": "display_data"
537
+ }
538
+ ],
539
+ "source": [
540
+ "with minichain.start_chain(\"chatgpt\") as backend:\n",
541
+ " prompt = ChatPrompt(backend.OpenAI())\n",
542
+ " state = State([])\n",
543
+ " for t in fake_human:\n",
544
+ " state.human_input = t\n",
545
+ " display(Markdown(f'**Human:** <span style=\"color: blue\">{t}</span>'))\n",
546
+ " state = prompt(state)\n",
547
+ " display(Markdown(f'**Assistant:** {state.memory[-1][1]}'))\n",
548
+ " display(Markdown(f'--------------'))"
549
+ ]
550
+ },
551
+ {
552
+ "cell_type": "code",
553
+ "execution_count": 8,
554
+ "id": "49506eaa",
555
+ "metadata": {
556
+ "execution": {
557
+ "iopub.execute_input": "2023-02-27T16:23:39.944473Z",
558
+ "iopub.status.busy": "2023-02-27T16:23:39.943436Z",
559
+ "iopub.status.idle": "2023-02-27T16:23:40.011091Z",
560
+ "shell.execute_reply": "2023-02-27T16:23:40.010474Z"
561
+ },
562
+ "tags": [
563
+ "hide_inp"
564
+ ]
565
+ },
566
+ "outputs": [
567
+ {
568
+ "data": {
569
+ "text/html": [
570
+ "\n",
571
+ "<!-- <link rel=\"stylesheet\" href=\"https://cdn.rawgit.com/Chalarangelo/mini.css/v3.0.1/dist/mini-default.min.css\"> -->\n",
572
+ " <main class=\"container\">\n",
573
+ "\n",
574
+ "<h3>ChatPrompt</h3>\n",
575
+ "\n",
576
+ "<dl>\n",
577
+ " <dt>Input:</dt>\n",
578
+ " <dd>\n",
579
+ "<div class=\"highlight\"><pre><span></span><span class=\"n\">State</span><span class=\"p\">(</span><span class=\"n\">memory</span><span class=\"o\">=</span><span class=\"p\">[(</span><span class=\"s1\">&#39;human 1&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;output 1&#39;</span><span class=\"p\">),</span> <span class=\"p\">(</span><span class=\"s1\">&#39;human 2&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;output 2&#39;</span><span class=\"p\">)],</span> <span class=\"n\">human_input</span><span class=\"o\">=</span><span class=\"s1\">&#39;cd ~&#39;</span><span class=\"p\">)</span>\n",
580
+ "</pre></div>\n",
581
+ "\n",
582
+ "\n",
583
+ " </dd>\n",
584
+ "\n",
585
+ " <dt> Full Prompt: </dt>\n",
586
+ " <dd>\n",
587
+ " <details>\n",
588
+ " <summary>Prompt</summary>\n",
589
+ " <p>Assistant is a large language model trained by OpenAI.<br><br>Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.<br><br>Assistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.<br><br>Overall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.<br><br><br>Human: human 1<br>AI: output 1<br><br>Human: human 2<br>AI: output 2<br><br><br>Human: <div style='color:red'>cd ~</div><br>Assistant:</p>\n",
590
+ " </details>\n",
591
+ " </dd>\n",
592
+ "\n",
593
+ " <dt> Response: </dt>\n",
594
+ " <dd>\n",
595
+ " Text Assistant: Hello\n",
596
+ " </dd>\n",
597
+ "\n",
598
+ " <dt>Value:</dt>\n",
599
+ " <dd>\n",
600
+ "<div class=\"highlight\"><pre><span></span><span class=\"n\">State</span><span class=\"p\">(</span><span class=\"n\">memory</span><span class=\"o\">=</span><span class=\"p\">[(</span><span class=\"s1\">&#39;human 2&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;output 2&#39;</span><span class=\"p\">),</span> <span class=\"p\">(</span><span class=\"s1\">&#39;cd ~&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39; Hello&#39;</span><span class=\"p\">)],</span> <span class=\"n\">human_input</span><span class=\"o\">=</span><span class=\"s1\">&#39;&#39;</span><span class=\"p\">)</span>\n",
601
+ "</pre></div>\n",
602
+ "\n",
603
+ " </dd>\n",
604
+ "</main>\n"
605
+ ],
606
+ "text/plain": [
607
+ "HTML(html='\\n<!-- <link rel=\"stylesheet\" href=\"https://cdn.rawgit.com/Chalarangelo/mini.css/v3.0.1/dist/mini-default.min.css\"> -->\\n <main class=\"container\">\\n\\n<h3>ChatPrompt</h3>\\n\\n<dl>\\n <dt>Input:</dt>\\n <dd>\\n<div class=\"highlight\"><pre><span></span><span class=\"n\">State</span><span class=\"p\">(</span><span class=\"n\">memory</span><span class=\"o\">=</span><span class=\"p\">[(</span><span class=\"s1\">&#39;human 1&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;output 1&#39;</span><span class=\"p\">),</span> <span class=\"p\">(</span><span class=\"s1\">&#39;human 2&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;output 2&#39;</span><span class=\"p\">)],</span> <span class=\"n\">human_input</span><span class=\"o\">=</span><span class=\"s1\">&#39;cd ~&#39;</span><span class=\"p\">)</span>\\n</pre></div>\\n\\n\\n </dd>\\n\\n <dt> Full Prompt: </dt>\\n <dd>\\n <details>\\n <summary>Prompt</summary>\\n <p>Assistant is a large language model trained by OpenAI.<br><br>Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.<br><br>Assistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.<br><br>Overall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.<br><br><br>Human: human 1<br>AI: output 1<br><br>Human: human 2<br>AI: output 2<br><br><br>Human: <div style=\\'color:red\\'>cd ~</div><br>Assistant:</p>\\n </details>\\n </dd>\\n\\n <dt> Response: </dt>\\n <dd>\\n Text Assistant: Hello\\n </dd>\\n\\n <dt>Value:</dt>\\n <dd>\\n<div class=\"highlight\"><pre><span></span><span class=\"n\">State</span><span class=\"p\">(</span><span class=\"n\">memory</span><span class=\"o\">=</span><span class=\"p\">[(</span><span class=\"s1\">&#39;human 2&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;output 2&#39;</span><span class=\"p\">),</span> <span class=\"p\">(</span><span class=\"s1\">&#39;cd ~&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39; Hello&#39;</span><span class=\"p\">)],</span> <span class=\"n\">human_input</span><span class=\"o\">=</span><span class=\"s1\">&#39;&#39;</span><span class=\"p\">)</span>\\n</pre></div>\\n\\n </dd>\\n</main>\\n')"
608
+ ]
609
+ },
610
+ "execution_count": 8,
611
+ "metadata": {},
612
+ "output_type": "execute_result"
613
+ }
614
+ ],
615
+ "source": [
616
+ "ChatPrompt().show(State([(\"human 1\", \"output 1\"), (\"human 2\", \"output 2\") ], \"cd ~\"),\n",
617
+ " \"Text Assistant: Hello\")"
618
+ ]
619
+ },
620
+ {
621
+ "cell_type": "markdown",
622
+ "id": "8c8c967b",
623
+ "metadata": {},
624
+ "source": [
625
+ "View the run log."
626
+ ]
627
+ },
628
+ {
629
+ "cell_type": "code",
630
+ "execution_count": 9,
631
+ "id": "7884cf9d",
632
+ "metadata": {
633
+ "execution": {
634
+ "iopub.execute_input": "2023-02-27T16:23:40.013468Z",
635
+ "iopub.status.busy": "2023-02-27T16:23:40.013285Z",
636
+ "iopub.status.idle": "2023-02-27T16:23:40.076730Z",
637
+ "shell.execute_reply": "2023-02-27T16:23:40.076097Z"
638
+ }
639
+ },
640
+ "outputs": [
641
+ {
642
+ "name": "stderr",
643
+ "output_type": "stream",
644
+ "text": [
645
+ "\u001b[38;5;15mbe24331e-675b-4c1f-aa66-65b84a7602e3\u001b[1m\u001b[0m\n",
646
+ "└── \u001b[38;5;5mchatgpt\u001b[0m/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 16:23:05Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m33.953s\u001b[2m\u001b[0m\n",
647
+ " └── \u001b[38;5;5mchatgpt\u001b[0m/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 16:23:39Z\u001b[2m\u001b[0m\n",
648
+ "\n",
649
+ "\u001b[38;5;15m60ca1813-07db-499b-b10b-d5b64709303f\u001b[1m\u001b[0m\n",
650
+ "└── \u001b[38;5;5m<class '__main__.ChatPrompt'>\u001b[0m/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 16:23:15Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m3.264s\u001b[2m\u001b[0m\n",
651
+ " ├── <unnamed>\n",
652
+ " │ └── \u001b[38;5;5mInput Function\u001b[0m/2/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 16:23:15Z\u001b[2m\u001b[0m\n",
653
+ " ├── \u001b[38;5;5meliot:destination_failure\u001b[0m/3\u001b[0m \u001b[38;5;15m2023-02-27 16:23:15Z\u001b[2m\u001b[0m\n",
654
+ " │ ���── \u001b[38;5;4mexception\u001b[0m: builtins.AttributeError\u001b[0m\n",
655
+ " │ ├── \u001b[38;5;4mmessage\u001b[0m: {\"'input'\": 'State(memory=[(\\'cd ~\\', \\' \\\\n```\\\\n$ cd ~\\\\n$ pwd\\\\n/home/username\\\\n```\\'), (\\'{Please make a file jokes.txt inside and put some jokes inside}\\', \\'\\\\n\\\\n```\\\\n$ touch jokes.txt\\\\n$ echo \"Why did the chicken cross the road? To get to the other side!\" >> jokes.txt\\\\n$ echo \"What did the fish say when it hit the wall? Dam!\" >> jokes.txt\\\\n$ echo \"Why did the scarecrow win the Nobel Prize? Because he was outstanding in his field!\" >> jokes.txt\\\\n```\\')], human_input=\\'echo -e \"x=lambda y:y*5+3;print(\\\\\\'Result:\\\\\\' + str(x(6)))\" > run.py && python3 run.py\\')', \"'action_status'\": \"'started'\", \"'timestamp'\": '1677514995.8653514', \"'task_uuid'\": \"'60ca1813-07db-499b-b10b-d5b64709303f'\", \"'action_type'\": \"'Input Function'\", \"'task_level'\": '[2, 1]'}\u001b[0m\n",
656
+ " │ └── \u001b[38;5;4mreason\u001b[0m: module 'numpy' has no attribute 'bool'.⏎\n",
657
+ " │ `np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.⏎\n",
658
+ " │ The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:⏎\n",
659
+ " │ https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations\u001b[0m\n",
660
+ " ├── \u001b[38;5;5mPrompted\u001b[0m/4/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 16:23:15Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m3.259s\u001b[2m\u001b[0m\n",
661
+ " │ ├── \u001b[38;5;4mprompt\u001b[0m: Assistant is a large language model trained by OpenAI.⏎\n",
662
+ " │ │ ⏎\n",
663
+ " │ │ Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.⏎\n",
664
+ " │ │ ⏎\n",
665
+ " │ │ Assistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.⏎\n",
666
+ " │ │ ⏎\n",
667
+ " │ │ Overall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.⏎\n",
668
+ " │ │ ⏎\n",
669
+ " │ │ ⏎\n",
670
+ " │ │ Human: cd ~⏎\n",
671
+ " │ │ AI: ⏎\n",
672
+ " │ │ ```⏎\n",
673
+ " │ │ $ cd ~⏎\n",
674
+ " │ │ $ pwd⏎\n",
675
+ " │ │ /home/username⏎\n",
676
+ " │ │ ```⏎\n",
677
+ " │ │ ⏎\n",
678
+ " │ │ Human: {Please make a file jokes.txt inside and put some jokes inside}⏎\n",
679
+ " │ │ AI: ⏎\n",
680
+ " │ │ ⏎\n",
681
+ " │ │ ```⏎\n",
682
+ " │ │ $ touch jokes.txt⏎\n",
683
+ " │ │ $ echo \"Why did the chicken cross the road? To get to the other side!\" >> jokes.txt⏎\n",
684
+ " │ │ $ echo \"What did the fish say when it hit the wall? Dam!\" >> jokes.txt⏎\n",
685
+ " │ │ $ echo \"Why did the scarecrow win the Nobel Prize? Because he was outstanding in his field!\" >> jokes.txt⏎\n",
686
+ " │ │ ```⏎\n",
687
+ " │ │ ⏎\n",
688
+ " │ │ ⏎\n",
689
+ " │ │ Human: echo -e \"x=lambda y:y*5+3;print('Result:' + str(x(6)))\" > run.py && python3 run.py⏎\n",
690
+ " │ │ Assistant:\u001b[0m\n",
691
+ " │ └── \u001b[38;5;5mPrompted\u001b[0m/4/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 16:23:19Z\u001b[2m\u001b[0m\n",
692
+ " ├── \u001b[38;5;5mResult\u001b[0m/5/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 16:23:19Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m0.000s\u001b[2m\u001b[0m\n",
693
+ " │ ├── \u001b[38;5;4mresult\u001b[0m: ⏎\n",
694
+ " │ │ ⏎\n",
695
+ " │ │ ```⏎\n",
696
+ " │ │ $ echo -e \"x=lambda y:y*5+3;print('Result:' + str(x(6)))\" > run.py⏎\n",
697
+ " │ │ $ python3 run.py⏎\n",
698
+ " │ │ Result: 33⏎\n",
699
+ " │ │ ```\u001b[0m\n",
700
+ " │ └── \u001b[38;5;5mResult\u001b[0m/5/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 16:23:19Z\u001b[2m\u001b[0m\n",
701
+ " └── \u001b[38;5;5m<class '__main__.ChatPrompt'>\u001b[0m/6\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 16:23:19Z\u001b[2m\u001b[0m\n",
702
+ "\n",
703
+ "\u001b[38;5;15mc2062d1e-37fb-44e9-9e3f-35fd33720af5\u001b[1m\u001b[0m\n",
704
+ "└── \u001b[38;5;5m<class '__main__.ChatPrompt'>\u001b[0m/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 16:23:06Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m1.477s\u001b[2m\u001b[0m\n",
705
+ " ├── <unnamed>\n",
706
+ " │ └── \u001b[38;5;5mInput Function\u001b[0m/2/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 16:23:06Z\u001b[2m\u001b[0m\n",
707
+ " ├── \u001b[38;5;5meliot:destination_failure\u001b[0m/3\u001b[0m \u001b[38;5;15m2023-02-27 16:23:06Z\u001b[2m\u001b[0m\n",
708
+ " │ ├── \u001b[38;5;4mexception\u001b[0m: builtins.AttributeError\u001b[0m\n",
709
+ " │ ├── \u001b[38;5;4mmessage\u001b[0m: {\"'input'\": \"State(memory=[], human_input='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.')\", \"'action_status'\": \"'started'\", \"'timestamp'\": '1677514986.2875783', \"'task_uuid'\": \"'c2062d1e-37fb-44e9-9e3f-35fd33720af5'\", \"'action_type'\": \"'Input Function'\", \"'task_level'\": '[2, 1]'}\u001b[0m\n",
710
+ " │ └── \u001b[38;5;4mreason\u001b[0m: module 'numpy' has no attribute 'bool'.⏎\n",
711
+ " │ `np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.⏎\n",
712
+ " │ The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:⏎\n",
713
+ " │ https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations\u001b[0m\n",
714
+ " ├── \u001b[38;5;5mPrompted\u001b[0m/4/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 16:23:06Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m1.472s\u001b[2m\u001b[0m\n",
715
+ " │ ├── \u001b[38;5;4mprompt\u001b[0m: Assistant is a large language model trained by OpenAI.⏎\n",
716
+ " │ │ ⏎\n",
717
+ " │ │ Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.⏎\n",
718
+ " │ │ ⏎\n",
719
+ " │ │ Assistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.⏎\n",
720
+ " │ │ ⏎\n",
721
+ " │ │ Overall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.⏎\n",
722
+ " │ │ ⏎\n",
723
+ " │ │ ⏎\n",
724
+ " │ │ ⏎\n",
725
+ " │ │ Human: 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.⏎\n",
726
+ " │ │ Assistant:\u001b[0m\n",
727
+ " │ └── \u001b[38;5;5mPrompted\u001b[0m/4/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 16:23:07Z\u001b[2m\u001b[0m\n",
728
+ " ├── \u001b[38;5;5mResult\u001b[0m/5/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 16:23:07Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m0.000s\u001b[2m\u001b[0m\n",
729
+ " │ ├── \u001b[38;5;4mresult\u001b[0m: ⏎\n",
730
+ " │ │ ```⏎\n",
731
+ " │ │ $ pwd⏎\n",
732
+ " │ │ /⏎\n",
733
+ " │ │ ```\u001b[0m\n",
734
+ " │ └── \u001b[38;5;5mResult\u001b[0m/5/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 16:23:07Z\u001b[2m\u001b[0m\n",
735
+ " └── \u001b[38;5;5m<class '__main__.ChatPrompt'>\u001b[0m/6\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 16:23:07Z\u001b[2m\u001b[0m\n",
736
+ "\n",
737
+ "\u001b[38;5;15mea339a52-82af-4c19-8ee6-1d2f081bc437\u001b[1m\u001b[0m\n",
738
+ "└── \u001b[38;5;5m<class '__main__.ChatPrompt'>\u001b[0m/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 16:23:28Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m11.867s\u001b[2m\u001b[0m\n",
739
+ " ├── <unnamed>\n",
740
+ " │ └── \u001b[38;5;5mInput Function\u001b[0m/2/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 16:23:28Z\u001b[2m\u001b[0m\n",
741
+ " ├── \u001b[38;5;5meliot:destination_failure\u001b[0m/3\u001b[0m \u001b[38;5;15m2023-02-27 16:23:28Z\u001b[2m\u001b[0m\n",
742
+ " │ ├── \u001b[38;5;4mexception\u001b[0m: builtins.AttributeError\u001b[0m\n",
743
+ " │ ├── \u001b[38;5;4mmessage\u001b[0m: {\"'input'\": 'State(memory=[(\\'echo -e \"print(list(filter(lambda x: all(x%d for d in range(2,x)),range(2,3**10)))[:10])\" > run.py && python3 run.py\\', \\'\\\\n\\\\n```\\\\n$ echo -e \"print(list(filter(lambda x: all(x%d for d in range(2,x)),range(2,3**10)))[:10])\" > run.py\\\\n$ python3 run.py\\\\n[2, 3, 5, 7, 11, 13, 17, 19, 23, 29]\\\\n```\\'), (\\'echo -e \"echo \\\\\\'Hello from Docker\" > entrypoint.sh && echo -e \"FROM ubuntu:20.04\\\\nCOPY entrypoint.sh entrypoint.sh\\\\nENTRYPOINT [\"/bin/sh\",\"entrypoint.sh\"]\">Dockerfile && docker build . -t my_docker_image && docker run -t my_docker_image\\', \\'\\\\n\\\\n```\\\\n$ echo -e \"echo \\\\\\'Hello from Docker\" > entrypoint.sh\\\\n$ echo -e \"FROM ubuntu:20.04\\\\nCOPY entrypoint.sh entrypoint.sh\\\\nENTRYPOINT [\"/bin/sh\",\"entrypoint.sh\"]\">Dockerfile\\\\n$ docker build . -t my_docker_image\\\\n$ docker run -t my_docker_image\\\\nHello from Docker\\\\n```\\')], human_input=\\'nvidia-smi\\')', \"'action_status'\": \"'started'\", \"'timestamp'\": '1677515008.0539572', \"'task_uuid'\": \"'ea339a52-82af-4c19-8ee6-1d2f081bc437'\", \"'action_type'\": \"'Input Function'\", \"'task_level'\": '[2, 1]'}\u001b[0m\n",
744
+ " │ └── \u001b[38;5;4mreason\u001b[0m: module 'numpy' has no attribute 'bool'.⏎\n",
745
+ " │ `np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.⏎\n",
746
+ " │ The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:⏎\n",
747
+ " │ https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations\u001b[0m\n",
748
+ " ├── \u001b[38;5;5mPrompted\u001b[0m/4/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 16:23:28Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m11.858s\u001b[2m\u001b[0m\n",
749
+ " │ ├── \u001b[38;5;4mprompt\u001b[0m: Assistant is a large language model trained by OpenAI.⏎\n",
750
+ " │ │ ⏎\n",
751
+ " │ │ Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.⏎\n",
752
+ " │ │ ⏎\n",
753
+ " │ │ Assistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.⏎\n",
754
+ " │ │ ⏎\n",
755
+ " │ │ Overall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.⏎\n",
756
+ " │ │ ⏎\n",
757
+ " │ │ ⏎\n",
758
+ " │ │ Human: echo -e \"print(list(filter(lambda x: all(x%d for d in range(2,x)),range(2,3**10)))[:10])\" > run.py && python3 run.py⏎\n",
759
+ " │ │ AI: ⏎\n",
760
+ " │ │ ⏎\n",
761
+ " │ │ ```⏎\n",
762
+ " │ │ $ echo -e \"print(list(filter(lambda x: all(x%d for d in range(2,x)),range(2,3**10)))[:10])\" > run.py⏎\n",
763
+ " │ │ $ python3 run.py⏎\n",
764
+ " │ │ [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]⏎\n",
765
+ " │ │ ```⏎\n",
766
+ " │ │ ⏎\n",
767
+ " │ │ Human: echo -e \"echo 'Hello from Docker\" > entrypoint.sh && echo -e \"FROM ubuntu:20.04⏎\n",
768
+ " │ │ COPY entrypoint.sh entrypoint.sh⏎\n",
769
+ " │ │ ENTRYPOINT [\"/bin/sh\",\"entrypoint.sh\"]\">Dockerfile && docker build . -t my_docker_image && docker run -t my_docker_image⏎\n",
770
+ " │ │ AI: ⏎\n",
771
+ " │ │ ⏎\n",
772
+ " │ │ ```⏎\n",
773
+ " │ │ $ echo -e \"echo 'Hello from Docker\" > entrypoint.sh⏎\n",
774
+ " │ │ $ echo -e \"FROM ubuntu:20.04⏎\n",
775
+ " │ │ COPY entrypoint.sh entrypoint.sh⏎\n",
776
+ " │ │ ENTRYPOINT [\"/bin/sh\",\"entrypoint.sh\"]\">Dockerfile⏎\n",
777
+ " │ │ $ docker build . -t my_docker_image⏎\n",
778
+ " │ │ $ docker run -t my_docker_image⏎\n",
779
+ " │ │ Hello from Docker⏎\n",
780
+ " │ │ ```⏎\n",
781
+ " │ │ ⏎\n",
782
+ " │ │ ⏎\n",
783
+ " │ │ Human: nvidia-smi⏎\n",
784
+ " │ │ Assistant:\u001b[0m\n",
785
+ " │ └── \u001b[38;5;5mPrompted\u001b[0m/4/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 16:23:39Z\u001b[2m\u001b[0m\n",
786
+ " ├── \u001b[38;5;5mResult\u001b[0m/5/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 16:23:39Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m0.000s\u001b[2m\u001b[0m\n",
787
+ " │ ├── \u001b[38;5;4mresult\u001b[0m: ⏎\n",
788
+ " │ │ ⏎\n",
789
+ " │ │ ```⏎\n",
790
+ " │ │ $ nvidia-smi⏎\n",
791
+ " │ │ Sat May 15 21:45:02 2021 ⏎\n",
792
+ " │ │ +-----------------------------------------------------------------------------+⏎\n",
793
+ " │ │ | NVIDIA-SMI 460.32.03 Driver Version: 460.32.03 CUDA Version: 11.2 |⏎\n",
794
+ " │ │ |-------------------------------+----------------------+----------------------+⏎\n",
795
+ " │ │ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |⏎\n",
796
+ " │ │ | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |⏎\n",
797
+ " │ │ |===============================+======================+======================|⏎\n",
798
+ " │ │ | 0 GeForce RTX 208... Off | 00000000:01:00.0 Off | N/A |⏎\n",
799
+ " │ │ | N/A 45C P0 28W / N/A | 590MiB / 7979MiB | 0% Default |⏎\n",
800
+ " │ │ +-------------------------------+----------------------+----------------------+⏎\n",
801
+ " │ │ ⏎\n",
802
+ " │ │ +-----------------------------------------------------------------------------+⏎\n",
803
+ " │ │ | Processes: GPU Memory |⏎\n",
804
+ " │ │ | GPU PID Type Process name Usage |⏎\n",
805
+ " │ │ |=============================================================================|⏎\n",
806
+ " │ │ |\u001b[0m\n",
807
+ " │ └── \u001b[38;5;5mResult\u001b[0m/5/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 16:23:39Z\u001b[2m\u001b[0m\n",
808
+ " └── \u001b[38;5;5m<class '__main__.ChatPrompt'>\u001b[0m/6\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 16:23:39Z\u001b[2m\u001b[0m\n",
809
+ "\n",
810
+ "\u001b[38;5;15m5a8d829e-f545-4f75-b1b3-efb6cdb5d8e4\u001b[1m\u001b[0m\n",
811
+ "└── \u001b[38;5;5m<class '__main__.ChatPrompt'>\u001b[0m/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 16:23:19Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m4.063s\u001b[2m\u001b[0m\n",
812
+ " ├── <unnamed>\n",
813
+ " │ └── \u001b[38;5;5mInput Function\u001b[0m/2/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 16:23:19Z\u001b[2m\u001b[0m\n",
814
+ " ├── \u001b[38;5;5meliot:destination_failure\u001b[0m/3\u001b[0m \u001b[38;5;15m2023-02-27 16:23:19Z\u001b[2m\u001b[0m\n",
815
+ " │ ├── \u001b[38;5;4mexception\u001b[0m: builtins.AttributeError\u001b[0m\n",
816
+ " │ ├── \u001b[38;5;4mmessage\u001b[0m: {\"'input'\": 'State(memory=[(\\'{Please make a file jokes.txt inside and put some jokes inside}\\', \\'\\\\n\\\\n```\\\\n$ touch jokes.txt\\\\n$ echo \"Why did the chicken cross the road? To get to the other side!\" >> jokes.txt\\\\n$ echo \"What did the fish say when it hit the wall? Dam!\" >> jokes.txt\\\\n$ echo \"Why did the scarecrow win the Nobel Prize? Because he was outstanding in his field!\" >> jokes.txt\\\\n```\\'), (\\'echo -e \"x=lambda y:y*5+3;print(\\\\\\'Result:\\\\\\' + str(x(6)))\" > run.py && python3 run.py\\', \\'\\\\n\\\\n```\\\\n$ echo -e \"x=lambda y:y*5+3;print(\\\\\\'Result:\\\\\\' + str(x(6)))\" > run.py\\\\n$ python3 run.py\\\\nResult: 33\\\\n```\\')], human_input=\\'echo -e \"print(list(filter(lambda x: all(x%d for d in range(2,x)),range(2,3**10)))[:10])\" > run.py && python3 run.py\\')', \"'action_status'\": \"'started'\", \"'timestamp'\": '1677514999.1337094', \"'task_uuid'\": \"'5a8d829e-f545-4f75-b1b3-efb6cdb5d8e4'\", \"'action_type'\": \"'Input Function'\", \"'task_level'\": '[2, 1]'}\u001b[0m\n",
817
+ " │ └── \u001b[38;5;4mreason\u001b[0m: module 'numpy' has no attribute 'bool'.⏎\n",
818
+ " │ `np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.⏎\n",
819
+ " │ The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:⏎\n",
820
+ " │ https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations\u001b[0m\n",
821
+ " ├── \u001b[38;5;5mPrompted\u001b[0m/4/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 16:23:19Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m4.061s\u001b[2m\u001b[0m\n",
822
+ " │ ├── \u001b[38;5;4mprompt\u001b[0m: Assistant is a large language model trained by OpenAI.⏎\n",
823
+ " │ │ ⏎\n",
824
+ " │ │ Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.⏎\n",
825
+ " │ │ ⏎\n",
826
+ " │ │ Assistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.⏎\n",
827
+ " │ │ ⏎\n",
828
+ " │ │ Overall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.⏎\n",
829
+ " │ │ ⏎\n",
830
+ " │ │ ⏎\n",
831
+ " │ │ Human: {Please make a file jokes.txt inside and put some jokes inside}⏎\n",
832
+ " │ │ AI: ⏎\n",
833
+ " │ │ ⏎\n",
834
+ " │ │ ```⏎\n",
835
+ " │ │ $ touch jokes.txt⏎\n",
836
+ " │ │ $ echo \"Why did the chicken cross the road? To get to the other side!\" >> jokes.txt⏎\n",
837
+ " │ │ $ echo \"What did the fish say when it hit the wall? Dam!\" >> jokes.txt⏎\n",
838
+ " │ │ $ echo \"Why did the scarecrow win the Nobel Prize? Because he was outstanding in his field!\" >> jokes.txt⏎\n",
839
+ " │ │ ```⏎\n",
840
+ " │ │ ⏎\n",
841
+ " │ │ Human: echo -e \"x=lambda y:y*5+3;print('Result:' + str(x(6)))\" > run.py && python3 run.py⏎\n",
842
+ " │ │ AI: ⏎\n",
843
+ " │ │ ⏎\n",
844
+ " │ │ ```⏎\n",
845
+ " │ │ $ echo -e \"x=lambda y:y*5+3;print('Result:' + str(x(6)))\" > run.py⏎\n",
846
+ " │ │ $ python3 run.py⏎\n",
847
+ " │ │ Result: 33⏎\n",
848
+ " │ │ ```⏎\n",
849
+ " │ │ ⏎\n",
850
+ " │ │ ⏎\n",
851
+ " │ │ Human: echo -e \"print(list(filter(lambda x: all(x%d for d in range(2,x)),range(2,3**10)))[:10])\" > run.py && python3 run.py⏎\n",
852
+ " │ │ Assistant:\u001b[0m\n",
853
+ " │ └── \u001b[38;5;5mPrompted\u001b[0m/4/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 16:23:23Z\u001b[2m\u001b[0m\n",
854
+ " ├── \u001b[38;5;5mResult\u001b[0m/5/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 16:23:23Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m0.000s\u001b[2m\u001b[0m\n",
855
+ " │ ├── \u001b[38;5;4mresult\u001b[0m: ⏎\n",
856
+ " │ │ ⏎\n",
857
+ " │ │ ```⏎\n",
858
+ " │ │ $ echo -e \"print(list(filter(lambda x: all(x%d for d in range(2,x)),range(2,3**10)))[:10])\" > run.py⏎\n",
859
+ " │ │ $ python3 run.py⏎\n",
860
+ " │ │ [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]⏎\n",
861
+ " │ │ ```\u001b[0m\n",
862
+ " │ └── \u001b[38;5;5mResult\u001b[0m/5/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 16:23:23Z\u001b[2m\u001b[0m\n",
863
+ " └── \u001b[38;5;5m<class '__main__.ChatPrompt'>\u001b[0m/6\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 16:23:23Z\u001b[2m\u001b[0m\n",
864
+ "\n",
865
+ "\u001b[38;5;15m8d9f2eb7-c022-48e6-bdeb-c35b8852c934\u001b[1m\u001b[0m\n",
866
+ "└── \u001b[38;5;5m<class '__main__.ChatPrompt'>\u001b[0m/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 16:23:09Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m1.437s\u001b[2m\u001b[0m\n",
867
+ " ├── <unnamed>\n",
868
+ " │ └── \u001b[38;5;5mInput Function\u001b[0m/2/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 16:23:09Z\u001b[2m\u001b[0m\n",
869
+ " ├── \u001b[38;5;5meliot:destination_failure\u001b[0m/3\u001b[0m \u001b[38;5;15m2023-02-27 16:23:09Z\u001b[2m\u001b[0m\n",
870
+ " │ ├── \u001b[38;5;4mexception\u001b[0m: builtins.AttributeError\u001b[0m\n",
871
+ " │ ├── \u001b[38;5;4mmessage\u001b[0m: {\"'input'\": \"State(memory=[('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.', '\\\\n```\\\\n$ pwd\\\\n/\\\\n```'), ('ls ~', '\\\\n```\\\\n$ ls ~\\\\nDesktop/ Documents/ Downloads/ Music/ Pictures/ Public/ Templates/ Videos/\\\\n```')], human_input='cd ~')\", \"'action_status'\": \"'started'\", \"'timestamp'\": '1677514989.5083773', \"'task_uuid'\": \"'8d9f2eb7-c022-48e6-bdeb-c35b8852c934'\", \"'action_type'\": \"'Input Function'\", \"'task_level'\": '[2, 1]'}\u001b[0m\n",
872
+ " │ └── \u001b[38;5;4mreason\u001b[0m: module 'numpy' has no attribute 'bool'.⏎\n",
873
+ " │ `np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.⏎\n",
874
+ " │ The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:⏎\n",
875
+ " │ https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations\u001b[0m\n",
876
+ " ├── \u001b[38;5;5mPrompted\u001b[0m/4/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 16:23:09Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m1.428s\u001b[2m\u001b[0m\n",
877
+ " │ ├── \u001b[38;5;4mprompt\u001b[0m: Assistant is a large language model trained by OpenAI.⏎\n",
878
+ " │ │ ⏎\n",
879
+ " │ │ Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.⏎\n",
880
+ " │ │ ⏎\n",
881
+ " │ │ Assistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.⏎\n",
882
+ " │ │ ⏎\n",
883
+ " │ │ Overall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.⏎\n",
884
+ " │ │ ⏎\n",
885
+ " │ │ ⏎\n",
886
+ " │ │ Human: 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.⏎\n",
887
+ " │ │ AI: ⏎\n",
888
+ " │ │ ```⏎\n",
889
+ " │ │ $ pwd⏎\n",
890
+ " │ │ /⏎\n",
891
+ " │ │ ```⏎\n",
892
+ " │ │ ⏎\n",
893
+ " │ │ Human: ls ~⏎\n",
894
+ " │ │ AI: ⏎\n",
895
+ " │ │ ```⏎\n",
896
+ " │ │ $ ls ~⏎\n",
897
+ " │ │ Desktop/ Documents/ Downloads/ Music/ Pictures/ Public/ Templates/ Videos/⏎\n",
898
+ " │ │ ```⏎\n",
899
+ " │ │ ⏎\n",
900
+ " │ │ ⏎\n",
901
+ " │ │ Human: cd ~⏎\n",
902
+ " │ │ Assistant:\u001b[0m\n",
903
+ " │ └── \u001b[38;5;5mPrompted\u001b[0m/4/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 16:23:10Z\u001b[2m\u001b[0m\n",
904
+ " ├── \u001b[38;5;5mResult\u001b[0m/5/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 16:23:10Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m0.000s\u001b[2m\u001b[0m\n",
905
+ " │ ├── \u001b[38;5;4mresult\u001b[0m: ⏎\n",
906
+ " │ │ ```⏎\n",
907
+ " │ │ $ cd ~⏎\n",
908
+ " │ │ $ pwd⏎\n",
909
+ " │ │ /home/username⏎\n",
910
+ " │ │ ```\u001b[0m\n",
911
+ " │ └── \u001b[38;5;5mResult\u001b[0m/5/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 16:23:10Z\u001b[2m\u001b[0m\n",
912
+ " └── \u001b[38;5;5m<class '__main__.ChatPrompt'>\u001b[0m/6\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 16:23:10Z\u001b[2m\u001b[0m\n",
913
+ "\n",
914
+ "\u001b[38;5;15m6a51f09a-2d2a-4883-a864-3bb66ba6215b\u001b[1m\u001b[0m\n",
915
+ "└── \u001b[38;5;5m<class '__main__.ChatPrompt'>\u001b[0m/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 16:23:07Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m1.718s\u001b[2m\u001b[0m\n",
916
+ " ├── <unnamed>\n",
917
+ " │ └── \u001b[38;5;5mInput Function\u001b[0m/2/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 16:23:07Z\u001b[2m\u001b[0m\n",
918
+ " ├── \u001b[38;5;5meliot:destination_failure\u001b[0m/3\u001b[0m \u001b[38;5;15m2023-02-27 16:23:07Z\u001b[2m\u001b[0m\n",
919
+ " │ ├── \u001b[38;5;4mexception\u001b[0m: builtins.AttributeError\u001b[0m\n",
920
+ " │ ├── \u001b[38;5;4mmessage\u001b[0m: {\"'input'\": \"State(memory=[('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.', '\\\\n```\\\\n$ pwd\\\\n/\\\\n```')], human_input='ls ~')\", \"'action_status'\": \"'started'\", \"'timestamp'\": '1677514987.7763977', \"'task_uuid'\": \"'6a51f09a-2d2a-4883-a864-3bb66ba6215b'\", \"'action_type'\": \"'Input Function'\", \"'task_level'\": '[2, 1]'}\u001b[0m\n",
921
+ " │ └── \u001b[38;5;4mreason\u001b[0m: module 'numpy' has no attribute 'bool'.⏎\n",
922
+ " │ `np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.⏎\n",
923
+ " │ The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:⏎\n",
924
+ " │ https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations\u001b[0m\n",
925
+ " ├── \u001b[38;5;5mPrompted\u001b[0m/4/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 16:23:07Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m1.710s\u001b[2m\u001b[0m\n",
926
+ " │ ├── \u001b[38;5;4mprompt\u001b[0m: Assistant is a large language model trained by OpenAI.⏎\n",
927
+ " │ │ ⏎\n",
928
+ " │ │ Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.⏎\n",
929
+ " │ │ ⏎\n",
930
+ " │ │ Assistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.⏎\n",
931
+ " │ │ ⏎\n",
932
+ " │ │ Overall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.⏎\n",
933
+ " │ │ ⏎\n",
934
+ " │ │ ⏎\n",
935
+ " │ │ Human: 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.⏎\n",
936
+ " │ │ AI: ⏎\n",
937
+ " │ │ ```⏎\n",
938
+ " │ │ $ pwd⏎\n",
939
+ " │ │ /⏎\n",
940
+ " │ │ ```⏎\n",
941
+ " │ │ ⏎\n",
942
+ " │ │ ⏎\n",
943
+ " │ │ Human: ls ~⏎\n",
944
+ " │ │ Assistant:\u001b[0m\n",
945
+ " │ └── \u001b[38;5;5mPrompted\u001b[0m/4/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 16:23:09Z\u001b[2m\u001b[0m\n",
946
+ " ├── \u001b[38;5;5mResult\u001b[0m/5/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 16:23:09Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m0.000s\u001b[2m\u001b[0m\n",
947
+ " │ ├── \u001b[38;5;4mresult\u001b[0m: ⏎\n",
948
+ " │ │ ```⏎\n",
949
+ " │ │ $ ls ~⏎\n",
950
+ " │ │ Desktop/ Documents/ Downloads/ Music/ Pictures/ Public/ Templates/ Videos/⏎\n",
951
+ " │ │ ```\u001b[0m\n",
952
+ " │ └── \u001b[38;5;5mResult\u001b[0m/5/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 16:23:09Z\u001b[2m\u001b[0m\n",
953
+ " └── \u001b[38;5;5m<class '__main__.ChatPrompt'>\u001b[0m/6\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 16:23:09Z\u001b[2m\u001b[0m\n",
954
+ "\n",
955
+ "\u001b[38;5;15m00a84ff6-6fc1-4afc-88b1-e82a893855d3\u001b[1m\u001b[0m\n",
956
+ "└── \u001b[38;5;5m<class '__main__.ChatPrompt'>\u001b[0m/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 16:23:23Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m4.841s\u001b[2m\u001b[0m\n",
957
+ " ├── <unnamed>\n",
958
+ " │ └── \u001b[38;5;5mInput Function\u001b[0m/2/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 16:23:23Z\u001b[2m\u001b[0m\n",
959
+ " ├── \u001b[38;5;5meliot:destination_failure\u001b[0m/3\u001b[0m \u001b[38;5;15m2023-02-27 16:23:23Z\u001b[2m\u001b[0m\n",
960
+ " │ ├── \u001b[38;5;4mexception\u001b[0m: builtins.AttributeError\u001b[0m\n",
961
+ " │ ├── \u001b[38;5;4mmessage\u001b[0m: {\"'input'\": 'State(memory=[(\\'echo -e \"x=lambda y:y*5+3;print(\\\\\\'Result:\\\\\\' + str(x(6)))\" > run.py && python3 run.py\\', \\'\\\\n\\\\n```\\\\n$ echo -e \"x=lambda y:y*5+3;print(\\\\\\'Result:\\\\\\' + str(x(6)))\" > run.py\\\\n$ python3 run.py\\\\nResult: 33\\\\n```\\'), (\\'echo -e \"print(list(filter(lambda x: all(x%d for d in range(2,x)),range(2,3**10)))[:10])\" > run.py && python3 run.py\\', \\'\\\\n\\\\n```\\\\n$ echo -e \"print(list(filter(lambda x: all(x%d for d in range(2,x)),range(2,3**10)))[:10])\" > run.py\\\\n$ python3 run.py\\\\n[2, 3, 5, 7, 11, 13, 17, 19, 23, 29]\\\\n```\\')], human_input=\\'echo -e \"echo \\\\\\'Hello from Docker\" > entrypoint.sh && echo -e \"FROM ubuntu:20.04\\\\nCOPY entrypoint.sh entrypoint.sh\\\\nENTRYPOINT [\"/bin/sh\",\"entrypoint.sh\"]\">Dockerfile && docker build . -t my_docker_image && docker run -t my_docker_image\\')', \"'action_status'\": \"'started'\", \"'timestamp'\": '1677515003.1996367', \"'task_uuid'\": \"'00a84ff6-6fc1-4afc-88b1-e82a893855d3'\", \"'action_type'\": \"'Input Function'\", \"'task_level'\": '[2, 1]'}\u001b[0m\n",
962
+ " │ └── \u001b[38;5;4mreason\u001b[0m: module 'numpy' has no attribute 'bool'.⏎\n",
963
+ " │ `np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.⏎\n",
964
+ " │ The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:⏎\n",
965
+ " │ https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations\u001b[0m\n",
966
+ " ├── \u001b[38;5;5mPrompted\u001b[0m/4/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 16:23:23Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m4.838s\u001b[2m\u001b[0m\n",
967
+ " │ ├── \u001b[38;5;4mprompt\u001b[0m: Assistant is a large language model trained by OpenAI.⏎\n",
968
+ " │ │ ⏎\n",
969
+ " │ │ Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.⏎\n",
970
+ " │ │ ⏎\n",
971
+ " │ │ Assistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.⏎\n",
972
+ " │ │ ⏎\n",
973
+ " │ │ Overall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.⏎\n",
974
+ " │ │ ⏎\n",
975
+ " │ │ ⏎\n",
976
+ " │ │ Human: echo -e \"x=lambda y:y*5+3;print('Result:' + str(x(6)))\" > run.py && python3 run.py⏎\n",
977
+ " │ │ AI: ⏎\n",
978
+ " │ │ ⏎\n",
979
+ " │ │ ```⏎\n",
980
+ " │ │ $ echo -e \"x=lambda y:y*5+3;print('Result:' + str(x(6)))\" > run.py⏎\n",
981
+ " │ │ $ python3 run.py⏎\n",
982
+ " │ │ Result: 33⏎\n",
983
+ " │ │ ```⏎\n",
984
+ " │ │ ⏎\n",
985
+ " │ │ Human: echo -e \"print(list(filter(lambda x: all(x%d for d in range(2,x)),range(2,3**10)))[:10])\" > run.py && python3 run.py⏎\n",
986
+ " │ │ AI: ⏎\n",
987
+ " │ │ ⏎\n",
988
+ " │ │ ```⏎\n",
989
+ " │ │ $ echo -e \"print(list(filter(lambda x: all(x%d for d in range(2,x)),range(2,3**10)))[:10])\" > run.py⏎\n",
990
+ " │ │ $ python3 run.py⏎\n",
991
+ " │ │ [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]⏎\n",
992
+ " │ │ ```⏎\n",
993
+ " │ │ ⏎\n",
994
+ " │ │ ⏎\n",
995
+ " │ │ Human: echo -e \"echo 'Hello from Docker\" > entrypoint.sh && echo -e \"FROM ubuntu:20.04⏎\n",
996
+ " │ │ COPY entrypoint.sh entrypoint.sh⏎\n",
997
+ " │ │ ENTRYPOINT [\"/bin/sh\",\"entrypoint.sh\"]\">Dockerfile && docker build . -t my_docker_image && docker run -t my_docker_image⏎\n",
998
+ " │ │ Assistant:\u001b[0m\n",
999
+ " │ └── \u001b[38;5;5mPrompted\u001b[0m/4/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 16:23:28Z\u001b[2m\u001b[0m\n",
1000
+ " ├── \u001b[38;5;5mResult\u001b[0m/5/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 16:23:28Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m0.000s\u001b[2m\u001b[0m\n",
1001
+ " │ ├── \u001b[38;5;4mresult\u001b[0m: ⏎\n",
1002
+ " │ │ ⏎\n",
1003
+ " │ │ ```⏎\n",
1004
+ " │ │ $ echo -e \"echo 'Hello from Docker\" > entrypoint.sh⏎\n",
1005
+ " │ │ $ echo -e \"FROM ubuntu:20.04⏎\n",
1006
+ " │ │ COPY entrypoint.sh entrypoint.sh⏎\n",
1007
+ " │ │ ENTRYPOINT [\"/bin/sh\",\"entrypoint.sh\"]\">Dockerfile⏎\n",
1008
+ " │ │ $ docker build . -t my_docker_image⏎\n",
1009
+ " │ │ $ docker run -t my_docker_image⏎\n",
1010
+ " │ │ Hello from Docker⏎\n",
1011
+ " │ │ ```\u001b[0m\n",
1012
+ " │ └── \u001b[38;5;5mResult\u001b[0m/5/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 16:23:28Z\u001b[2m\u001b[0m\n",
1013
+ " └── \u001b[38;5;5m<class '__main__.ChatPrompt'>\u001b[0m/6\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 16:23:28Z\u001b[2m\u001b[0m\n",
1014
+ "\n",
1015
+ "\u001b[38;5;15mb0225ad7-9ac0-4735-b895-3fa45eeef9db\u001b[1m\u001b[0m\n",
1016
+ "└── \u001b[38;5;5m<class '__main__.ChatPrompt'>\u001b[0m/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 16:23:10Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m4.909s\u001b[2m\u001b[0m\n",
1017
+ " ├── <unnamed>\n",
1018
+ " │ └── \u001b[38;5;5mInput Function\u001b[0m/2/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 16:23:10Z\u001b[2m\u001b[0m\n",
1019
+ " ├── \u001b[38;5;5meliot:destination_failure\u001b[0m/3\u001b[0m \u001b[38;5;15m2023-02-27 16:23:10Z\u001b[2m\u001b[0m\n",
1020
+ " │ ├── \u001b[38;5;4mexception\u001b[0m: builtins.AttributeError\u001b[0m\n",
1021
+ " │ ├── \u001b[38;5;4mmessage\u001b[0m: {\"'input'\": \"State(memory=[('ls ~', '\\\\n```\\\\n$ ls ~\\\\nDesktop/ Documents/ Downloads/ Music/ Pictures/ Public/ Templates/ Videos/\\\\n```'), ('cd ~', ' \\\\n```\\\\n$ cd ~\\\\n$ pwd\\\\n/home/username\\\\n```')], human_input='{Please make a file jokes.txt inside and put some jokes inside}')\", \"'action_status'\": \"'started'\", \"'timestamp'\": '1677514990.9499614', \"'task_uuid'\": \"'b0225ad7-9ac0-4735-b895-3fa45eeef9db'\", \"'action_type'\": \"'Input Function'\", \"'task_level'\": '[2, 1]'}\u001b[0m\n",
1022
+ " │ └── \u001b[38;5;4mreason\u001b[0m: module 'numpy' has no attribute 'bool'.⏎\n",
1023
+ " │ `np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.⏎\n",
1024
+ " │ The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:⏎\n",
1025
+ " │ https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations\u001b[0m\n",
1026
+ " ├── \u001b[38;5;5mPrompted\u001b[0m/4/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 16:23:10Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m4.906s\u001b[2m\u001b[0m\n",
1027
+ " │ ├── \u001b[38;5;4mprompt\u001b[0m: Assistant is a large language model trained by OpenAI.⏎\n",
1028
+ " │ │ ⏎\n",
1029
+ " │ │ Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.⏎\n",
1030
+ " │ │ ⏎\n",
1031
+ " │ │ Assistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.⏎\n",
1032
+ " │ │ ⏎\n",
1033
+ " │ │ Overall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.⏎\n",
1034
+ " │ │ ⏎\n",
1035
+ " │ │ ⏎\n",
1036
+ " │ │ Human: ls ~⏎\n",
1037
+ " │ │ AI: ⏎\n",
1038
+ " │ │ ```⏎\n",
1039
+ " │ │ $ ls ~⏎\n",
1040
+ " │ │ Desktop/ Documents/ Downloads/ Music/ Pictures/ Public/ Templates/ Videos/⏎\n",
1041
+ " │ │ ```⏎\n",
1042
+ " │ │ ⏎\n",
1043
+ " │ │ Human: cd ~⏎\n",
1044
+ " │ │ AI: ⏎\n",
1045
+ " │ │ ```⏎\n",
1046
+ " │ │ $ cd ~⏎\n",
1047
+ " │ │ $ pwd⏎\n",
1048
+ " │ │ /home/username⏎\n",
1049
+ " │ │ ```⏎\n",
1050
+ " │ │ ⏎\n",
1051
+ " │ │ ⏎\n",
1052
+ " │ │ Human: {Please make a file jokes.txt inside and put some jokes inside}⏎\n",
1053
+ " │ │ Assistant:\u001b[0m\n",
1054
+ " │ └── \u001b[38;5;5mPrompted\u001b[0m/4/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 16:23:15Z\u001b[2m\u001b[0m\n",
1055
+ " ├── \u001b[38;5;5mResult\u001b[0m/5/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 16:23:15Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m0.000s\u001b[2m\u001b[0m\n",
1056
+ " │ ├── \u001b[38;5;4mresult\u001b[0m: ⏎\n",
1057
+ " │ │ ⏎\n",
1058
+ " │ │ ```⏎\n",
1059
+ " │ │ $ touch jokes.txt⏎\n",
1060
+ " │ │ $ echo \"Why did the chicken cross the road? To get to the other side!\" >> jokes.txt⏎\n",
1061
+ " │ │ $ echo \"What did the fish say when it hit the wall? Dam!\" >> jokes.txt⏎\n",
1062
+ " │ │ $ echo \"Why did the scarecrow win the Nobel Prize? Because he was outstanding in his field!\" >> jokes.txt⏎\n",
1063
+ " │ │ ```\u001b[0m\n",
1064
+ " │ └── \u001b[38;5;5mResult\u001b[0m/5/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 16:23:15Z\u001b[2m\u001b[0m\n",
1065
+ " └── \u001b[38;5;5m<class '__main__.ChatPrompt'>\u001b[0m/6\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 16:23:15Z\u001b[2m\u001b[0m\n",
1066
+ "\n"
1067
+ ]
1068
+ }
1069
+ ],
1070
+ "source": [
1071
+ "minichain.show_log(\"chatgpt.log\")"
1072
+ ]
1073
+ }
1074
+ ],
1075
+ "metadata": {
1076
+ "jupytext": {
1077
+ "cell_metadata_filter": "tags,-all"
1078
+ },
1079
+ "kernelspec": {
1080
+ "display_name": "minichain",
1081
+ "language": "python",
1082
+ "name": "minichain"
1083
+ },
1084
+ "language_info": {
1085
+ "codemirror_mode": {
1086
+ "name": "ipython",
1087
+ "version": 3
1088
+ },
1089
+ "file_extension": ".py",
1090
+ "mimetype": "text/x-python",
1091
+ "name": "python",
1092
+ "nbconvert_exporter": "python",
1093
+ "pygments_lexer": "ipython3",
1094
+ "version": "3.10.6"
1095
+ }
1096
+ },
1097
+ "nbformat": 4,
1098
+ "nbformat_minor": 5
1099
+ }
chatgpt.log ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"action_status": "started", "timestamp": 1677514985.975952, "task_uuid": "be24331e-675b-4c1f-aa66-65b84a7602e3", "action_type": "chatgpt", "task_level": [1]}
2
+ {"action_status": "started", "timestamp": 1677514986.2875004, "task_uuid": "c2062d1e-37fb-44e9-9e3f-35fd33720af5", "action_type": "<class '__main__.ChatPrompt'>", "task_level": [1]}
3
+ {"reason": "module 'numpy' has no attribute 'bool'.\n`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.\nThe aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:\n https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations", "exception": "builtins.AttributeError", "message": "{\"'input'\": \"State(memory=[], human_input='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.')\", \"'action_status'\": \"'started'\", \"'timestamp'\": '1677514986.2875783', \"'task_uuid'\": \"'c2062d1e-37fb-44e9-9e3f-35fd33720af5'\", \"'action_type'\": \"'Input Function'\", \"'task_level'\": '[2, 1]'}", "timestamp": 1677514986.287665, "task_uuid": "c2062d1e-37fb-44e9-9e3f-35fd33720af5", "task_level": [3], "message_type": "eliot:destination_failure"}
4
+ {"action_status": "succeeded", "timestamp": 1677514986.2912104, "task_uuid": "c2062d1e-37fb-44e9-9e3f-35fd33720af5", "action_type": "Input Function", "task_level": [2, 2]}
5
+ {"prompt": "Assistant is a large language model trained by OpenAI.\n\nAssistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.\n\nAssistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.\n\nOverall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.\n\n\n\nHuman: 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.\nAssistant:", "action_status": "started", "timestamp": 1677514986.2913702, "task_uuid": "c2062d1e-37fb-44e9-9e3f-35fd33720af5", "action_type": "Prompted", "task_level": [4, 1]}
6
+ {"action_status": "succeeded", "timestamp": 1677514987.7635746, "task_uuid": "c2062d1e-37fb-44e9-9e3f-35fd33720af5", "action_type": "Prompted", "task_level": [4, 2]}
7
+ {"result": "\n```\n$ pwd\n/\n```", "action_status": "started", "timestamp": 1677514987.763787, "task_uuid": "c2062d1e-37fb-44e9-9e3f-35fd33720af5", "action_type": "Result", "task_level": [5, 1]}
8
+ {"action_status": "succeeded", "timestamp": 1677514987.763915, "task_uuid": "c2062d1e-37fb-44e9-9e3f-35fd33720af5", "action_type": "Result", "task_level": [5, 2]}
9
+ {"action_status": "succeeded", "timestamp": 1677514987.7640302, "task_uuid": "c2062d1e-37fb-44e9-9e3f-35fd33720af5", "action_type": "<class '__main__.ChatPrompt'>", "task_level": [6]}
10
+ {"action_status": "started", "timestamp": 1677514987.7762234, "task_uuid": "6a51f09a-2d2a-4883-a864-3bb66ba6215b", "action_type": "<class '__main__.ChatPrompt'>", "task_level": [1]}
11
+ {"reason": "module 'numpy' has no attribute 'bool'.\n`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.\nThe aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:\n https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations", "exception": "builtins.AttributeError", "message": "{\"'input'\": \"State(memory=[('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.', '\\\\n```\\\\n$ pwd\\\\n/\\\\n```')], human_input='ls ~')\", \"'action_status'\": \"'started'\", \"'timestamp'\": '1677514987.7763977', \"'task_uuid'\": \"'6a51f09a-2d2a-4883-a864-3bb66ba6215b'\", \"'action_type'\": \"'Input Function'\", \"'task_level'\": '[2, 1]'}", "timestamp": 1677514987.776682, "task_uuid": "6a51f09a-2d2a-4883-a864-3bb66ba6215b", "task_level": [3], "message_type": "eliot:destination_failure"}
12
+ {"action_status": "succeeded", "timestamp": 1677514987.7836592, "task_uuid": "6a51f09a-2d2a-4883-a864-3bb66ba6215b", "action_type": "Input Function", "task_level": [2, 2]}
13
+ {"prompt": "Assistant is a large language model trained by OpenAI.\n\nAssistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.\n\nAssistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.\n\nOverall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.\n\n\nHuman: 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.\nAI: \n```\n$ pwd\n/\n```\n\n\nHuman: ls ~\nAssistant:", "action_status": "started", "timestamp": 1677514987.7838352, "task_uuid": "6a51f09a-2d2a-4883-a864-3bb66ba6215b", "action_type": "Prompted", "task_level": [4, 1]}
14
+ {"action_status": "succeeded", "timestamp": 1677514989.494076, "task_uuid": "6a51f09a-2d2a-4883-a864-3bb66ba6215b", "action_type": "Prompted", "task_level": [4, 2]}
15
+ {"result": "\n```\n$ ls ~\nDesktop/ Documents/ Downloads/ Music/ Pictures/ Public/ Templates/ Videos/\n```", "action_status": "started", "timestamp": 1677514989.4943125, "task_uuid": "6a51f09a-2d2a-4883-a864-3bb66ba6215b", "action_type": "Result", "task_level": [5, 1]}
16
+ {"action_status": "succeeded", "timestamp": 1677514989.4944377, "task_uuid": "6a51f09a-2d2a-4883-a864-3bb66ba6215b", "action_type": "Result", "task_level": [5, 2]}
17
+ {"action_status": "succeeded", "timestamp": 1677514989.4945207, "task_uuid": "6a51f09a-2d2a-4883-a864-3bb66ba6215b", "action_type": "<class '__main__.ChatPrompt'>", "task_level": [6]}
18
+ {"action_status": "started", "timestamp": 1677514989.5081844, "task_uuid": "8d9f2eb7-c022-48e6-bdeb-c35b8852c934", "action_type": "<class '__main__.ChatPrompt'>", "task_level": [1]}
19
+ {"reason": "module 'numpy' has no attribute 'bool'.\n`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.\nThe aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:\n https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations", "exception": "builtins.AttributeError", "message": "{\"'input'\": \"State(memory=[('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.', '\\\\n```\\\\n$ pwd\\\\n/\\\\n```'), ('ls ~', '\\\\n```\\\\n$ ls ~\\\\nDesktop/ Documents/ Downloads/ Music/ Pictures/ Public/ Templates/ Videos/\\\\n```')], human_input='cd ~')\", \"'action_status'\": \"'started'\", \"'timestamp'\": '1677514989.5083773', \"'task_uuid'\": \"'8d9f2eb7-c022-48e6-bdeb-c35b8852c934'\", \"'action_type'\": \"'Input Function'\", \"'task_level'\": '[2, 1]'}", "timestamp": 1677514989.5086985, "task_uuid": "8d9f2eb7-c022-48e6-bdeb-c35b8852c934", "task_level": [3], "message_type": "eliot:destination_failure"}
20
+ {"action_status": "succeeded", "timestamp": 1677514989.5162013, "task_uuid": "8d9f2eb7-c022-48e6-bdeb-c35b8852c934", "action_type": "Input Function", "task_level": [2, 2]}
21
+ {"prompt": "Assistant is a large language model trained by OpenAI.\n\nAssistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.\n\nAssistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.\n\nOverall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.\n\n\nHuman: 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.\nAI: \n```\n$ pwd\n/\n```\n\nHuman: ls ~\nAI: \n```\n$ ls ~\nDesktop/ Documents/ Downloads/ Music/ Pictures/ Public/ Templates/ Videos/\n```\n\n\nHuman: cd ~\nAssistant:", "action_status": "started", "timestamp": 1677514989.516413, "task_uuid": "8d9f2eb7-c022-48e6-bdeb-c35b8852c934", "action_type": "Prompted", "task_level": [4, 1]}
22
+ {"action_status": "succeeded", "timestamp": 1677514990.9448535, "task_uuid": "8d9f2eb7-c022-48e6-bdeb-c35b8852c934", "action_type": "Prompted", "task_level": [4, 2]}
23
+ {"result": " \n```\n$ cd ~\n$ pwd\n/home/username\n```", "action_status": "started", "timestamp": 1677514990.9449363, "task_uuid": "8d9f2eb7-c022-48e6-bdeb-c35b8852c934", "action_type": "Result", "task_level": [5, 1]}
24
+ {"action_status": "succeeded", "timestamp": 1677514990.9449837, "task_uuid": "8d9f2eb7-c022-48e6-bdeb-c35b8852c934", "action_type": "Result", "task_level": [5, 2]}
25
+ {"action_status": "succeeded", "timestamp": 1677514990.9450145, "task_uuid": "8d9f2eb7-c022-48e6-bdeb-c35b8852c934", "action_type": "<class '__main__.ChatPrompt'>", "task_level": [6]}
26
+ {"action_status": "started", "timestamp": 1677514990.949691, "task_uuid": "b0225ad7-9ac0-4735-b895-3fa45eeef9db", "action_type": "<class '__main__.ChatPrompt'>", "task_level": [1]}
27
+ {"reason": "module 'numpy' has no attribute 'bool'.\n`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.\nThe aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:\n https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations", "exception": "builtins.AttributeError", "message": "{\"'input'\": \"State(memory=[('ls ~', '\\\\n```\\\\n$ ls ~\\\\nDesktop/ Documents/ Downloads/ Music/ Pictures/ Public/ Templates/ Videos/\\\\n```'), ('cd ~', ' \\\\n```\\\\n$ cd ~\\\\n$ pwd\\\\n/home/username\\\\n```')], human_input='{Please make a file jokes.txt inside and put some jokes inside}')\", \"'action_status'\": \"'started'\", \"'timestamp'\": '1677514990.9499614', \"'task_uuid'\": \"'b0225ad7-9ac0-4735-b895-3fa45eeef9db'\", \"'action_type'\": \"'Input Function'\", \"'task_level'\": '[2, 1]'}", "timestamp": 1677514990.9501207, "task_uuid": "b0225ad7-9ac0-4735-b895-3fa45eeef9db", "task_level": [3], "message_type": "eliot:destination_failure"}
28
+ {"action_status": "succeeded", "timestamp": 1677514990.9532957, "task_uuid": "b0225ad7-9ac0-4735-b895-3fa45eeef9db", "action_type": "Input Function", "task_level": [2, 2]}
29
+ {"prompt": "Assistant is a large language model trained by OpenAI.\n\nAssistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.\n\nAssistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.\n\nOverall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.\n\n\nHuman: ls ~\nAI: \n```\n$ ls ~\nDesktop/ Documents/ Downloads/ Music/ Pictures/ Public/ Templates/ Videos/\n```\n\nHuman: cd ~\nAI: \n```\n$ cd ~\n$ pwd\n/home/username\n```\n\n\nHuman: {Please make a file jokes.txt inside and put some jokes inside}\nAssistant:", "action_status": "started", "timestamp": 1677514990.9533696, "task_uuid": "b0225ad7-9ac0-4735-b895-3fa45eeef9db", "action_type": "Prompted", "task_level": [4, 1]}
30
+ {"action_status": "succeeded", "timestamp": 1677514995.858929, "task_uuid": "b0225ad7-9ac0-4735-b895-3fa45eeef9db", "action_type": "Prompted", "task_level": [4, 2]}
31
+ {"result": "\n\n```\n$ touch jokes.txt\n$ echo \"Why did the chicken cross the road? To get to the other side!\" >> jokes.txt\n$ echo \"What did the fish say when it hit the wall? Dam!\" >> jokes.txt\n$ echo \"Why did the scarecrow win the Nobel Prize? Because he was outstanding in his field!\" >> jokes.txt\n```", "action_status": "started", "timestamp": 1677514995.8590267, "task_uuid": "b0225ad7-9ac0-4735-b895-3fa45eeef9db", "action_type": "Result", "task_level": [5, 1]}
32
+ {"action_status": "succeeded", "timestamp": 1677514995.8590858, "task_uuid": "b0225ad7-9ac0-4735-b895-3fa45eeef9db", "action_type": "Result", "task_level": [5, 2]}
33
+ {"action_status": "succeeded", "timestamp": 1677514995.859122, "task_uuid": "b0225ad7-9ac0-4735-b895-3fa45eeef9db", "action_type": "<class '__main__.ChatPrompt'>", "task_level": [6]}
34
+ {"action_status": "started", "timestamp": 1677514995.86515, "task_uuid": "60ca1813-07db-499b-b10b-d5b64709303f", "action_type": "<class '__main__.ChatPrompt'>", "task_level": [1]}
35
+ {"reason": "module 'numpy' has no attribute 'bool'.\n`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.\nThe aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:\n https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations", "exception": "builtins.AttributeError", "message": "{\"'input'\": 'State(memory=[(\\'cd ~\\', \\' \\\\n```\\\\n$ cd ~\\\\n$ pwd\\\\n/home/username\\\\n```\\'), (\\'{Please make a file jokes.txt inside and put some jokes inside}\\', \\'\\\\n\\\\n```\\\\n$ touch jokes.txt\\\\n$ echo \"Why did the chicken cross the road? To get to the other side!\" >> jokes.txt\\\\n$ echo \"What did the fish say when it hit the wall? Dam!\" >> jokes.txt\\\\n$ echo \"Why did the scarecrow win the Nobel Prize? Because he was outstanding in his field!\" >> jokes.txt\\\\n```\\')], human_input=\\'echo -e \"x=lambda y:y*5+3;print(\\\\\\'Result:\\\\\\' + str(x(6)))\" > run.py && python3 run.py\\')', \"'action_status'\": \"'started'\", \"'timestamp'\": '1677514995.8653514', \"'task_uuid'\": \"'60ca1813-07db-499b-b10b-d5b64709303f'\", \"'action_type'\": \"'Input Function'\", \"'task_level'\": '[2, 1]'}", "timestamp": 1677514995.8655088, "task_uuid": "60ca1813-07db-499b-b10b-d5b64709303f", "task_level": [3], "message_type": "eliot:destination_failure"}
36
+ {"action_status": "succeeded", "timestamp": 1677514995.8692126, "task_uuid": "60ca1813-07db-499b-b10b-d5b64709303f", "action_type": "Input Function", "task_level": [2, 2]}
37
+ {"prompt": "Assistant is a large language model trained by OpenAI.\n\nAssistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.\n\nAssistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.\n\nOverall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.\n\n\nHuman: cd ~\nAI: \n```\n$ cd ~\n$ pwd\n/home/username\n```\n\nHuman: {Please make a file jokes.txt inside and put some jokes inside}\nAI: \n\n```\n$ touch jokes.txt\n$ echo \"Why did the chicken cross the road? To get to the other side!\" >> jokes.txt\n$ echo \"What did the fish say when it hit the wall? Dam!\" >> jokes.txt\n$ echo \"Why did the scarecrow win the Nobel Prize? Because he was outstanding in his field!\" >> jokes.txt\n```\n\n\nHuman: echo -e \"x=lambda y:y*5+3;print('Result:' + str(x(6)))\" > run.py && python3 run.py\nAssistant:", "action_status": "started", "timestamp": 1677514995.8693106, "task_uuid": "60ca1813-07db-499b-b10b-d5b64709303f", "action_type": "Prompted", "task_level": [4, 1]}
38
+ {"action_status": "succeeded", "timestamp": 1677514999.1287231, "task_uuid": "60ca1813-07db-499b-b10b-d5b64709303f", "action_type": "Prompted", "task_level": [4, 2]}
39
+ {"result": "\n\n```\n$ echo -e \"x=lambda y:y*5+3;print('Result:' + str(x(6)))\" > run.py\n$ python3 run.py\nResult: 33\n```", "action_status": "started", "timestamp": 1677514999.1288157, "task_uuid": "60ca1813-07db-499b-b10b-d5b64709303f", "action_type": "Result", "task_level": [5, 1]}
40
+ {"action_status": "succeeded", "timestamp": 1677514999.1288638, "task_uuid": "60ca1813-07db-499b-b10b-d5b64709303f", "action_type": "Result", "task_level": [5, 2]}
41
+ {"action_status": "succeeded", "timestamp": 1677514999.1288946, "task_uuid": "60ca1813-07db-499b-b10b-d5b64709303f", "action_type": "<class '__main__.ChatPrompt'>", "task_level": [6]}
42
+ {"action_status": "started", "timestamp": 1677514999.1336586, "task_uuid": "5a8d829e-f545-4f75-b1b3-efb6cdb5d8e4", "action_type": "<class '__main__.ChatPrompt'>", "task_level": [1]}
43
+ {"reason": "module 'numpy' has no attribute 'bool'.\n`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.\nThe aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:\n https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations", "exception": "builtins.AttributeError", "message": "{\"'input'\": 'State(memory=[(\\'{Please make a file jokes.txt inside and put some jokes inside}\\', \\'\\\\n\\\\n```\\\\n$ touch jokes.txt\\\\n$ echo \"Why did the chicken cross the road? To get to the other side!\" >> jokes.txt\\\\n$ echo \"What did the fish say when it hit the wall? Dam!\" >> jokes.txt\\\\n$ echo \"Why did the scarecrow win the Nobel Prize? Because he was outstanding in his field!\" >> jokes.txt\\\\n```\\'), (\\'echo -e \"x=lambda y:y*5+3;print(\\\\\\'Result:\\\\\\' + str(x(6)))\" > run.py && python3 run.py\\', \\'\\\\n\\\\n```\\\\n$ echo -e \"x=lambda y:y*5+3;print(\\\\\\'Result:\\\\\\' + str(x(6)))\" > run.py\\\\n$ python3 run.py\\\\nResult: 33\\\\n```\\')], human_input=\\'echo -e \"print(list(filter(lambda x: all(x%d for d in range(2,x)),range(2,3**10)))[:10])\" > run.py && python3 run.py\\')', \"'action_status'\": \"'started'\", \"'timestamp'\": '1677514999.1337094', \"'task_uuid'\": \"'5a8d829e-f545-4f75-b1b3-efb6cdb5d8e4'\", \"'action_type'\": \"'Input Function'\", \"'task_level'\": '[2, 1]'}", "timestamp": 1677514999.1337867, "task_uuid": "5a8d829e-f545-4f75-b1b3-efb6cdb5d8e4", "task_level": [3], "message_type": "eliot:destination_failure"}
44
+ {"action_status": "succeeded", "timestamp": 1677514999.135381, "task_uuid": "5a8d829e-f545-4f75-b1b3-efb6cdb5d8e4", "action_type": "Input Function", "task_level": [2, 2]}
45
+ {"prompt": "Assistant is a large language model trained by OpenAI.\n\nAssistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.\n\nAssistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.\n\nOverall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.\n\n\nHuman: {Please make a file jokes.txt inside and put some jokes inside}\nAI: \n\n```\n$ touch jokes.txt\n$ echo \"Why did the chicken cross the road? To get to the other side!\" >> jokes.txt\n$ echo \"What did the fish say when it hit the wall? Dam!\" >> jokes.txt\n$ echo \"Why did the scarecrow win the Nobel Prize? Because he was outstanding in his field!\" >> jokes.txt\n```\n\nHuman: echo -e \"x=lambda y:y*5+3;print('Result:' + str(x(6)))\" > run.py && python3 run.py\nAI: \n\n```\n$ echo -e \"x=lambda y:y*5+3;print('Result:' + str(x(6)))\" > run.py\n$ python3 run.py\nResult: 33\n```\n\n\nHuman: echo -e \"print(list(filter(lambda x: all(x%d for d in range(2,x)),range(2,3**10)))[:10])\" > run.py && python3 run.py\nAssistant:", "action_status": "started", "timestamp": 1677514999.1354215, "task_uuid": "5a8d829e-f545-4f75-b1b3-efb6cdb5d8e4", "action_type": "Prompted", "task_level": [4, 1]}
46
+ {"action_status": "succeeded", "timestamp": 1677515003.1960745, "task_uuid": "5a8d829e-f545-4f75-b1b3-efb6cdb5d8e4", "action_type": "Prompted", "task_level": [4, 2]}
47
+ {"result": "\n\n```\n$ echo -e \"print(list(filter(lambda x: all(x%d for d in range(2,x)),range(2,3**10)))[:10])\" > run.py\n$ python3 run.py\n[2, 3, 5, 7, 11, 13, 17, 19, 23, 29]\n```", "action_status": "started", "timestamp": 1677515003.1962907, "task_uuid": "5a8d829e-f545-4f75-b1b3-efb6cdb5d8e4", "action_type": "Result", "task_level": [5, 1]}
48
+ {"action_status": "succeeded", "timestamp": 1677515003.1963375, "task_uuid": "5a8d829e-f545-4f75-b1b3-efb6cdb5d8e4", "action_type": "Result", "task_level": [5, 2]}
49
+ {"action_status": "succeeded", "timestamp": 1677515003.1963675, "task_uuid": "5a8d829e-f545-4f75-b1b3-efb6cdb5d8e4", "action_type": "<class '__main__.ChatPrompt'>", "task_level": [6]}
50
+ {"action_status": "started", "timestamp": 1677515003.1995413, "task_uuid": "00a84ff6-6fc1-4afc-88b1-e82a893855d3", "action_type": "<class '__main__.ChatPrompt'>", "task_level": [1]}
51
+ {"reason": "module 'numpy' has no attribute 'bool'.\n`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.\nThe aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:\n https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations", "exception": "builtins.AttributeError", "message": "{\"'input'\": 'State(memory=[(\\'echo -e \"x=lambda y:y*5+3;print(\\\\\\'Result:\\\\\\' + str(x(6)))\" > run.py && python3 run.py\\', \\'\\\\n\\\\n```\\\\n$ echo -e \"x=lambda y:y*5+3;print(\\\\\\'Result:\\\\\\' + str(x(6)))\" > run.py\\\\n$ python3 run.py\\\\nResult: 33\\\\n```\\'), (\\'echo -e \"print(list(filter(lambda x: all(x%d for d in range(2,x)),range(2,3**10)))[:10])\" > run.py && python3 run.py\\', \\'\\\\n\\\\n```\\\\n$ echo -e \"print(list(filter(lambda x: all(x%d for d in range(2,x)),range(2,3**10)))[:10])\" > run.py\\\\n$ python3 run.py\\\\n[2, 3, 5, 7, 11, 13, 17, 19, 23, 29]\\\\n```\\')], human_input=\\'echo -e \"echo \\\\\\'Hello from Docker\" > entrypoint.sh && echo -e \"FROM ubuntu:20.04\\\\nCOPY entrypoint.sh entrypoint.sh\\\\nENTRYPOINT [\"/bin/sh\",\"entrypoint.sh\"]\">Dockerfile && docker build . -t my_docker_image && docker run -t my_docker_image\\')', \"'action_status'\": \"'started'\", \"'timestamp'\": '1677515003.1996367', \"'task_uuid'\": \"'00a84ff6-6fc1-4afc-88b1-e82a893855d3'\", \"'action_type'\": \"'Input Function'\", \"'task_level'\": '[2, 1]'}", "timestamp": 1677515003.1997197, "task_uuid": "00a84ff6-6fc1-4afc-88b1-e82a893855d3", "task_level": [3], "message_type": "eliot:destination_failure"}
52
+ {"action_status": "succeeded", "timestamp": 1677515003.201452, "task_uuid": "00a84ff6-6fc1-4afc-88b1-e82a893855d3", "action_type": "Input Function", "task_level": [2, 2]}
53
+ {"prompt": "Assistant is a large language model trained by OpenAI.\n\nAssistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.\n\nAssistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.\n\nOverall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.\n\n\nHuman: echo -e \"x=lambda y:y*5+3;print('Result:' + str(x(6)))\" > run.py && python3 run.py\nAI: \n\n```\n$ echo -e \"x=lambda y:y*5+3;print('Result:' + str(x(6)))\" > run.py\n$ python3 run.py\nResult: 33\n```\n\nHuman: echo -e \"print(list(filter(lambda x: all(x%d for d in range(2,x)),range(2,3**10)))[:10])\" > run.py && python3 run.py\nAI: \n\n```\n$ echo -e \"print(list(filter(lambda x: all(x%d for d in range(2,x)),range(2,3**10)))[:10])\" > run.py\n$ python3 run.py\n[2, 3, 5, 7, 11, 13, 17, 19, 23, 29]\n```\n\n\nHuman: echo -e \"echo 'Hello from Docker\" > entrypoint.sh && echo -e \"FROM ubuntu:20.04\nCOPY entrypoint.sh entrypoint.sh\nENTRYPOINT [\"/bin/sh\",\"entrypoint.sh\"]\">Dockerfile && docker build . -t my_docker_image && docker run -t my_docker_image\nAssistant:", "action_status": "started", "timestamp": 1677515003.2015123, "task_uuid": "00a84ff6-6fc1-4afc-88b1-e82a893855d3", "action_type": "Prompted", "task_level": [4, 1]}
54
+ {"action_status": "succeeded", "timestamp": 1677515008.0399287, "task_uuid": "00a84ff6-6fc1-4afc-88b1-e82a893855d3", "action_type": "Prompted", "task_level": [4, 2]}
55
+ {"result": "\n\n```\n$ echo -e \"echo 'Hello from Docker\" > entrypoint.sh\n$ echo -e \"FROM ubuntu:20.04\nCOPY entrypoint.sh entrypoint.sh\nENTRYPOINT [\"/bin/sh\",\"entrypoint.sh\"]\">Dockerfile\n$ docker build . -t my_docker_image\n$ docker run -t my_docker_image\nHello from Docker\n```", "action_status": "started", "timestamp": 1677515008.0401833, "task_uuid": "00a84ff6-6fc1-4afc-88b1-e82a893855d3", "action_type": "Result", "task_level": [5, 1]}
56
+ {"action_status": "succeeded", "timestamp": 1677515008.040339, "task_uuid": "00a84ff6-6fc1-4afc-88b1-e82a893855d3", "action_type": "Result", "task_level": [5, 2]}
57
+ {"action_status": "succeeded", "timestamp": 1677515008.040439, "task_uuid": "00a84ff6-6fc1-4afc-88b1-e82a893855d3", "action_type": "<class '__main__.ChatPrompt'>", "task_level": [6]}
58
+ {"action_status": "started", "timestamp": 1677515008.053587, "task_uuid": "ea339a52-82af-4c19-8ee6-1d2f081bc437", "action_type": "<class '__main__.ChatPrompt'>", "task_level": [1]}
59
+ {"reason": "module 'numpy' has no attribute 'bool'.\n`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.\nThe aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:\n https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations", "exception": "builtins.AttributeError", "message": "{\"'input'\": 'State(memory=[(\\'echo -e \"print(list(filter(lambda x: all(x%d for d in range(2,x)),range(2,3**10)))[:10])\" > run.py && python3 run.py\\', \\'\\\\n\\\\n```\\\\n$ echo -e \"print(list(filter(lambda x: all(x%d for d in range(2,x)),range(2,3**10)))[:10])\" > run.py\\\\n$ python3 run.py\\\\n[2, 3, 5, 7, 11, 13, 17, 19, 23, 29]\\\\n```\\'), (\\'echo -e \"echo \\\\\\'Hello from Docker\" > entrypoint.sh && echo -e \"FROM ubuntu:20.04\\\\nCOPY entrypoint.sh entrypoint.sh\\\\nENTRYPOINT [\"/bin/sh\",\"entrypoint.sh\"]\">Dockerfile && docker build . -t my_docker_image && docker run -t my_docker_image\\', \\'\\\\n\\\\n```\\\\n$ echo -e \"echo \\\\\\'Hello from Docker\" > entrypoint.sh\\\\n$ echo -e \"FROM ubuntu:20.04\\\\nCOPY entrypoint.sh entrypoint.sh\\\\nENTRYPOINT [\"/bin/sh\",\"entrypoint.sh\"]\">Dockerfile\\\\n$ docker build . -t my_docker_image\\\\n$ docker run -t my_docker_image\\\\nHello from Docker\\\\n```\\')], human_input=\\'nvidia-smi\\')', \"'action_status'\": \"'started'\", \"'timestamp'\": '1677515008.0539572', \"'task_uuid'\": \"'ea339a52-82af-4c19-8ee6-1d2f081bc437'\", \"'action_type'\": \"'Input Function'\", \"'task_level'\": '[2, 1]'}", "timestamp": 1677515008.0543113, "task_uuid": "ea339a52-82af-4c19-8ee6-1d2f081bc437", "task_level": [3], "message_type": "eliot:destination_failure"}
60
+ {"action_status": "succeeded", "timestamp": 1677515008.0610886, "task_uuid": "ea339a52-82af-4c19-8ee6-1d2f081bc437", "action_type": "Input Function", "task_level": [2, 2]}
61
+ {"prompt": "Assistant is a large language model trained by OpenAI.\n\nAssistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.\n\nAssistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.\n\nOverall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.\n\n\nHuman: echo -e \"print(list(filter(lambda x: all(x%d for d in range(2,x)),range(2,3**10)))[:10])\" > run.py && python3 run.py\nAI: \n\n```\n$ echo -e \"print(list(filter(lambda x: all(x%d for d in range(2,x)),range(2,3**10)))[:10])\" > run.py\n$ python3 run.py\n[2, 3, 5, 7, 11, 13, 17, 19, 23, 29]\n```\n\nHuman: echo -e \"echo 'Hello from Docker\" > entrypoint.sh && echo -e \"FROM ubuntu:20.04\nCOPY entrypoint.sh entrypoint.sh\nENTRYPOINT [\"/bin/sh\",\"entrypoint.sh\"]\">Dockerfile && docker build . -t my_docker_image && docker run -t my_docker_image\nAI: \n\n```\n$ echo -e \"echo 'Hello from Docker\" > entrypoint.sh\n$ echo -e \"FROM ubuntu:20.04\nCOPY entrypoint.sh entrypoint.sh\nENTRYPOINT [\"/bin/sh\",\"entrypoint.sh\"]\">Dockerfile\n$ docker build . -t my_docker_image\n$ docker run -t my_docker_image\nHello from Docker\n```\n\n\nHuman: nvidia-smi\nAssistant:", "action_status": "started", "timestamp": 1677515008.0612898, "task_uuid": "ea339a52-82af-4c19-8ee6-1d2f081bc437", "action_type": "Prompted", "task_level": [4, 1]}
62
+ {"action_status": "succeeded", "timestamp": 1677515019.9196224, "task_uuid": "ea339a52-82af-4c19-8ee6-1d2f081bc437", "action_type": "Prompted", "task_level": [4, 2]}
63
+ {"result": "\n\n```\n$ nvidia-smi\nSat May 15 21:45:02 2021 \n+-----------------------------------------------------------------------------+\n| NVIDIA-SMI 460.32.03 Driver Version: 460.32.03 CUDA Version: 11.2 |\n|-------------------------------+----------------------+----------------------+\n| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |\n| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |\n|===============================+======================+======================|\n| 0 GeForce RTX 208... Off | 00000000:01:00.0 Off | N/A |\n| N/A 45C P0 28W / N/A | 590MiB / 7979MiB | 0% Default |\n+-------------------------------+----------------------+----------------------+\n \n+-----------------------------------------------------------------------------+\n| Processes: GPU Memory |\n| GPU PID Type Process name Usage |\n|=============================================================================|\n|", "action_status": "started", "timestamp": 1677515019.919849, "task_uuid": "ea339a52-82af-4c19-8ee6-1d2f081bc437", "action_type": "Result", "task_level": [5, 1]}
64
+ {"action_status": "succeeded", "timestamp": 1677515019.920001, "task_uuid": "ea339a52-82af-4c19-8ee6-1d2f081bc437", "action_type": "Result", "task_level": [5, 2]}
65
+ {"action_status": "succeeded", "timestamp": 1677515019.9200878, "task_uuid": "ea339a52-82af-4c19-8ee6-1d2f081bc437", "action_type": "<class '__main__.ChatPrompt'>", "task_level": [6]}
66
+ {"action_status": "succeeded", "timestamp": 1677515019.9287043, "task_uuid": "be24331e-675b-4c1f-aa66-65b84a7602e3", "action_type": "chatgpt", "task_level": [2]}
chatgpt.pmpt.tpl ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Assistant is a large language model trained by OpenAI.
2
+
3
+ Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.
4
+
5
+ Assistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.
6
+
7
+ Overall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.
8
+
9
+ {% for d in memory %}
10
+ Human: {{d[0]}}
11
+ AI: {{d[1]}}
12
+ {% endfor %}
13
+
14
+ Human: {{human_input}}
15
+ Assistant:
chatgpt.py ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # # ChatGPT
2
+
3
+ # "ChatGPT" like examples. Adapted from
4
+ # [LangChain](https://langchain.readthedocs.io/en/latest/modules/memory/examples/chatgpt_clone.html)'s
5
+ # version of this [blog
6
+ # post](https://www.engraved.blog/building-a-virtual-machine-inside/).
7
+
8
+
9
+ import warnings
10
+ from dataclasses import dataclass
11
+ from typing import List, Tuple
12
+ from IPython.display import Markdown, display
13
+ import minichain
14
+
15
+ # + tags=["hide_inp"]
16
+ warnings.filterwarnings("ignore")
17
+ # -
18
+
19
+
20
+ # Generic stateful Memory
21
+
22
+ MEMORY = 2
23
+
24
+ @dataclass
25
+ class State:
26
+ memory: List[Tuple[str, str]]
27
+ human_input: str = ""
28
+
29
+ def push(self, response: str) -> "State":
30
+ memory = self.memory if len(self.memory) < MEMORY else self.memory[1:]
31
+ return State(memory + [(self.human_input, response)])
32
+
33
+ # Chat prompt with memory
34
+
35
+ class ChatPrompt(minichain.TemplatePrompt):
36
+ template_file = "chatgpt.pmpt.tpl"
37
+ def parse(self, out: str, inp: State) -> State:
38
+ result = out.split("Assistant:")[-1]
39
+ return inp.push(result)
40
+
41
+ class Human(minichain.Prompt):
42
+ def parse(self, out: str, inp: State) -> State:
43
+ return inp.human_input = out
44
+
45
+
46
+ fake_human = [
47
+ "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.",
48
+ "ls ~",
49
+ "cd ~",
50
+ "{Please make a file jokes.txt inside and put some jokes inside}",
51
+ """echo -e "x=lambda y:y*5+3;print('Result:' + str(x(6)))" > run.py && python3 run.py""",
52
+ """echo -e "print(list(filter(lambda x: all(x%d for d in range(2,x)),range(2,3**10)))[:10])" > run.py && python3 run.py""",
53
+ """echo -e "echo 'Hello from Docker" > entrypoint.sh && echo -e "FROM ubuntu:20.04\nCOPY entrypoint.sh entrypoint.sh\nENTRYPOINT [\"/bin/sh\",\"entrypoint.sh\"]">Dockerfile && docker build . -t my_docker_image && docker run -t my_docker_image""",
54
+ "nvidia-smi"
55
+ ]
56
+
57
+ with minichain.start_chain("chatgpt") as backend:
58
+ prompt = ChatPrompt(backend.OpenAI())
59
+ human = Human(backend.Mock(fake_human))
60
+ state = State([])
61
+ for i in range(len(fake_human)):
62
+ human.chain(prompt)
63
+ # display(Markdown(f'**Human:** <span style="color: blue">{t}</span>'))
64
+ # display(Markdown(f'**Assistant:** {state.memory[-1][1]}'))
65
+ # display(Markdown(f'--------------'))
66
+
67
+
68
+ # + tags=["hide_inp"]
69
+ ChatPrompt().show(State([("human 1", "output 1"), ("human 2", "output 2") ], "cd ~"),
70
+ "Text Assistant: Hello")
71
+ # -
72
+
73
+ # View the run log.
74
+
75
+ minichain.show_log("chatgpt.log")
color.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Answer a math problem with code.
2
+ # Adapted from Dust [maths-generate-code](https://dust.tt/spolu/a/d12ac33169)
3
+
4
+ from minichain import Backend, JinjaPrompt, Prompt, start_chain, SimplePrompt, show_log
5
+
6
+
7
+ # Prompt that asks LLM for code from math.
8
+
9
+ class ColorPrompt(Prompt[str, bool]):
10
+ def parse(inp: str) -> str:
11
+ return f"Answer 'Yes' if this is a color, {inp}. Answer:"
12
+
13
+ def parse(out: str, inp) -> bool:
14
+ # Encode the parsing logic
15
+ return out.strip() == "Yes"
16
+ ColorPrompt().show({"inp": "dog"}, "No")
17
+
18
+
19
+ with start_chain("color") as backend:
20
+ question = 'What is the sum of the powers of 3 (3^i) that are smaller than 100?'
21
+ prompt = MathPrompt(backend.OpenAI()).chain(SimplePrompt(backend.Python()))
22
+ result = prompt({"question": question})
23
+ print(result)
24
+
25
+
26
+ show_log("math.log")
examples.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from chat import gradio as chat
3
+ from ner import gradio as ner
4
+ from math_demo import gradio as math_demo
5
+ from bash import gradio as bash
6
+ from pal import gradio as pal
7
+ from gatsby import gradio as gatsby
8
+ from stats import gradio as stats
9
+
10
+ css = "#clean div.form {border: 0px} #response {border: 0px; background: #ffeec6} #prompt {border: 0px;background: aliceblue} #json {border: 0px} #result {border: 0px; background: #c5e0e5} #inner {padding: 20px} #inner textarea {border: 0px} .tabs div.tabitem {border: 0px}"
11
+
12
+ with gr.Blocks(css=css) as demo:
13
+ gr.HTML("<center> <img width='10%' style='display:inline; padding: 5px' src='https://user-images.githubusercontent.com/35882/218286642-67985b6f-d483-49be-825b-f62b72c469cd.png'> <h1 style='display:inline'> Mini-Chain </h1> <img width='10%' style='display:inline;padding: 5px' src='https://avatars.githubusercontent.com/u/25720743?s=200&v=4'> </center><br><center><a href='https://github.com/srush/minichain'>[code]</a> <a href='https://user-images.githubusercontent.com/35882/218286642-67985b6f-d483-49be-825b-f62b72c469cd.png'>[docs]</a></center>")
14
+
15
+ gr.TabbedInterface([chat, gatsby, math_demo, ner, bash, pal, stats],
16
+ ["Chat", "QA", "Math", "NER", "Bash", "PAL", "Stats"],
17
+ css= css)
18
+
19
+ demo.launch()
20
+
gatsby.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
gatsby.log ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {"action_status": "started", "timestamp": 1678759606.9333436, "task_uuid": "3246fe37-fa91-436b-96be-67648cd1ef76", "action_type": "gatsby", "task_level": [1]}
2
+ {"action_status": "succeeded", "timestamp": 1678759606.9335442, "task_uuid": "3246fe37-fa91-436b-96be-67648cd1ef76", "action_type": "gatsby", "task_level": [2]}
3
+ {"action_status": "started", "timestamp": 1678759606.9647467, "task_uuid": "86f09cf7-ec3b-41eb-aac0-144426f1a6f4", "action_type": "stats", "task_level": [1]}
4
+ {"action_status": "succeeded", "timestamp": 1678759606.964883, "task_uuid": "86f09cf7-ec3b-41eb-aac0-144426f1a6f4", "action_type": "stats", "task_level": [2]}
gatsby.pmpt.tpl ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Context information is below.
2
+
3
+
4
+ ---------------------
5
+
6
+
7
+ {% for doc in docs %}
8
+ * {{doc}}
9
+ {% endfor %}
10
+
11
+ ---------------------
12
+
13
+ Given the context information and not prior knowledge, answer the question: {{question}}
gatsby.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Questions answering with Hugging Face embeddings. Adapted from the
2
+ # [LlamaIndex
3
+ # example](https://github.com/jerryjliu/gpt_index/blob/main/examples/gatsby/TestGatsby.ipynb).
4
+
5
+ import datasets
6
+ import numpy as np
7
+
8
+ from minichain import EmbeddingPrompt, TemplatePrompt, show_log, start_chain
9
+
10
+ # Load data with embeddings (computed beforehand)
11
+
12
+ gatsby = datasets.load_from_disk("gatsby")
13
+ gatsby.add_faiss_index("embeddings")
14
+
15
+ # Fast KNN retieval prompt
16
+
17
+ class KNNPrompt(EmbeddingPrompt):
18
+ def prompt(self, inp):
19
+ return inp["query"]
20
+
21
+ def find(self, out, inp):
22
+ res = gatsby.get_nearest_examples("embeddings", np.array(out), 1)
23
+ return {"question": inp["query"], "docs": res.examples["passages"]}
24
+
25
+ # QA prompt to ask question with examples
26
+
27
+
28
+ class QAPrompt(TemplatePrompt):
29
+ template_file = "gatsby.pmpt.tpl"
30
+
31
+
32
+ with start_chain("gatsby") as backend:
33
+ # question = "What did Gatsby do before he met Daisy?"
34
+ prompt = KNNPrompt(
35
+ backend.HuggingFaceEmbed("sentence-transformers/all-mpnet-base-v2")
36
+ ).chain(QAPrompt(backend.OpenAI()))
37
+ # result = prompt(question)
38
+ # print(result)
39
+
40
+
41
+ gradio = prompt.to_gradio(fields=["query"],
42
+ examples=["What did Gatsby do before he met Daisy?"],
43
+ keys={"HF_KEY"})
44
+ if __name__ == "__main__":
45
+ gradio.launch()
46
+
47
+
48
+
49
+ # + tags=["hide_inp"]
50
+ # QAPrompt().show({"question": "Who was Gatsby?", "docs": ["doc1", "doc2", "doc3"]}, "")
51
+ # # -
52
+
53
+ # show_log("gatsby.log")
gatsby/data-00000-of-00001.arrow ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aaf95ec56542a1f5bd2aa3c48afb7551abb21249fd8e155855cb582ab70e64fa
3
+ size 454712
gatsby/dataset_info.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "citation": "",
3
+ "description": "",
4
+ "features": {
5
+ "passages": {
6
+ "dtype": "string",
7
+ "_type": "Value"
8
+ },
9
+ "embeddings": {
10
+ "feature": {
11
+ "dtype": "float64",
12
+ "_type": "Value"
13
+ },
14
+ "_type": "Sequence"
15
+ }
16
+ },
17
+ "homepage": "",
18
+ "license": ""
19
+ }
gatsby/state.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_data_files": [
3
+ {
4
+ "filename": "data-00000-of-00001.arrow"
5
+ }
6
+ ],
7
+ "_fingerprint": "58e539e18c1f1ec8",
8
+ "_format_columns": null,
9
+ "_format_kwargs": {},
10
+ "_format_type": null,
11
+ "_output_all_columns": false,
12
+ "_split": null
13
+ }
gatsby_part.txt ADDED
The diff for this file is too large to render. See raw diff
 
math.ipynb ADDED
@@ -0,0 +1,302 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "c0381b39",
6
+ "metadata": {},
7
+ "source": [
8
+ "Notebook to answer a math problem with code.\n",
9
+ "Adapted from Dust [maths-generate-code](https://dust.tt/spolu/a/d12ac33169)"
10
+ ]
11
+ },
12
+ {
13
+ "cell_type": "code",
14
+ "execution_count": 1,
15
+ "id": "d709d448",
16
+ "metadata": {
17
+ "execution": {
18
+ "iopub.execute_input": "2023-02-27T14:14:11.694164Z",
19
+ "iopub.status.busy": "2023-02-27T14:14:11.693422Z",
20
+ "iopub.status.idle": "2023-02-27T14:14:11.909671Z",
21
+ "shell.execute_reply": "2023-02-27T14:14:11.908948Z"
22
+ },
23
+ "lines_to_next_cell": 1
24
+ },
25
+ "outputs": [],
26
+ "source": [
27
+ "import minichain"
28
+ ]
29
+ },
30
+ {
31
+ "cell_type": "markdown",
32
+ "id": "8ae06a28",
33
+ "metadata": {},
34
+ "source": [
35
+ "Prompt that asks LLM for code from math."
36
+ ]
37
+ },
38
+ {
39
+ "cell_type": "code",
40
+ "execution_count": 2,
41
+ "id": "89496133",
42
+ "metadata": {
43
+ "execution": {
44
+ "iopub.execute_input": "2023-02-27T14:14:11.914563Z",
45
+ "iopub.status.busy": "2023-02-27T14:14:11.913355Z",
46
+ "iopub.status.idle": "2023-02-27T14:14:11.918659Z",
47
+ "shell.execute_reply": "2023-02-27T14:14:11.918034Z"
48
+ },
49
+ "lines_to_next_cell": 1
50
+ },
51
+ "outputs": [],
52
+ "source": [
53
+ "class MathPrompt(minichain.TemplatePrompt[str]):\n",
54
+ " template_file = \"math.pmpt.tpl\""
55
+ ]
56
+ },
57
+ {
58
+ "cell_type": "markdown",
59
+ "id": "22169567",
60
+ "metadata": {},
61
+ "source": [
62
+ "Ask a question and run it as python code."
63
+ ]
64
+ },
65
+ {
66
+ "cell_type": "code",
67
+ "execution_count": 3,
68
+ "id": "6e122554",
69
+ "metadata": {
70
+ "execution": {
71
+ "iopub.execute_input": "2023-02-27T14:14:11.923599Z",
72
+ "iopub.status.busy": "2023-02-27T14:14:11.922332Z",
73
+ "iopub.status.idle": "2023-02-27T14:14:14.957037Z",
74
+ "shell.execute_reply": "2023-02-27T14:14:14.956368Z"
75
+ }
76
+ },
77
+ "outputs": [
78
+ {
79
+ "name": "stdout",
80
+ "output_type": "stream",
81
+ "text": [
82
+ "121\n",
83
+ "\n"
84
+ ]
85
+ }
86
+ ],
87
+ "source": [
88
+ "with minichain.start_chain(\"math\") as backend:\n",
89
+ " question = \"What is the sum of the powers of 3 (3^i) that are smaller than 100?\"\n",
90
+ " prompt = MathPrompt(backend.OpenAI()).chain(minichain.SimplePrompt(backend.Python()))\n",
91
+ " result = prompt({\"question\": question})\n",
92
+ " print(result)"
93
+ ]
94
+ },
95
+ {
96
+ "cell_type": "markdown",
97
+ "id": "c41d0936",
98
+ "metadata": {},
99
+ "source": [
100
+ "View the prompt"
101
+ ]
102
+ },
103
+ {
104
+ "cell_type": "code",
105
+ "execution_count": 4,
106
+ "id": "df25f904",
107
+ "metadata": {
108
+ "execution": {
109
+ "iopub.execute_input": "2023-02-27T14:14:14.960159Z",
110
+ "iopub.status.busy": "2023-02-27T14:14:14.959694Z",
111
+ "iopub.status.idle": "2023-02-27T14:14:15.006679Z",
112
+ "shell.execute_reply": "2023-02-27T14:14:15.006127Z"
113
+ },
114
+ "tags": [
115
+ "hide_inp"
116
+ ]
117
+ },
118
+ "outputs": [
119
+ {
120
+ "data": {
121
+ "text/html": [
122
+ "\n",
123
+ "<!-- <link rel=\"stylesheet\" href=\"https://cdn.rawgit.com/Chalarangelo/mini.css/v3.0.1/dist/mini-default.min.css\"> -->\n",
124
+ " <main class=\"container\">\n",
125
+ "\n",
126
+ "<h3>MathPrompt</h3>\n",
127
+ "\n",
128
+ "<dl>\n",
129
+ " <dt>Input:</dt>\n",
130
+ " <dd>\n",
131
+ "<div class=\"highlight\"><pre><span></span><span class=\"p\">{</span><span class=\"s1\">&#39;question&#39;</span><span class=\"p\">:</span> <span class=\"s1\">&#39;What is 10 + 12?&#39;</span><span class=\"p\">}</span>\n",
132
+ "</pre></div>\n",
133
+ "\n",
134
+ "\n",
135
+ " </dd>\n",
136
+ "\n",
137
+ " <dt> Full Prompt: </dt>\n",
138
+ " <dd>\n",
139
+ " <details>\n",
140
+ " <summary>Prompt</summary>\n",
141
+ " <p>Question:<br>What is 37593 * 67?<br>Code:<br>37593 * 67<br><br>Question:<br>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?<br>Code:<br>(16-3-4)*2<br><br>Question:<br>How many of the integers between 0 and 99 inclusive are divisible by 8?<br>Code:<br>count = 0<br>for i in range(0, 99+1):<br> if i % 8 == 0: count += 1<br><br>Question:<br>A robe takes 2 bolts of blue fiber and half that much white fiber. How many bolts in total does it take?<br>Code:<br>2 + 2/2<br><br>Question:<br><div style='color:red'>What is 10 + 12?</div><br>Code:</p>\n",
142
+ " </details>\n",
143
+ " </dd>\n",
144
+ "\n",
145
+ " <dt> Response: </dt>\n",
146
+ " <dd>\n",
147
+ " 10 + 12\n",
148
+ " </dd>\n",
149
+ "\n",
150
+ " <dt>Value:</dt>\n",
151
+ " <dd>\n",
152
+ "<div class=\"highlight\"><pre><span></span><span class=\"mi\">10</span> <span class=\"o\">+</span> <span class=\"mi\">12</span>\n",
153
+ "</pre></div>\n",
154
+ "\n",
155
+ " </dd>\n",
156
+ "</main>\n"
157
+ ],
158
+ "text/plain": [
159
+ "HTML(html='\\n<!-- <link rel=\"stylesheet\" href=\"https://cdn.rawgit.com/Chalarangelo/mini.css/v3.0.1/dist/mini-default.min.css\"> -->\\n <main class=\"container\">\\n\\n<h3>MathPrompt</h3>\\n\\n<dl>\\n <dt>Input:</dt>\\n <dd>\\n<div class=\"highlight\"><pre><span></span><span class=\"p\">{</span><span class=\"s1\">&#39;question&#39;</span><span class=\"p\">:</span> <span class=\"s1\">&#39;What is 10 + 12?&#39;</span><span class=\"p\">}</span>\\n</pre></div>\\n\\n\\n </dd>\\n\\n <dt> Full Prompt: </dt>\\n <dd>\\n <details>\\n <summary>Prompt</summary>\\n <p>Question:<br>What is 37593 * 67?<br>Code:<br>37593 * 67<br><br>Question:<br>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?<br>Code:<br>(16-3-4)*2<br><br>Question:<br>How many of the integers between 0 and 99 inclusive are divisible by 8?<br>Code:<br>count = 0<br>for i in range(0, 99+1):<br> if i % 8 == 0: count += 1<br><br>Question:<br>A robe takes 2 bolts of blue fiber and half that much white fiber. How many bolts in total does it take?<br>Code:<br>2 + 2/2<br><br>Question:<br><div style=\\'color:red\\'>What is 10 + 12?</div><br>Code:</p>\\n </details>\\n </dd>\\n\\n <dt> Response: </dt>\\n <dd>\\n 10 + 12\\n </dd>\\n\\n <dt>Value:</dt>\\n <dd>\\n<div class=\"highlight\"><pre><span></span><span class=\"mi\">10</span> <span class=\"o\">+</span> <span class=\"mi\">12</span>\\n</pre></div>\\n\\n </dd>\\n</main>\\n')"
160
+ ]
161
+ },
162
+ "execution_count": 4,
163
+ "metadata": {},
164
+ "output_type": "execute_result"
165
+ }
166
+ ],
167
+ "source": [
168
+ "MathPrompt().show({\"question\": \"What is 10 + 12?\"}, \"10 + 12\")"
169
+ ]
170
+ },
171
+ {
172
+ "cell_type": "markdown",
173
+ "id": "5f726907",
174
+ "metadata": {},
175
+ "source": [
176
+ "View the log"
177
+ ]
178
+ },
179
+ {
180
+ "cell_type": "code",
181
+ "execution_count": 5,
182
+ "id": "0aa84914",
183
+ "metadata": {
184
+ "execution": {
185
+ "iopub.execute_input": "2023-02-27T14:14:15.009395Z",
186
+ "iopub.status.busy": "2023-02-27T14:14:15.008955Z",
187
+ "iopub.status.idle": "2023-02-27T14:14:15.032165Z",
188
+ "shell.execute_reply": "2023-02-27T14:14:15.031585Z"
189
+ }
190
+ },
191
+ "outputs": [
192
+ {
193
+ "name": "stderr",
194
+ "output_type": "stream",
195
+ "text": [
196
+ "\u001b[38;5;15md962c2e7-4475-4094-bd1d-24f450acac26\u001b[1m\u001b[0m\n",
197
+ "└── \u001b[38;5;5m<class '__main__.MathPrompt'>\u001b[0m/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:14:12Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m2.713s\u001b[2m\u001b[0m\n",
198
+ " ├── \u001b[38;5;5mInput Function\u001b[0m/2/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:14:12Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m0.002s\u001b[2m\u001b[0m\n",
199
+ " │ ├── \u001b[38;5;4minput\u001b[0m: \u001b[0m\n",
200
+ " │ │ └── \u001b[38;5;4mquestion\u001b[0m: What is the sum of the powers of 3 (3^i) that are smaller than 100?\u001b[0m\n",
201
+ " │ └── \u001b[38;5;5mInput Function\u001b[0m/2/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:14:12Z\u001b[2m\u001b[0m\n",
202
+ " ├── \u001b[38;5;5mPrompted\u001b[0m/3/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:14:12Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m2.711s\u001b[2m\u001b[0m\n",
203
+ " │ ├── \u001b[38;5;4mprompt\u001b[0m: Question:⏎\n",
204
+ " │ │ What is 37593 * 67?⏎\n",
205
+ " │ │ Code:⏎\n",
206
+ " │ │ 37593 * 67⏎\n",
207
+ " │ │ ⏎\n",
208
+ " │ │ Question:⏎\n",
209
+ " │ │ 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",
210
+ " │ │ Code:⏎\n",
211
+ " │ │ (16-3-4)*2⏎\n",
212
+ " │ │ ⏎\n",
213
+ " │ │ Question:⏎\n",
214
+ " │ │ How many of the integers between 0 and 99 inclusive are divisible by 8?⏎\n",
215
+ " │ │ Code:⏎\n",
216
+ " │ │ count = 0⏎\n",
217
+ " │ │ for i in range(0, 99+1):⏎\n",
218
+ " │ │ if i % 8 == 0: count += 1⏎\n",
219
+ " │ │ ⏎\n",
220
+ " │ │ Question:⏎\n",
221
+ " │ │ A robe takes 2 bolts of blue fiber and half that much white fiber. How many bolts in total does it take?⏎\n",
222
+ " │ │ Code:⏎\n",
223
+ " │ │ 2 + 2/2⏎\n",
224
+ " │ │ ⏎\n",
225
+ " │ │ Question:⏎\n",
226
+ " │ │ What is the sum of the powers of 3 (3^i) that are smaller than 100?⏎\n",
227
+ " │ │ Code:\u001b[0m\n",
228
+ " │ └── \u001b[38;5;5mPrompted\u001b[0m/3/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:14:14Z\u001b[2m\u001b[0m\n",
229
+ " ├── \u001b[38;5;5mResult\u001b[0m/4/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:14:14Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m0.000s\u001b[2m\u001b[0m\n",
230
+ " │ ├── \u001b[38;5;4mresult\u001b[0m: ⏎\n",
231
+ " │ │ sum = 0⏎\n",
232
+ " │ │ for i in range(0, 100):⏎\n",
233
+ " │ │ if 3**i < 100:⏎\n",
234
+ " │ │ sum += 3**i⏎\n",
235
+ " │ │ ⏎\n",
236
+ " │ │ print(sum)\u001b[0m\n",
237
+ " │ └── \u001b[38;5;5mResult\u001b[0m/4/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:14:14Z\u001b[2m\u001b[0m\n",
238
+ " └── \u001b[38;5;5m<class '__main__.MathPrompt'>\u001b[0m/5\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:14:14Z\u001b[2m\u001b[0m\n",
239
+ "\n",
240
+ "\u001b[38;5;15m3ce24477-fa41-4ca1-b11e-f7d253a7c511\u001b[1m\u001b[0m\n",
241
+ "└── \u001b[38;5;5m<class 'minichain.prompts.SimplePrompt'>\u001b[0m/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:14:14Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m0.000s\u001b[2m\u001b[0m\n",
242
+ " ├── \u001b[38;5;5mInput Function\u001b[0m/2/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:14:14Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m0.000s\u001b[2m\u001b[0m\n",
243
+ " │ ├── \u001b[38;5;4minput\u001b[0m: ⏎\n",
244
+ " │ │ sum = 0⏎\n",
245
+ " │ │ for i in range(0, 100):⏎\n",
246
+ " │ │ if 3**i < 100:⏎\n",
247
+ " │ │ sum += 3**i⏎\n",
248
+ " │ │ ⏎\n",
249
+ " │ │ print(sum)\u001b[0m\n",
250
+ " │ └── \u001b[38;5;5mInput Function\u001b[0m/2/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:14:14Z\u001b[2m\u001b[0m\n",
251
+ " ├── \u001b[38;5;5mPrompted\u001b[0m/3/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:14:14Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m0.000s\u001b[2m\u001b[0m\n",
252
+ " │ ├── \u001b[38;5;4mprompt\u001b[0m: ⏎\n",
253
+ " │ │ sum = 0⏎\n",
254
+ " │ │ for i in range(0, 100):⏎\n",
255
+ " │ │ if 3**i < 100:⏎\n",
256
+ " │ │ sum += 3**i⏎\n",
257
+ " │ │ ⏎\n",
258
+ " │ │ print(sum)\u001b[0m\n",
259
+ " │ └── \u001b[38;5;5mPrompted\u001b[0m/3/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:14:14Z\u001b[2m\u001b[0m\n",
260
+ " ├── \u001b[38;5;5mResult\u001b[0m/4/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:14:14Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m0.000s\u001b[2m\u001b[0m\n",
261
+ " │ ├── \u001b[38;5;4mresult\u001b[0m: 121⏎\n",
262
+ " │ │ \u001b[0m\n",
263
+ " │ └── \u001b[38;5;5mResult\u001b[0m/4/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:14:14Z\u001b[2m\u001b[0m\n",
264
+ " └── \u001b[38;5;5m<class 'minichain.prompts.SimplePrompt'>\u001b[0m/5\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:14:14Z\u001b[2m\u001b[0m\n",
265
+ "\n",
266
+ "\u001b[38;5;15m4d75cc49-ca9f-4512-8ca0-9393732c7d14\u001b[1m\u001b[0m\n",
267
+ "└── \u001b[38;5;5mmath\u001b[0m/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:14:11Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m3.028s\u001b[2m\u001b[0m\n",
268
+ " └── \u001b[38;5;5mmath\u001b[0m/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:14:14Z\u001b[2m\u001b[0m\n",
269
+ "\n"
270
+ ]
271
+ }
272
+ ],
273
+ "source": [
274
+ "minichain.show_log(\"math.log\")"
275
+ ]
276
+ }
277
+ ],
278
+ "metadata": {
279
+ "jupytext": {
280
+ "cell_metadata_filter": "tags,-all"
281
+ },
282
+ "kernelspec": {
283
+ "display_name": "minichain",
284
+ "language": "python",
285
+ "name": "minichain"
286
+ },
287
+ "language_info": {
288
+ "codemirror_mode": {
289
+ "name": "ipython",
290
+ "version": 3
291
+ },
292
+ "file_extension": ".py",
293
+ "mimetype": "text/x-python",
294
+ "name": "python",
295
+ "nbconvert_exporter": "python",
296
+ "pygments_lexer": "ipython3",
297
+ "version": "3.10.6"
298
+ }
299
+ },
300
+ "nbformat": 4,
301
+ "nbformat_minor": 5
302
+ }
math.log ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {"action_status": "started", "timestamp": 1678759606.5984528, "task_uuid": "694c3be6-2b7a-47b3-8d6a-0408b8dc6a26", "action_type": "math", "task_level": [1]}
2
+ {"action_status": "succeeded", "timestamp": 1678759606.5985456, "task_uuid": "694c3be6-2b7a-47b3-8d6a-0408b8dc6a26", "action_type": "math", "task_level": [2]}
3
+ {"action_status": "started", "timestamp": 1678759606.621539, "task_uuid": "b1f606f3-d7b6-48bb-a3a5-77e51fda3fa6", "action_type": "bash", "task_level": [1]}
4
+ {"action_status": "succeeded", "timestamp": 1678759606.6216574, "task_uuid": "b1f606f3-d7b6-48bb-a3a5-77e51fda3fa6", "action_type": "bash", "task_level": [2]}
5
+ {"action_status": "started", "timestamp": 1678759606.6456344, "task_uuid": "147ddfba-ef61-4a52-9f0c-1107c3fbaa6a", "action_type": "pal", "task_level": [1]}
6
+ {"action_status": "succeeded", "timestamp": 1678759606.645799, "task_uuid": "147ddfba-ef61-4a52-9f0c-1107c3fbaa6a", "action_type": "pal", "task_level": [2]}
7
+ {"action_status": "started", "timestamp": 1678759606.9333436, "task_uuid": "3246fe37-fa91-436b-96be-67648cd1ef76", "action_type": "gatsby", "task_level": [1]}
8
+ {"action_status": "succeeded", "timestamp": 1678759606.9335442, "task_uuid": "3246fe37-fa91-436b-96be-67648cd1ef76", "action_type": "gatsby", "task_level": [2]}
9
+ {"action_status": "started", "timestamp": 1678759606.9647467, "task_uuid": "86f09cf7-ec3b-41eb-aac0-144426f1a6f4", "action_type": "stats", "task_level": [1]}
10
+ {"action_status": "succeeded", "timestamp": 1678759606.964883, "task_uuid": "86f09cf7-ec3b-41eb-aac0-144426f1a6f4", "action_type": "stats", "task_level": [2]}
math.pmpt.tpl ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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:
math_demo.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
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
+ gradio = prompt.to_gradio(fields =["question"],
22
+ examples=["What is the sum of the powers of 3 (3^i) that are smaller than 100?"],
23
+ out_type="markdown"
24
+
25
+ )
26
+ if __name__ == "__main__":
27
+ gradio.launch()
28
+
29
+
30
+ # View the prompt
31
+
32
+ # + tags=["hide_inp"]
33
+ # MathPrompt().show({"question": "What is 10 + 12?"}, "10 + 12")
34
+ # # -
35
+
36
+ # # View the log
37
+
38
+ # minichain.show_log("math.log")
math_prompts.py ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2022 PAL Authors. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ MATH_PROMPT = '''
17
+ Q: Olivia has $23. She bought five bagels for $3 each. How much money does she have left?
18
+
19
+ # solution in Python:
20
+
21
+
22
+ def solution():
23
+ """Olivia has $23. She bought five bagels for $3 each. How much money does she have left?"""
24
+ money_initial = 23
25
+ bagels = 5
26
+ bagel_cost = 3
27
+ money_spent = bagels * bagel_cost
28
+ money_left = money_initial - money_spent
29
+ result = money_left
30
+ return result
31
+
32
+
33
+
34
+
35
+
36
+ Q: Michael had 58 golf balls. On tuesday, he lost 23 golf balls. On wednesday, he lost 2 more. How many golf balls did he have at the end of wednesday?
37
+
38
+ # solution in Python:
39
+
40
+
41
+ def solution():
42
+ """Michael had 58 golf balls. On tuesday, he lost 23 golf balls. On wednesday, he lost 2 more. How many golf balls did he have at the end of wednesday?"""
43
+ golf_balls_initial = 58
44
+ golf_balls_lost_tuesday = 23
45
+ golf_balls_lost_wednesday = 2
46
+ golf_balls_left = golf_balls_initial - golf_balls_lost_tuesday - golf_balls_lost_wednesday
47
+ result = golf_balls_left
48
+ return result
49
+
50
+
51
+
52
+
53
+
54
+ Q: There were nine computers in the server room. Five more computers were installed each day, from monday to thursday. How many computers are now in the server room?
55
+
56
+ # solution in Python:
57
+
58
+
59
+ def solution():
60
+ """There were nine computers in the server room. Five more computers were installed each day, from monday to thursday. How many computers are now in the server room?"""
61
+ computers_initial = 9
62
+ computers_per_day = 5
63
+ num_days = 4 # 4 days between monday and thursday
64
+ computers_added = computers_per_day * num_days
65
+ computers_total = computers_initial + computers_added
66
+ result = computers_total
67
+ return result
68
+
69
+
70
+
71
+
72
+
73
+ Q: Shawn has five toys. For Christmas, he got two toys each from his mom and dad. How many toys does he have now?
74
+
75
+ # solution in Python:
76
+
77
+
78
+ def solution():
79
+ """Shawn has five toys. For Christmas, he got two toys each from his mom and dad. How many toys does he have now?"""
80
+ toys_initial = 5
81
+ mom_toys = 2
82
+ dad_toys = 2
83
+ total_received = mom_toys + dad_toys
84
+ total_toys = toys_initial + total_received
85
+ result = total_toys
86
+ return result
87
+
88
+
89
+
90
+
91
+
92
+ Q: Jason had 20 lollipops. He gave Denny some lollipops. Now Jason has 12 lollipops. How many lollipops did Jason give to Denny?
93
+
94
+ # solution in Python:
95
+
96
+
97
+ def solution():
98
+ """Jason had 20 lollipops. He gave Denny some lollipops. Now Jason has 12 lollipops. How many lollipops did Jason give to Denny?"""
99
+ jason_lollipops_initial = 20
100
+ jason_lollipops_after = 12
101
+ denny_lollipops = jason_lollipops_initial - jason_lollipops_after
102
+ result = denny_lollipops
103
+ return result
104
+
105
+
106
+
107
+
108
+
109
+ Q: Leah had 32 chocolates and her sister had 42. If they ate 35, how many pieces do they have left in total?
110
+
111
+ # solution in Python:
112
+
113
+
114
+ def solution():
115
+ """Leah had 32 chocolates and her sister had 42. If they ate 35, how many pieces do they have left in total?"""
116
+ leah_chocolates = 32
117
+ sister_chocolates = 42
118
+ total_chocolates = leah_chocolates + sister_chocolates
119
+ chocolates_eaten = 35
120
+ chocolates_left = total_chocolates - chocolates_eaten
121
+ result = chocolates_left
122
+ return result
123
+
124
+
125
+
126
+
127
+
128
+ Q: If there are 3 cars in the parking lot and 2 more cars arrive, how many cars are in the parking lot?
129
+
130
+ # solution in Python:
131
+
132
+
133
+ def solution():
134
+ """If there are 3 cars in the parking lot and 2 more cars arrive, how many cars are in the parking lot?"""
135
+ cars_initial = 3
136
+ cars_arrived = 2
137
+ total_cars = cars_initial + cars_arrived
138
+ result = total_cars
139
+ return result
140
+
141
+
142
+
143
+
144
+
145
+ Q: There are 15 trees in the grove. Grove workers will plant trees in the grove today. After they are done, there will be 21 trees. How many trees did the grove workers plant today?
146
+
147
+ # solution in Python:
148
+
149
+
150
+ def solution():
151
+ """There are 15 trees in the grove. Grove workers will plant trees in the grove today. After they are done, there will be 21 trees. How many trees did the grove workers plant today?"""
152
+ trees_initial = 15
153
+ trees_after = 21
154
+ trees_added = trees_after - trees_initial
155
+ result = trees_added
156
+ return result
157
+
158
+
159
+
160
+
161
+
162
+ Q: {question}
163
+
164
+ # solution in Python:
165
+ '''.strip() + '\n\n\n'
ner.ipynb ADDED
@@ -0,0 +1,284 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "2e16f61f",
6
+ "metadata": {},
7
+ "source": [
8
+ "# NER"
9
+ ]
10
+ },
11
+ {
12
+ "cell_type": "markdown",
13
+ "id": "904e43dd",
14
+ "metadata": {},
15
+ "source": [
16
+ "Notebook implementation of named entity recognition.\n",
17
+ "Adapted from [promptify](https://github.com/promptslab/Promptify/blob/main/promptify/prompts/nlp/templates/ner.jinja)."
18
+ ]
19
+ },
20
+ {
21
+ "cell_type": "code",
22
+ "execution_count": 2,
23
+ "id": "b4b1d58e",
24
+ "metadata": {
25
+ "execution": {
26
+ "iopub.execute_input": "2023-03-13T23:43:12.445242Z",
27
+ "iopub.status.busy": "2023-03-13T23:43:12.444962Z",
28
+ "iopub.status.idle": "2023-03-13T23:43:12.450741Z",
29
+ "shell.execute_reply": "2023-03-13T23:43:12.450139Z"
30
+ }
31
+ },
32
+ "outputs": [],
33
+ "source": [
34
+ "import json"
35
+ ]
36
+ },
37
+ {
38
+ "cell_type": "code",
39
+ "execution_count": 3,
40
+ "id": "fdb154d0",
41
+ "metadata": {
42
+ "execution": {
43
+ "iopub.execute_input": "2023-03-13T23:43:12.453113Z",
44
+ "iopub.status.busy": "2023-03-13T23:43:12.452884Z",
45
+ "iopub.status.idle": "2023-03-13T23:43:12.649309Z",
46
+ "shell.execute_reply": "2023-03-13T23:43:12.648483Z"
47
+ },
48
+ "lines_to_next_cell": 1
49
+ },
50
+ "outputs": [],
51
+ "source": [
52
+ "import minichain"
53
+ ]
54
+ },
55
+ {
56
+ "cell_type": "markdown",
57
+ "id": "d5665917",
58
+ "metadata": {},
59
+ "source": [
60
+ "Prompt to extract NER tags as json"
61
+ ]
62
+ },
63
+ {
64
+ "cell_type": "code",
65
+ "execution_count": 4,
66
+ "id": "1cfe0e75",
67
+ "metadata": {
68
+ "execution": {
69
+ "iopub.execute_input": "2023-03-13T23:43:12.654908Z",
70
+ "iopub.status.busy": "2023-03-13T23:43:12.653463Z",
71
+ "iopub.status.idle": "2023-03-13T23:43:12.660078Z",
72
+ "shell.execute_reply": "2023-03-13T23:43:12.659313Z"
73
+ },
74
+ "lines_to_next_cell": 1
75
+ },
76
+ "outputs": [],
77
+ "source": [
78
+ "class NERPrompt(minichain.TemplatePrompt):\n",
79
+ " template_file = \"ner.pmpt.tpl\"\n",
80
+ "\n",
81
+ " def parse(self, response, inp):\n",
82
+ " return json.loads(response)"
83
+ ]
84
+ },
85
+ {
86
+ "cell_type": "markdown",
87
+ "id": "11619d3d",
88
+ "metadata": {},
89
+ "source": [
90
+ "Use NER to ask a simple queston."
91
+ ]
92
+ },
93
+ {
94
+ "cell_type": "code",
95
+ "execution_count": 5,
96
+ "id": "584bef0d",
97
+ "metadata": {
98
+ "execution": {
99
+ "iopub.execute_input": "2023-03-13T23:43:12.667113Z",
100
+ "iopub.status.busy": "2023-03-13T23:43:12.665599Z",
101
+ "iopub.status.idle": "2023-03-13T23:43:12.673456Z",
102
+ "shell.execute_reply": "2023-03-13T23:43:12.672558Z"
103
+ },
104
+ "lines_to_next_cell": 1
105
+ },
106
+ "outputs": [],
107
+ "source": [
108
+ "class TeamPrompt(minichain.Prompt):\n",
109
+ " def prompt(self, inp):\n",
110
+ " return \"Can you describe these basketball teams? \" + \\\n",
111
+ " \" \".join([i[\"E\"] for i in inp if i[\"T\"] ==\"Team\"])\n",
112
+ "\n",
113
+ " def parse(self, response, inp):\n",
114
+ " return response"
115
+ ]
116
+ },
117
+ {
118
+ "cell_type": "markdown",
119
+ "id": "6ea6c161",
120
+ "metadata": {},
121
+ "source": [
122
+ "Run the system."
123
+ ]
124
+ },
125
+ {
126
+ "cell_type": "code",
127
+ "execution_count": 6,
128
+ "id": "a8ee77f4",
129
+ "metadata": {
130
+ "execution": {
131
+ "iopub.execute_input": "2023-03-13T23:43:12.678805Z",
132
+ "iopub.status.busy": "2023-03-13T23:43:12.678446Z",
133
+ "iopub.status.idle": "2023-03-13T23:43:12.682592Z",
134
+ "shell.execute_reply": "2023-03-13T23:43:12.682060Z"
135
+ }
136
+ },
137
+ "outputs": [],
138
+ "source": [
139
+ "with minichain.start_chain(\"ner\") as backend:\n",
140
+ " ner_prompt = NERPrompt(backend.OpenAI())\n",
141
+ " team_prompt = TeamPrompt(backend.OpenAI())\n",
142
+ " prompt = ner_prompt.chain(team_prompt)\n",
143
+ " # results = prompt(\n",
144
+ " # {\"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.\",\n",
145
+ " # \"labels\" : [\"Team\", \"Date\"],\n",
146
+ " # \"domain\": \"Sports\"\n",
147
+ " # }\n",
148
+ " # )\n",
149
+ " # print(results)"
150
+ ]
151
+ },
152
+ {
153
+ "cell_type": "code",
154
+ "execution_count": 7,
155
+ "id": "55b9ce94",
156
+ "metadata": {
157
+ "execution": {
158
+ "iopub.execute_input": "2023-03-13T23:43:12.684777Z",
159
+ "iopub.status.busy": "2023-03-13T23:43:12.684591Z",
160
+ "iopub.status.idle": "2023-03-13T23:43:12.687815Z",
161
+ "shell.execute_reply": "2023-03-13T23:43:12.687194Z"
162
+ }
163
+ },
164
+ "outputs": [],
165
+ "source": [
166
+ "ner_prompt.set_display_options(markdown=True)\n",
167
+ "team_prompt.set_display_options(markdown=True) "
168
+ ]
169
+ },
170
+ {
171
+ "cell_type": "code",
172
+ "execution_count": 8,
173
+ "id": "fe56c4ba",
174
+ "metadata": {
175
+ "execution": {
176
+ "iopub.execute_input": "2023-03-13T23:43:12.690233Z",
177
+ "iopub.status.busy": "2023-03-13T23:43:12.689776Z",
178
+ "iopub.status.idle": "2023-03-13T23:43:19.799186Z",
179
+ "shell.execute_reply": "2023-03-13T23:43:19.798652Z"
180
+ },
181
+ "lines_to_next_cell": 2
182
+ },
183
+ "outputs": [
184
+ {
185
+ "name": "stdout",
186
+ "output_type": "stream",
187
+ "text": [
188
+ "Running on local URL: http://127.0.0.1:7860\n",
189
+ "\n",
190
+ "To create a public link, set `share=True` in `launch()`.\n"
191
+ ]
192
+ },
193
+ {
194
+ "data": {
195
+ "text/html": [
196
+ "<div><iframe src=\"http://127.0.0.1:7860/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
197
+ ],
198
+ "text/plain": [
199
+ "<IPython.core.display.HTML object>"
200
+ ]
201
+ },
202
+ "metadata": {},
203
+ "output_type": "display_data"
204
+ },
205
+ {
206
+ "data": {
207
+ "text/plain": []
208
+ },
209
+ "execution_count": 8,
210
+ "metadata": {},
211
+ "output_type": "execute_result"
212
+ }
213
+ ],
214
+ "source": [
215
+ "prompt.to_gradio(fields =[\"text_input\", \"labels\", \"domain\"],\n",
216
+ " 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\"]]).launch()"
217
+ ]
218
+ },
219
+ {
220
+ "cell_type": "markdown",
221
+ "id": "0c81d136",
222
+ "metadata": {},
223
+ "source": [
224
+ "View prompt examples."
225
+ ]
226
+ },
227
+ {
228
+ "cell_type": "code",
229
+ "execution_count": 8,
230
+ "id": "d75cba8c",
231
+ "metadata": {
232
+ "execution": {
233
+ "iopub.execute_input": "2023-03-13T23:43:19.802519Z",
234
+ "iopub.status.busy": "2023-03-13T23:43:19.802098Z",
235
+ "iopub.status.idle": "2023-03-13T23:43:19.805558Z",
236
+ "shell.execute_reply": "2023-03-13T23:43:19.804994Z"
237
+ },
238
+ "tags": [
239
+ "hide_inp"
240
+ ]
241
+ },
242
+ "outputs": [],
243
+ "source": [
244
+ "# NERPrompt().show(\n",
245
+ "# {\n",
246
+ "# \"input\": \"I went to New York\",\n",
247
+ "# \"domain\": \"Travel\",\n",
248
+ "# \"labels\": [\"City\"]\n",
249
+ "# },\n",
250
+ "# '[{\"T\": \"City\", \"E\": \"New York\"}]',\n",
251
+ "# )\n",
252
+ "# # -\n",
253
+ "\n",
254
+ "# # View log.\n",
255
+ "\n",
256
+ "# minichain.show_log(\"ner.log\")"
257
+ ]
258
+ }
259
+ ],
260
+ "metadata": {
261
+ "jupytext": {
262
+ "cell_metadata_filter": "tags,-all"
263
+ },
264
+ "kernelspec": {
265
+ "display_name": "minichain",
266
+ "language": "python",
267
+ "name": "minichain"
268
+ },
269
+ "language_info": {
270
+ "codemirror_mode": {
271
+ "name": "ipython",
272
+ "version": 3
273
+ },
274
+ "file_extension": ".py",
275
+ "mimetype": "text/x-python",
276
+ "name": "python",
277
+ "nbconvert_exporter": "python",
278
+ "pygments_lexer": "ipython3",
279
+ "version": "3.10.6"
280
+ }
281
+ },
282
+ "nbformat": 4,
283
+ "nbformat_minor": 5
284
+ }
ner.log ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"action_status": "started", "timestamp": 1678759606.5748045, "task_uuid": "a2181bdc-7e7a-47a7-9a58-6abf2c2e10cd", "action_type": "ner", "task_level": [1]}
2
+ {"action_status": "succeeded", "timestamp": 1678759606.5748866, "task_uuid": "a2181bdc-7e7a-47a7-9a58-6abf2c2e10cd", "action_type": "ner", "task_level": [2]}
3
+ {"action_status": "started", "timestamp": 1678759606.5984528, "task_uuid": "694c3be6-2b7a-47b3-8d6a-0408b8dc6a26", "action_type": "math", "task_level": [1]}
4
+ {"action_status": "succeeded", "timestamp": 1678759606.5985456, "task_uuid": "694c3be6-2b7a-47b3-8d6a-0408b8dc6a26", "action_type": "math", "task_level": [2]}
5
+ {"action_status": "started", "timestamp": 1678759606.621539, "task_uuid": "b1f606f3-d7b6-48bb-a3a5-77e51fda3fa6", "action_type": "bash", "task_level": [1]}
6
+ {"action_status": "succeeded", "timestamp": 1678759606.6216574, "task_uuid": "b1f606f3-d7b6-48bb-a3a5-77e51fda3fa6", "action_type": "bash", "task_level": [2]}
7
+ {"action_status": "started", "timestamp": 1678759606.6456344, "task_uuid": "147ddfba-ef61-4a52-9f0c-1107c3fbaa6a", "action_type": "pal", "task_level": [1]}
8
+ {"action_status": "succeeded", "timestamp": 1678759606.645799, "task_uuid": "147ddfba-ef61-4a52-9f0c-1107c3fbaa6a", "action_type": "pal", "task_level": [2]}
9
+ {"action_status": "started", "timestamp": 1678759606.9333436, "task_uuid": "3246fe37-fa91-436b-96be-67648cd1ef76", "action_type": "gatsby", "task_level": [1]}
10
+ {"action_status": "succeeded", "timestamp": 1678759606.9335442, "task_uuid": "3246fe37-fa91-436b-96be-67648cd1ef76", "action_type": "gatsby", "task_level": [2]}
11
+ {"action_status": "started", "timestamp": 1678759606.9647467, "task_uuid": "86f09cf7-ec3b-41eb-aac0-144426f1a6f4", "action_type": "stats", "task_level": [1]}
12
+ {"action_status": "succeeded", "timestamp": 1678759606.964883, "task_uuid": "86f09cf7-ec3b-41eb-aac0-144426f1a6f4", "action_type": "stats", "task_level": [2]}
ner.pmpt.tpl ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ You are a highly intelligent and accurate {{ domain }} domain Named-entity recognition(NER) system. You take Passage as input and your task is to recognize and extract specific types of {{ domain }} domain named entities in that given passage and classify into a set of following predefined entity types:
2
+
3
+ {{labels}}
4
+
5
+ Your output format is only {{ output_format|default('[{"T": type of entity from predefined entity types, "E": entity in the input text}]') }} form, no other form.
6
+
7
+ Input: {{ text_input }}
8
+ Output:
ner.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # # NER
2
+
3
+ # Notebook implementation of named entity recognition.
4
+ # Adapted from [promptify](https://github.com/promptslab/Promptify/blob/main/promptify/prompts/nlp/templates/ner.jinja).
5
+
6
+ import json
7
+
8
+ import minichain
9
+
10
+ # Prompt to extract NER tags as json
11
+
12
+ class NERPrompt(minichain.TemplatePrompt):
13
+ template_file = "ner.pmpt.tpl"
14
+
15
+ def parse(self, response, inp):
16
+ return json.loads(response)
17
+
18
+ # Use NER to ask a simple queston.
19
+
20
+ class TeamPrompt(minichain.Prompt):
21
+ def prompt(self, inp):
22
+ return "Can you describe these basketball teams? " + \
23
+ " ".join([i["E"] for i in inp if i["T"] =="Team"])
24
+
25
+ def parse(self, response, inp):
26
+ return response
27
+
28
+ # Run the system.
29
+
30
+ with minichain.start_chain("ner") as backend:
31
+ ner_prompt = NERPrompt(backend.OpenAI())
32
+ team_prompt = TeamPrompt(backend.OpenAI())
33
+ prompt = ner_prompt.chain(team_prompt)
34
+ # results = prompt(
35
+ # {"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.",
36
+ # "labels" : ["Team", "Date"],
37
+ # "domain": "Sports"
38
+ # }
39
+ # )
40
+ # print(results)
41
+
42
+ gradio = prompt.to_gradio(fields =["text_input", "labels", "domain"],
43
+ 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"]])
44
+
45
+
46
+ if __name__ == "__main__":
47
+ gradio.launch()
48
+
49
+
50
+ # View prompt examples.
51
+
52
+ # + tags=["hide_inp"]
53
+ # NERPrompt().show(
54
+ # {
55
+ # "input": "I went to New York",
56
+ # "domain": "Travel",
57
+ # "labels": ["City"]
58
+ # },
59
+ # '[{"T": "City", "E": "New York"}]',
60
+ # )
61
+ # # -
62
+
63
+ # # View log.
64
+
65
+ # minichain.show_log("ner.log")
olympics.data/data-00000-of-00001.arrow ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:65d013abf42f4fb498d054ef6fc192592b78e640749b80bb9bdb5521b9651999
3
+ size 51276496
olympics.data/dataset_info.json ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "builder_name": "csv",
3
+ "citation": "",
4
+ "config_name": "default",
5
+ "dataset_size": 2548363,
6
+ "description": "",
7
+ "download_checksums": {
8
+ "https://cdn.openai.com/API/examples/data/olympics_sections_text.csv": {
9
+ "num_bytes": 2503410,
10
+ "checksum": null
11
+ }
12
+ },
13
+ "download_size": 2503410,
14
+ "features": {
15
+ "title": {
16
+ "dtype": "string",
17
+ "_type": "Value"
18
+ },
19
+ "heading": {
20
+ "dtype": "string",
21
+ "_type": "Value"
22
+ },
23
+ "content": {
24
+ "dtype": "string",
25
+ "_type": "Value"
26
+ },
27
+ "tokens": {
28
+ "dtype": "int64",
29
+ "_type": "Value"
30
+ },
31
+ "embeddings": {
32
+ "feature": {
33
+ "dtype": "float64",
34
+ "_type": "Value"
35
+ },
36
+ "_type": "Sequence"
37
+ }
38
+ },
39
+ "homepage": "",
40
+ "license": "",
41
+ "size_in_bytes": 5051773,
42
+ "splits": {
43
+ "train": {
44
+ "name": "train",
45
+ "num_bytes": 2548363,
46
+ "num_examples": 3964,
47
+ "dataset_name": "csv"
48
+ }
49
+ },
50
+ "version": {
51
+ "version_str": "0.0.0",
52
+ "major": 0,
53
+ "minor": 0,
54
+ "patch": 0
55
+ }
56
+ }
olympics.data/state.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_data_files": [
3
+ {
4
+ "filename": "data-00000-of-00001.arrow"
5
+ }
6
+ ],
7
+ "_fingerprint": "78ad0f5ec2d98f88",
8
+ "_format_columns": null,
9
+ "_format_kwargs": {},
10
+ "_format_type": null,
11
+ "_output_all_columns": false,
12
+ "_split": "train"
13
+ }
olympics.tar ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e51ad58da153bc2f290d6a168f394473db4f4e78d57774c2097eddee91e04459
3
+ size 51281920