Skip to content

Commit fc0cfd7

Browse files
authored
docs (#848)
1 parent 4d32441 commit fc0cfd7

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

docs/modules/chains/generic/llm_chain.ipynb

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,51 @@
121121
"llm_chain.predict(adjective=\"sad\", subject=\"ducks\")"
122122
]
123123
},
124+
{
125+
"cell_type": "markdown",
126+
"id": "672f59d4",
127+
"metadata": {},
128+
"source": [
129+
"## From string\n",
130+
"You can also construct an LLMChain from a string template directly."
131+
]
132+
},
133+
{
134+
"cell_type": "code",
135+
"execution_count": 3,
136+
"id": "f8bc262e",
137+
"metadata": {},
138+
"outputs": [],
139+
"source": [
140+
"template = \"\"\"Write a {adjective} poem about {subject}.\"\"\"\n",
141+
"llm_chain = LLMChain.from_string(llm=OpenAI(temperature=0), template=template)\n"
142+
]
143+
},
144+
{
145+
"cell_type": "code",
146+
"execution_count": 4,
147+
"id": "cb164a76",
148+
"metadata": {},
149+
"outputs": [
150+
{
151+
"data": {
152+
"text/plain": [
153+
"\"\\n\\nThe ducks swim in the pond,\\nTheir feathers so soft and warm,\\nBut they can't help but feel so forlorn.\\n\\nTheir quacks echo in the air,\\nBut no one is there to hear,\\nFor they have no one to share.\\n\\nThe ducks paddle around in circles,\\nTheir heads hung low in despair,\\nFor they have no one to care.\\n\\nThe ducks look up to the sky,\\nBut no one is there to see,\\nFor they have no one to be.\\n\\nThe ducks drift away in the night,\\nTheir hearts filled with sorrow and pain,\\nFor they have no one to gain.\""
154+
]
155+
},
156+
"execution_count": 4,
157+
"metadata": {},
158+
"output_type": "execute_result"
159+
}
160+
],
161+
"source": [
162+
"llm_chain.predict(adjective=\"sad\", subject=\"ducks\")"
163+
]
164+
},
124165
{
125166
"cell_type": "code",
126167
"execution_count": null,
127-
"id": "8310cdaa",
168+
"id": "9f0adbc7",
128169
"metadata": {},
129170
"outputs": [],
130171
"source": []

0 commit comments

Comments
 (0)