-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprompt_template.py
24 lines (20 loc) · 947 Bytes
/
prompt_template.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
'''
from: https://langchain.readthedocs.io/en/latest/modules/prompts/getting_started.html
'''
from langchain import PromptTemplate
if __name__ == "__main__":
# An example prompt with no input variables
no_input_prompt = PromptTemplate(input_variables=[], template="Tell me a joke.")
print(no_input_prompt.format())
# -> "Tell me a joke."
# An example prompt with one input variable
one_input_prompt = PromptTemplate(input_variables=["adjective"], template="Tell me a {adjective} joke.")
print(one_input_prompt.format(adjective="funny"))
# -> "Tell me a funny joke."
# An example prompt with multiple input variables
multiple_input_prompt = PromptTemplate(
input_variables=["adjective", "content"],
template="Tell me a {adjective} joke about {content}."
)
print(multiple_input_prompt.format(adjective="funny", content="chickens"))
# -> "Tell me a funny joke about chickens."