File size: 3,601 Bytes
f5ec828 872b692 f5ec828 872b692 f5ec828 872b692 f5ec828 872b692 f5ec828 872b692 f5ec828 872b692 f5ec828 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "04b70841",
"metadata": {},
"outputs": [],
"source": [
"!pip install -q git+https://github.com/srush/MiniChain\n",
"!git clone https://github.com/srush/MiniChain; cp -fr MiniChain/examples/* . "
]
},
{
"cell_type": "markdown",
"id": "f8ea4879",
"metadata": {},
"source": [
"Prompt from ...\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0370e1bb",
"metadata": {},
"outputs": [],
"source": [
"prompt = \"\"\"\n",
"Question: Who lived longer, Muhammad Ali or Alan Turing?\n",
"Are follow up questions needed here: Yes.\n",
"Follow up: How old was Muhammad Ali when he died?\n",
"Intermediate answer: Muhammad Ali was 74 years old when he died.\n",
"Follow up: How old was Alan Turing when he died?\n",
"Intermediate answer: Alan Turing was 41 years old when he died.\n",
"So the final answer is: Muhammad Ali\n",
"\n",
"Question: When was the founder of craigslist born?\n",
"Are follow up questions needed here: Yes.\n",
"Follow up: Who was the founder of craigslist?\n",
"Intermediate answer: Craigslist was founded by Craig Newmark.\n",
"Follow up: When was Craig Newmark born?\n",
"Intermediate answer: Craig Newmark was born on December 6, 1952.\n",
"So the final answer is: December 6, 1952\n",
"\n",
"Question: Who was the maternal grandfather of George Washington?\n",
"Are follow up questions needed here: Yes.\n",
"Follow up: Who was the mother of George Washington?\n",
"Intermediate answer: The mother of George Washington was Mary Ball Washington.\n",
"Follow up: Who was the father of Mary Ball Washington?\n",
"Intermediate answer: The father of Mary Ball Washington was Joseph Ball.\n",
"So the final answer is: Joseph Ball\n",
"\n",
"Question: Are both the directors of Jaws and Casino Royale from the same country?\n",
"Are follow up questions needed here: Yes.\n",
"Follow up: Who is the director of Jaws?\n",
"Intermediate answer: The director of Jaws is Steven Spielberg.\n",
"Follow up: Where is Steven Spielberg from?\n",
"Intermediate answer: The United States.\n",
"Follow up: Who is the director of Casino Royale?\n",
"Intermediate answer: The director of Casino Royale is Martin Campbell.\n",
"Follow up: Where is Martin Campbell from?\n",
"Intermediate answer: New Zealand.\n",
"So the final answer is: No\n",
"\n",
"Question: {{input}}\n",
"Are followup questions needed here: {% if agent_scratchpad %}Yes{%else%}No{% endif %}.\n",
"\"\"\""
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "82a93b59",
"metadata": {
"lines_to_next_cell": 1
},
"outputs": [],
"source": [
"import jinja2"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4e5105b2",
"metadata": {},
"outputs": [],
"source": [
"class SelfAsk:\n",
" def render(self, input: str, agent_scratchpad: bool):\n",
" return jinja.render(prompt, dict(input=input,\n",
" agent_scatchpad=agent_scratchpad))\n",
"\n",
" def parse(self, response: str):\n",
" pass\n",
"\n",
"\n",
" def stop(self):\n",
" return []"
]
}
],
"metadata": {
"jupytext": {
"cell_metadata_filter": "-all",
"main_language": "python",
"notebook_metadata_filter": "-all"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
|