mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-04 04:07:54 +00:00
Docs: updated getting_started.md (#5151)
# Docs: updated getting_started.md Just accommodating some unnecessary spaces in the example of "pass few shot examples to a prompt template". @vowelparrot
This commit is contained in:
parent
b1b7f3541c
commit
de4ef24f75
@ -150,7 +150,6 @@ In this example, we'll create a prompt to generate word antonyms.
|
|||||||
```python
|
```python
|
||||||
from langchain import PromptTemplate, FewShotPromptTemplate
|
from langchain import PromptTemplate, FewShotPromptTemplate
|
||||||
|
|
||||||
|
|
||||||
# First, create the list of few shot examples.
|
# First, create the list of few shot examples.
|
||||||
examples = [
|
examples = [
|
||||||
{"word": "happy", "antonym": "sad"},
|
{"word": "happy", "antonym": "sad"},
|
||||||
@ -159,10 +158,10 @@ examples = [
|
|||||||
|
|
||||||
# Next, we specify the template to format the examples we have provided.
|
# Next, we specify the template to format the examples we have provided.
|
||||||
# We use the `PromptTemplate` class for this.
|
# We use the `PromptTemplate` class for this.
|
||||||
example_formatter_template = """
|
example_formatter_template = """Word: {word}
|
||||||
Word: {word}
|
Antonym: {antonym}
|
||||||
Antonym: {antonym}\n
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
example_prompt = PromptTemplate(
|
example_prompt = PromptTemplate(
|
||||||
input_variables=["word", "antonym"],
|
input_variables=["word", "antonym"],
|
||||||
template=example_formatter_template,
|
template=example_formatter_template,
|
||||||
@ -176,14 +175,14 @@ few_shot_prompt = FewShotPromptTemplate(
|
|||||||
example_prompt=example_prompt,
|
example_prompt=example_prompt,
|
||||||
# The prefix is some text that goes before the examples in the prompt.
|
# The prefix is some text that goes before the examples in the prompt.
|
||||||
# Usually, this consists of intructions.
|
# Usually, this consists of intructions.
|
||||||
prefix="Give the antonym of every input",
|
prefix="Give the antonym of every input\n",
|
||||||
# The suffix is some text that goes after the examples in the prompt.
|
# The suffix is some text that goes after the examples in the prompt.
|
||||||
# Usually, this is where the user input will go
|
# Usually, this is where the user input will go
|
||||||
suffix="Word: {input}\nAntonym:",
|
suffix="Word: {input}\nAntonym: ",
|
||||||
# The input variables are the variables that the overall prompt expects.
|
# The input variables are the variables that the overall prompt expects.
|
||||||
input_variables=["input"],
|
input_variables=["input"],
|
||||||
# The example_separator is the string we will use to join the prefix, examples, and suffix together with.
|
# The example_separator is the string we will use to join the prefix, examples, and suffix together with.
|
||||||
example_separator="\n\n",
|
example_separator="\n",
|
||||||
)
|
)
|
||||||
|
|
||||||
# We can now generate a prompt using the `format` method.
|
# We can now generate a prompt using the `format` method.
|
||||||
|
Loading…
Reference in New Issue
Block a user