mirror of
https://github.com/langchain-ai/langchain.git
synced 2026-10-09 19:35:20 +03:00
3.9 KiB
3.9 KiB
In [ ]:
!pip install nlpcloudIn [3]:
# get a token: https://docs.nlpcloud.com/#authentication
from getpass import getpass
NLPCLOUD_API_KEY = getpass()········
In [5]:
import os
os.environ["NLPCLOUD_API_KEY"] = NLPCLOUD_API_KEYIn [6]:
from langchain.llms import NLPCloud
from langchain.prompts import PromptTemplate
from langchain.chains import LLMChainIn [7]:
template = """Question: {question}
Answer: Let's think step by step."""
prompt = PromptTemplate(template=template, input_variables=["question"])In [8]:
llm = NLPCloud()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 the team that won the Super Bowl that year was the San Francisco 49ers.'