In the second code cell I commented out the line:
openai.api_key = os.environ['OPENAI_API_KEY']
and I ran this short example:
from langchain.llms import OpenAI
from langchain.prompts import PromptTemplate
from langchain.chains import LLMChain
template = """Question: {question}
Answer: Let's think step by step."""
prompt = PromptTemplate(template=template, input_variables=["question"])
llm = OpenAI()
llm_chain = LLMChain(prompt=prompt, llm=llm)
question = "What NFL team won the Super Bowl in the year Justin Beiber was born?"
llm_chain.run(question)
it still worked.
So if one sets the API key in the .env file for example with “OPENAI_API_KEY” then one does not need to set it in opena9_api_key, correct?
Is there some specific reason that line is used?
George