python import os os.environ["OPENAI_API_KEY"] = "your_openai_api_key_here"
export OPENAI_API_KEY=key
from llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext, LLMPredictor from langchain.llms import OpenAI documents = SimpleDirectoryReader('data').load_data() service_context = ServiceContext.from_defaults( llm_predictor=LLMPredictor(llm=OpenAI(model_name='text-davinci-003', temperature=0, openai_api_key='apiKey')) ) index = VectorStoreIndex.from_documents(documents, service_context=service_context) query_engine = index.as_query_engine() response = query_engine.query("What did the author do growing up?") print(response)
SET OPENAI_API_KEY=key