So anybody having similar problem try passing down your organization id:
from llama_index import VectorStoreIndex, SimpleDirectoryReader
from llama_index import ServiceContext
from llama_index.llms import OpenAI
from llama_index.embeddings import OpenAIEmbedding
import logging
import sys
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))
embedding_model = OpenAIEmbedding(
api_key="sk-XXXXXXXXXXXXXXXXXXXXXX",
organization="org-XXXXXXXXXXXXXXXXXXXXXXXXX",
)
llm = OpenAI(
api_key="sk-XXXXXXXXXXXXXXXXXXXXXXXXX",
organization="org-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
model="gpt-4-1106-preview",
)
service_context = ServiceContext.from_defaults(llm=llm, embed_model=embedding_model)
def main():
documents = SimpleDirectoryReader("data2").load_data(show_progress=True)
index = VectorStoreIndex.from_documents(documents, show_progress=True, service_context=service_context)
query_engine = index.as_query_engine(service_context=service_context)
response = query_engine.query("What did the author do growing up?")
print(response)
if __name__ == "__main__":
main()