From 6c7150f97c7d924cd4603fcd8de5f1dc185a39b2 Mon Sep 17 00:00:00 2001
From: Harrison Chase <hw.chase.17@gmail.com>
Date: Sat, 22 Oct 2022 16:17:07 -0700
Subject: [PATCH] add simple prompt example

---
 README.md                     | 20 ++++++++++-
 examples/simple_prompts.ipynb | 64 +++++++++++++++++++++++++++++++++++
 2 files changed, 83 insertions(+), 1 deletion(-)
 create mode 100644 examples/simple_prompts.ipynb

diff --git a/README.md b/README.md
index 7ae714024e7fa..059f2f8094c25 100644
--- a/README.md
+++ b/README.md
@@ -54,4 +54,22 @@ llm = OpenAI(temperature=0)
 llm_math = LLMMathChain(llm=llm)
 
 llm_math.run("How many of the integers between 0 and 99 inclusive are divisible by 8?")
-```
\ No newline at end of file
+```
+
+**Generic Prompting**
+
+You can also use this for simple prompting pipelines, as in the below example and this [example notebook](examples/simple_prompts.ipynb).
+
+```
+from langchain import Prompt, OpenAI, LLMChain
+
+template = """Question: {question}
+
+Answer: Let's think step by step."""
+prompt = Prompt(template=template, input_variables=["question"])
+llm_chain = LLMChain(prompt=prompt, llm=OpenAI(temperature=0))
+
+question = "What NFL team won the Super Bowl in the year Justin Beiber was born?"
+
+llm_chain.predict(question=question)
+```
diff --git a/examples/simple_prompts.ipynb b/examples/simple_prompts.ipynb
new file mode 100644
index 0000000000000..73d50fe9060b0
--- /dev/null
+++ b/examples/simple_prompts.ipynb
@@ -0,0 +1,64 @@
+{
+ "cells": [
+  {
+   "cell_type": "code",
+   "execution_count": 7,
+   "id": "51a54c4d",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "' The year Justin Beiber was born was 1994. In 1994, the Dallas Cowboys won the Super Bowl.'"
+      ]
+     },
+     "execution_count": 7,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "from langchain import Prompt, OpenAI, LLMChain\n",
+    "\n",
+    "template = \"\"\"Question: {question}\n",
+    "\n",
+    "Answer: Let's think step by step.\"\"\"\n",
+    "prompt = Prompt(template=template, input_variables=[\"question\"])\n",
+    "llm_chain = LLMChain(prompt=prompt, llm=OpenAI(temperature=0))\n",
+    "\n",
+    "question = \"What NFL team won the Super Bowl in the year Justin Beiber was born?\"\n",
+    "\n",
+    "llm_chain.predict(question=question)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "03dd6918",
+   "metadata": {},
+   "outputs": [],
+   "source": []
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3 (ipykernel)",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.7.6"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}