mirror of
https://github.com/langchain-ai/langchain.git
synced 2026-10-09 03:15:19 +03:00
- Updated `langchain/docs/modules/models/llms/integrations/` notebooks: added links to the original sites, the install information, etc. - Added the `nlpcloud` notebook. - Removed "Example" from Titles of some notebooks, so all notebook titles are consistent.
3.3 KiB
3.3 KiB
In [4]:
# get a token: https://platform.openai.com/account/api-keys
from getpass import getpass
OPENAI_API_KEY = getpass()········
In [5]:
import os
os.environ["OPENAI_API_KEY"] = OPENAI_API_KEYIn [6]:
from langchain.llms import OpenAI
from langchain import PromptTemplate, LLMChainIn [7]:
template = """Question: {question}
Answer: Let's think step by step."""
prompt = PromptTemplate(template=template, input_variables=["question"])In [8]:
llm = OpenAI()In [9]:
llm_chain = LLMChain(prompt=prompt, llm=llm)In [10]:
question = "What NFL team won the Super Bowl in the year Justin Beiber was born?"
llm_chain.run(question)Out [10]:
' Justin Bieber was born in 1994, so we are looking for the Super Bowl winner from that year. The Super Bowl in 1994 was Super Bowl XXVIII, and the winner was the Dallas Cowboys.'