mirror of
https://github.com/langchain-ai/langchain.git
synced 2026-10-06 09:55:21 +03:00
2.0 KiB
2.0 KiB
In [1]:
from langchain import PromptTemplate, OpenAI, LLMChain
template = """Question: {question}
Answer: Let's think step by step."""
prompt = PromptTemplate(template=template, input_variables=["question"])
llm_chain = LLMChain(prompt=prompt, llm=OpenAI(temperature=0), verbose=True)
question = "What NFL team won the Super Bowl in the year Justin Beiber was born?"
llm_chain.run(question)Out [1]:
[1m> Entering new chain...[0m Prompt after formatting: [32;1m[1;3mQuestion: What NFL team won the Super Bowl in the year Justin Beiber was born? Answer: Let's think step by step.[0m [1m> Finished chain.[0m
' The year Justin Beiber was born was 1994. In 1994, the Dallas Cowboys won the Super Bowl.'
In [ ]: