Skip to content

Commit bfb23f4

Browse files
authored
typo bugfixes in getting started with prompts (#651)
tl;dr: input -> word, output -> antonym, rename to dynamic_prompt consistently The provided code in this example doesn't run, because the keys are `word` and `antonym`, rather than `input` and `output`. Also, the `ExampleSelector`-based prompt is named `few_shot_prompt` when defined and `dynamic_prompt` in the follow-up example. The former name is less descriptive and collides with an earlier example, so I opted for the latter. Thanks for making a really cool library!
1 parent 3adc522 commit bfb23f4

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

docs/modules/prompts/getting_started.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,11 @@ from langchain.prompts.example_selector import LengthBasedExampleSelector
155155

156156
# These are a lot of examples of a pretend task of creating antonyms.
157157
examples = [
158-
{"input": "happy", "output": "sad"},
159-
{"input": "tall", "output": "short"},
160-
{"input": "energetic", "output": "lethargic"},
161-
{"input": "sunny", "output": "gloomy"},
162-
{"input": "windy", "output": "calm"},
158+
{"word": "happy", "antonym": "sad"},
159+
{"word": "tall", "antonym": "short"},
160+
{"word": "energetic", "antonym": "lethargic"},
161+
{"word": "sunny", "antonym": "gloomy"},
162+
{"word": "windy", "antonym": "calm"},
163163
]
164164

165165
# We'll use the `LengthBasedExampleSelector` to select the examples.
@@ -174,7 +174,7 @@ example_selector = LengthBasedExampleSelector(
174174
)
175175

176176
# We can now use the `example_selector` to create a `FewShotPromptTemplate`.
177-
few_shot_prompt = FewShotPromptTemplate(
177+
dynamic_prompt = FewShotPromptTemplate(
178178
# We provide an ExampleSelector instead of examples.
179179
example_selector=example_selector,
180180
example_prompt=example_prompt,
@@ -185,7 +185,7 @@ few_shot_prompt = FewShotPromptTemplate(
185185
)
186186

187187
# We can now generate a prompt using the `format` method.
188-
print(few_shot_prompt.format(input="big"))
188+
print(dynamic_prompt.format(input="big"))
189189
# -> Give the antonym of every input
190190
# ->
191191
# -> Word: happy
@@ -224,4 +224,4 @@ print(dynamic_prompt.format(adjective=long_string))
224224
<!-- TODO(shreya): Add correct link here. -->
225225
LangChain comes with a few example selectors that you can use. For more details on how to use them, see [Example Selectors](./examples/example_selectors.ipynb).
226226

227-
You can create custom example selectors that select examples based on any criteria you want. For more details on how to do this, see [Creating a custom example selector](examples/custom_example_selector.ipynb).
227+
You can create custom example selectors that select examples based on any criteria you want. For more details on how to do this, see [Creating a custom example selector](examples/custom_example_selector.ipynb).

0 commit comments

Comments
 (0)